/* ============================================================
   BASE — reset, typography, accessibility primitives
   ============================================================ */

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

* {
    margin: 0;
}

/* The reset above is what pinned every modal to the top left corner: the
   browser centres an open `<dialog>` with its own `margin: auto`, and `*`
   outranks a UA rule. Putting it back is the whole centring mechanism. */
dialog {
    margin: auto;
}

/* The browser hides `[hidden]` with a plain `display: none`, which ANY class
   setting `display` outranks. `.message` is `display: flex` and `.yuna-speech`
   is `display: grid`, so both rendered as empty boxes on the reading page
   while still carrying the attribute. This is the one place `!important`
   earns its keep: the attribute has to win over every layout rule. */
[hidden] {
    display: none !important;
}

html {
    /* 15px on a phone, 16px from a tablet up. Every size and every space in
       the app is in rem, so moving the root moves the whole system together
       instead of leaving the type small inside desktop-sized boxes. */
    font-size: clamp(0.9375rem, 0.875rem + 0.3vw, 1rem);
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    /* The page colour lives here, not on `body`, so the `.sky` layer at
       z-index -1 is guaranteed to paint above it rather than behind it. */
    background-color: var(--bg-page);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-sans);
    /* Cormorant draws old-style figures by default, so a 1 came out as a
       small roman numeral and the 3, 4 and 9 dropped below the baseline.
       Its subset ships `lnum` and `tnum`, so asking for them once here fixes
       every digit in the app rather than one rule at a time. */
    font-variant-numeric: lining-nums tabular-nums;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    /* Transparent: the colour is on `html` and the atmosphere on `.sky`. */
    background: transparent;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    /* Guards against any child forcing the viewport wider on mobile. */
    overflow-x: hidden;
}

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

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

button {
    cursor: pointer;
    background: none;
    border: none;
}

a {
    color: var(--accent);
    text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
    text-underline-offset: 0.2em;
    transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
    color: var(--accent-hover);
}

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

/* --- Headings -------------------------------------------- */

h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
    text-wrap: balance;
}

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

/* A phone is not a small desktop: the headings step down one size rather
   than keeping a scale drawn for a wide screen. */
@media (max-width: 639px) {
    h1 { font-size: var(--text-2xl); }
    h2 { font-size: var(--text-xl); }
    h3 { font-size: var(--text-lg); }
}
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

@media (min-width: 768px) {
    h1 { font-size: var(--text-4xl); }
}

/* --- Shared text utilities -------------------------------- */

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--accent-ink);
}

.lead {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    text-wrap: pretty;
}

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

/* --- Accessibility ---------------------------------------- */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: var(--z-overlay);
    padding: var(--space-2) var(--space-4);
    font-weight: var(--weight-semibold);
    color: var(--text-on-accent);
    background: var(--accent);
    border-radius: var(--radius-md);
    transform: translateY(-200%);
    transition: transform var(--duration-fast) var(--ease-out);
}

.skip-link:focus-visible {
    transform: translateY(0);
}

:focus-visible {
    outline: var(--border-width-thick) solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* --- Material Symbols ------------------------------------- */

.material-symbols-rounded {
    font-family: "Material Symbols Rounded", sans-serif;
    font-weight: normal;
    font-style: normal;
    font-size: 1.25em;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    direction: ltr;
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
    /* Hide the ligature text while the icon font loads. */
    font-feature-settings: "liga";
    -webkit-font-feature-settings: "liga";
    user-select: none;
    flex-shrink: 0;
}

/* --- Motion preferences ----------------------------------- */

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

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- Print ------------------------------------------------- */

@media print {
    .site-nav,
    .site-footer {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }
}
