/* ==========================================================================
   Walt Disney World Trip Planner — presentation layer  (task 2.05)

   Started as Inky's export template. Rewritten for the thing this actually is:
   ~60,000 words read on a phone across 217 pages, one tap at a time.

   What changed and why:
     * Body copy was #888 on white — about 3.5:1, which fails WCAG AA. For a
       long read that is the single worst thing in the file. Now ~13:1.
     * Everything was sized in `pt`, a print unit that ignores the reader's
       browser font-size setting. Now `rem`, so their setting is respected.
     * `font-weight: lighter` at 300 made thin grey text thinner. Now 400.
     * The masthead ate most of the first screen on a phone. Tightened.
     * Choices are the primary control on every page and were plain inline
       text. They now have real tap targets (>=44px) and a hit area.

   Load-bearing details — do not "tidy" these away:
     * `.outerContainer` must stay a positioned, scrolling element. main.js
       animates scroll by writing to its scrollTop (see scrollDown()), and
       reads scrollHeight/clientHeight off it.
     * `.container` height is written inline by main.js while choices are
       swapped, to stop the scroll jumping. Don't set a conflicting height.
     * `.hide` / `.invisible` / `.container > *` drive the fade-in.
     * Dark mode is `body.dark`, applied by main.js — which already reads
       prefers-color-scheme itself. Do NOT add a CSS media query for it, or a
       system-dark reader who chooses light will be overridden.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&family=Quattrocento:wght@700&display=swap');

:root {
    --bg:          #fdfcfa;
    --ink:         #23201c;
    --ink-muted:   #5c554d;
    --ink-faint:   #8a8177;
    --accent:      #8a5410;
    --accent-hot:  #23201c;
    --rule:        #e6e0d8;

    --measure:     34rem;      /* ~70 characters at this size */
    --step:        1.5rem;     /* vertical rhythm unit */

    --font-body:   'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                   Roboto, Helvetica, Arial, sans-serif;
    --font-display:'Quattrocento', Georgia, 'Times New Roman', Times, serif;
}

body.dark {
    /* Not pure black: white text on #000 haloes badly over a long read. */
    --bg:          #15171b;
    --ink:         #e9e6e2;
    --ink-muted:   #a49d95;
    --ink-faint:   #7b746c;
    --accent:      #e2a44b;
    --accent-hot:  #ffffff;
    --rule:        #2b2f36;
}

/* --------------------------------------------------------------- structure */

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    background: var(--bg);
    color: var(--ink);
    overflow: hidden;                  /* outerContainer does the scrolling */
    margin: 0;
}

@media screen and (prefers-reduced-motion: no-preference) {
    body.switched { transition: color 0.4s, background-color 0.4s; }
}

/* Keeps <iframe> embedding working, and main.js scrolls this element. */
.outerContainer {
    position: absolute;
    display: block;
    margin: 0;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    overflow: scroll;
    overflow-x: hidden;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    margin-top: 24px;
    background-size: cover;
    background-repeat: no-repeat;
}

@media screen and (max-width: 980px) {
    /* Clears the badge (29px) plus the controls row stacked under it. */
    .outerContainer { margin-top: 50px; }
}

.container {
    display: block;
    max-width: var(--measure);
    margin: 0 auto;
    padding: 1.25rem 1.25rem 0;
    padding-top: 2rem;
    background: var(--bg);
}

@media screen and (prefers-reduced-motion: no-preference) {
    .switched .container { transition: background-color 0.4s; }
}

/* ----------------------------------------------------------------- masthead */

h1, h2 {
    text-align: center;
    font-family: var(--font-display);
    margin: 0;
    padding: 0;
    color: var(--ink);
}

h1 {
    /* Was a flat 30pt, which wrapped to three lines and ate a phone screen. */
    font-size: clamp(1.75rem, 7vw, 2.375rem);
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 0.9375rem;
    font-style: italic;
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--ink-faint);
}

.header {
    /* Was 3em top and bottom on top of the container's 4em. */
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

.byline { font-style: italic; }

.written-in-ink {
    z-index: 3;
    font-size: 0.6875rem;
    font-family: var(--font-body);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    font-weight: 600;
    position: fixed;
    display: block;
    width: 100%;
    background: var(--bg);
    margin: 0;
    padding-top: 7px;
    padding-bottom: 7px;
    height: 15px;
    top: 0;
}

@media screen and (prefers-reduced-motion: no-preference) {
    .written-in-ink { transition: color 0.4s, background 0.4s; }
}

/* --------------------------------------------------------------- body copy */

p {
    font-size: 1.0625rem;
    color: var(--ink);
    line-height: 1.65;
    font-weight: 400;
    margin: 0 0 var(--step);
    /* Long place and attraction names shouldn't punch out of the measure. */
    overflow-wrap: break-word;
}

@media screen and (min-width: 40rem) {
    p { font-size: 1.125rem; }
}

strong { color: var(--ink); font-weight: 700; }
em     { font-style: italic; }

/* The italic disclaimer that opens the story. */
#story > p:first-of-type em,
p > em:only-child {
    color: var(--ink-muted);
}

img { display: block; margin: 0 auto; max-width: 100%; }

/* ------------------------------------------------------------------- links */

a {
    font-weight: 600;
    color: var(--accent);
    font-family: var(--font-body);
    text-decoration: none;
}

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

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

.unclickable {
    font-weight: 600;
    color: var(--ink-faint);
    font-family: var(--font-body);
    text-decoration: none;
    cursor: not-allowed;
}

@media screen and (prefers-reduced-motion: no-preference) {
    a         { transition: color 0.4s; }
    a:hover   { transition: color 0.1s; }
}

/* ----------------------------------------------------------------- choices */

/* The primary control on all 217 pages. Needs a real tap target. */
.choice {
    text-align: center;
    line-height: 1.4;
    margin: 0;
}

:not(.choice) + .choice {
    padding-top: var(--step);
    margin-top: var(--step);
    border-top: 1px solid var(--rule);
}

.choice a,
.choice span {
    font-size: 1.0625rem;
    display: block;
    padding: 0.75rem 0.5rem;      /* >=44px tall with the line-height above */
    min-height: 1.5rem;
}

.choice a:hover {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    border-radius: 6px;
}

/* --------------------------------------------------------------- story end */

.end {
    text-align: center;
    font-weight: 700;
    color: var(--ink);
    padding-top: var(--step);
    padding-bottom: var(--step);
}

/* ---------------------------------------------------------------- controls */

#controls {
    z-index: 4;
    font-size: 0.6875rem;
    text-align: center;
    padding-bottom: 6px;
    position: fixed;
    right: 14px;
    top: 5px;
    user-select: none;
    background: var(--bg);
}

@media screen and (prefers-reduced-motion: no-preference) {
    #controls { transition: color 0.4s, background 0.4s; }
}

#controls a { cursor: pointer; }
#controls [disabled] { color: var(--ink-faint); opacity: 0.55; }
#controls > *:not(:last-child):after { content: " | "; color: var(--ink-faint); }

@media screen and (max-width: 980px) {
    /* Full-width row beneath the ink badge. The badge box is 7+15+7 = 29px,
       so anything less than that here draws the controls on top of it. */
    #controls {
        z-index: 2;
        padding-top: 31px;
        top: 0;
        left: 0;
        right: 0;
    }
}

/* ------------------------------------------------------------------ footer */
/* Task 1.13. Lives outside #story so main.js's removeAll() never clears it. */

.site-footer {
    max-width: var(--measure);
    margin: calc(var(--step) * 2) auto 0;
    padding: var(--step) 1.25rem calc(var(--step) * 2);
    border-top: 1px solid var(--rule);
    color: var(--ink-muted);
    font-size: 0.8125rem;
    line-height: 1.6;
}

.site-footer p { font-size: inherit; color: inherit; margin: 0 0 0.75rem; }
.site-footer p:last-child { margin-bottom: 0; }
.site-footer a { font-weight: 600; text-decoration: underline; }
/* Needs the .site-footer prefix: `.site-footer p { color: inherit }` above is
   more specific than a bare class, and would otherwise win. */
.site-footer .footer-confirm { font-weight: 600; color: var(--ink); }

/* ------------------------------------------------------- fade-in machinery */
/* main.js toggles these; keep the selectors exactly as they are. */

.container .hide      { opacity: 0.0; }
.container .invisible { display: none; }
.container > *        { opacity: 1.0; }

@media screen and (prefers-reduced-motion: no-preference) {
    .container > * { transition: opacity 1.0s; }
}
