/* ==========================================================================
   Dearest Handler: one stylesheet for everything
   Sections: 1 tokens · 2 reset · 3 typography · 4 masthead · 5 issue body
             6 segments · 7 media · 8 subscribe · 9 site pages · 10 footer
             11 motion · 12 print
   ========================================================================== */

/* 1. Design tokens ------------------------------------------------------- */

:root {
  --paper: #f6f1e7;
  --ink: #1d1b18;
  --ink-soft: #5a554c;
  --rule: #1d1b18;
  --accent: #8a2a2a;        /* oxblood, for small highlights */
  --tag: #e9e0cc;           /* Lost and Found tags, score badges */
  --shadow: rgba(40, 30, 15, 0.18);

  --font-display: "Playfair Display", "Bodoni 72", Didot, Georgia, serif;
  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: "Courier Prime", "Courier New", monospace;   /* Maintenance Log */

  --measure: 65ch;
  --space: 1.5rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1a17;
    --ink: #ece6d8;
    --ink-soft: #a9a293;
    --rule: #ece6d8;
    --accent: #d07a6a;
    --tag: #2c2a25;
    --shadow: rgba(0, 0, 0, 0.5);
  }
}

/* 2. Reset ---------------------------------------------------------------- */

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

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

body, h1, h2, h3, p, ol, ul, figure, blockquote { margin: 0; }

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

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

/* 3. Typography ----------------------------------------------------------- */

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(1.0625rem, 0.95rem + 0.4vw, 1.1875rem);
  line-height: 1.6;
  padding: 0 1.25rem;
  font-variant-numeric: oldstyle-nums;
}

a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover { color: var(--accent); }

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

em, i { font-style: italic; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.4rem 0.8rem;
  z-index: 10;
}
.skip-link:focus { left: 0.5rem; }

/* Shared reading column */
.masthead,
.issue,
.page,
.issue-nav,
.subscribe,
.site-footer {
  max-width: var(--measure);
  margin-inline: auto;
}

/* 4. Masthead ------------------------------------------------------------- */

.masthead {
  text-align: center;
  padding-top: calc(var(--space) * 1.5);
  margin-bottom: calc(var(--space) * 2);
}

.masthead__title {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 1.4rem + 6vw, 4.75rem);
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.masthead__title:hover { color: inherit; }

.masthead__tagline {
  margin-top: 0.5rem;
  font-variant: small-caps;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}

.masthead__dateline {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
  padding: 0.35rem 0 0.3rem;
  border-top: 4px double var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

@media (max-width: 30rem) {
  .masthead__dateline { justify-content: center; }
}

/* 5. Issue body ----------------------------------------------------------- */

.issue > * + *,
.page > * + * { margin-top: var(--space); }

.salutation {
  font-style: italic;
  font-size: 1.3em;
}

.lead::first-letter {
  float: left;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 4.1em;
  line-height: 0.8;
  padding: 0.08em 0.08em 0 0;
  color: var(--accent);
}

/* Section labels: small caps, centered, rules either side */
.section {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: calc(var(--space) * 2.25) !important;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  font-variant: small-caps;
  text-transform: lowercase;
  letter-spacing: 0.2em;
  text-align: center;
}
.section::before,
.section::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--rule);
}

/* 6. Segments ------------------------------------------------------------- */

/* Diamond Watch */
.diamond-watch > * + * { margin-top: calc(var(--space) * 0.75); }

.score {
  display: inline-block;
  padding: 0 0.45em;
  border: 1px solid var(--ink-soft);
  border-radius: 2px;
  background: var(--tag);
  font-family: var(--font-mono);
  font-size: 0.82em;
  line-height: 1.5;
  white-space: nowrap;
  font-variant-numeric: lining-nums;
}

/* Male Advisory: boxed like a weather alert */
.advisory {
  border: 2px solid var(--ink-soft);
  padding: 0.75rem 1rem;
  color: var(--ink-soft);
}
.advisory::before {
  content: "Advisory status: ";
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.advisory--active {
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--accent);
}
.advisory--active::before { color: var(--accent); }

/* Maintenance Log: logbook lines, mono timestamps, hanging indent */
.log {
  list-style: none;
  padding: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(1.6em - 1px),
    color-mix(in srgb, var(--ink-soft) 30%, transparent) calc(1.6em - 1px),
    color-mix(in srgb, var(--ink-soft) 30%, transparent) 1.6em
  );
  line-height: 1.6;
}
.log li {                         /* hanging indent: timestamp column + text column */
  display: grid;
  grid-template-columns: 6.75rem 1fr;
  align-items: baseline;
}
.log time {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--ink-soft);
}

/* The Lost and Found: paper tags */
.lost-found {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.9rem;
}
.lost-found li {
  position: relative;
  background: var(--tag);
  padding: 0.6rem 1rem 0.6rem 2rem;
  border-radius: 2px 10px 10px 2px;
  box-shadow: 1px 2px 3px var(--shadow);
  transform: rotate(1deg);
}
.lost-found li:nth-child(even) { transform: rotate(-1deg); }
.lost-found li::before {          /* the tag's string hole */
  content: "";
  position: absolute;
  left: 0.7rem;
  top: 50%;
  width: 0.55rem;
  height: 0.55rem;
  margin-top: -0.275rem;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--ink-soft);
}

/* The Forecast */
/* The section label above supplies the top rule */
.forecast {
  font-style: italic;
}
.forecast > * + * { margin-top: calc(var(--space) * 0.75); }

/* Housekeeping */
.housekeeping {
  margin-top: calc(var(--space) * 2) !important;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* Sign-off */
.signoff {
  text-align: right;
  font-style: italic;
}
.signoff__name {
  font-style: normal;
  font-variant: small-caps;
  letter-spacing: 0.1em;
}

/* 7. Media ---------------------------------------------------------------- */

.media {
  margin-block: calc(var(--space) * 1.5) !important;
}

.media--reel,
.media--wide,
.media--square { margin-inline: auto; }

.media__frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--tag);
}

/* aspect ratio lives on the frame so the caption sits below it */
/* width cap keeps 9:16 intact while holding the height to about 80vh */
.media--reel .media__frame   { aspect-ratio: 9 / 16; width: min(100%, 80vh * 9 / 16); margin-inline: auto; }
.media--wide .media__frame   { aspect-ratio: 16 / 9; }
.media--square .media__frame { aspect-ratio: 1; }

.media__frame {
  border: 1px solid var(--ink-soft);
  box-shadow: 2px 3px 8px var(--shadow);
  overflow: hidden;
}

/* A video without a frame wrapper still behaves */
.media > video { object-fit: cover; background: var(--tag); }
.media--reel > video   { aspect-ratio: 9 / 16; width: min(100%, 80vh * 9 / 16); margin-inline: auto; }
.media--wide > video   { aspect-ratio: 16 / 9; }
.media--square > video { aspect-ratio: 1; }

.media figcaption {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-soft);
  text-align: center;
}

/* Still sketches: pasted in */
.media--sketch img {
  width: 100%;
  height: auto;
  padding: 0.6rem;
  background: #fffdf8;
  border: 1px solid color-mix(in srgb, var(--ink-soft) 40%, transparent);
  box-shadow: 2px 4px 10px var(--shadow);
  transform: rotate(-0.4deg);
}

/* Audio + transcript */
.media--audio audio {
  width: 100%;
}
.transcript {
  margin-top: 0.6rem;
  font-size: 0.95rem;
}
.transcript summary {
  cursor: pointer;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-soft);
  list-style: none;
  text-align: right;
}
.transcript summary::-webkit-details-marker { display: none; }
.transcript summary::after { content: " (continued below) \2192"; }
.transcript[open] summary::after { content: " (fold away) \2191"; }
.transcript > :not(summary) {
  margin-top: 0.75rem;
  padding-left: 1rem;
  border-left: 2px solid var(--rule);
}

/* 8. Subscribe: a classified ad ------------------------------------------- */

.subscribe {
  margin-top: calc(var(--space) * 3);
  padding: 1.25rem 1.25rem 1rem;
  border: 4px double var(--rule);
  text-align: center;
}
.subscribe label {
  display: block;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.subscribe__row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.subscribe input[type="email"] {
  flex: 1 1 14rem;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 0;
}
.subscribe input::placeholder { color: var(--ink-soft); opacity: 0.8; }
.subscribe button {
  flex: 0 0 auto;
  padding: 0.55rem 1.1rem;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
  font-variant: small-caps;
  letter-spacing: 0.12em;
  cursor: pointer;
}
.subscribe button:hover { background: var(--accent); border-color: var(--accent); }
.subscribe__note {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-soft);
}

/* 9. Site pages ----------------------------------------------------------- */

.issue-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: calc(var(--space) * 2);
  padding-top: 0.6rem;
  border-top: 1px solid var(--rule);
  font-variant: small-caps;
  letter-spacing: 0.1em;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.2;
  text-align: center;
}

/* Front page "now on the stands" teaser */
.front-lead {
  text-align: center;
}
.front-lead__kicker {
  font-variant: small-caps;
  letter-spacing: 0.18em;
  color: var(--accent);
}
.front-lead__headline {
  margin-top: 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.5rem);
  line-height: 1.15;
}
.front-lead__headline a { text-decoration: none; }
.front-lead__dek {
  margin-top: 0.75rem;
  font-style: italic;
  color: var(--ink-soft);
}
.front-lead__more {
  margin-top: 1rem;
  font-variant: small-caps;
  letter-spacing: 0.12em;
}

/* Archive: table of contents with dotted leaders */
.toc {
  list-style: none;
  padding: 0;
}
.toc li + li { margin-top: 1rem; }
.toc a {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
}
.toc__num {
  font-variant: small-caps;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.toc__leader {
  flex: 1;
  border-bottom: 2px dotted var(--ink-soft);
  transform: translateY(-0.3em);
  min-width: 1rem;
}
.toc__date {
  white-space: nowrap;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.toc__hook {
  margin-top: 0.15rem !important;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* 10. Footer -------------------------------------------------------------- */

.site-footer {
  margin-top: calc(var(--space) * 2.5);
  padding: 1rem 0 2.5rem;
  border-top: 4px double var(--rule);
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
}
.site-footer nav {
  margin-bottom: 0.5rem;
  font-variant: small-caps;
  letter-spacing: 0.12em;
}
.site-footer nav a + a { margin-left: 1rem; }

/* 11. Motion -------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .lost-found li,
  .lost-found li:nth-child(even),
  .media--sketch img { transform: none; }
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* 12. Print: comes out like a broadsheet page ------------------------------ */

@media print {
  :root {
    --paper: #fff;
    --ink: #000;
    --ink-soft: #444;
    --rule: #000;
    --accent: #000;
    --tag: #f2f2f2;
  }
  body { font-size: 10.5pt; padding: 0; }
  .subscribe, .issue-nav, .media--reel, .media--wide, .media--square,
  .media--audio audio, .skip-link { display: none; }
  .transcript > :not(summary) { display: block; }
  .transcript summary { display: none; }
  .issue { max-width: none; }
  .section { break-after: avoid; }
}
