/* Context Times — shared design tokens and site styles.
   "Digital broadsheet," light-first. Dark is derived from light.
   All colors are CSS custom properties; do not hard-code colors in pages. */

:root {
  color-scheme: light;

  /* Palette — light (primary identity) */
  --bg: #faf8f4;          /* warm paper */
  --surface: #ffffff;
  --ink: #1c1c22;
  --muted: #5c5f6b;
  --rule: rgba(28, 28, 34, 0.14);
  --accent: #2456c4;      /* links */
  --brand: #b3372f;       /* masthead rule only — editorial red */

  /* Type */
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;

  /* Measure */
  --measure: 42rem;
}

/* Dark, derived: applied when the system prefers dark and the user has not
   forced light, or when the user explicitly selects dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #17181c;        /* neutral, not navy */
    --surface: #1e2025;
    --ink: #e9e7e2;       /* warm paper-white */
    --muted: #9a9da8;
    --rule: rgba(233, 231, 226, 0.14);
    --accent: #7da2f0;
    --brand: #c9564e;
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17181c;
  --surface: #1e2025;
  --ink: #e9e7e2;
  --muted: #9a9da8;
  --rule: rgba(233, 231, 226, 0.14);
  --accent: #7da2f0;
  --brand: #c9564e;
}

* {
  box-sizing: border-box;
}

html {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
}

main {
  width: min(var(--measure), calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.25rem 0 4rem;
}

/* Front page uses a slightly wider measure via a modifier. */
main.front {
  width: min(52rem, calc(100% - 2rem));
}

h1,
h2,
p {
  margin: 0;
}

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

/* ---- Masthead (the brand) ---- */

.masthead {
  padding-top: 0.25rem;
  padding-bottom: 1.25rem;
}

.masthead-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
}

.masthead .wordmark {
  font-size: clamp(2rem, 6vw, 3.1rem);
}

/* Smaller wordmark on interior (article) pages. */
.masthead.compact .wordmark {
  font-size: clamp(1.5rem, 4.5vw, 2rem);
}

.masthead-meta {
  margin-top: 0.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.masthead-tagline {
  font-style: italic;
}

/* The one distinctive brand element: a thin editorial-red rule. */
.brand-rule {
  height: 3px;
  margin-top: 0.9rem;
  background: var(--brand);
  border: 0;
}

/* ---- Theme toggle ---- */

.theme-toggle {
  flex: none;
  appearance: none;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* ---- Front page list ---- */

.front-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
}

.front-list li {
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--rule);
}

.front-list li:first-child {
  padding-top: 0.4rem;
}

.front-headline {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.4rem, 3.5vw, 1.9rem);
  line-height: 1.14;
}

.front-headline a {
  color: var(--ink);
  text-decoration: none;
}

.front-headline a:hover {
  color: var(--accent);
}

.front-dek {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.5;
}

.front-date {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.intro {
  margin-top: 1rem;
  max-width: 40rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

/* ---- Article ---- */

.back {
  display: inline-block;
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.back:hover {
  color: var(--ink);
}

.article-head {
  padding-bottom: 1.5rem;
}

article h1,
.article-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.12;
  color: var(--ink);
}

.dek {
  margin-top: 0.8rem;
  max-width: 34rem;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.4;
  color: var(--muted);
}

.byline {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.cover {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--rule);
}

.cover-figure {
  margin: 1.75rem 0 0;
}

.cover-credit {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

article {
  padding-top: 1.75rem;
  font-size: 1.075rem;
  line-height: 1.7;
  color: var(--ink);
}

article p {
  margin-bottom: 1.2rem;
}

.label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

section.meta {
  padding-top: 1.75rem;
  margin-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

.tags {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  font-size: 0.82rem;
  color: var(--ink);
  text-decoration: none;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

ul.sources {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  justify-content: space-between;
}

footer a {
  color: var(--muted);
}

footer a:hover {
  color: var(--ink);
}
