/* Reset, typography, focus, layout and buttons in the handoff's look (Tailwind defaults reproduced by hand).
   Logical properties only. */

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

* { margin: 0; }

html {
    /* The sticky header's live height: the condensed bar once it has stuck (SiteHeader sets data-condensed). Read by
       the sticky selection header and stage and by tawleh.js observeVisibility (the buy bar's header line). */
    --header-live-h: var(--header-height);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Anchored sections land below the sticky header. */
    scroll-padding-block-start: calc(var(--header-height) + var(--space-4));
    /* While the mobile buy bar is shown (tawleh.js publishHeight sets --buybar-h), focused controls stay above it. */
    scroll-padding-block-end: var(--buybar-h, 0px);
    color-scheme: light;
}

html:has(.site-header[data-condensed]) { --header-live-h: var(--header-condensed); }

/* Handoff: <html class="scroll-smooth">, but only when the visitor has not asked for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* Set by tawleh.js lockScroll() while a drawer or dialog is open. */
html.scroll-locked { overflow: hidden; }
html.scroll-locked body { padding-inline-end: var(--scrollbar-gap, 0); }

body {
    min-block-size: 100vh;
    min-block-size: 100dvh;
    background-color: var(--cream);
    color: var(--choco);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: clip;
}

img, picture, video, canvas, svg { display: block; max-inline-size: 100%; }
img, video { block-size: auto; }

input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }

p, li, dd, figcaption { overflow-wrap: break-word; }

ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

a { color: inherit; text-decoration: none; }

address { font-style: normal; }

::selection { background: var(--chartreuse); color: var(--choco-dark); }

::placeholder { color: var(--placeholder); }

/* Subtle scrollbars (handoff template) */
::-webkit-scrollbar { inline-size: 8px; block-size: 8px; }
::-webkit-scrollbar-track { background: var(--cream-soft); }
::-webkit-scrollbar-thumb { background: var(--choco-light); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--choco); }

/* ------------------------------------------------------------------ typography */

h1, h2, h3 {
    color: var(--choco-dark);
    font-family: var(--font-display);
    font-weight: 800;
    text-wrap: balance;
}

h1 { font-size: var(--text-2xl); line-height: 1.33; letter-spacing: var(--tracking-tight); }
h2 { font-size: var(--text-2xl); line-height: 1.33; }
h3 { font-size: var(--text-lg); line-height: 1.55; }

@media (min-width: 640px) {
    h1 { font-size: var(--text-3xl); line-height: 1.2; }
}

@media (min-width: 1024px) {
    h1, h2 { font-size: var(--text-4xl); line-height: 1.11; }
}

.lead { color: var(--choco-muted); font-size: var(--text-sm); line-height: 1.625; }

@media (min-width: 640px) {
    .lead { font-size: var(--text-base); }
}

.muted { color: var(--choco-muted); }

.visually-hidden {
    position: absolute !important;
    inline-size: 1px; block-size: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
    white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ focus (handoff §9 developer note) */

:focus { outline: none; }

/* Chartreuse ring, with a chocolate inner ring so it still shows on cream surfaces. */
:focus-visible {
    outline: 2px solid var(--chartreuse);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--choco);
}

/* On chocolate (header, footer, drawer header) the chartreuse ring alone has ample contrast. */
.on-choco :focus-visible { box-shadow: none; }

/* A cream card inside a chocolate band: back to chocolate text; the band's light headings and its
   ring-only focus style (below) skip everything inside it. */
.on-light { color: var(--choco); }

/* Headings or landmarks focused programmatically should not show a ring. */
[tabindex="-1"]:focus-visible { outline: none; box-shadow: none; }

.skip-link {
    position: fixed;
    inset-block-start: var(--space-3);
    inset-inline-start: var(--space-3);
    z-index: 1000;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-xl);
    background: var(--chartreuse);
    color: var(--choco-dark);
    font-size: var(--text-sm);
    font-weight: 800;
    transform: translateY(calc(-100% - var(--space-6)));
    transition: transform var(--dur-hover) var(--ease-out);
}
.skip-link:focus-visible { transform: none; }

/* ------------------------------------------------------------------ layout */

.container {
    inline-size: 100%;
    max-inline-size: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.container--narrow { max-inline-size: calc(var(--container-narrow) + 2 * var(--gutter)); }

/* Page sections (polish spec §5.1): full-width bands with one vertical rhythm and an alternating surface. The
   content sits in .section__inner, the same 1280 px column and gutters as .container. */
.section {
    padding-block: var(--section-space);
    background: var(--section-bg, transparent);
}

.section--cream { --section-bg: var(--cream); }
.section--cream-light { --section-bg: var(--cream-light); }

/* Two bands of the same surface in a row read as one: no doubled gap between them. */
.section--cream + .section--cream,
.section--cream-light + .section--cream-light,
.section--choco + .section--choco { padding-block-start: 0; }

/* Chocolate band: cream text; the chartreuse ring alone has ample contrast here (as .on-choco). */
.section--choco {
    --section-bg: var(--choco);
    color: var(--cream);
}
/* Only the band's own headings turn light; those on a nested cream card (.on-light) keep the dark heading colour. */
.section--choco :is(h2, h3):not(.on-light *) { color: var(--cream-light); }
.section--choco :focus-visible:not(.on-light *) { box-shadow: none; }

.section__inner {
    inline-size: 100%;
    max-inline-size: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.stack > * + * { margin-block-start: var(--stack-space, var(--space-4)); }

/* ------------------------------------------------------------------ buttons (handoff §5.1) */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-block-size: 44px;
    padding: var(--space-3) var(--space-5);
    border: 1px solid transparent;
    border-radius: var(--radius-2xl);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 700;
    line-height: 1.42;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        background-color var(--dur-press) var(--ease-out),
        color var(--dur-press) var(--ease-out),
        box-shadow var(--dur-press) var(--ease-out),
        transform var(--dur-press) var(--ease-out);
}

.btn:disabled { opacity: 0.55; }

/* Primary chartreuse CTA */
.btn--primary {
    background: var(--chartreuse);
    color: var(--choco-dark);
    font-weight: 800;
    box-shadow: var(--shadow-chartreuse);
}
.btn--primary:not(:disabled):hover { background: var(--chartreuse-hover); }
.btn--primary:not(:disabled):active { transform: scale(0.98); }
/* Its own shadow would replace the global focus ring's chocolate inner ring: keep both. */
.btn--primary:focus-visible { box-shadow: 0 0 0 2px var(--choco), var(--shadow-chartreuse); }
/* On chocolate the chocolate inner ring would vanish into the surface and only thicken the button's edge: the
   chartreuse outline alone shows there. Higher specificity than the rule above, so it wins wherever it is declared. */
:is(.on-choco, .section--choco) .btn--primary:focus-visible:not(.on-light *) { box-shadow: var(--shadow-chartreuse); }

/* Secondary light CTA */
.btn--light {
    background: var(--cream-light);
    border-color: var(--cream-light);
    color: var(--choco-dark);
}
.btn--light:not(:disabled):hover { background: var(--white); }

/* Chocolate (used on cream pages such as 404) */
.btn--dark {
    background: var(--choco);
    color: var(--cream-light);
}
.btn--dark:not(:disabled):hover { background: var(--choco-dark); }

/* ------------------------------------------------------------------ configurator step cards (handoff §4.2) */
/* bg-cream-light p-5 rounded-3xl border border-cream-border shadow-warm space-y-4; the step title is the
   template's small uppercase label (text-sm font-extrabold uppercase tracking-wide). */

.step-card {
    display: grid;
    gap: var(--space-4);
    min-inline-size: 0;
    padding: var(--space-5);
    border: 1px solid var(--cream-border);
    border-radius: var(--radius-3xl);
    background: var(--cream-light);
    box-shadow: var(--shadow-warm);
}

.step-card__title {
    color: var(--choco-dark);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 800;
    line-height: 1.25rem;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.step-card__hint {
    color: var(--choco-muted);
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1rem;
}

/* ------------------------------------------------------------------ Blazor error UI */

#blazor-error-ui {
    position: fixed;
    inset-inline: var(--space-4);
    inset-block-end: calc(var(--space-4) + env(safe-area-inset-bottom));
    z-index: 1000;
    display: none;
    align-items: center;
    gap: var(--space-4);
    max-inline-size: 32rem;
    margin-inline: auto;
    padding: var(--space-3) var(--space-4);
    border: 1px solid rgb(194 198 41 / 0.4);
    border-radius: var(--radius-2xl);
    background: var(--choco-dark);
    color: var(--cream-light);
    box-shadow: var(--shadow-warm-lg);
    font-size: var(--text-sm);
    font-weight: 600;
}
/* Blazor shows the bar with an inline display:block; lay it out as a row instead. */
#blazor-error-ui[style*="block"] { display: flex !important; }
#blazor-error-ui .reload { font-weight: 800; color: var(--chartreuse); }
#blazor-error-ui .dismiss { margin-inline-start: auto; min-inline-size: 44px; min-block-size: 44px; color: inherit; }

.blazor-error-boundary {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-2xl);
    background: var(--choco-dark);
    color: var(--cream-light);
}

/* ------------------------------------------------------------------ reduced motion */

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