/* Dreaming Ages: readability + accessibility layer (WCAG 2.2 AA, most AAA text rules).
   Loaded AFTER each page's own inline <style>, so it wins on equal specificity (":root:root body" prefix adds a little more).
   Night look and brand colours are unchanged; this only raises text size/contrast/spacing, limits line length,
   keeps stars out of the text column, and adds a skip link, strong focus rings and reduced-motion/contrast support. */

:root{
  --da-ink:#f4f1e8;          /* body text, near-white warm   (~16:1 on the page navy) */
  --da-ink-2:#dfe2f1;        /* secondary text               (~13:1) */
  --da-gold:#f3e6b4;         /* links + headings accent      (~14:1) */
  --da-gold-2:#ecdca0;       /* timestamps / badges          (~13:1) */
  --da-col:23rem;            /* half the text column: stars are masked inside this */
}

/* 1. Size: 18px default, in rem so browser text-size and zoom still scale it */
html{font-size:112.5%;-webkit-text-size-adjust:100%;text-size-adjust:100%}
:root:root body{font-size:1rem;color:var(--da-ink);line-height:1.7}
:root:root body :is(p,li,dd,dt,td,th,figcaption,summary,label,blockquote){font-size:1rem;line-height:1.7;color:var(--da-ink)}
:root:root body :is(ol,ul){line-height:1.7}
:root:root body .lead{font-size:1.1875rem;color:#fff;line-height:1.65}
:root:root body .sub{font-size:1.25rem;line-height:1.65;color:var(--da-ink)}

/* secondary / small text: never below 16px, and still high contrast */
:root:root body :is(.small,.meta,.fine,.yt-note,.disc,.consent,.crumbs,.eyebrow,.phase,.when,.chip,.open,.note,.ytm,.c,.sources li,small,footer,.da-site,.da-topnav,.brand,.badge,.num,.q-kicker,.getit,.tl,.ep small,.ep span){font-size:.9rem;line-height:1.6}
/* muted grey-blue secondary text -> lighter; gold accents (.badge .brand .num .when .chip .q-kicker .open) keep their own colours */
:root:root body :is(.small,.meta,.fine,.yt-note,.disc,.consent,.crumbs,.eyebrow,.note,.ytm,.c,.sources li,small,footer,.da-site){color:var(--da-ink-2)}
:root:root body :is(.sources li){font-size:.95rem}
:root:root body .da-topnav{font-size:.95rem}
:root:root body .da-topnav .wm{font-size:.85rem}
:root:root body .da-site{font-size:.95rem;line-height:1.8;color:var(--da-ink-2)}
:root:root body .brand{font-size:.9rem}
:root:root body .btn{font-size:1.0625rem;min-height:2.75rem;padding:.7rem 1.3rem;box-sizing:border-box}
/* 26 Oct 2026: a button in an episode's companion box names the episode ('Get the Day of the Dead companion'); a long name wraps inside the button, which grows taller to fit (never clipped, never wider than the card) */
:root:root body .prose .card .btn{max-width:100%;text-align:center;line-height:1.35;overflow-wrap:anywhere}

/* 2. Headings keep their look, with a little more air */
:root:root body h1{line-height:1.2}
:root:root body h2{line-height:1.3}
:root:root body h3{line-height:1.35}

/* 3. Line length: about 65-75 characters. Episode pages: the whole article column is centred at 31em (about 72 characters
   of Georgia at 18px); video and header stay full width. Other pages: paragraphs capped, centred ones stay centred. */
:root:root body :is(.prose,article){max-width:31em;margin-left:auto;margin-right:auto}
:root:root body main :is(p,li):not(.badge){max-width:34em}
:root:root body :is(.center,.sub,.hero,.cta,.intro) :is(p,.sub){margin-left:auto;margin-right:auto}
:root:root body :is(.prose,article) :is(p,li,ol,ul){max-width:none}
:root:root body main :is(.meta,.watch,.sub,.brand,p[style*="center"]){margin-left:auto;margin-right:auto}

/* 4. Links: always underlined inside text, thicker, with a gold that passes on the navy */
:root:root body a{text-decoration-thickness:.075em;text-underline-offset:.2em}
:root:root body :is(p,li,small,.small,.fine,.c) a:not(.btn):not(.ep):not(.tl){text-decoration-line:underline}
:root:root body a:hover{color:#fff}
:root:root body .chapters .t,:root:root body .chapters .t{color:var(--da-gold-2)}
:root:root body .chapters li{color:var(--da-ink)}
:root:root body .chapters a{color:var(--da-ink);border-bottom-width:2px}
:root:root body .da-topnav a,:root:root body .da-site a{display:inline-block;padding:.45rem .3rem;margin:0 .15rem}
:root:root body .da-topnav a:not([aria-current]){color:var(--da-ink-2)}
:root:root body .da-topnav a[aria-current]{color:#fff}
:root:root body .da-topnav .wm{padding:.45rem 0;margin:0;color:#e6d9a8}
:root:root body .crumbs a{color:var(--da-ink-2);text-decoration:underline}

/* 5. Cards: more opaque so the text sits on a calm dark panel */
:root:root body main :is(.card,.ep){background:rgba(10,14,30,.9)}

/* 6. Stars stay in the margins. The sky canvas is masked inside the text column; on narrow screens the column is the whole screen, so stars are hidden. */
:root:root body #sky{
  -webkit-mask-image:linear-gradient(to right,#000 0,#000 calc(50% - var(--da-col) - 2rem),transparent calc(50% - var(--da-col)),transparent calc(50% + var(--da-col)),#000 calc(50% + var(--da-col) + 2rem),#000 100%);
          mask-image:linear-gradient(to right,#000 0,#000 calc(50% - var(--da-col) - 2rem),transparent calc(50% - var(--da-col)),transparent calc(50% + var(--da-col)),#000 calc(50% + var(--da-col) + 2rem),#000 100%);
  opacity:.85}
/* 6b. Phones and narrow windows (preview 26 Oct 2026): the column is the whole screen, so instead of hiding the night sky it is kept
   to the top of the screen: stars fade out by 60% of the height, fainter than on desktop (35% opacity keeps body text above 4.5:1 even
   directly behind a star), and a smaller crescent moon sits in the top-right corner just under the nav row, scrolls away with the page and stays behind the text. */
@media (max-width:52rem){
  :root:root body #sky{opacity:.35;
    -webkit-mask-image:linear-gradient(to bottom,#000 0,#000 25%,transparent 60%);mask-image:linear-gradient(to bottom,#000 0,#000 25%,transparent 60%)}
  :root:root body:has(#sky) .moon{position:absolute;top:5.4rem;right:.9rem;left:auto;width:28px;height:28px;
    box-shadow:inset -5px 4px 0 0 #f1e6c0;filter:drop-shadow(0 0 5px rgba(255,246,210,.3));opacity:.85;pointer-events:none}
}

/* 7. Focus: two-tone ring (white outside, dark inside) that shows on navy AND on the gold buttons */
:root:root body :is(a,button,input,select,textarea,summary,[tabindex]:not([tabindex="-1"])):focus-visible{
  outline:3px solid #fff;outline-offset:3px;box-shadow:0 0 0 3px #05070f;border-radius:3px}
:root:root body :is(a,button,input,select,textarea,summary):focus:not(:focus-visible){outline:none}
:root:root body input,:root:root body select,:root:root body textarea{font-size:1rem;min-height:2.75rem;color:#fff}
:root:root body input::placeholder{color:#c9cde4;opacity:1}

/* 8. Skip link */
.da-skip{position:absolute;left:.75rem;top:-6rem;z-index:1000;padding:.8rem 1.1rem;background:#f4eedc;color:#0d1326;
  font:1rem/1.3 Georgia,"Times New Roman",serif;border-radius:8px;text-decoration:underline;transition:none}
.da-skip:focus{top:.75rem;outline:3px solid #fff;box-shadow:0 0 0 3px #05070f}
[id="da-main"]:focus{outline:none}

/* 9. Motion: no stars or animation for people who ask for less */
@media (prefers-reduced-motion:reduce){
  /* stars are drawn once and do not twinkle (see da_readable._patch_sky_js); the page's own rule that hid them is overridden here */
  :root:root body #sky{display:block}
  :root:root body *,:root:root body *::before,:root:root body *::after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition:none!important;scroll-behavior:auto!important}
}

/* 10. High-contrast preference: pure white text, no stars, solid panels, firmer borders */
@media (prefers-contrast:more){
  :root:root body{color:#fff}
  :root:root body :is(p,li,.small,.meta,.fine,.crumbs,.sources li,.da-site,.da-topnav a){color:#fff}
  :root:root body #sky{display:none}
  :root:root body main :is(.card,.ep){background:#0a0e1e;border-color:#cfd3ea}
  :root:root body a{color:#fff3c4}
}

/* 11. Top nav must wrap rather than run off the edge on phones and at 200-400% zoom */
:root:root body .da-topnav .l{flex-wrap:wrap;gap:0 .6rem}
:root:root body .da-topnav{gap:0 .8rem}

/* 12. Footnote numbers (superscript links in the sleep guide) were about 11px; make them readable and easier to hit */
:root:root body sup{font-size:.8em}
:root:root body sup a{opacity:1;padding:0 .25em;text-decoration:underline}
:root:root body .ep span{font-size:1rem;color:var(--da-ink)}
:root:root body .ep small{font-size:.9rem}

/* 13. Touch targets (second patch, Ian 25 Oct 2026): links that stand on their own line are at least 44px tall.
   Links inside a sentence stay inline (WCAG 2.5.8 exempts them) so paragraphs do not change. */
:root:root body :is(.da-topnav,.da-site,footer,.crumbs,.links) a,
:root:root body :is(li,p.small,p.links,.watch,.disc):has(> a:only-child) > a,
:root:root body .chapters a,
:root:root body :is(a.getit,a.tl,.back){display:inline-flex;align-items:center;min-height:44px;box-sizing:border-box;vertical-align:middle}
:root:root body .chapters a{display:flex;border-bottom:0;padding:.25rem 0;text-decoration:underline;text-decoration-thickness:.075em;text-underline-offset:.2em}
:root:root body .chapters li{border-bottom:1px solid rgba(217,201,143,.25)}
:root:root body .da-topnav a,:root:root body .da-site a{padding:.2rem .5rem}

/* 14. Kit signup: visible labels above each field (the placeholder alone disappears while typing) */
.da-fl{display:block;text-align:left;margin:0 0 .35rem;font-size:1rem;line-height:1.4;color:var(--da-ink,#f4f1e8)}
:root:root body form .da-fl + input{margin-bottom:1rem}

/* 15. Pages whose content was wrapped in <main> by da_readable.py (the 404): keep the 34em column centred, as the page's own text-align:center intends */
:root:root body main[data-da="wrap"]{max-width:34em;margin-left:auto;margin-right:auto}

/* 16. Footer (preview 26 Oct 2026): three evenly spaced, centred link groups, then one short line and the contact address on their own lines.
   Phones: each group is a 2-column grid so every link has the same width and a 44px target. Desktop: each group is one centred row. */
:root:root body .da-site{display:flex;flex-direction:column;align-items:center;gap:0;max-width:40rem;margin:2.5rem auto 1.25rem;padding:1.1rem .75rem 0;text-align:center}
:root:root body .da-site .g{display:flex;flex-wrap:wrap;justify-content:center;gap:0 .6rem;width:100%}
:root:root body .da-site .g a{margin:0;padding:.2rem .6rem}
:root:root body .da-site .c{display:block;flex-basis:auto;width:100%;margin:.45rem 0 0;text-align:center}
:root:root body .da-site .c + .c{margin-top:0}
:root:root body .da-site .c a{margin:0}
@media (max-width:40rem){
  :root:root body .da-site .g{display:grid;grid-template-columns:1fr 1fr;gap:0;max-width:21rem}
  :root:root body .da-site .g a{justify-content:center;text-align:center;white-space:normal;padding:.2rem .4rem}
}
@media (max-width:24rem){:root:root body .da-site{padding-left:0;padding-right:0}:root:root body .da-site .g{max-width:none}:root:root body .da-site .g a{padding:.2rem 0;font-size:.9rem}}

/* 17. Long unbroken text (source URLs on the episode pages) wraps instead of pushing the page wider than a phone screen (all-hallows was 409px wide at 400px) */
:root:root body :is(main,article) :is(p,li,dd,figcaption,a){overflow-wrap:break-word}

/* 18. Day / Night switch (preview 26 Oct 2026). Night is the default look and is not touched by anything below.
   Day (<html data-theme="day">, set by the inline script in <head> from localStorage) is a calm cream page with deep-navy text and dark-gold
   accents, no stars; the moon becomes a faint sun. Every rule is under :root:root[data-theme="day"] so Night pages are unchanged and
   pages with no JS stay Night. Contrast is checked by scripts/release/test_da_readable.py (palette) and a browser audit over every page. */
.da-theme{display:inline-flex;align-items:center;gap:.45rem;box-sizing:border-box;min-height:44px;min-width:44px;padding:0 .85rem;margin:0;
  font:inherit;font-size:.85rem;line-height:1;color:#dfe2f1;background:transparent;border:1px solid #8d94b3;border-radius:22px;cursor:pointer;
  -webkit-appearance:none;appearance:none;white-space:nowrap}
.da-theme[hidden]{display:none}
.da-theme svg{flex:none;display:block}
.da-theme:hover{border-color:#f3e6b4;color:#fff}
:root{--dd-ink:#1b2342;--dd-ink2:#39426a;--dd-gold:#7a5200;--dd-line:#6b7390;--dd-card:rgba(255,255,255,.72)}
:root:root[data-theme="day"]{--ink:#1b2342;--soft:#39426a;--mute:#4f5878;--muted:#4f5878;--quiet:#4f5878;--gold:#7a5200;--gold2:#7a5200;--gold-soft:#7a5200;--gold-line:rgba(122,82,0,.5);--card:rgba(255,255,255,.72);--line:rgba(122,82,0,.45)}   /* the pages' own colour variables */
:root:root[data-theme="day"] body{background:linear-gradient(180deg,#fcf8ec 0,#f8f1de 55%,#f2e9d0 100%) fixed;background-color:#f8f1de;color:var(--dd-ink);text-shadow:none}
:root:root[data-theme="day"] body :is(h1,h2,h3,h4,h5,p,li,ul,ol,div,span,small,em,strong,b,i,cite,time,dt,dd,td,th,label,summary,details,blockquote,figcaption,section,article,header,main,footer){color:var(--dd-ink);text-shadow:none}
:root:root[data-theme="day"] body :is(.small,.meta,.fine,.sub,.lead,.crumbs,.t,.date,.sources li,.cinzel,figcaption,.da-site .c,.da-site .c span,.ep small,.ep span,.chapters .t,.note,.disc){color:var(--dd-ink2)}
:root:root[data-theme="day"] body :is(.badge,.eyebrow,.kicker,.k,.n,.tag,.chip){color:var(--dd-gold)}
:root:root[data-theme="day"] body .num{color:#151b38}
:root:root[data-theme="day"] body a{color:var(--dd-gold)}
:root:root[data-theme="day"] body a:hover{color:var(--dd-ink)}
:root:root[data-theme="day"] body :is(.da-topnav a:not([aria-current]),.da-site a,.crumbs a){color:var(--dd-ink2)}
:root:root[data-theme="day"] body .da-topnav a[aria-current]{color:var(--dd-ink);text-decoration-color:rgba(122,82,0,.6)}
:root:root[data-theme="day"] body .da-topnav .wm{color:var(--dd-gold)}
:root:root[data-theme="day"] body .da-site{border-top-color:rgba(27,35,66,.2)}
:root:root[data-theme="day"] body .da-site .c a{color:var(--dd-gold)}
/* pages that style the body and headings inline (the 404) need !important to follow the switch */
:root:root[data-theme="day"] body[style]{background:#f8f1de!important;color:#1b2342!important}
:root:root[data-theme="day"] body :is(h1,a)[style*="color"]{color:var(--dd-gold)!important}
:root:root[data-theme="day"] body h1[style*="color"]{color:var(--dd-ink)!important}
/* cards, panels, forms */
:root:root[data-theme="day"] body :is(.card,.ep,.hcard,.comp,.prose,.signup,.quiz,.cta,.book,.note,details.narr,li.comp,main.card,.steps li,.tips li,.ai li){background:var(--dd-card);background-image:none;border-color:rgba(27,35,66,.2)}
:root:root[data-theme="day"] body main :is(.card,.ep){background:var(--dd-card)}
:root:root[data-theme="day"] body :is(.badge,.chip,.n,a.tl,a.getit,.back){border-color:rgba(122,82,0,.5)}
:root:root[data-theme="day"] body :is(li,.chapters li,.book){border-color:rgba(27,35,66,.18)}
:root:root[data-theme="day"] body input,:root:root[data-theme="day"] body select,:root:root[data-theme="day"] body textarea{background:#fff;color:var(--dd-ink);border:1px solid var(--dd-line)}
:root:root[data-theme="day"] body input::placeholder{color:#575f80;opacity:1}
/* buttons: gold fill with dark text stays; ghost buttons get a navy outline */
:root:root[data-theme="day"] body :is(a.btn,button.btn,.btn,button:not(.da-theme):not(.yt)){color:#151b38}
:root:root[data-theme="day"] body :is(a.btn,button.btn,.btn):hover{color:#151b38}
:root:root[data-theme="day"] body :is(a.btn,button.btn,.btn):not(.ghost),:root:root[data-theme="day"] body .num{background-color:#e3c77a;box-shadow:inset 0 0 0 1px rgba(122,82,0,.55)}
:root:root[data-theme="day"] body :is(a.btn.ghost,.btn.ghost){color:var(--dd-ink);background:transparent;border-color:var(--dd-line)}
:root:root[data-theme="day"] body :is(.bar){background:rgba(27,35,66,.14)}
:root:root[data-theme="day"] body .steps .n{background:transparent}
/* video tiles are photographs on a dark ground: they keep their night look */
:root:root[data-theme="day"] body .vid,:root:root[data-theme="day"] body .vid *{color:#f4eedc}
:root:root[data-theme="day"] body .vid{border-color:rgba(27,35,66,.25)}
/* sky: no stars; the moon becomes a faint sun */
:root:root[data-theme="day"] body #sky{display:none}
:root:root[data-theme="day"] body .sky{background-image:none}
:root:root[data-theme="day"] body .moon{background:radial-gradient(circle at 42% 40%,#fff3c8 0,#f6d98a 60%,#efc566 100%)!important;box-shadow:none!important;filter:drop-shadow(0 0 10px rgba(239,197,102,.4))!important;opacity:.6!important;transform:none!important}
/* focus ring: navy outside, white inside, so it shows on cream and on gold */
:root:root[data-theme="day"] body :is(a,button,input,select,textarea,summary,[tabindex]:not([tabindex="-1"])):focus-visible{outline:3px solid #1b2342;outline-offset:3px;box-shadow:0 0 0 3px #fff}
:root:root[data-theme="day"] body .da-theme{color:var(--dd-ink);border-color:var(--dd-line)}
:root:root[data-theme="day"] body .da-theme:hover{border-color:var(--dd-ink);color:var(--dd-ink)}
/* the label inside the switch follows the button, not the generic span colour above */
:root:root[data-theme="day"] body .da-theme span{color:inherit}
/* legacy: pages published at 5:19-5:27 PM ET on 25 Oct carried two icons + two labels in the button; this keeps those cached pages showing one of each. New pages have one icon and one label (set by the head script) and do not use these classes. */
.da-theme .da-moon,.da-theme .da-n{display:none}
:root:root[data-theme="day"] body .da-theme .da-sun,:root:root[data-theme="day"] body .da-theme .da-d{display:none}
:root:root[data-theme="day"] body .da-theme .da-moon{display:block}
:root:root[data-theme="day"] body .da-theme .da-n{display:inline}
@media (prefers-contrast:more){
  :root:root[data-theme="day"] body{background:#fff;color:#000}
  :root:root[data-theme="day"] body :is(p,li,div,span,small,h1,h2,h3,.small,.meta,.fine,.crumbs,.da-site a,.da-topnav a){color:#000}
  :root:root[data-theme="day"] body a{color:#4a3000}
  :root:root[data-theme="day"] body main :is(.card,.ep){background:#fff;border-color:#000}
}
@media (max-width:24rem){.da-theme{padding:0 .7rem}}
