/*
  Artometrics finished-surface system.
  One set of tokens and component rules shared by report pages, home collections,
  topic pages, downloads and transcripts, so a box, a heading or a tile looks the
  same wherever it appears. Loaded after the page styles, before report-body rules.

  Rule of thumb: content boxes (facts, charts, tiles, cards) carry the pink shadow.
  Action boxes (download tiles, source targets) carry the blue one.
*/

:root {
  --sys-ink: #f3ead7;
  --sys-line: #f3ead7;
  --sys-panel: #121014;
  --sys-plot: #0e1110;
  --sys-muted: #b7d0cb;
  --sys-link: #9db7ff;
  --sys-pink: #ff3d8a;
  --sys-blue: #0047ff;
  --sys-red: #e60000;
  --sys-shadow: 4px 4px 0 var(--sys-pink);
  --sys-shadow-action: 4px 4px 0 var(--sys-blue);
  --sys-gap: 16px;
  --sys-section: 44px;
  --sys-pad: 14px;
  --sys-display: "Anton", Impact, "Arial Narrow", sans-serif;
  --sys-sans: "DM Sans", system-ui, sans-serif;
  --sys-mono: "DM Mono", ui-monospace, monospace;
  --sys-h2: clamp(1.75rem, 5vw, 2.5rem);
  --sys-h3: clamp(1.25rem, 3.6vw, 1.6rem);
  /* Sticky header (.mast) height. anchor-jump.js replaces this with the measured value. */
  --mast-height: 112px;
  --anchor-offset: calc(var(--mast-height) + 16px);
}

[id] {
  scroll-margin-top: var(--anchor-offset);
}

html[data-theme="light"] {
  --sys-ink: #14110e;
  --sys-line: #14110e;
  --sys-panel: #fffdf8;
  --sys-plot: #fffdf8;
  --sys-muted: #3e362e;
  --sys-link: #0047ff;
}

@media (min-width: 900px) {
  :root {
    --mast-height: 125px;
    --sys-gap: 20px;
    --sys-section: 56px;
    --sys-pad: 16px;
  }
}

/* ---------- Boxes ---------- */
.sys-box,
.story-tile,
.chart-frame,
.file-tile,
.card,
.report-related a,
.report-status,
.source-entry,
.carousel-card {
  border: 1px solid var(--sys-line);
  background: var(--sys-panel);
  box-shadow: var(--sys-shadow);
  border-radius: 0;
}

.file-tile,
.source-entry:target {
  box-shadow: var(--sys-shadow-action);
}

/* ---------- Headings ---------- */
.desk-section > h2,
.desk-column h2,
.report-related > h2,
.source-block h2,
.sys-h2,
.report-body h2,
.report-section > h2 {
  margin: var(--sys-section) 0 14px;
  font-family: var(--sys-display);
  font-weight: 400;
  font-size: var(--sys-h2);
  line-height: 0.98;
  letter-spacing: -0.02em;
  text-transform: none;
  text-align: left;
  color: var(--sys-ink);
  text-wrap: balance;
}

.desk-section > h2 a,
.desk-column h2 a {
  color: var(--sys-ink);
  text-decoration: none;
}

.desk-section > h2 a::after {
  content: " \2192";
  color: var(--sys-pink);
}

.report-body h3,
.sys-h3,
.chart-frame__title {
  margin: 28px 0 10px;
  font-family: var(--sys-display);
  font-weight: 400;
  font-size: var(--sys-h3);
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--sys-ink);
  text-wrap: balance;
}

.sys-eyebrow {
  margin: 0 0 8px;
  font-family: var(--sys-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sys-link);
}

/* ---------- Home collections: story tiles ---------- */
.story-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sys-gap);
  padding: 0 4px 4px 0;
}

.story-grid > .story-tile:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  aspect-ratio: 16 / 9;
}

@media (min-width: 720px) {
  .story-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .story-grid > .story-tile:last-child:nth-child(odd) {
    grid-column: auto;
    aspect-ratio: 1;
  }
  .story-grid > .story-tile:last-child:nth-child(4n + 3) {
    grid-column: span 2;
    aspect-ratio: 2 / 1;
  }
}

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

.story-tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  color: var(--sys-ink);
  text-decoration: none;
}

.story-tile:hover,
.story-tile:focus-visible {
  box-shadow: var(--sys-shadow-action);
}

/* ---------- Cards and lists (downloads, blog index, stacks) ---------- */
.stack {
  gap: var(--sys-gap);
  padding-right: 4px;
}

.card {
  padding: var(--sys-pad);
}

.card h2 {
  margin: 4px 0 8px;
  font-family: var(--sys-display);
  font-size: clamp(1.4rem, 3.4vw, 1.9rem);
  line-height: 1.02;
  color: var(--sys-ink);
}

.report-related {
  display: grid;
  gap: var(--sys-gap);
  margin-top: var(--sys-section);
  padding: 0 4px 0 0;
  border-top: 0;
}

.report-related > h2 {
  margin: 0;
}

.report-related a {
  display: block;
  min-height: 56px;
  padding: var(--sys-pad);
  color: var(--sys-ink);
  text-decoration: none;
  font-family: var(--sys-display);
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1.05;
  border-bottom: 1px solid var(--sys-line);
}

/* ---------- Download tiles ---------- */
.file-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sys-gap);
  margin: 0;
  padding: 0 4px 4px 0;
  list-style: none;
}

.file-grid > li:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

@media (min-width: 720px) {
  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  }
  .file-grid > li:last-child:nth-child(odd) {
    grid-column: auto;
  }
}

.file-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  min-height: 72px;
  padding: 10px 12px;
  color: var(--sys-ink);
  text-decoration: none;
}

.file-tile:hover,
.file-tile:focus-visible {
  background: var(--sys-blue);
  color: #f3ead7;
}

html[data-theme] .file-tile .file-tile__label {
  color: var(--sys-ink);
}

html[data-theme] .file-tile:hover,
html[data-theme] .file-tile:focus-visible,
html[data-theme] .file-tile:hover .file-tile__label,
html[data-theme] .file-tile:focus-visible .file-tile__label {
  color: #f3ead7;
}

.file-tile__label {
  font-family: var(--sys-display);
  font-size: 1.15rem;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.file-tile__meta {
  font-family: var(--sys-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sys-muted);
}

.file-tile:hover .file-tile__meta,
.file-tile:focus-visible .file-tile__meta {
  color: #f3ead7;
}

/* ---------- Banner carousel: manual only ---------- */
.banner-carousel__controls {
  gap: 12px;
}

.banner-carousel__controls button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--sys-line);
  background: var(--sys-panel);
  box-shadow: var(--sys-shadow-action);
  color: var(--sys-ink);
  font-family: var(--sys-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---------- Manual chart carousel ---------- */
.carousel {
  margin: 0 0 var(--sys-gap);
}

.carousel__track {
  display: flex;
  gap: var(--sys-gap);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: auto;
  padding: 0 4px 8px 0;
  -webkit-overflow-scrolling: touch;
}

.carousel__track > .carousel-card {
  flex: 0 0 min(88%, 28rem);
  scroll-snap-align: start;
  margin: 0;
  padding: 10px;
}

.carousel-card img {
  display: block;
  width: 100%;
  height: auto;
  background: #fffdf8;
}

.carousel-card figcaption {
  margin-top: 8px;
  font-style: normal;
  font-size: 14px;
  line-height: 1.4;
  color: var(--sys-muted);
}

.carousel__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.carousel__controls button {
  flex: none;
  white-space: nowrap;
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border: 1px solid var(--sys-line);
  background: var(--sys-panel);
  box-shadow: var(--sys-shadow-action);
  color: var(--sys-ink);
  font-family: var(--sys-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.carousel__status {
  margin: 0;
  font-family: var(--sys-mono);
  font-size: 12px;
  color: var(--sys-muted);
}

/* ---------- Plain text pages (transcripts, changelog) ---------- */
.text-page {
  max-width: 44rem;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.text-page__actions .file-tile {
  flex: 1 1 13rem;
}

.text-page__body {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 17px;
  line-height: 1.6;
  color: var(--sys-ink);
}

.text-page__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sys-gap);
  margin: 16px 0 24px;
  padding: 0 4px 4px 0;
}

.card h2 a {
  color: var(--sys-ink);
  text-decoration: none;
}

.card h2 a:hover,
.card h2 a:focus-visible {
  text-decoration: underline;
  text-decoration-color: var(--sys-pink);
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
}

.card .file-grid {
  margin-top: 12px;
}
