/* Daydi SSR — the reading surface: /maqolalar and one article.
   Tokens come from style.css; this file only adds what long-form text needs. Two rules run through
   all of it: the text sits in a measured column (~70 characters, where a line stops being tiring),
   and anything wider than the text — a photo, a chart, a table — breaks out of that column instead
   of shrinking the type. Loaded only by the two article templates, so no other page pays for it. */

.page--article { padding-block-end: clamp(32px, 4vw, 64px); }

/* ------------------------------------------------------------------ index: tags + cards */

.tagbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block: 0 clamp(20px, 2.4vw, 32px);
}
.tagbar .chip { text-transform: none; }

/* The count is a label for the grid below, not a second headline competing with the h1. */
.section__head--count h2 { font-size: var(--fs-h3); }
.journal { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.jcard {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.jcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); text-decoration: none; }
.jcard__photo {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(150deg, var(--band-b), var(--band-c) 62%, #3F7A5C) center / cover;
}
.jcard__photo img { width: 100%; height: 100%; object-fit: cover; }
.jcard__body { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 20px; }
.jcard__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 13px;
}
.jcard__title { font-size: var(--fs-h3); line-height: 1.22; }
.jcard__summary { margin: 0; color: var(--ink-muted); font-size: 0.94rem; }
.jcard__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.jcard__tag {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-muted);
  font-size: 12px;
}

/* ------------------------------------------------------------------ the article itself */

/* The reading column is set in rem, not ch: `ch` is relative to each element's own font, so a
   68ch heading and a 68ch paragraph are different widths and their left edges stop lining up.
   40rem is ~70 characters at the body size below. */
.article { --measure: 40rem; }
.article__head { max-width: min(100%, var(--measure)); margin-block: clamp(8px, 1.6vw, 24px) 0; }
.article__head h1 { font-size: clamp(1.9rem, 1.2rem + 2.1vw, 3.1rem); line-height: 1.06; }
.article__head .lead { margin-block: 14px 0; max-width: none; color: var(--ink-muted); }
.article__byline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-block: 16px 0;
  color: var(--ink-muted);
  font-size: 14px;
}
.article__tags { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 14px 0; }
.article__tags .chip { text-transform: none; }
.article__note { margin-block: 18px 0; }

/* The cover is the one full-bleed element: it sets the mood, then the column takes over. */
.article__cover { margin: clamp(22px, 3vw, 40px) 0 0; }
.article__cover-photo { background: var(--surface-alt); }
.article__cover img {
  width: 100%;
  max-height: min(72vh, 720px);
  object-fit: cover;
}
.article__cover-credit { padding: 10px var(--gutter) 0; }

/* ------------------------------------------------------------------ the body column */

.article__body {
  margin-block: clamp(26px, 3.4vw, 46px) 0;
  font-size: clamp(16.5px, 15.6px + 0.24vw, 19px);
  line-height: 1.72;
}
/* One column, wider elements opt out below. `min-width: 0` is what lets a table scroll instead of
   pushing the whole page sideways on a phone. */
.article__body > * { max-width: min(100%, var(--measure)); margin-inline: auto; min-width: 0; }
/* Wider than the text, never wider than the page. */
.article__body > .figure--wide,
.article__body > .figure-pair,
.article__body > .chart,
.article__body > .table-scroll { max-width: min(100%, 1180px); }
.article__body > p { margin-block: 0 1.1em; }
.article__body > h2,
.article__body > h3 {
  position: relative;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.article__body > h2 { margin-block: 1.9em 0.55em; font-size: clamp(1.4rem, 1.15rem + 0.9vw, 2rem); }
.article__body > h3 { margin-block: 1.5em 0.4em; font-size: clamp(1.12rem, 1.02rem + 0.4vw, 1.4rem); }
.article__body > h2:first-child, .article__body > h3:first-child { margin-block-start: 0; }
.article__body > ul, .article__body > ol { margin-block: 0 1.2em; padding-inline-start: 1.4em; }
.article__body > ul li, .article__body > ol li { margin-block-end: 0.4em; }
.article__body > hr {
  margin-block: clamp(32px, 4vw, 56px);
  border: 0;
  border-top: 1px solid var(--line);
}
.article__body code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-alt);
  font-size: 0.9em;
}
.article__body > .code {
  overflow-x: auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface-alt);
  font-size: 0.86em;
  line-height: 1.6;
}

/* A heading anchor is for people who want to link to a section, not decoration: invisible until the
   heading is hovered or the link is focused with a keyboard. */
.anchor {
  margin-inline-start: 0.35em;
  color: var(--line);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity 160ms ease;
}
h2:hover > .anchor, h3:hover > .anchor, .anchor:focus-visible { opacity: 1; color: var(--pine); }

/* ------------------------------------------------------------------ pull quote and callouts */

.pullquote {
  margin-block: clamp(26px, 3vw, 40px);
  padding-inline-start: clamp(16px, 2vw, 28px);
  border-inline-start: 3px solid var(--pine);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.12rem, 1rem + 0.6vw, 1.5rem);
  font-weight: 700;
  line-height: 1.34;
  letter-spacing: -0.01em;
}
.pullquote p { margin: 0 0 0.4em; }
.pullquote p:last-child { margin-bottom: 0; }

.callout {
  margin-block: clamp(22px, 2.6vw, 34px);
  padding: 16px clamp(16px, 2vw, 22px);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--pine);
  border-radius: var(--r-control);
  background: var(--surface);
  font-size: 0.96em;
  line-height: 1.62;
}
.callout p { margin: 0 0 0.6em; }
.callout p:last-child { margin-bottom: 0; }
.callout__label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pine);
}
.callout--warning { border-inline-start-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.callout--warning .callout__label { color: var(--danger); }
.callout--tip { border-inline-start-color: var(--sun); background: color-mix(in srgb, var(--sun) 12%, var(--surface)); }
.callout--tip .callout__label { color: var(--warning); }

/* ------------------------------------------------------------------ figures */

.figure { margin-block: clamp(26px, 3.2vw, 44px); }
.figure img { width: 100%; height: auto; border-radius: var(--r-card); }
.figure__open { display: block; }
.figure__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-block-start: 10px;
  color: var(--ink-muted);
  font-size: 13.5px;
  line-height: 1.5;
}
.figure__caption { flex: 1 1 18ch; }
.figure__credit { color: var(--ink-muted); font-size: 12.5px; }
.figure__credit a { color: var(--ink-muted); text-decoration: underline; }

/* `{.wide}` leaves the reading column; it never leaves the page gutter (see the rule above). */
.figure-pair {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  /* the row as a whole breathes like one figure; the figures inside it do not */
  margin-block: clamp(26px, 3.2vw, 44px);
}
.figure-pair .figure { margin-block: 0; }
/* Half the width means half the room: the caption and the credit stack instead of fighting.
   The caption also stops growing — in a column it would stretch to the tallest figure in the row and
   drop the credit to the bottom of the gap. */
.figure-pair .figure__meta { flex-direction: column; align-items: flex-start; gap: 2px; }
.figure-pair .figure__caption { flex: none; }
.figure-error, .chart-error {
  margin-block: 18px;
  padding: 10px 14px;
  border: 1px dashed var(--danger);
  border-radius: var(--r-control);
  color: var(--danger);
  font-size: 0.92em;
}

/* ------------------------------------------------------------------ tables */

.table-scroll, .chart__scroll { overflow-x: auto; }
/* A three-column table stretched to 1180 px is mostly gap. `fit-content` lets a narrow table sit at
   the text width and a wide one break out — and scroll — without a class per table. */
.article__body > .table-scroll {
  width: fit-content;
  min-width: min(100%, var(--measure));
  margin-block: clamp(24px, 3vw, 38px);
}
.md-table, .chart__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
  line-height: 1.45;
}
.md-table th, .md-table td, .chart__table th, .chart__table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
}
.md-table thead th, .chart__table thead th {
  border-bottom: 2px solid var(--line);
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.md-table tbody tr:nth-child(even), .chart__table tbody tr:nth-child(even) { background: var(--surface-alt); }
.ta-right { text-align: end; font-variant-numeric: tabular-nums; }
.ta-center { text-align: center; }
.ta-left { text-align: start; }
.chart__table caption { text-align: start; padding-block-end: 8px; color: var(--ink-muted); font-size: 12px; }

/* ------------------------------------------------------------------ charts */

.chart {
  margin-block: clamp(26px, 3.2vw, 44px);
  padding: clamp(14px, 1.8vw, 22px);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}
.chart__title {
  margin-block-end: 12px;
  font-family: var(--font-display);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.15rem);
  font-weight: 700;
  line-height: 1.25;
}
.chart__svg { width: 100%; height: auto; }
.chart--donut .chart__svg { max-width: 260px; margin-inline: auto; }
.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-block: 12px 0;
  padding: 0;
  list-style: none;
  font-size: 13.5px;
}
.chart__key { display: flex; align-items: center; gap: 8px; }
.chart__swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.chart__key-value { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.chart__table { margin-block-start: 14px; }
.chart__source { margin-block: 12px 0; color: var(--ink-muted); font-size: 12.5px; }

/* ------------------------------------------------------------------ sources, share, related */

.article__sources, .article__share, .article__related, .article__nav, .article__back {
  max-width: min(100%, var(--measure));
  margin-inline: auto;
}
.article__sources {
  margin-block: clamp(34px, 4vw, 52px) 0;
  padding-block-start: clamp(20px, 2.4vw, 30px);
  border-top: 1px solid var(--line);
}
.article__sources h2 { font-size: var(--fs-h3); }
.article__sources ol { margin-block: 14px 0; padding-inline-start: 1.3em; color: var(--ink-muted); font-size: 0.94rem; }
.article__sources li { margin-block-end: 6px; overflow-wrap: anywhere; }

.article__share { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-block: clamp(26px, 3vw, 38px) 0; }
.article__share .label { margin-block: 0; }
.article__share-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }

.article__related {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  margin-block: clamp(26px, 3vw, 40px) 0;
}

.article__nav {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  margin-block: clamp(30px, 3.4vw, 44px) 0;
}
.article__step {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  color: inherit;
}
.article__step:hover { border-color: var(--pine); text-decoration: none; }
.article__step--next { text-align: end; }
.article__step-title { font-family: var(--font-display); font-weight: 700; line-height: 1.25; }
.article__back { margin-block: clamp(24px, 2.6vw, 34px) 0; }

@media (max-width: 640px) {
  .article__cover img { max-height: 58vh; }
  .article__body { line-height: 1.68; }
}
