/**
 * Home Garments - Main Stylesheet
 * Token bridge, reset, base typography, motion utilities.
 */

:root {
    /* Short aliases for the theme.json tokens used throughout the CSS. */
    --hg-ease: var(--wp--custom--motion--ease, cubic-bezier(0.2, 0.7, 0.2, 1));
    --hg-fast: var(--wp--custom--motion--fast, 160ms);
    --hg-base: var(--wp--custom--motion--base, 320ms);
    --hg-slow: var(--wp--custom--motion--slow, 640ms);
    --hg-radius-sm: var(--wp--custom--radius--sm, 6px);
    --hg-radius-md: var(--wp--custom--radius--md, 12px);
    --hg-radius-pill: var(--wp--custom--radius--pill, 999px);
    --hg-shadow-sm: var(--wp--preset--shadow--sm, 0 1px 2px rgba(28, 26, 23, 0.06));
    --hg-shadow-md: var(--wp--preset--shadow--md, 0 8px 24px rgba(28, 26, 23, 0.1));
    --hg-shadow-lg: var(--wp--preset--shadow--lg, 0 24px 48px rgba(28, 26, 23, 0.16));
    --hg-header-height: 72px;
    /* Fixed colours for text on photos and dark bands; they don't flip with the theme. */
    --hg-light: #F7F3EE;
    --hg-ink: #141311;
}

/* Black theme: the visitor toggle sets data-theme="dark" on <html>. Every block
   colour class reads these variables, so swapping them restyles the whole store. */
html[data-theme="dark"] {
    color-scheme: dark;
    --wp--preset--color--base: #0F0E0D;
    --wp--preset--color--surface: #1A1816;
    --wp--preset--color--surface-light: #24211E;
    --wp--preset--color--contrast: #F3EEE7;
    --wp--preset--color--contrast-muted: #A39A8F;
    --wp--preset--color--accent: #D9805F;
    --wp--preset--color--accent-hover: #E79A7C;
    --wp--preset--color--accent-soft: #3A2A22;
    --wp--preset--color--border-subtle: #34302B;
    --wp--preset--color--dark: #000000;
    --wp--preset--color--dark-surface: #1F1D1A;
    --hg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --hg-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
    --hg-shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.6);
}

/* Dark bands keep light text in both themes. */
html[data-theme="dark"] .has-dark-background-color.has-base-color {
    color: var(--hg-light) !important;
}

/* Smooth colour change when the visitor flips the theme. */
html.hg-theme-anim,
html.hg-theme-anim * {
    transition: background-color var(--hg-base) var(--hg-ease), color var(--hg-base) var(--hg-ease), border-color var(--hg-base) var(--hg-ease) !important;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* WooCommerce hides alternates with the hidden attribute; never let display rules undo it. */
[hidden] {
    display: none !important;
}

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

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

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--hg-fast) var(--hg-ease), opacity var(--hg-fast) var(--hg-ease);
}

h1,
h2,
h3,
h4 {
    font-optical-sizing: auto;
    text-wrap: balance;
    margin-block: 0 0.5em;
}

p {
    margin-block: 0 1em;
}

::selection {
    background: var(--wp--preset--color--accent-soft);
    color: var(--wp--preset--color--contrast);
}

:focus-visible {
    outline: 2px solid var(--wp--preset--color--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

/* In-page anchors land below the sticky header. */
:where([id]) {
    scroll-margin-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--hg-header-height) + 1rem);
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Small uppercase label above headings. */
.hg-eyebrow {
    font-family: var(--wp--preset--font-family--inter);
    font-size: var(--wp--preset--font-size--x-small);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--wp--preset--color--accent);
    margin-bottom: 0.75rem;
}

/* Inline SVG icons from home_garments_icon(). */
.hg-icon {
    width: 20px;
    height: 20px;
    flex: none;
}

/* Scroll reveal: hidden only once JS has marked the document, so visitors
   without JS (and bots) always get visible content. */
.hg-reveal {
    transition: opacity var(--hg-slow) var(--hg-ease), transform var(--hg-slow) var(--hg-ease);
}

html.js:not(.hg-no-reveal) .hg-reveal:not(.is-visible) {
    opacity: 0;
    transform: translateY(16px);
}

/* Marquee: the track holds its items twice so -50% loops seamlessly.
   Items use margin instead of gap so the two halves measure identically. */
.hg-marquee {
    overflow: hidden;
}

.hg-marquee__track {
    display: flex;
    width: max-content;
    animation: hg-marquee 40s linear infinite;
}

.hg-marquee__track > * {
    margin-right: 1rem;
    flex: none;
}

.hg-marquee:hover .hg-marquee__track {
    animation-play-state: paused;
}

@keyframes hg-marquee {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-50%);
    }
}

/* Rise-in used for the hero copy and staggered grids. */
@keyframes hg-rise {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes hg-settle {
    from {
        transform: scale(1.08);
    }

    to {
        transform: scale(1);
    }
}

/* Staggered children: they rise one after another once their section is
   revealed (homepage) or as soon as the page loads (shop grid). */
.hg-reveal.is-visible :is(.hg-tiles__grid > .wp-block-column, .wc-block-product-template > li, .hg-testimonials .wp-block-column),
.hg-shop__grid .wc-block-product-template > li {
    animation: hg-rise var(--hg-slow) var(--hg-ease) both;
}

:is(.hg-tiles__grid > .wp-block-column, .wc-block-product-template > li, .hg-testimonials .wp-block-column):nth-child(2) { animation-delay: 80ms; }
:is(.hg-tiles__grid > .wp-block-column, .wc-block-product-template > li, .hg-testimonials .wp-block-column):nth-child(3) { animation-delay: 160ms; }
:is(.hg-tiles__grid > .wp-block-column, .wc-block-product-template > li, .hg-testimonials .wp-block-column):nth-child(4) { animation-delay: 240ms; }
.wc-block-product-template > li:nth-child(5) { animation-delay: 320ms; }
.wc-block-product-template > li:nth-child(6) { animation-delay: 400ms; }
.wc-block-product-template > li:nth-child(n+7) { animation-delay: 480ms; }

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .hg-reveal,
    html.js .hg-reveal:not(.is-visible) {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .hg-marquee__track {
        animation: none;
        width: auto;
        flex-wrap: wrap;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
