/* Kartick Rajen — broadsheet edition.
   Black ink on white paper. Greys only ever come from ink at reduced opacity. */

@font-face {
    font-family: "Newsreader";
    src: url("../assets/fonts/newsreader.woff2") format("woff2");
    font-weight: 200 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Newsreader";
    src: url("../assets/fonts/newsreader-italic.woff2") format("woff2");
    font-weight: 200 800;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "Chomsky";
    src: url("../assets/fonts/chomsky.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

:root {
    --paper: #ffffff;
    --ink: #000000;
    --ink-80: rgb(0 0 0 / 0.8);
    --ink-20: rgb(0 0 0 / 0.2);
    --serif: "Newsreader", Georgia, "Times New Roman", serif;
    --gothic: "Chomsky", "Old English Text MT", serif;
    --gutter: clamp(14px, 2.2vw, 28px);
    --page: 1320px;
}

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

html {
    background: var(--paper);
    color: var(--ink);
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 64px;
}

body {
    margin: 0;
    font-family: var(--serif);
    font-size: 1.125rem;
    line-height: 1.55;
    font-optical-sizing: auto;
    font-kerning: normal;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }

a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}
a:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
::selection { background: var(--ink); color: var(--paper); }

/* The live ink layer sits between the paper and the type. */
#ink {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}
.masthead, .sections, .ticker, main, .colophon { position: relative; z-index: 1; }

.wrap {
    max-width: var(--page);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

/* ── Masthead ─────────────────────────────────────────── */
.masthead { padding-top: clamp(16px, 2.6vw, 32px); }

.mast-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: var(--gutter);
}

.nameplate {
    font-family: var(--gothic);
    font-weight: 400;
    font-size: clamp(48px, 8.6vw, 124px);
    line-height: 1.08;
    text-align: center;
    white-space: nowrap;
}
.nameplate a { text-decoration: none; }
.nameplate a:hover { background: none; color: inherit; }

.ear {
    font-size: 0.875rem;
    line-height: 1.3;
    font-style: italic;
    max-width: 17.5em;
    text-wrap: balance;
}
.ear:empty { visibility: hidden; }
.ear-left { justify-self: start; }
.ear-right { justify-self: end; text-align: right; }

.folio {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: clamp(6px, 1vw, 12px);
    padding-block: 0.4rem;
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
    font-size: 0.875rem;
}

/* ── Section bar ──────────────────────────────────────── */
.sections {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgb(255 255 255 / 0.94);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
.sections-row {
    display: flex;
    align-items: center;
    min-height: 48px;
    border-bottom: 1px solid var(--ink);
    overflow-x: auto;
    scrollbar-width: none;
}
.sections-row::-webkit-scrollbar { display: none; }
.sections-row ul { display: flex; gap: clamp(4px, 1.6vw, 24px); }
.sections-row a {
    display: inline-block;
    padding: 0.2em 0.35em;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    white-space: nowrap;
}
.sections-row a[aria-current] {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.35em;
}
.sections-row .mini {
    font-family: var(--gothic);
    font-weight: 400;
    font-size: 1.6rem;
    line-height: 1;
    max-width: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-width 0.35s ease, opacity 0.25s ease, margin 0.35s ease;
}
.sections.is-stuck .mini {
    max-width: 9em;
    opacity: 1;
    margin-right: clamp(10px, 2vw, 28px);
}

/* ── Ticker ───────────────────────────────────────────── */
.ticker {
    background: var(--ink);
    color: var(--paper);
    overflow: hidden;
}
.ticker-track {
    display: flex;
    width: max-content;
    animation: ticker 70s linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker ul { display: flex; }
.ticker li {
    padding: 0.5rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}
.ticker li::after {
    content: "\25B2";
    font-size: 0.6em;
    margin-left: 0.7em;
    vertical-align: 0.25em;
}
@keyframes ticker { to { transform: translateX(-50%); } }

/* ── Lead story ───────────────────────────────────────── */
.lead {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    grid-template-areas:
        "head head"
        "deck fig"
        "body fig"
        "cta  fig";
    grid-template-rows: auto auto auto 1fr;
    column-gap: calc(var(--gutter) * 2);
    padding-top: clamp(22px, 3.2vw, 44px);
}

.headline {
    grid-area: head;
    font-weight: 800;
    font-size: clamp(40px, 6.2vw, 88px);
    line-height: 0.96;
    letter-spacing: -0.018em;
    word-spacing: 0.05em;
    font-variation-settings: "opsz" 72;
    text-wrap: balance;
    margin-bottom: 0.4em;
    max-width: 16em;
}

.deck {
    grid-area: deck;
    font-style: italic;
    font-size: clamp(19px, 1.65vw, 23px);
    line-height: 1.32;
    padding-bottom: 0.85em;
    margin-bottom: 1em;
    border-bottom: 1px solid var(--ink);
    text-wrap: pretty;
}

.lead-body {
    grid-area: body;
    columns: 2 16em;
    column-gap: calc(var(--gutter) * 1.5);
    column-rule: 1px solid var(--ink);
}
.lead-body p + p { text-indent: 1.4em; }
.lead-body p:first-child::first-letter {
    float: left;
    font-weight: 800;
    font-size: 4.3em;
    line-height: 0.8;
    padding: 0.06em 0.08em 0 0;
    font-variation-settings: "opsz" 72;
}

.lead-cta { grid-area: cta; margin-top: 1.1em; font-weight: 600; }

.lead-figure { grid-area: fig; align-self: start; }
.ink-slot { aspect-ratio: 1; width: 100%; position: relative; }
.ink-slot canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.fig-readout {
    min-height: 1.5em;
    margin-top: 0.5em;
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
figcaption {
    margin-top: 0.6em;
    padding-top: 0.5em;
    border-top: 1px solid var(--ink);
    font-size: 0.875rem;
    line-height: 1.38;
    font-style: italic;
    color: var(--ink-80);
}

/* Without scripting there is no picture to caption. */
html:not(.js) .lead-figure { display: none; }
html:not(.js) .lead {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "head" "deck" "body" "cta";
}
html:not(.js) .deck,
html:not(.js) .lead-body { max-width: 50rem; }

/* ── Sections ─────────────────────────────────────────── */
.section { padding-top: clamp(44px, 6vw, 76px); }

.section-head {
    border-top: 4px solid var(--ink);
    border-bottom: 1px solid var(--ink);
    padding: 0.3em 0 0.35em;
    margin-bottom: clamp(18px, 2.4vw, 28px);
}
.section-head h2 {
    font-weight: 800;
    font-size: clamp(28px, 3.3vw, 44px);
    line-height: 1;
    letter-spacing: -0.015em;
    font-variation-settings: "opsz" 72;
}

/* Columns divided by hairline rules, like a broadsheet page. */
.cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: clamp(26px, 3vw, 40px);
    margin-inline: calc(-1 * var(--gutter));
    overflow: hidden;
}
.cols > * {
    padding-inline: var(--gutter);
    margin-left: -1px;
    border-left: 1px solid var(--ink);
}

@media (min-width: 640px) {
    .cols-2, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
    .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1180px) {
    .cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ── Anonymous note ───────────────────────────────────── */
.note {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: calc(var(--gutter) * 1.5);
    margin-top: clamp(32px, 4vw, 48px);
    padding-top: clamp(16px, 2vw, 24px);
    border-top: 1px solid var(--ink);
}
.note h3 {
    font-weight: 700;
    font-size: clamp(22px, 2vw, 28px);
    line-height: 1.1;
    font-variation-settings: "opsz" 48;
    margin-bottom: 0.4em;
}
.note-intro p { font-style: italic; color: var(--ink-80); }
.note-fields { display: grid; gap: 0.35rem; }
.note label { font-weight: 600; font-size: 0.95rem; margin-top: 0.6rem; }
.note label:first-child { margin-top: 0; }
.note label span { font-weight: 400; font-style: italic; color: var(--ink-80); }
.note textarea,
.note input[type="email"] {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--ink);
    border-radius: 0;
    padding: 0.6em 0.7em;
}
.note textarea { resize: vertical; min-height: 8em; }
.note textarea:focus,
.note input:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
.note .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.note-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 1.2rem; margin-top: 0.8rem; }
.note button {
    font: inherit;
    font-weight: 700;
    color: var(--paper);
    background: var(--ink);
    border: 1px solid var(--ink);
    border-radius: 0;
    padding: 0.6em 1.6em;
    cursor: pointer;
}
.note button:hover { color: var(--ink); background: var(--paper); }
.note button:disabled { opacity: 0.5; cursor: progress; }
.note-status { font-style: italic; }

.story h3 {
    font-weight: 700;
    font-size: clamp(21px, 1.8vw, 25px);
    line-height: 1.1;
    letter-spacing: -0.01em;
    font-variation-settings: "opsz" 48;
    text-wrap: balance;
    margin-bottom: 0.35em;
}
.story .meta,
.in-progress .meta {
    font-style: italic;
    font-size: 0.9375rem;
    color: var(--ink-80);
    margin-bottom: 0.55em;
}
.story .byline { font-size: 0.9375rem; margin-bottom: 0.6em; }
.dateline {
    font-variant-caps: all-small-caps;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.more { font-weight: 600; }

/* Working paper: set apart by a rule, not a box. */
.in-progress {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
    gap: calc(var(--gutter) * 1.5);
    align-items: start;
    margin-top: clamp(28px, 3.4vw, 44px);
    padding-top: clamp(14px, 1.6vw, 20px);
    border-top: 1px solid var(--ink);
}
.in-progress h3 {
    font-weight: 700;
    font-size: clamp(21px, 1.9vw, 27px);
    line-height: 1.1;
    font-variation-settings: "opsz" 48;
    text-wrap: balance;
}

/* ── Halftone photographs ─────────────────────────────── */
.photo {
    position: relative;
    aspect-ratio: 16 / 9;
    margin-bottom: 0.8em;
    overflow: hidden;
    background: var(--paper);
}
.photo img,
.photo canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.photo img { object-fit: cover; filter: grayscale(1) contrast(1.15); }
.photo canvas { opacity: 0; }
.photo.ht-ready img { opacity: 0; }
.photo.ht-ready canvas { opacity: 1; }

/* ── Contact ──────────────────────────────────────────── */
.contact-list > div {
    display: grid;
    grid-template-columns: 8em minmax(0, 1fr);
    gap: 0.75em;
    padding: 0.5em 0;
    border-bottom: 1px solid var(--ink-20);
}
.contact-list dt { font-style: italic; color: var(--ink-80); }
.contact-list dd { font-size: 1.125rem; overflow-wrap: anywhere; }
.link-list li { border-bottom: 1px solid var(--ink-20); }
.link-list a {
    display: inline-block;
    padding: 0.3em 0;
    font-size: 1.375rem;
    font-weight: 600;
}

/* ── Colophon ─────────────────────────────────────────── */
.colophon { margin-top: clamp(56px, 7vw, 96px); }
.colophon-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.4rem 1.5rem;
    padding: 0.6em 0 3em;
    border-top: 4px solid var(--ink);
    font-size: 0.875rem;
}

/* ── Smaller screens ──────────────────────────────────── */
@media (max-width: 900px) {
    .lead {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "head" "deck" "fig" "body" "cta";
    }
    .lead-figure { margin-bottom: 1.4em; }
    .ink-slot { max-width: 520px; margin-inline: auto; }
    .in-progress,
    .note { grid-template-columns: minmax(0, 1fr); gap: 0.6em; }
}

@media (max-width: 760px) {
    .mast-row { grid-template-columns: minmax(0, 1fr); }
    .ear { display: none; }
    .folio span:nth-child(1),
    .folio span:nth-child(3) { display: none; }
    .folio { justify-content: center; }
    .sections-row .mini { display: none; }
    .sections-row ul { gap: 0; }
    .sections-row a { font-size: 0.9rem; padding-inline: 0.3em; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .ticker-track { animation: none; }
    .sections-row .mini { transition: none; }
}
