@layer reset, tokens, base, layout, components, utilities;

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }

@layer reset {
    *, *::before, *::after { box-sizing: border-box; }
    html { width: 100%; max-width: 100%; overflow-x: hidden; text-size-adjust: 100%; scroll-behavior: smooth; }
    body, h1, h2, h3, p, figure, blockquote, ol, ul { margin: 0; }
    ol, ul { padding: 0; list-style: none; }
    img, picture, video, canvas, svg { display: block; max-width: 100%; }
    button, input, textarea, select { font: inherit; color: inherit; border-radius: 0; }
    button, a { -webkit-tap-highlight-color: transparent; }
    button { border: 0; }
    a { color: inherit; text-decoration: none; }
}

@layer tokens {
    :root {
        color-scheme: dark;
        --bg: #0a0a0a;
        --bg-alt: #0f0f0f;
        --surface: #141414;
        --surface-strong: #1b1b1b;
        --text: #f0eee8;
        --text-strong: #ffffff;
        --muted: #96938b;
        --line: #2a2927;
        --line-strong: #514d47;
        --accent: #ff4d2e;
        --accent-ink: #ff654a;
        --accent-contrast: #0a0a0a;
        --danger: #ff5d5d;
        --success: #62d98c;
        --header-height: 82px;
        --page-gutter: clamp(20px, 4.5vw, 76px);
        --content-width: 1680px;
        --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
        --font-display: "Arial Narrow", "Roboto Condensed", Impact, var(--font-sans);
        --ease-out: cubic-bezier(.16, 1, .3, 1);
    }

    html[data-theme="light"] {
        color-scheme: light;
        --bg: #efede6;
        --bg-alt: #e7e4dc;
        --surface: #f7f5ef;
        --surface-strong: #ddd9d0;
        --text: #20201f;
        --text-strong: #090909;
        --muted: #6d6a63;
        --line: #c6c1b7;
        --line-strong: #8e887d;
        --accent-contrast: #090909;
        --accent-ink: #ad2915;
    }
}

@layer base {
    html { background: var(--bg); }
    body {
        width: 100%;
        max-width: 100%;
        min-width: 320px;
        min-height: 100vh;
        overflow-x: hidden;
        background: var(--bg);
        color: var(--text);
        font-family: var(--font-sans);
        font-size: 16px;
        line-height: 1.55;
        transition: background-color .25s ease, color .25s ease;
    }
    body::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: -10;
        pointer-events: none;
        opacity: .03;
        background-image: linear-gradient(90deg, var(--text) 1px, transparent 1px), linear-gradient(var(--text) 1px, transparent 1px);
        background-size: 64px 64px;
    }
    ::selection { background: var(--accent); color: var(--accent-contrast); }
    :focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 4px; }
    h1, h2, h3 {
        max-width: 100%;
        color: var(--text-strong);
        font-family: var(--font-display);
        font-weight: 800;
        line-height: .92;
        letter-spacing: -.045em;
        text-transform: uppercase;
        text-wrap: balance;
        overflow-wrap: break-word;
    }
    p { text-wrap: pretty; }
    code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--accent); }
    dialog { border-radius: 0; }
}

@layer layout {
    #content { width: 100%; max-width: 100%; min-height: calc(100vh - var(--header-height)); overflow-x: clip; }
    .page-intro {
        width: min(100%, var(--content-width));
        margin-inline: auto;
        padding: calc(var(--header-height) + clamp(56px, 6vw, 96px)) var(--page-gutter) clamp(52px, 6vw, 88px);
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(280px, 440px);
        align-items: end;
        gap: clamp(30px, 6vw, 100px);
        border-bottom: 1px solid var(--line);
    }
    .page-intro h1 { margin-top: 16px; font-size: clamp(2.8rem, 4vw, 4.4rem); line-height: .98; }
    .page-intro > p { max-width: 440px; color: var(--muted); font-size: clamp(1rem, 1.1vw, 1.14rem); line-height: 1.65; }
}

@layer components {
    .skip-link {
        position: fixed;
        left: 12px;
        top: 12px;
        z-index: 9999;
        padding: 12px 16px;
        transform: translateY(-160%);
        background: var(--accent);
        color: var(--accent-contrast);
        font-weight: 800;
    }
    .skip-link:focus { transform: translateY(0); }

    .section-index {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        color: var(--accent-ink);
        font-size: .68rem;
        font-weight: 800;
        letter-spacing: .2em;
        text-transform: uppercase;
    }
    .section-index::before { content: ""; width: 28px; height: 2px; background: currentColor; }

    .button {
        position: relative;
        display: inline-flex;
        width: fit-content;
        min-height: 54px;
        align-items: center;
        justify-content: center;
        padding: 0 28px;
        overflow: hidden;
        font-size: .74rem;
        font-weight: 900;
        letter-spacing: .14em;
        text-transform: uppercase;
        clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
        transition: transform .25s var(--ease-out), filter .25s ease;
    }
    .button::after { content: "↗"; margin-left: 22px; font-size: 1rem; }
    .button:hover { transform: translateY(-3px); filter: brightness(1.08); }
    .button--accent { background: var(--accent); color: var(--accent-contrast); }

    .interaction-form { margin: 0; }
    .interaction-button {
        width: 44px;
        height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        border: 1px solid color-mix(in srgb, var(--text) 24%, transparent);
        background: color-mix(in srgb, var(--bg) 84%, transparent);
        color: var(--text-strong);
        font-size: 1.2rem;
        line-height: 1;
        cursor: pointer;
        backdrop-filter: blur(12px);
        transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
    }
    .interaction-button:hover { transform: translateY(-2px); border-color: var(--accent); }
    .interaction-button.is-active { border-color: var(--accent); background: var(--accent); color: var(--accent-contrast); }
    .interaction-button:disabled { opacity: .55; cursor: wait; }
    .interaction-button--count { width: auto; min-width: 54px; padding-inline: 11px; font-size: 1rem; }
    .interaction-button--count b { font-size: .64rem; font-weight: 900; }

    .site-header {
        position: fixed;
        z-index: 1000;
        top: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: clip;
        border-bottom: 1px solid transparent;
        transition: background-color .25s ease, border-color .25s ease, transform .35s var(--ease-out);
    }
    .site-header.is-scrolled {
        border-color: var(--line);
        background: color-mix(in srgb, var(--bg) 88%, transparent);
        backdrop-filter: blur(16px) saturate(130%);
    }
    .site-header__inner {
        width: min(100%, var(--content-width));
        max-width: 100%;
        min-height: var(--header-height);
        margin-inline: auto;
        padding-inline: var(--page-gutter);
        display: grid;
        grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
        align-items: center;
        gap: 30px;
    }
    .brand { display: flex; width: fit-content; min-width: 0; align-items: center; gap: 13px; }
    .brand__mark { position: relative; width: 42px; height: 42px; }
    .brand__logo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
    .brand__logo--light { display: none; }
    html[data-theme="light"] .brand__logo--dark { display: none; }
    html[data-theme="light"] .brand__logo--light { display: block; }
    .brand__copy { display: grid; line-height: 1; }
    .brand__copy strong { color: var(--text-strong); font-size: .9rem; letter-spacing: .08em; }
    .brand__copy small { margin-top: 7px; color: var(--muted); font-size: .58rem; letter-spacing: .16em; text-transform: uppercase; }

    .main-nav { display: flex; align-items: center; gap: clamp(18px, 2.4vw, 42px); }
    .main-nav a {
        position: relative;
        padding: 31px 0 27px;
        color: var(--muted);
        font-size: .72rem;
        font-weight: 750;
        letter-spacing: .09em;
        text-transform: uppercase;
        transition: color .2s ease;
    }
    .main-nav a::after {
        content: "";
        position: absolute;
        bottom: -1px;
        left: 0;
        width: 100%;
        height: 3px;
        transform: scaleX(0);
        transform-origin: right;
        background: var(--accent);
        transition: transform .25s var(--ease-out);
    }
    .main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--text-strong); }
    .main-nav a:hover::after, .main-nav a[aria-current="page"]::after { transform: scaleX(1); transform-origin: left; }

    .header-actions { min-width: 0; flex: 0 0 auto; justify-self: end; display: flex; align-items: center; gap: 8px; }
    .header-search { position: relative; }
    .header-control, .menu-toggle {
        width: 42px;
        height: 42px;
        display: grid;
        place-items: center;
        border: 1px solid var(--line);
        background: transparent;
        color: var(--text);
        cursor: pointer;
        transition: border-color .2s ease, background .2s ease, color .2s ease;
    }
    .header-control:hover, .menu-toggle:hover { border-color: var(--accent); color: var(--accent); }
    .header-control[aria-expanded="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-contrast); }
    .header-control:disabled { border-color: var(--line); color: var(--muted); cursor: not-allowed; opacity: .72; }
    .header-control svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: square; }
    .header-control--account { width: auto; padding-inline: 12px; grid-auto-flow: column; gap: 8px; }
    .header-control--account span { font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
    .header-control--cart { position: relative; }
    .cart-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding-inline: 4px; display: grid; place-items: center; border: 2px solid var(--bg); background: var(--surface-strong); color: var(--muted); font-size: .54rem; font-weight: 900; line-height: 1; }
    .search-panel { position: absolute; z-index: 20; top: calc(100% + 18px); right: 0; width: min(390px, calc(100vw - (var(--page-gutter) * 2))); padding: 20px; border: 1px solid var(--line-strong); border-top: 3px solid var(--accent); background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: 0 24px 70px rgba(0, 0, 0, .34); backdrop-filter: blur(18px) saturate(125%); }
    .search-panel[hidden] { display: none; }
    .search-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--text-strong); font-size: .63rem; font-weight: 900; letter-spacing: .16em; }
    .search-panel__head small { padding: 4px 6px; background: var(--accent); color: var(--accent-contrast); font-size: .52rem; letter-spacing: .12em; }
    .search-panel__field { min-height: 54px; margin-top: 18px; padding-inline: 16px; display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 12px; border: 1px solid var(--line); background: var(--bg-alt); }
    .search-panel__field svg { width: 18px; fill: none; stroke: var(--muted); stroke-width: 1.7; }
    .search-panel__field input { width: 100%; height: 52px; border: 0; outline: 0; background: transparent; color: var(--muted); opacity: 1; -webkit-text-fill-color: var(--muted); }
    .search-panel__field input::placeholder { color: var(--muted); opacity: .78; }
    .search-panel p { margin-top: 14px; color: var(--muted); font-size: .76rem; line-height: 1.55; }
    .menu-toggle { display: none; align-content: center; gap: 6px; }
    .menu-toggle i { width: 19px; height: 1px; background: currentColor; transition: transform .2s ease; }
    .menu-toggle[aria-expanded="true"] i:first-of-type { transform: translateY(3.5px) rotate(45deg); }
    .menu-toggle[aria-expanded="true"] i:last-of-type { transform: translateY(-3.5px) rotate(-45deg); }

    .mobile-menu {
        width: 100%;
        max-width: 100%;
        max-height: calc(100dvh - var(--header-height));
        overflow-y: auto;
        overflow-x: hidden;
        border-top: 1px solid var(--line);
        border-bottom: 1px solid var(--line);
        background: var(--bg);
    }
    .mobile-menu a {
        width: 100%;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 20px var(--page-gutter);
        border-bottom: 1px solid var(--line);
        font-family: var(--font-display);
        font-size: 1.7rem;
        font-weight: 800;
        text-transform: uppercase;
    }
    .mobile-menu a span { min-width: 0; overflow-wrap: anywhere; }
    .mobile-menu a b { flex: 0 0 auto; margin-left: 20px; font-weight: 500; }
    .mobile-menu a[aria-current="page"] { color: var(--accent); }

    .account-dialog {
        width: min(520px, calc(100% - 32px));
        padding: clamp(28px, 5vw, 52px);
        border: 1px solid var(--line-strong);
        background: var(--surface);
        color: var(--text);
        box-shadow: 0 30px 100px rgba(0, 0, 0, .45);
    }
    .account-dialog::backdrop { background: rgba(0, 0, 0, .75); backdrop-filter: blur(8px); }
    .account-dialog h2 { margin: 32px 0 20px; font-size: clamp(2.2rem, 5vw, 3.2rem); }
    .account-dialog p { color: var(--muted); }
    .dialog-close {
        position: absolute;
        right: 0;
        top: 0;
        width: 48px;
        height: 48px;
        background: transparent;
        border-left: 1px solid var(--line);
        border-bottom: 1px solid var(--line);
        cursor: pointer;
        font-size: 1.6rem;
    }
    .account-status { display: flex; align-items: center; gap: 10px; margin-top: 34px; color: var(--muted); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
    .account-status i { width: 8px; height: 8px; background: var(--accent); }

    .flash-stack {
        position: fixed;
        z-index: 1200;
        top: calc(var(--header-height) + 16px);
        right: var(--page-gutter);
        width: min(430px, calc(100% - (var(--page-gutter) * 2)));
        display: grid;
        gap: 10px;
        pointer-events: none;
    }
    .flash {
        padding: 15px 18px;
        border: 1px solid var(--line-strong);
        border-left: 4px solid var(--accent);
        background: color-mix(in srgb, var(--surface) 94%, transparent);
        color: var(--text);
        box-shadow: 0 18px 50px rgba(0, 0, 0, .24);
        backdrop-filter: blur(14px);
        font-size: .9rem;
        line-height: 1.45;
    }
    .flash--success { border-left-color: var(--success); }
    .flash--error { border-left-color: var(--danger); }

    .site-footer {
        width: 100%;
        max-width: 100%;
        overflow-x: clip;
        position: relative;
        z-index: 4;
        border-top: 1px solid var(--line);
        background: var(--bg);
    }
    .site-footer__top, .site-footer__bottom {
        width: min(100%, var(--content-width));
        margin-inline: auto;
        padding-inline: var(--page-gutter);
    }
    .site-footer__top {
        min-height: 260px;
        padding-block: 60px;
        display: grid;
        grid-template-columns: 1.2fr .72fr .82fr auto;
        align-items: start;
        gap: 40px;
    }
    .footer-wordmark { color: var(--text-strong); font-family: var(--font-display); font-size: clamp(3.2rem, 5vw, 4.8rem); font-weight: 900; line-height: .85; letter-spacing: -.07em; }
    .site-footer__top p { margin-top: 20px; color: var(--muted); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; }
    .footer-title { margin-bottom: 5px; color: var(--text-strong); font-size: .6rem; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
    .footer-nav { display: grid; align-content: start; gap: 13px; }
    .footer-nav a, .footer-social a { color: var(--muted); font-size: .75rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
    .footer-nav a:hover, .footer-social a:hover { color: var(--accent); }
    .footer-nav--after-hours a:first-of-type { color: var(--accent-ink); }
    .footer-social-wrap { display: grid; align-content: start; gap: 11px; }
    .footer-social { display: flex; gap: 8px; }
    .footer-social a { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); }
    .site-footer__bottom { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; }
    .footer-version:hover { color: var(--accent); }

    .empty-state {
        grid-column: 1 / -1;
        min-height: 330px;
        display: grid;
        align-content: center;
        justify-items: start;
        padding: clamp(30px, 5vw, 76px);
        border: 1px solid var(--line);
        background: linear-gradient(135deg, var(--surface), transparent);
    }
    .empty-state > span { color: var(--accent); font-size: .67rem; font-weight: 850; letter-spacing: .18em; }
    .empty-state h2 { max-width: 700px; margin: 24px 0 16px; font-size: clamp(2rem, 3vw, 3.2rem); }
    .empty-state p { max-width: 640px; color: var(--muted); }
}

@layer utilities {
    .sr-only {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }
}

@media (max-width: 980px) {
    :root { --header-height: 72px; }
    .site-header__inner { min-height: var(--header-height); grid-template-columns: minmax(0, 1fr) auto; gap: 14px; }
    .main-nav { display: none; }
    .menu-toggle { display: grid; }
    .page-intro { grid-template-columns: 1fr; gap: 26px; }
    .page-intro > p { padding-bottom: 0; }
    .site-footer__top { grid-template-columns: 1fr 1fr 1fr; }
    .site-footer__top > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 1180px) {
    .site-header__inner { grid-template-columns: minmax(0, 1fr) auto; gap: 14px; }
    .main-nav { display: none; }
    .menu-toggle { display: grid; }
}

@media (max-width: 640px) {
    :root { --page-gutter: clamp(18px, 5vw, 26px); }
    .brand__copy { display: none; }
    .brand__mark { width: 38px; height: 38px; }
    .header-actions { gap: 6px; }
    .header-control, .menu-toggle { width: 40px; height: 40px; }
    .header-control--account { width: 42px; padding: 0; }
    .header-control--account span { display: none; }
    .search-panel { position: fixed; top: calc(var(--header-height) + 10px); right: var(--page-gutter); }
    .site-footer__top { grid-template-columns: 1fr; }
    .footer-social-wrap { grid-column: auto; }
    .site-footer__bottom { padding-block: 18px; flex-direction: column; align-items: flex-start; }
    .site-footer__bottom span:last-child { display: none; }
    .button { width: 100%; }
    .page-intro {
        padding-top: calc(var(--header-height) + 58px);
        padding-bottom: 48px;
        gap: 22px;
    }
    .page-intro h1 {
        margin-top: 14px;
        font-size: clamp(2.35rem, 9.5vw, 3.15rem);
        line-height: .94;
        letter-spacing: -.045em;
    }
    .page-intro > p { max-width: 34rem; font-size: .98rem; line-height: 1.6; }
    .section-index { font-size: .62rem; letter-spacing: .16em; }
    .section-index::before { width: 22px; }
    .mobile-menu a { padding-block: 17px; font-size: clamp(1.35rem, 7vw, 1.75rem); }
    .empty-state { min-height: 260px; }
    .empty-state h2 { font-size: clamp(1.8rem, 7.5vw, 2.35rem); }
}

@media (max-width: 380px) {
    .site-header__inner { gap: 8px; }
    .header-actions { gap: 4px; }
    .header-control, .menu-toggle, .header-control--account { width: 38px; height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
    .button, .header-control, .menu-toggle, .footer-social a, .search-panel, .interaction-button { border: 2px solid ButtonText; }
    .section-index::before, .account-status i { forced-color-adjust: none; }
}
