/* Story pages. Colours and fonts come from per-post custom properties set inline. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: clamp(18px, 1.05rem + 0.25vw, 21px); line-height: 1.65;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.preview-flag { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 60; background: #c62828; color: #fff; font: 600 13px/1 system-ui, sans-serif; padding: 9px 14px; border-radius: 99px; }

/* Reading progress + slim top bar */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 50; }
.progress span { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
.story-bar {
  position: fixed; inset: 0 0 auto 0; z-index: 40; height: 56px; display: flex; align-items: center; gap: 16px;
  padding: 0 clamp(16px, 4vw, 40px); color: #fff; transition: background .3s, color .3s, box-shadow .3s;
  font-family: var(--font-display);
}
.story-bar .brand { font-weight: 700; text-decoration: none; letter-spacing: .01em; white-space: nowrap; }
.story-bar .bar-title { flex: 1; min-width: 0; opacity: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-body); font-size: 15px; transition: opacity .3s; }
.story-bar .bar-links { margin-left: auto; display: flex; gap: 20px; font: 600 13px/1 var(--font-display); text-transform: uppercase; letter-spacing: .1em; }
.story-bar .bar-links a { text-decoration: none; opacity: .85; }
.story-bar .bar-links a:hover { opacity: 1; color: inherit; }
.story-bar .bar-share { margin-left: 4px; background: none; border: 0; color: inherit; cursor: pointer; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; }
.story-bar svg, .share svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.story-bar.solid { background: color-mix(in srgb, var(--bg) 94%, transparent); color: var(--text); box-shadow: 0 1px 0 color-mix(in srgb, var(--text) 12%, transparent); backdrop-filter: blur(8px); }
.story-bar.solid .bar-title { opacity: .8; }
/* Pages without a photo hero start with a solid bar */
body:not(:has(.hero-photo)) .story-bar { color: var(--text); }

/* ----- Shared headline pieces ----- */
.kicker { font: 700 13px/1.2 var(--font-display); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 16px; }
.headline { font-family: var(--font-display); font-weight: 800; line-height: 1.04; letter-spacing: -.015em; margin: 0; font-size: clamp(2.3rem, 1.2rem + 4.6vw, 5.2rem); text-wrap: balance; }
.dek { font-size: clamp(1.15rem, 1rem + .6vw, 1.5rem); line-height: 1.45; margin: 20px 0 0; max-width: 46ch; opacity: .88; text-wrap: pretty; }
.byline { display: flex; flex-wrap: wrap; gap: 6px 18px; font: 500 14px/1.4 var(--font-display); letter-spacing: .02em; margin: 28px 0 0; opacity: .85; }
.byline .by { font-weight: 700; opacity: 1; }

/* ----- Photo hero (feature, immersive) ----- */
.hero-photo { position: relative; min-height: 100svh; display: flex; align-items: flex-end; color: #fff; isolation: isolate; overflow: hidden; }
.hero-photo .hero-media { position: absolute; inset: 0; margin: 0; z-index: -1; }
.hero-photo .hero-img { width: 100%; height: 100%; object-fit: cover; animation: heroZoom 18s ease-out both; }
.hero-photo::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0,0,0,.45) 0%, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 40%, rgba(0,0,0,.82) 100%); }
.hero-photo .hero-text { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 56px) clamp(48px, 9vh, 96px); }
.hero-photo .kicker { color: #fff; opacity: .9; }
.hero-photo .headline { max-width: 17ch; text-shadow: 0 2px 30px rgba(0,0,0,.35); }
.hero-center { align-items: center; text-align: center; }
.hero-center::after { background: radial-gradient(ellipse at center, rgba(0,0,0,.62) 0%, rgba(0,0,0,.45) 55%, rgba(0,0,0,.7) 100%); }
.hero-center .hero-text { padding-bottom: 0; }
.hero-center .headline, .hero-center .dek { margin-left: auto; margin-right: auto; }
.hero-center .byline { justify-content: center; }
.scroll-cue { position: absolute; bottom: 28px; left: 50%; translate: -50% 0; color: #fff; text-decoration: none; font-size: 28px; animation: bob 2s ease-in-out infinite; }
.hero-credit-row { max-width: 1180px; margin: 10px auto 0; padding: 0 clamp(20px, 5vw, 56px); }
.hero-caption { font: 13px/1.45 var(--font-display); color: var(--muted); margin: 10px 0 0; }
.hero-caption .credit { opacity: .8; font-style: italic; }
@keyframes heroZoom { from { transform: scale(1.08); } to { transform: scale(1); } }
@keyframes bob { 50% { transform: translateY(6px); } }

/* ----- Typographic hero (essay, or feature without photo) ----- */
.hero-type { max-width: 1000px; margin: 0 auto; padding: calc(56px + clamp(48px, 12vh, 140px)) clamp(20px, 5vw, 56px) clamp(32px, 6vh, 64px); text-align: center; }
.hero-type .headline { font-size: clamp(2.5rem, 1.2rem + 5.4vw, 6rem); }
.hero-type .dek, .hero-type .headline { margin-left: auto; margin-right: auto; }
.hero-type .byline { justify-content: center; }
.hero-type::after { content: ""; display: block; width: 64px; height: 3px; background: var(--accent); margin: 48px auto 0; }
.hero-wide { max-width: 1240px; margin: 0 auto 24px; padding: 0 clamp(0px, 3vw, 32px); }
.hero-wide .hero-caption { padding: 0 20px; }

/* ----- Report hero ----- */
.hero-report { background: var(--surface); padding: calc(56px + clamp(36px, 8vh, 96px)) clamp(20px, 5vw, 56px) clamp(36px, 7vh, 72px); display: grid; gap: 40px; max-width: none; }
.hero-report > * { max-width: 1180px; }
.hero-report.with-img { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; }
.hero-report .hero-text { justify-self: end; width: 100%; max-width: 640px; }
.hero-report .headline { font-size: clamp(2.1rem, 1.2rem + 3.2vw, 4rem); }
.hero-report .hero-media { margin: 0; }
.hero-report .hero-img { border-radius: 4px; aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.hero-report:not(.with-img) .hero-text { justify-self: center; max-width: 900px; }
@media (max-width: 860px) { .hero-report.with-img { grid-template-columns: 1fr; } .hero-report .hero-text { justify-self: start; } }

/* ----- Body ----- */
.story-main { position: relative; padding: clamp(32px, 6vh, 64px) clamp(20px, 5vw, 56px) 32px; }
.story-column { max-width: 680px; margin: 0 auto; }
.story-body > :first-child { margin-top: 0; }
.story-body p { margin: 0 0 1.25em; text-wrap: pretty; hyphens: auto; }
.layout-feature .story-body > p:first-of-type::first-letter,
.layout-essay .story-body > p:first-of-type::first-letter {
  float: left; font-family: var(--font-display); font-weight: 800; font-size: 4.6em; line-height: .82; margin: .06em .1em 0 0; color: var(--accent);
}
.story-body h2 { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); line-height: 1.15; margin: 2.2em 0 .7em; letter-spacing: -.01em; text-wrap: balance; }
.story-body h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.25em; line-height: 1.25; margin: 1.8em 0 .5em; }
.story-body h4 { font-family: var(--font-display); font-size: 1em; margin: 1.6em 0 .4em; }
.story-body ul, .story-body ol { padding-left: 1.3em; margin: 0 0 1.25em; }
.story-body li { margin: .35em 0; }
.story-body li::marker { color: var(--accent); }
.story-body hr { border: 0; text-align: center; margin: 2.5em 0; }
.story-body hr::before { content: "• • •"; letter-spacing: .6em; color: var(--accent); }
.story-body sup { line-height: 0; font-size: .7em; }
.story-body sup a { text-decoration: none; color: var(--accent); font-weight: 700; padding: 0 1px; }

.story-body blockquote { margin: 1.8em 0; padding: 0 0 0 1.1em; border-left: 3px solid var(--accent); font-style: italic; }
.story-body blockquote.pull {
  border: 0; padding: 0; margin: 2.2em -4vw; font-style: normal; text-align: center;
  font: 700 clamp(1.5rem, 1.1rem + 1.6vw, 2.3rem)/1.25 var(--font-display); color: var(--accent); text-wrap: balance;
}
.story-body blockquote.pull::before { content: "“"; display: block; font-size: 2.4em; line-height: .6; opacity: .5; }
.story-body blockquote p:last-child { margin-bottom: 0; }

.story-body figure { margin: 2.2em 0; }
.story-body figure img { width: 100%; border-radius: 2px; }
.story-body figcaption, .story-body .caption { font: 14px/1.45 var(--font-display); color: var(--muted); margin-top: 10px; }
/* Images break out of the text column */
.layout-feature .story-body figure, .layout-immersive .story-body figure { margin-left: calc(50% - min(50vw, 560px)); margin-right: calc(50% - min(50vw, 560px)); }
.layout-feature .story-body figure figcaption, .layout-immersive .story-body figure figcaption { max-width: 680px; margin-left: auto; margin-right: auto; padding: 0 20px; }
.story-body figure.full { margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw); }

.table-wrap { overflow-x: auto; margin: 2em 0; border-top: 2px solid var(--text); }
.layout-essay .table-wrap { margin-left: max(-12vw, -160px); margin-right: max(-12vw, -160px); }
/* Report: the left column holds the contents, so wide tables only grow into the right margin. */
.layout-report .table-wrap { margin-right: max(-14vw, -200px); }
.story-body table { border-collapse: collapse; width: 100%; font: 14.5px/1.45 var(--font-display); font-variant-numeric: tabular-nums; }
.story-body td, .story-body th { padding: 10px 12px; border-bottom: 1px solid color-mix(in srgb, var(--text) 15%, transparent); text-align: left; vertical-align: top; }
.story-body tr:first-child td { font-weight: 700; }
.story-body td p { margin: 0; }

.footnotes { margin-top: 3.5em; padding-top: 1.5em; border-top: 1px solid color-mix(in srgb, var(--text) 20%, transparent); font-size: .82em; line-height: 1.55; color: var(--muted); }
.footnotes .notes-title { font-size: 1rem; text-transform: uppercase; letter-spacing: .12em; margin: 0 0 1em; color: var(--text); }
.footnotes li { margin: .5em 0; scroll-margin-top: 80px; }
.footnotes li:target { color: var(--text); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.footnotes p { margin: 0; }
.footnotes a[href^="#footnote-ref"], .footnotes a[href^="#endnote-ref"] { text-decoration: none; color: var(--accent); }

.key-points { background: var(--surface); border-top: 4px solid var(--accent); padding: 22px 26px 12px; margin: 0 0 36px; font-family: var(--font-display); }
.key-points h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .14em; margin: 0 0 12px; color: var(--accent); }
.key-points ul { margin: 0; padding-left: 1.1em; font-size: .95em; line-height: 1.5; }
.key-points li { margin: 0 0 .7em; }
.key-points li::marker { color: var(--accent); }

.download a { display: inline-block; font: 700 15px/1 var(--font-display); background: var(--accent); color: var(--bg); text-decoration: none; padding: 14px 20px; border-radius: 3px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 2.5em 0 0; }
.tags span { font: 600 12px/1 var(--font-display); text-transform: uppercase; letter-spacing: .08em; border: 1px solid color-mix(in srgb, var(--text) 25%, transparent); padding: 7px 10px; border-radius: 99px; }

/* Share */
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font: 600 13px/1 var(--font-display); }
.share-top { margin: 0 0 36px; padding-bottom: 24px; border-bottom: 1px solid color-mix(in srgb, var(--text) 12%, transparent); }
.share-bottom { margin: 3em 0 0; padding: 24px 0; border-top: 1px solid color-mix(in srgb, var(--text) 12%, transparent); }
.share-label { text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-right: 4px; }
.share a, .share button { display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px; border: 1px solid color-mix(in srgb, var(--text) 22%, transparent); border-radius: 99px; text-decoration: none; background: none; color: var(--text); font: inherit; cursor: pointer; }
.share a:hover, .share button:hover { border-color: var(--accent); color: var(--accent); }
.share svg { width: 16px; height: 16px; }
.share [hidden] { display: none; }
.share-native:not([hidden]) ~ a { display: none; }
.toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 20px; opacity: 0; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 99px; font: 600 14px/1 var(--font-display); transition: .25s; pointer-events: none; z-index: 70; }
.toast.show { opacity: 1; translate: -50% 0; }

/* ----- Report: sticky contents ----- */
.layout-report .story-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 680px) minmax(0, 1fr); gap: 0 clamp(24px, 4vw, 56px); }
.layout-report .story-column { grid-column: 2; margin: 0; width: 100%; }
.toc { grid-column: 1; justify-self: end; width: 100%; max-width: 250px; position: sticky; top: 88px; align-self: start; font: 14px/1.4 var(--font-display); max-height: calc(100vh - 110px); overflow: auto; }
.toc-label { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700; color: var(--accent); margin: 0 0 12px; }
.toc ol { list-style: none; padding: 0; margin: 0; counter-reset: toc; border-left: 2px solid color-mix(in srgb, var(--text) 12%, transparent); }
.toc li { counter-increment: toc; }
.toc a { display: block; padding: 7px 0 7px 14px; margin-left: -2px; border-left: 2px solid transparent; text-decoration: none; color: var(--muted); }
.toc a::before { content: counter(toc, decimal-leading-zero) "  "; font-variant-numeric: tabular-nums; opacity: .6; }
.toc a.active, .toc a:hover { color: var(--text); border-left-color: var(--accent); }
@media (max-width: 1080px) {
  .layout-report .story-main { display: block; }
  .layout-report .table-wrap { margin-right: 0; }
  .layout-report .story-column { margin: 0 auto; max-width: 680px; }
  .toc { position: static; max-width: 680px; margin: 0 auto 32px; max-height: none; background: var(--surface); padding: 18px 20px; }
  .toc ol { border: 0; } .toc a { padding: 5px 0; border: 0; margin: 0; }
}

/* ----- Immersive chapters ----- */
.layout-immersive .story-main { padding-left: 0; padding-right: 0; }
.layout-immersive .story-column { max-width: none; }
.layout-immersive .key-points, .layout-immersive .share, .layout-immersive .chapter-body, .layout-immersive .tags, .layout-immersive .story-body > .footnotes, .layout-immersive .download { max-width: 680px; margin-left: auto; margin-right: auto; padding-left: 20px; padding-right: 20px; }
.chapter { margin: 0; }
.chapter-open { position: relative; min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 15vh 20px; margin: 4em 0 3em; background: var(--surface); isolation: isolate; overflow: hidden; }
.chapter.has-cover .chapter-open { min-height: 100svh; color: #fff; background: #000; }
.chapter-cover { position: absolute; inset: 0; z-index: -1; }
.chapter-cover img { width: 100%; height: 100%; object-fit: cover; opacity: .62; transform: scale(1.06); transition: transform 1.6s ease-out, opacity 1.2s; }
.chapter-open.inview .chapter-cover img { transform: scale(1); opacity: .55; }
.chapter-title { max-width: 900px; }
.chapter-no { display: block; font: 800 clamp(3rem, 2rem + 6vw, 8rem)/1 var(--font-display); color: var(--accent); opacity: .9; margin-bottom: .1em; }
.chapter.has-cover .chapter-no { color: #fff; opacity: .7; }
.chapter-open h2 { font: 800 clamp(2rem, 1.2rem + 3.4vw, 4.2rem)/1.05 var(--font-display); margin: 0; text-wrap: balance; letter-spacing: -.015em; }
.chapter-title { opacity: 0; transform: translateY(24px); transition: opacity .9s, transform .9s; }
.chapter-open.inview .chapter-title { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .hero-photo .hero-img, .scroll-cue { animation: none; }
  .chapter-title { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}

/* Essay: a quieter, bookish column */
.layout-essay .story-column { max-width: 640px; }
.layout-essay .story-body h2 { text-align: center; font-size: 1.5em; }
.layout-essay .story-body h2::before { content: ""; display: block; width: 40px; height: 2px; background: var(--accent); margin: 0 auto .9em; }

/* More stories */
.more { background: var(--surface); padding: clamp(40px, 8vh, 80px) clamp(20px, 5vw, 56px); margin-top: 48px; }
.more-head { max-width: 1180px; margin: 0 auto 28px; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.more-head a { font: 600 14px/1 var(--font-display); text-decoration: none; color: var(--accent); }
.more h2 { margin: 0; font: 700 13px/1 var(--font-display); text-transform: uppercase; letter-spacing: .14em; color: var(--accent); }
.more-grid { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 28px; }
.more-card { text-decoration: none; display: flex; flex-direction: column; gap: 10px; }
.more-card img, .more-blank { aspect-ratio: 16 / 10; object-fit: cover; width: 100%; background: color-mix(in srgb, var(--accent) 25%, var(--surface)); }
.more-card .kicker { margin: 4px 0 0; font-size: 11px; }
.more-title { font: 700 1.15rem/1.25 var(--font-display); }
.more-card:hover .more-title { color: var(--accent); }
.story-foot { text-align: center; font: 14px/1 var(--font-display); color: var(--muted); padding: 32px 20px 48px; }
.story-foot a { text-decoration: none; }

@media (max-width: 640px) {
  .story-body blockquote.pull { margin-left: 0; margin-right: 0; }
  .layout-essay .table-wrap { margin-left: 0; margin-right: 0; }
  .story-bar .bar-title { display: none; }
  .story-bar .bar-links { gap: 14px; font-size: 12px; }
}
@media print {
  .story-bar, .progress, .share, .more, .toast, .scroll-cue { display: none !important; }
  .hero-photo { min-height: auto; color: var(--text); } .hero-photo::after { display: none; }
  .hero-photo .hero-media { position: static; }
}
