/* =========================================================================
   Gas Strainer Store — Common Stylesheet (Phase 2)
   -------------------------------------------------------------------------
   Design direction: "steel & flame" — a utilitarian, spec-sheet-clean
   catalog look drawn from the product itself (woven wire mesh, brushed
   steel, stove-flame blue) rather than a generic storefront template.

   Sections:
     1. Design tokens (CSS custom properties)
     2. Reset / base
     3. Typography
     4. Layout utilities
     5. Buttons & form controls (shared primitives)
     6. Header — topbar (logo / search / actions)
     7. Navigation — desktop bar + mobile off-canvas drawer
     8. Footer
     9. Responsive breakpoints
     10. Accessibility (focus, reduced motion)
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Design tokens
   ------------------------------------------------------------------------- */
:root {
    /* Color — "steel & flame" palette */
    --color-bg:            #F7F8F9; /* Steel White — page background */
    --color-surface:       #FFFFFF; /* Cards, header, footer surfaces */
    --color-surface-alt:   #EEF1F3; /* Subtle alt surface (footer top) */
    --color-graphite:      #1F2A2E; /* Primary text / headings */
    --color-slate:         #5B6B72; /* Secondary text */
    --color-mesh-silver:   #D8DDE1; /* Borders, hairlines */
    --color-mesh-silver-dk:#C2C9CD; /* Slightly darker hairline */
    --color-flame:         #1C6FD1; /* Primary accent — stove-flame blue */
    --color-flame-dark:    #14549F; /* Hover/active state of flame */
    --color-flame-tint:    #EAF2FC; /* Very light flame background tint */
    --color-amber:         #E8A33D; /* Secondary accent — badges/alerts */
    --color-danger:        #C4432B;
    --color-success:       #2E8B57;
    --color-overlay:       rgba(31, 42, 46, 0.55);

    /* Typography */
    --font-display: "Space Grotesk", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-body:    "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono:    "IBM Plex Mono", "Courier New", Courier, monospace;

    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-md:   1.125rem;
    --text-lg:   1.25rem;
    --text-xl:   1.5rem;
    --text-2xl:  1.875rem;
    --text-3xl:  2.25rem;
    --text-4xl:  3rem;

    --leading-tight: 1.2;
    --leading-normal: 1.55;

    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;

    /* Radius — small and deliberate, not pill-shaped (industrial, not soft) */
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 8px;
    --radius-full: 999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(31, 42, 46, 0.06);
    --shadow-md: 0 4px 12px rgba(31, 42, 46, 0.10);
    --shadow-lg: 0 12px 32px rgba(31, 42, 46, 0.16);

    /* Layout */
    --container-max: 1280px;
    --container-pad: var(--space-4);
    --header-topbar-height: 76px;
    --header-nav-height: 48px;

    /* Motion */
    --transition-fast: 150ms ease;
    --transition-base: 220ms ease;

    /* Z-index scale */
    --z-header: 100;
    --z-overlay: 90;
    --z-drawer: 200;
}

/* -------------------------------------------------------------------------
   2. Reset / base
   ------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background-color: var(--color-bg);
    color: var(--color-graphite);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
}

body.nav-open {
    overflow: hidden; /* lock background scroll while mobile drawer is open */
}

img, svg {
    display: block;
    max-width: 100%;
}

a {
    color: var(--color-flame);
    text-decoration: none;
}

a:hover {
    color: var(--color-flame-dark);
}

ul, ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input, button, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* -------------------------------------------------------------------------
   3. Typography
   ------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--color-graphite);
    line-height: var(--leading-tight);
    margin: 0 0 var(--space-3);
    font-weight: 600;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
    margin: 0 0 var(--space-4);
    color: var(--color-slate);
}

/* Utility: technical/spec text (prices, SKUs, quantities) uses mono face
   throughout the site to reinforce the "spec sheet" character of the brand */
.mono, .price, .sku {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
   4. Layout utilities
   ------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--container-pad);
}

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

.skip-link {
    position: absolute;
    top: -48px;
    left: var(--space-3);
    z-index: 1000;
    background: var(--color-graphite);
    color: #fff;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: var(--space-3);
    color: #fff;
}

.site-main {
    min-height: 40vh; /* keeps footer from riding up on short pages during Phase 2 */
}

/* Generic flash/alert banner — used by header.php's site-wide flash
   message display (e.g. after login/logout) and reused by page-specific
   forms (auth pages define the same classes locally too; harmless
   duplication, kept here so the banner works even on pages that don't
   load account.css). */
.form-alert {
    font-size: var(--text-sm);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}
.form-alert--error   { background-color: #FBEAE7; color: var(--color-danger); }
.form-alert--success { background-color: #E5F3EC; color: var(--color-success); }
.form-alert ul { margin: 0; padding-left: var(--space-5); list-style: disc; }

/* Signature texture: a faint woven "mesh" crosshatch, echoing the strainer's
   wire mesh. Used sparingly as a background accent (footer top strip, and
   behind the active nav-link underline) rather than all over the page. */
.mesh-texture {
    background-image:
        repeating-linear-gradient(45deg, var(--color-mesh-silver) 0 1px, transparent 1px 10px),
        repeating-linear-gradient(-45deg, var(--color-mesh-silver) 0 1px, transparent 1px 10px);
    background-color: var(--color-surface-alt);
}

/* -------------------------------------------------------------------------
   5. Buttons & form controls (shared primitives used across the whole site)
   ------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--color-flame);
    color: #fff;
}
.btn-primary:hover { background-color: var(--color-flame-dark); color: #fff; }

.btn-outline {
    background-color: transparent;
    border-color: var(--color-mesh-silver-dk);
    color: var(--color-graphite);
}
.btn-outline:hover { border-color: var(--color-flame); color: var(--color-flame); }

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-mesh-silver-dk);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    color: var(--color-graphite);
}

.form-input:focus-visible {
    outline: 2px solid var(--color-flame);
    outline-offset: 1px;
    border-color: var(--color-flame);
}

/* -------------------------------------------------------------------------
   6. Header — topbar (logo / search / actions)
   ------------------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-mesh-silver);
    transition: box-shadow var(--transition-base);
}

.site-header.is-scrolled {
    box-shadow: var(--shadow-md);
}

.header-topbar__inner {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    min-height: var(--header-topbar-height);
}

/* Logo */
.site-logo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
    color: var(--color-graphite);
}
.site-logo:hover { color: var(--color-graphite); }

.site-logo__mark {
    width: 34px;
    height: 34px;
    color: var(--color-flame);
    flex-shrink: 0;
}

.site-logo__text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-lg);
    letter-spacing: -0.01em;
    line-height: 1;
    white-space: nowrap;
}

/* Search */
.site-search {
    flex: 1 1 auto;
    display: flex;
    max-width: 560px;
    margin-inline: auto;
}

.site-search__input {
    flex: 1 1 auto;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-mesh-silver-dk);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    background-color: var(--color-bg);
}

.site-search__input:focus-visible {
    outline: none;
    border-color: var(--color-flame);
    background-color: var(--color-surface);
}

.site-search__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline: var(--space-4);
    background-color: var(--color-graphite);
    color: #fff;
    border: 1px solid var(--color-graphite);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.site-search__submit:hover { background-color: var(--color-flame); border-color: var(--color-flame); }

.site-search__submit svg { width: 18px; height: 18px; }
.site-search__submit-label { display: none; } /* icon-only submit button; label kept for screen readers via visually-hidden usage in markup */

/* Header actions (login / cart) */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    flex-shrink: 0;
}

.header-actions__link {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--color-graphite);
    font-size: var(--text-xs);
    font-weight: 600;
    position: relative;
}
.header-actions__link:hover { color: var(--color-flame); }

.header-actions__link svg {
    width: 22px;
    height: 22px;
}

.cart-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: var(--radius-full);
    background-color: var(--color-flame);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Mobile nav toggle (hamburger -> X) */
.nav-toggle {
    display: none; /* shown only on mobile, see breakpoints */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--color-mesh-silver-dk);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.nav-toggle__bar {
    width: 18px;
    height: 2px;
    background-color: var(--color-graphite);
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) {
    opacity: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile-only search trigger (icon button that reveals the search input) */
.site-search-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--color-mesh-silver-dk);
    border-radius: var(--radius-md);
    color: var(--color-graphite);
    flex-shrink: 0;
}
.site-search-toggle svg { width: 18px; height: 18px; }

/* -------------------------------------------------------------------------
   7. Navigation — desktop bar + mobile off-canvas drawer
   ------------------------------------------------------------------------- */
.site-nav {
    background-color: var(--color-graphite);
}

.site-nav__list {
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

.site-nav__link {
    display: inline-flex;
    align-items: center;
    height: var(--header-nav-height);
    color: #E7EBED;
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    position: relative;
    border-bottom: 2px solid transparent;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.site-nav__link:hover {
    color: #fff;
    border-color: var(--color-mesh-silver-dk);
}

.site-nav__link--active {
    color: #fff;
    border-color: var(--color-flame);
}

/* Overlay behind the mobile drawer */
.nav-drawer-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--color-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    z-index: var(--z-overlay);
}

body.nav-open .nav-drawer-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* -------------------------------------------------------------------------
   8. Footer
   ------------------------------------------------------------------------- */
.site-footer {
    margin-top: var(--space-8);
    background-color: #20292E;
    border-top: 1px solid rgba(255,255,255,.12);
    color: #fff;
}

.site-footer__texture {
    height: 6px;
    background-image:
        repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 1px, transparent 1px 8px),
        repeating-linear-gradient(-45deg, rgba(255,255,255,.08) 0 1px, transparent 1px 8px);
    background-color: #1A2227;
}

.site-footer__inner {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: var(--space-6);
    padding-block: var(--space-7);
}

.site-footer__col h3 {
    font-size: var(--text-md);
    margin-bottom: var(--space-3);
    color: #fff;
}

.site-footer__col h4 {
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #fff;
    margin-bottom: var(--space-3);
}

.site-footer__col p {
    font-size: var(--text-sm);
    margin-bottom: var(--space-2);
    color: rgba(255,255,255,.75);
}

.site-footer__col ul li {
    margin-bottom: var(--space-2);
}

.site-footer__col ul a {
    color: rgba(255,255,255,.75);
    font-size: var(--text-sm);
    text-decoration: none;
}

.site-footer__col ul a:hover {
    color: #4DA3FF;
}
.site-footer__col ul a:hover { color: var(--color-flame); }

.site-footer__bottom {
    border-top: 1px solid rgba(255,255,255,.12);
    padding-block: var(--space-4);
}

.site-footer__bottom p {
    margin: 0;
    font-size: var(--text-xs);
    color: rgba(255,255,255,.65);
    text-align: center;
}

/* -------------------------------------------------------------------------
   9. Responsive breakpoints
   ------------------------------------------------------------------------- */

/* ----- Tablet and below (<= 991px): collapse nav into off-canvas drawer --- */
@media (max-width: 991px) {
    .nav-toggle {
        display: inline-flex;
    }

    .header-topbar__inner {
        min-height: 64px;
        gap: var(--space-3);
    }

    .site-logo__text {
        font-size: var(--text-md);
    }

    /* Search collapses to an icon trigger; the full input becomes a
       full-width row that appears beneath the topbar when toggled open */
    .site-search {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        padding: var(--space-3) var(--container-pad);
        background-color: var(--color-surface);
        border-bottom: 1px solid var(--color-mesh-silver);
        max-width: none;
        margin: 0;
    }

    .site-search.is-open {
        display: flex;
    }

    .site-search-toggle {
        display: inline-flex;
    }

    .header-topbar__inner {
        position: relative;
    }

    .header-actions__link span.header-actions__label {
        display: none; /* icon-only on smaller screens to save space */
    }

    /* Off-canvas nav drawer */
    .site-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 84vw);
    background-color: var(--color-graphite);
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    z-index: 99999 !important;
    overflow-y: auto;
    pointer-events: auto !important;
    padding-top: var(--header-topbar-height);
}

    body.nav-open .site-nav {
        transform: translateX(0);
    }

    .site-nav .container {
        padding: 0;
    }

    .site-nav__list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .site-nav__link {
        height: auto;
        padding: var(--space-4) var(--space-5);
        border-bottom: 1px solid rgba(255,255,255,0.08);
        border-left: 3px solid transparent;
        width: 100%;
        pointer-events: auto;
        position: relative;
        z-index: 201;
    }

    .site-nav__link:hover,
    .site-nav__link--active {
        border-bottom-color: rgba(255,255,255,0.08);
        border-left-color: var(--color-flame);
        background-color: rgba(255,255,255,0.03);
    }

    .site-footer__inner {
        grid-template-columns: 1fr 1fr;
    }
}

/* ----- Small mobile (<= 575px) ----- */
@media (max-width: 575px) {
    :root {
        --container-pad: var(--space-3);
    }

    .header-actions {
        gap: var(--space-3);
    }

    .site-footer__inner {
        grid-template-columns: 1fr;
        gap: var(--space-5);
        padding-block: var(--space-6);
    }
}

/* ----- Large desktop refinement ----- */
@media (min-width: 1400px) {
    :root {
        --container-pad: var(--space-5);
    }
}

/* -------------------------------------------------------------------------
   10. Accessibility
   ------------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--color-flame);
    outline-offset: 2px;
}

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