/* TAIDB — v1 stylesheet. Mobile first. Benchmark: TSDB. */

:root {
  --night: #0e1620;      /* the cave */
  --night-2: #182431;
  --ember: #e39b3b;      /* firelight */
  --ember-ink: #a5620f;  /* firelight, readable on paper */
  --paper: #f7f5f1;
  --card: #ffffff;
  --ink: #16191d;
  --muted: #646a72;
  --rule: #e2ddd5;
  --chip: #efebe4;
  --radius: 10px;
  --wrap: 1180px;
  --ui: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --narrow: "Archivo Narrow", "Archivo", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 var(--ui); -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

/* ---------- Top bar ---------- */
.topbar { background: var(--night); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-in { display: flex; align-items: center; gap: 18px; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; }
.brand-word { font-weight: 800; letter-spacing: .14em; font-size: 19px; }
.brand-mark { width: 22px; height: 22px; border: 2px solid var(--ember); border-radius: 6px; position: relative; }
.brand-mark::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: 4px; height: 3px; border-radius: 2px; background: var(--ember); }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { text-decoration: none; font-weight: 600; font-size: 15px; padding: 8px 10px; border-radius: 8px; color: #dfe5ea; }
.nav a:hover, .nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.08); }
.rss { color: #9fb0bf; display: inline-flex; padding: 6px; }
.rss:hover { color: var(--ember); }
@media (max-width: 420px) { .rss { display: none; } .nav a { padding: 8px 7px; } }

/* ---------- Hero ---------- */
.hero { background: var(--night); color: #fff; position: relative; overflow: hidden; }
.hero-wall {
  position: absolute; inset: -40px -40px -40px 35%;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
  transform: rotate(-8deg); opacity: .45; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 45%);
          mask-image: linear-gradient(90deg, transparent 0%, #000 45%);
}
.hero-wall img { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; }
@media (max-width: 719px) { .hero-wall { inset: -20px -60px -20px 20%; opacity: .25; } }
.hero-in { position: relative; padding-top: 44px; padding-bottom: 32px; }
.hero h1 { font-size: clamp(34px, 7vw, 58px); line-height: 1.02; letter-spacing: -.03em; margin: 0 0 10px; font-weight: 800; max-width: 14ch; }
.hero-sub { margin: 0 0 22px; color: #c6d0d9; font-size: 17px; max-width: 34ch; }
.search { display: flex; background: #fff; border-radius: 999px; padding: 5px; max-width: 640px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 16px; padding: 10px 16px; background: transparent; color: var(--ink); }
.search button { border: 0; border-radius: 999px; background: var(--ember); color: #1c1306; font-weight: 700; padding: 10px 20px; }
.search button:hover { background: #f0ac4f; }
.search-inline { box-shadow: none; border: 1px solid var(--rule); margin-bottom: 16px; }
.tracker { position: relative; border-top: 1px solid rgba(255,255,255,.08); background: rgba(0,0,0,.18); }
.tracker-in { display: flex; align-items: baseline; gap: 10px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
.tracker-num { font-family: var(--narrow); font-weight: 600; font-size: 24px; font-variant-numeric: tabular-nums; }
.tracker-label { color: #aebbc6; font-size: 14px; }
.tracker-pill { font-size: 12px; font-weight: 600; color: var(--ember); border: 1px solid rgba(227,155,59,.45); border-radius: 999px; padding: 2px 10px; }

/* ---------- Blocks ---------- */
.block { padding-top: 36px; padding-bottom: 12px; }
.block-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.block-head h1, .block-head h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; font-weight: 700; }
.block-head .more { margin-left: auto; font-size: 14px; font-weight: 600; color: var(--ember-ink); text-decoration: none; }
.block-head .more:hover { text-decoration: underline; }
.toggle { display: inline-flex; border: 1.5px solid var(--night); border-radius: 999px; padding: 2px; }
.toggle button { border: 0; background: transparent; border-radius: 999px; padding: 5px 14px; font-size: 14px; font-weight: 600; color: var(--night); }
.toggle button[aria-selected="true"] { background: var(--night); color: #fff; }

/* Rail: horizontal scroll on phones, like the benchmark */
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: 42%; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 12px; scrollbar-width: thin; }
.rail > * { scroll-snap-align: start; }
@media (min-width: 720px) { .rail { grid-auto-columns: 22%; } }
@media (min-width: 1040px) { .rail { grid-auto-columns: calc((100% - 6 * 14px) / 7); } }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 14px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1040px) { .grid { grid-template-columns: repeat(6, 1fr); } }

/* ---------- Card ---------- */
.card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; min-width: 0; }
.card[hidden] { display: none; }
.card-cover { display: block; border-radius: var(--radius); overflow: hidden; background: var(--night-2); aspect-ratio: 2/3; box-shadow: 0 2px 8px rgba(14,22,32,.14); }
.card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.card:hover .card-cover img { transform: scale(1.03); }
/* Panels are never cropped: shown whole on white inside the card */
.card[data-kind="panel"] .card-cover { background: #fff; }
.card[data-kind="panel"] .card-cover img { object-fit: contain; }
.card-title { font-weight: 700; font-size: 15px; line-height: 1.25; margin-top: 6px; }
.card-meta { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.chip { font-family: var(--narrow); font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; background: var(--chip); color: #4a4f56; padding: 2px 7px; border-radius: 5px; }
.chip-panel { background: #f6e3c8; color: #7a4a0c; }
.chip-story { background: #dde6ee; color: #23435c; }

/* ---------- News list ---------- */
.news { list-style: none; margin: 0; padding: 0; display: grid; gap: 0 40px; }
@media (min-width: 900px) { .news { grid-template-columns: 1fr 1fr; } .news-single { grid-template-columns: 1fr; max-width: 760px; } }
.news-item { border-bottom: 1px solid var(--rule); }
.news-link { display: flex; gap: 14px; padding: 14px 0; text-decoration: none; align-items: center; }
.news-thumb { flex: 0 0 104px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--night-2); }
.news-thumb img { width: 100%; height: 100%; object-fit: cover; }
.news-thumb-blank { display: grid; place-items: center; height: 100%; color: var(--ember); font-weight: 800; font-size: 22px; }
.news-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.news-meta { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.badge { background: var(--ember); color: #1c1306; font-weight: 700; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; }
.news-source { font-weight: 600; color: #3d434a; }
.news-title { font-weight: 600; font-size: 15.5px; line-height: 1.3; }
.news-link:hover .news-title { text-decoration: underline; }
.ext { color: var(--muted); font-weight: 400; }
.fineprint { color: var(--muted); font-size: 12px; margin: 14px 0 0; }

/* ---------- Article (entry + post) ---------- */
.article { padding-top: 28px; padding-bottom: 40px; }
.article-grid { display: grid; gap: 24px; }
@media (min-width: 900px) { .article-grid { grid-template-columns: minmax(0, 680px) 220px; gap: 48px; justify-content: center; } }
.kicker { margin: 0 0 6px; font-family: var(--narrow); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; font-size: 13px; color: var(--ember-ink); }
.kicker a { text-decoration: none; }
.article-title { font-size: clamp(28px, 5vw, 40px); line-height: 1.1; letter-spacing: -.025em; margin: 0 0 18px; font-weight: 800; color: var(--night); }
.deck { font-size: 19px; line-height: 1.5; color: #555b62; margin: 0 0 18px; }
.post-hero { border-radius: 14px; margin: 0 0 20px; width: 100%; aspect-ratio: 1200/630; object-fit: cover; }
.prose { font-size: 17px; line-height: 1.65; }
.prose h2 { font-size: 21px; color: var(--night); margin: 1.6em 0 .4em; }
.prose a { color: var(--ember-ink); }
.prose blockquote { margin: 1.2em 0; padding-left: 16px; border-left: 3px solid var(--ember); color: #474d54; }
.prose-story { font-family: var(--serif); font-size: 19px; line-height: 1.7; }
.prose-story p:first-of-type::first-letter { font-size: 3.1em; float: left; line-height: .9; padding: 4px 8px 0 0; font-weight: 600; color: var(--night); }

.article-side { font-size: 14px; }
@media (min-width: 900px) { .article-side { position: sticky; top: 76px; align-self: start; } }
.meta { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 10px; }
.meta li { border-left: 2px solid var(--ember); padding-left: 12px; color: #3d434a; }
.meta li.chips { border-left: 0; padding-left: 0; }

/* Panel: the work, large and centred */
.panel { margin: 0 auto 28px; max-width: 860px; }
.panel img { width: auto; max-width: 100%; height: auto; max-height: 78vh; margin: 0 auto; border-radius: 6px; box-shadow: 0 6px 30px rgba(14,22,32,.16); }
.panel-caption { font-family: var(--serif); font-style: italic; font-size: 19px; text-align: center; margin: 16px auto 0; max-width: 46ch; line-height: 1.45; }
.entry-panel .article-grid { margin-top: 6px; }

/* Story head: cover beside the deck */
.story-head { display: grid; grid-template-columns: 110px 1fr; gap: 16px; align-items: start; margin-bottom: 18px; }
.story-cover { border-radius: 8px; box-shadow: 0 4px 16px rgba(14,22,32,.18); aspect-ratio: 2/3; object-fit: cover; }
@media (min-width: 720px) { .story-head { grid-template-columns: 160px 1fr; gap: 24px; } }

/* ---------- Share ---------- */
.share-label { display: block; font-family: var(--narrow); font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.share-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--rule); background: var(--card); color: var(--ink); border-radius: 999px; padding: 8px 13px; font-size: 14px; font-weight: 600; text-decoration: none; min-height: 40px; }
.share-btn svg { width: 17px; height: 17px; }
.share-btn:hover { border-color: var(--night); }
.share-btn[hidden] { display: none; }

/* ---------- Read next ---------- */
.readnext { background: #ece6dc; padding: 32px 0 40px; border-radius: 28px 28px 0 0; }
.readnext h2 { margin: 0 0 16px; font-size: 22px; color: var(--night); }
.nextcard { display: block; max-width: 300px; background: var(--card); border-radius: 12px; overflow: hidden; text-decoration: none; box-shadow: 0 4px 16px rgba(14,22,32,.1); }
.nextcard img { aspect-ratio: 1200/630; object-fit: cover; width: 100%; }
.nextcard span { display: block; padding: 14px 16px; font-weight: 700; color: var(--night); }

/* ---------- Footer ---------- */
.footer { background: var(--night); color: #cfd8e0; padding: 40px 0 20px; }
main > :last-child:not(.readnext) { margin-bottom: 48px; }
.footer-in { display: grid; gap: 28px; }
@media (min-width: 720px) { .footer-in { grid-template-columns: 1fr auto; } }
.footer-note { color: #8797a5; margin: 8px 0 0; font-size: 14px; }
.footer-cols { display: flex; gap: 56px; }
.footer-cols h2 { font-family: var(--narrow); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--ember); margin: 0 0 10px; }
.footer-cols a { display: block; text-decoration: none; padding: 4px 0; font-size: 15px; }
.footer-cols a:hover { color: #fff; }
.footer-base { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid rgba(255,255,255,.08); margin-top: 28px; padding-top: 16px; font-size: 12.5px; color: #7d8d9b; }

.search-status { color: var(--muted); font-size: 14px; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
