.catalog {
    padding-bottom: clamp(56px, 8vw, 96px);
}

.catalog :where(h1, h2, h3, p) {
    margin: 0;
}

.catalog-header {
    padding-block: clamp(40px, 6vw, 72px) clamp(28px, 4vw, 44px);
    border-bottom: 1px solid var(--line-soft);
}

.catalog-header-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: end;
    gap: 28px;
}

@media (min-width: 900px) {
    .catalog-header-grid {
        grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
        gap: 56px;
    }
}

.catalog-header .sheet-tag {
    margin-bottom: 1.4rem;
}

.catalog-header h1 {
    margin-bottom: 0.8rem;
    font: 800 clamp(2.6rem, 6vw, 4.4rem) / 1 var(--font-display);
    letter-spacing: -0.03em;
}

.catalog-search {
    margin: 32px 0 14px;
}

.catalog-search label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.catalog-search-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.catalog-search-field {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.catalog-search-icon {
    position: absolute;
    left: 14px;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
    pointer-events: none;
}

.catalog-search input {
    flex: 1;
    min-width: 0;
    padding: 14px 14px 14px 44px;
    font-size: 1rem;
}

.catalog-search .btn {
    padding-block: 14px;
}

.catalog :disabled {
    cursor: not-allowed;
    opacity: 0.55;
}


.category-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 4px;
    margin-top: 20px;
    border-bottom: 1px solid var(--line);
    scroll-margin-top: calc(var(--nav-height) + 12px);
}

.category-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.category-links a,
.category-more-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: -1px; /* the selected underline sits on the nav's bottom border */
    padding: 12px 10px 10px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--muted);
    font: 600 0.92rem/1.2 var(--font-body);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.category-links a:hover,
.category-more-button:hover {
    color: var(--text);
}

.category-links a[aria-current="page"],
.category-more-button.is-current {
    border-bottom-color: var(--amber);
    color: var(--text);
}

.category-nav a:focus-visible,
.category-more-button:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: -2px;
}

.category-more {
    position: relative;
}

.category-more-arrow {
    width: 7px;
    height: 7px;
    margin-top: -4px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
}

.category-more.is-open .category-more-arrow {
    margin-top: 3px;
    transform: rotate(225deg);
}

.category-more-menu {
    max-height: 60vh;
    overflow-y: auto;
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 20;
    min-width: 240px;
    margin: 0;
    padding: 6px;
    list-style: none;
    border: 1px solid var(--line);
    border-top: 2px solid var(--amber);
    background: var(--panel);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
}

.category-more.is-open .category-more-menu {
    display: block;
}

.category-more-menu a {
    display: block;
    padding: 9px 12px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.category-more-menu a:hover {
    background: var(--surface-faint);
    color: var(--amber);
}

.category-more-menu a[aria-current="page"] {
    background: var(--amber-tint);
    color: var(--amber);
    font-weight: 600;
}

.catalog-results {
    margin-top: clamp(40px, 6vw, 64px);
    scroll-margin-top: calc(var(--nav-height) + 16px);
}

.catalog-results-head {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 12px 24px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.catalog-results-code {
    color: var(--measure);
    font: 600 0.72rem/1.4 var(--font-mono);
    letter-spacing: 0.14em;
}

.catalog-results-head h2 {
    font: 700 clamp(1.5rem, 2.6vw, 2rem) / 1.2 var(--font-display);
}

.catalog-count {
    margin-bottom: 16px !important;
    color: var(--muted);
    font-size: 0.9rem;
}

.catalog-notice {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: 24px;
    padding: clamp(24px, 4vw, 40px);
    border: 1px dashed var(--line-strong);
    background: var(--panel-alt);
}

@media (min-width: 720px) {
    .catalog-notice {
        grid-template-columns: 200px minmax(0, 1fr);
        gap: 40px;
    }
}

.catalog-notice-art {
    width: 100%;
    max-width: 200px;
    height: auto;
}

.notice-lines {
    fill: none;
    stroke: var(--amber);
    stroke-width: 1.6;
    stroke-linejoin: round;
}

.notice-marks {
    fill: none;
    stroke: var(--measure);
    stroke-width: 0.8;
    opacity: 0.7;
}

.catalog-notice h3 {
    margin-bottom: 0.5rem;
    font: 700 1.3rem/1.3 var(--font-display);
}

.catalog-notice p {
    max-width: 38rem;
    margin-bottom: 1.4rem;
    color: var(--muted);
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
    gap: 18px;
}

/* Keep card heights, prices, and buttons aligned. */
.product-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    overflow: hidden;
    overflow-wrap: anywhere;
    transition: border-color 0.2s;
}

.product-card:hover {
    border-color: var(--line-strong);
}

/* Keep product pictures the same size. */
.product-image {
    aspect-ratio: 2 / 1;
    /* Crop pictures to fit the 2:1 box. */
    overflow: hidden;
    border-bottom: 1px solid var(--line);
    background: var(--panel-alt);
}

.product-image img {
    /* Keep pictures above the grid pattern. */
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    padding: 10px;
    object-fit: contain;
}

.product-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
}

.product-category {
    color: var(--measure);
    font: 600 0.68rem/1.4 var(--font-mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* Limit text to two lines; show full names on hover. */
.product-name,
.product-specification {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

.product-name {
    /* Leave room for two lines to keep cards aligned. */
    min-height: 2.6em;
    font: 700 1.05rem/1.3 var(--font-display);
}

.product-specification {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.product-manufacturer {
    color: var(--muted);
    font-size: 0.8rem;
}

.product-meta {
    display: flex;
    flex-wrap: wrap;
    color: var(--muted);
    font: 0.72rem/1.6 var(--font-mono);
}

.product-meta span + span::before {
    content: "\00b7";
    margin: 0 6px;
}

/* margin-top: auto pushes the footer to the bottom of the card. */
.product-footer {
    display: grid;
    gap: 12px;
    margin: auto 16px 0;
    padding: 14px 0 16px;
    border-top: 1px dashed var(--line);
}

.product-price-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 10px;
}

.product-price {
    font: 700 1.35rem/1.2 var(--font-display);
}

.product-price span {
    color: var(--muted);
    font: 400 0.8rem var(--font-body);
}

.product-price-unknown {
    font-size: 1rem;
}

.product-status {
    padding: 2px 8px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--muted);
    font: 600 0.66rem/1.5 var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.product-status-available {
    border-color: var(--success-border);
    background: var(--success-bg);
    color: var(--success);
}

/* Qty label, number box and button on one row. */
.product-cart-form {
    display: grid;
    grid-template-columns: auto 4.25rem minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}

.product-cart-form label {
    color: var(--muted);
    font: 600 0.72rem var(--font-mono);
    text-transform: uppercase;
}

/* Keep quantity inputs and buttons the same height. */
.product-cart-form input,
.product-cart-form .btn,
.product-cart-unavailable {
    height: 2.6rem;
}

.product-cart-form input {
    min-width: 0;
    padding: 0 6px;
    text-align: center;
}

.product-cart-form .btn {
    padding: 0 12px;
    font-size: 0.9rem;
}

.product-cart-unavailable {
    display: block;
    width: 100%;
    padding: 0 10px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font: 600 0.9rem var(--font-body);
}

.catalog-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 32px;
    font-family: var(--font-mono);
}

@media (max-width: 640px) {
    .category-links {
        flex-wrap: nowrap;
        width: 100%;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .category-more {
        width: 100%;
    }

    .category-more-menu {
        position: static;
        min-width: 0;
        margin-bottom: 8px;
        box-shadow: none;
    }

    .catalog-search-controls {
        flex-wrap: wrap;
    }

    .catalog-search-field {
        flex-basis: 100%;
    }

    .catalog-search .btn {
        width: 100%;
    }
}

.product-reviews-link {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--measure);
    font-size: .78rem;
    text-underline-offset: 3px;
}
