/* Santa Barbara Dispatches. Paper and ink from the print edition; honey and dusk from the tea-table plate. */

@font-face {
  font-family: "Bodoni Moda";
  src: url("fonts/bodoni-moda.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bodoni Moda";
  src: url("fonts/bodoni-moda-italic.woff2") format("woff2");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f6f1e4;
  --paper-deep: #ebe2cc;
  --ink: #2a241b;
  --ink-soft: #645a4b;
  --honey: #c58a1c;
  --honey-ink: #85560a;
  --dusk: #22271e;
  --dusk-lit: #3a4131;
  --on-dusk: #efe8d6;
  --on-dusk-soft: #b9b39f;
  --display: "Bodoni Moda", "Bodoni 72", Didot, "Playfair Display", Georgia, serif;
  --text: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --gutter: clamp(16px, 4vw, 56px);
}

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

html { scroll-behavior: smooth; scroll-padding-top: 12px; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 1.0625rem/1.6 var(--text);
  -webkit-text-size-adjust: 100%;
}
body.has-dock { padding-bottom: 76px; }

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-underline-offset: 4px; text-decoration-thickness: 1px; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 20;
  padding: 8px 14px; background: var(--ink); color: var(--paper);
}
.skip:focus { top: 12px; }

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

.masthead {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 8px 24px;
  margin: 0 var(--gutter);
  padding: 22px 0 16px;
  border-bottom: 1px solid var(--ink);
}
.masthead-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.25rem, 2.6vw, 2.25rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  line-height: 1.1;
  margin-right: -0.2em; /* optical: cancel the trailing tracking */
}
.masthead-line, .masthead-nav {
  margin: 0;
  font-style: italic;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}
.masthead-line span + span::before { content: " / "; padding: 0 0.35em; color: var(--honey-ink); }
.masthead-nav { display: flex; justify-content: flex-end; gap: 22px; }
.masthead-nav a { color: var(--ink); text-decoration: none; padding: 4px 0; border-bottom: 1px solid transparent; }
.masthead-nav a:hover { border-bottom-color: var(--honey); }

/* ---------- episode ---------- */

.episode {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: clamp(28px, 4.5vw, 80px);
  align-items: center;
  margin: 0 var(--gutter);
  padding: clamp(24px, 4vw, 56px) 0 clamp(40px, 6vw, 88px);
}

.plate { margin: 0; }
.plate img { width: 100%; box-shadow: 0 1px 0 rgba(42, 36, 27, 0.25), 0 28px 50px -34px rgba(42, 36, 27, 0.7); }
.plate figcaption { margin-top: 12px; font-style: italic; font-size: 0.875rem; color: var(--ink-soft); }

.episode-kind { margin: 0; font-style: italic; color: var(--honey-ink); }

h1 {
  margin: 0.12em 0 0.34em -0.04em;
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(3.5rem, 7.6vw, 8.25rem);
  line-height: 0.9;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.dek { margin: 0; max-width: 34ch; font-size: clamp(1.125rem, 1.45vw, 1.4375rem); line-height: 1.42; }

/* ---------- player ---------- */

.player { margin-top: clamp(22px, 3vw, 36px); padding-top: 18px; border-top: 1px solid var(--ink); }
.player-label { margin: 0 0 12px; font-size: 0.9375rem; color: var(--ink-soft); }
.player audio { display: block; width: 100%; }

.player-ui { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 18px; align-items: center; }

.play {
  width: 68px; height: 68px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--honey);
  color: var(--ink);
  box-shadow: inset 0 -6px 10px -4px rgba(120, 70, 0, 0.55), inset 0 5px 8px -4px rgba(255, 236, 170, 0.9);
  transition: transform 0.12s ease;
}
.play:hover { transform: scale(1.04); }
.play:active { transform: scale(0.97); }
.play svg { width: 100%; height: 100%; fill: currentColor; }
.play .i-pause { display: none; }
.is-playing .play .i-play { display: none; }
.is-playing .play .i-pause { display: block; }

.player-times { display: flex; justify-content: space-between; font-size: 0.875rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.seek {
  --p: 0%;
  --rail: rgba(42, 36, 27, 0.22);
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 22px; margin: 0;
  background: transparent; cursor: pointer;
}
.seek::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--honey) var(--p), var(--rail) var(--p));
}
.seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -6px;
  border-radius: 50%; border: 2px solid var(--paper);
  background: var(--honey-ink);
}
.seek::-moz-range-track { height: 4px; border-radius: 2px; background: var(--rail); }
.seek::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--honey); }
.seek::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--paper); background: var(--honey-ink); }

.player-extras { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; font-size: 0.9375rem; }
.player-extras button { padding: 4px 0; border: 0; background: none; border-bottom: 1px solid rgba(42, 36, 27, 0.35); font-variant-numeric: tabular-nums; }
.player-extras button:hover, .player-extras a:hover { border-bottom-color: var(--honey); color: var(--honey-ink); }
.player-extras a { margin-left: auto; text-decoration: none; padding: 4px 0; border-bottom: 1px solid rgba(42, 36, 27, 0.35); }

.episode-next { margin: clamp(22px, 3vw, 34px) 0 0; }
.episode-next a { font-weight: bold; color: var(--honey-ink); }
.episode-next span { font-style: italic; font-size: 0.9375rem; color: var(--ink-soft); }

/* ---------- the issue ---------- */

.issue {
  background: radial-gradient(120% 70% at 50% 0%, var(--dusk-lit) 0%, var(--dusk) 62%);
  color: var(--on-dusk);
  padding: clamp(28px, 3.4vw, 52px) var(--gutter) clamp(28px, 4vw, 48px);
}

.issue-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 28px; margin-bottom: clamp(18px, 2vw, 28px); }
.issue-head h2 {
  margin: 0;
  font-family: var(--display); font-style: italic; font-weight: 400;
  font-size: clamp(2.25rem, 3.6vw, 3.25rem); line-height: 1; letter-spacing: -0.02em;
}
.issue-head p { margin: 0; font-style: italic; color: var(--on-dusk-soft); }

.viewer { background: transparent; }

.viewer-stage {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(8px, 1.6vw, 24px);
  outline-offset: 10px;
}

.spread {
  --page-h: clamp(420px, calc(100vh - 215px), 940px);
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: calc(var(--page-h) * 1.5455);
  margin: 0 auto;
  filter: drop-shadow(0 34px 34px rgba(0, 0, 0, 0.45));
  touch-action: pan-y pinch-zoom;
}

.leaf {
  position: relative;
  flex: 0 1 50%;
  aspect-ratio: 612 / 792;
  background: var(--paper);
  cursor: pointer;
}
.leaf img { width: 100%; height: 100%; -webkit-user-drag: none; user-select: none; }
.leaf-left::after, .leaf-right::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 9%; pointer-events: none;
}
.leaf-left::after { right: 0; background: linear-gradient(to left, rgba(52, 38, 12, 0.2), rgba(52, 38, 12, 0)); }
.leaf-right::after { left: 0; background: linear-gradient(to right, rgba(52, 38, 12, 0.2), rgba(52, 38, 12, 0)); }

.viewer[data-layout="single"] .spread { max-width: min(900px, 100%); }
.viewer[data-layout="single"] .leaf { flex-basis: 100%; }

@keyframes turn-next { from { opacity: 0; transform: translateX(22px); } }
@keyframes turn-prev { from { opacity: 0; transform: translateX(-22px); } }
.spread.turn-next > .leaf { animation: turn-next 0.26s cubic-bezier(0.2, 0.7, 0.2, 1); }
.spread.turn-prev > .leaf { animation: turn-prev 0.26s cubic-bezier(0.2, 0.7, 0.2, 1); }

.turn {
  width: 52px; height: 52px; padding: 0;
  border: 1px solid rgba(239, 232, 214, 0.4); border-radius: 50%;
  background: rgba(34, 39, 30, 0.55); color: var(--on-dusk);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.turn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.turn:hover:not(:disabled) { background: var(--honey); border-color: var(--honey); color: var(--ink); }
.turn:disabled { opacity: 0.25; cursor: default; }

.viewer-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px 28px;
  margin-top: clamp(20px, 3vw, 34px);
  padding-top: 16px;
  border-top: 1px solid rgba(239, 232, 214, 0.22);
}
.viewer-where { margin: 0; font-family: var(--display); font-style: italic; font-size: clamp(1.0625rem, 1.5vw, 1.3125rem); }
.viewer-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font-size: 0.9375rem; }
.viewer-tools button, .viewer-tools a, .jump select {
  padding: 7px 16px; border: 1px solid rgba(239, 232, 214, 0.4); border-radius: 999px;
  background: transparent; color: var(--on-dusk); text-decoration: none; line-height: 1.3;
}
.viewer-tools button:hover, .viewer-tools a:hover, .jump select:hover { border-color: var(--honey); color: #f0c56a; }
.jump { display: flex; align-items: center; gap: 10px; }
.jump span { font-style: italic; color: var(--on-dusk-soft); }
.jump select { max-width: min(62vw, 300px); padding-right: 10px; }
.jump option { color: var(--ink); background: var(--paper); }

.thumbs {
  display: flex; gap: 10px;
  margin: 18px 0 0; padding: 6px 2px 14px;
  list-style: none;
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: thin; scrollbar-color: rgba(239, 232, 214, 0.35) transparent;
}
.thumbs li { flex: 0 0 auto; }
.thumbs li:nth-child(2n + 1):not(:first-child) { margin-left: -8px; } /* pair the facing pages */
.thumbs button {
  display: block; padding: 0; border: 0; background: none;
  color: var(--on-dusk-soft); font-size: 0.75rem; font-variant-numeric: tabular-nums; text-align: center;
}
.thumbs img { width: 58px; height: 75px; background: var(--paper); opacity: 0.62; transition: opacity 0.15s ease; }
.thumbs span { display: block; margin-top: 4px; }
.thumbs button:hover img { opacity: 1; }
.thumbs button[aria-current="true"] { color: #f0c56a; }
.thumbs button[aria-current="true"] img { opacity: 1; outline: 2px solid var(--honey); outline-offset: 2px; }

.noscript { margin: 24px 0 0; }

.viewer:fullscreen { padding: 20px var(--gutter); overflow: auto; background: radial-gradient(120% 70% at 50% 0%, var(--dusk-lit) 0%, var(--dusk) 62%); color: var(--on-dusk); }
.viewer:fullscreen .spread { --page-h: calc(100vh - 210px); }
.viewer:fullscreen[data-layout="single"] .spread { max-width: min(1100px, 100%); }

/* ---------- colophon ---------- */

.colophon { margin: 0 var(--gutter); padding: clamp(28px, 4vw, 48px) 0 40px; text-align: center; font-size: 0.875rem; color: var(--ink-soft); }
.colophon p { margin: 0 auto 4px; max-width: 70ch; }
.disclosures summary {
  display: inline-block; list-style: none; cursor: pointer;
  font-size: 0.8125rem; color: var(--ink-soft);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
}
.disclosures summary::-webkit-details-marker { display: none; }
.disclosures summary:hover { color: var(--honey-ink); }
.disclosures-body { margin-top: 14px; }
.colophon .hex { width: 34px; height: 34px; margin: 0 auto 14px; display: block; fill: none; stroke: var(--honey-ink); stroke-width: 1; }

/* ---------- listening dock ---------- */

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: auto minmax(0, auto) minmax(80px, 1fr); align-items: center; gap: 16px;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: var(--paper); color: var(--ink);
  border-top: 1px solid var(--ink);
  box-shadow: 0 -14px 30px -18px rgba(0, 0, 0, 0.5);
}
.dock .play { width: 46px; height: 46px; }
.dock-title { margin: 0; font-family: var(--display); font-style: italic; font-size: 1.125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-title span { font-family: var(--text); font-style: normal; font-size: 0.8125rem; color: var(--ink-soft); margin-left: 10px; font-variant-numeric: tabular-nums; }

/* ---------- narrow screens ---------- */

@media (max-width: 899px) {
  .masthead { grid-template-columns: 1fr; justify-items: center; text-align: center; padding-top: 18px; }
  .masthead-name { order: -1; }
  .masthead-nav { justify-content: center; }

  .episode { grid-template-columns: 1fr; gap: 22px; }
  .plate { margin: 0 calc(var(--gutter) * -1); }
  .plate img { box-shadow: none; }
  .plate figcaption { padding: 0 var(--gutter); }
  h1 { font-size: clamp(3.25rem, 15vw, 6rem); }
  .dek { max-width: 44ch; }

  .viewer-stage { display: block; }
  .turn { position: absolute; top: 50%; z-index: 2; width: 44px; height: 44px; margin-top: -22px; background: rgba(34, 39, 30, 0.72); }
  .turn-prev { left: -6px; }
  .turn-next { right: -6px; }
  .viewer-tools [data-mode] { display: none; }
  .dock { grid-template-columns: auto minmax(0, 1fr); }
  .dock .seek { grid-column: 1 / -1; height: 16px; }
  body.has-dock { padding-bottom: 104px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spread.turn-next > .leaf, .spread.turn-prev > .leaf { animation: none; }
  .play, .turn, .thumbs img { transition: none; }
}
