/* ==========================================================================
   site.css — shared shell for jeff-parker.com
   Hand-written. No frameworks, no CDN, no external fonts.
   ========================================================================== */

/* --- reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img, picture, svg, video, canvas { display: block; max-width: 100%; }

/* Images carry width/height attributes so the browser can reserve space and
   avoid layout shift. But an attribute height makes the height *definite*,
   which switches off CSS aspect-ratio and lets object-fit crop the picture.
   height:auto hands control back to the stylesheet. Any rule that sets an
   explicit height still wins — this is an element selector. */
img { height: auto; }

/* The display rules above are author styles, and author styles beat the
   browser's own [hidden] { display: none } no matter the specificity. Without
   this, setting .hidden on an <img> or on anything with a display rule does
   nothing at all. Same reason .loadmore and .episode__hero need it. */
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* --- global tokens -------------------------------------------------------- */
:root {
  /* type stacks — system only, so nothing is fetched from a third party */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
                  "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;

  /* brand constants — these do NOT change with the season */
  --ink:        #2f4a72;
  --ink-deep:   #1d3153;
  --ink-soft:   #4a6491;
  --bar:        #26456b;
  --bar-hi:     #33578a;
  --plaque-1:   #f0e0bd;
  --plaque-2:   #d7bd8d;
  --plaque-3:   #b99a68;

  --shell-max:  46rem;
  --radius:     14px;
  --radius-lg:  26px;

  --topbar-h:   3.5rem;

  --shadow-sm:  0 1px 3px rgba(20, 35, 60, .18);
  --shadow-md:  0 6px 20px rgba(20, 35, 60, .20);
  --shadow-lg:  0 18px 48px rgba(20, 35, 60, .28);

  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* --- page frame ----------------------------------------------------------- */
body {
  min-height: 100svh;
  font-family: var(--font-body);
  color: var(--ink-deep);
  background: var(--season-bg-flat, #dfe4ee);
  overflow-x: hidden;
  padding-top: var(--topbar-h);
  -webkit-font-smoothing: antialiased;
}

/* The animated seasonal wash + particle canvas live behind everything. */
#backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: var(--season-wash);
  transition: background 900ms var(--ease);
}
#backdrop::after {
  /* soft vignette so the centred column always stays legible */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 50% 42%,
              rgba(255,255,255,.42) 0%,
              rgba(255,255,255,.12) 45%,
              rgba(255,255,255,0) 78%);
}
#particles {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* --- top bar -------------------------------------------------------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 .75rem;
  padding-top: env(safe-area-inset-top, 0);
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, var(--bar-hi), var(--bar));
  box-shadow: var(--shadow-sm);
  color: #eaf1fb;
}

.iconbtn {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  color: inherit;
  transition: background 160ms var(--ease), transform 160ms var(--ease);
}
.iconbtn:hover { background: rgba(255,255,255,.12); }
.iconbtn:active { transform: scale(.92); }
.iconbtn svg { width: 1.55rem; height: 1.55rem; }

/* focus ring, consistent everywhere */
:where(a, button, [tabindex]):focus-visible {
  outline: 3px solid #ffd66b;
  outline-offset: 2px;
  border-radius: 6px;
}

.topbar__spacer { flex: 1 1 auto; }

/* the white "PWA Install" pill from the design */
.installpill {
  flex: 0 1 22rem;
  margin: 0 auto;
  height: 2.35rem;
  display: none;              /* shown by ui.js only when installable */
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #33405a;
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.22);
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.installpill.is-visible { display: flex; }
.installpill:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.28); }
.installpill:active { transform: translateY(0) scale(.98); }
.installpill__glyph {
  width: 1.2rem; height: 1.2rem;
  border-radius: 5px;
  background: #4a3b2c;
  color: #fff;
  font-size: .5rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  letter-spacing: .04em;
}

/* --- slide-out menu ------------------------------------------------------- */
.menu {
  position: fixed;
  top: 0; left: 0;
  height: 100svh;
  width: min(19rem, 84vw);
  z-index: 100;
  padding: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 1rem) 1.25rem 1.5rem;
  background: linear-gradient(180deg, #2c4e77, #1c3454);
  color: #e7eefa;
  box-shadow: 12px 0 40px rgba(10,20,40,.4);
  transform: translateX(-102%);
  transition: transform 320ms var(--ease);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.menu[data-open="true"] { transform: translateX(0); }

.menu__title {
  font-family: var(--font-display);
  font-size: .78rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #9fc0e6;
  margin-bottom: .9rem;
}
.menu__list li + li { margin-top: .15rem; }
.menu__list a {
  display: block;
  padding: .8rem .85rem;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 1.12rem;
  transition: background 160ms var(--ease), padding-left 160ms var(--ease);
}
.menu__list a:hover,
.menu__list a[aria-current="page"] {
  background: rgba(255,255,255,.11);
  padding-left: 1.15rem;
}
.menu__list a[aria-current="page"] { color: #ffd98a; }

.menu__rule {
  height: 1px;
  background: rgba(255,255,255,.16);
  margin: 1.1rem 0;
  border: 0;
}

/* season switcher inside the menu */
.seasonpick { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; }
.seasonpick button {
  padding: .55rem .4rem;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 9px;
  background: rgba(255,255,255,.06);
  color: inherit;
  font-size: .8rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 160ms var(--ease), border-color 160ms var(--ease);
}
.seasonpick button:hover { background: rgba(255,255,255,.16); }
.seasonpick button[aria-pressed="true"] {
  background: #ffd98a;
  border-color: #ffd98a;
  color: #24405f;
  font-weight: 700;
}
.menu__hint {
  margin-top: .7rem;
  font-size: .74rem;
  line-height: 1.5;
  color: #a7c2e4;
}
.menu__hint button {
  border: 0; background: none; padding: 0;
  color: #ffd98a; cursor: pointer; text-decoration: underline;
  font-size: inherit;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(12, 22, 40, .5);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 280ms var(--ease), visibility 280ms;
}
.scrim[data-open="true"] { opacity: 1; visibility: visible; }

/* --- iOS "Add to Home Screen" sheet --------------------------------------- */
.iossheet {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 160%);
  width: min(24rem, calc(100vw - 1.5rem));
  z-index: 110;
  padding: 1.1rem 1.2rem 1.2rem;
  border-radius: 18px;
  background: #fdfcf8;
  color: #2b3d5c;
  box-shadow: var(--shadow-lg);
  transition: transform 420ms var(--ease);
}
.iossheet[data-open="true"] { transform: translate(-50%, 0); }
.iossheet h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: .45rem;
}
.iossheet p { font-size: .88rem; line-height: 1.6; }
.iossheet ol {
  list-style: decimal;
  padding-left: 1.15rem;
  margin: .7rem 0 0;
  font-size: .88rem;
  line-height: 1.75;
}
.iossheet__close {
  position: absolute;
  top: .5rem; right: .5rem;
  width: 2rem; height: 2rem;
  border: 0; border-radius: 50%;
  background: rgba(43,61,92,.08);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.iossheet__tail {
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 18px; height: 18px;
  transform: translateX(-50%) rotate(45deg);
  background: #fdfcf8;
}
.shareglyph {
  display: inline-block;
  width: 1em; height: 1em;
  vertical-align: -.12em;
}

/* --- update toast --------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translate(-50%, 200%);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .7rem .8rem .7rem 1.1rem;
  border-radius: 999px;
  background: #23385c;
  color: #eef4ff;
  font-size: .87rem;
  box-shadow: var(--shadow-md);
  transition: transform 380ms var(--ease);
}
.toast[data-open="true"] { transform: translate(-50%, 0); }
.toast button {
  border: 0;
  border-radius: 999px;
  padding: .4rem .9rem;
  background: #ffd98a;
  color: #23385c;
  font-weight: 700;
  cursor: pointer;
}

/* --- generic page furniture ---------------------------------------------- */
.shell {
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 1.5rem 1.15rem 4rem;
}

.pagehead { text-align: center; margin: 1.5rem 0 2rem; }
.pagehead h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 3rem);
  color: var(--ink);
  letter-spacing: -.015em;
  line-height: 1.05;
}
.pagehead p {
  margin-top: .55rem;
  font-size: .95rem;
  color: var(--ink-soft);
  font-style: italic;
}

.card {
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(47,74,114,.14);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
  padding: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .62rem 1.15rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: .87rem;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: transform 150ms var(--ease), background 150ms var(--ease);
}
.btn:hover { background: var(--ink-deep); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: rgba(47,74,114,.1); }

.backlink {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  color: var(--ink-soft);
  margin-bottom: .5rem;
}
.backlink:hover { color: var(--ink); }

.sitefoot {
  text-align: center;
  padding: 2rem 1rem calc(2rem + env(safe-area-inset-bottom, 0px));
  font-size: .78rem;
  color: var(--ink-soft);
  opacity: .85;
}

/* accessibility helpers */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skiplink {
  position: absolute;
  top: -4rem; left: .5rem;
  z-index: 200;
  padding: .6rem 1rem;
  background: #fff;
  color: var(--ink-deep);
  border-radius: 0 0 10px 10px;
  transition: top 180ms var(--ease);
}
.skiplink:focus { top: 0; }

/* honour the user's motion preference for the particle layer too */
@media (prefers-reduced-motion: reduce) {
  #particles { display: none; }
}
