/* Sarmadi LLC — AI Digest section styles
   Extends styles.css. Editorial. Restrained. Type-driven.
*/

:root {
  --digest-max: 1080px;
}

/* ============== DARK MODE ============== */
html[data-theme="dark"] {
  --paper: #0E0E12;
  --paper-2: #15151B;
  --paper-3: #1C1C24;
  --ink: #F2F1ED;
  --ink-2: #C9C8C1;
  --stone: #9A9AA1;
  --stone-2: #6B6B72;
  --line: #2A2A33;
  --line-2: #3A3A44;
}
html[data-theme="dark"] body { background: var(--paper); color: var(--ink); }
html[data-theme="dark"] .item-card { background: var(--paper-2); }
html[data-theme="dark"] .item-meta .type-badge.paper { background: var(--paper-3); }
html[data-theme="dark"] .item-meta .type-badge.news { background: var(--paper-2); }
html[data-theme="dark"] .tag-chip { background: var(--paper-2); }
html[data-theme="dark"] .key-num { background: var(--paper-2); }
html[data-theme="dark"] .filter-bar input,
html[data-theme="dark"] .filter-bar select { background: var(--paper-2); color: var(--ink); }
html[data-theme="dark"] .nav { background: color-mix(in oklab, var(--paper) 92%, transparent); }

/* Toggle button (injected by digest-ui.js into the masthead) */
.theme-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  border: 1px solid var(--line-2);
  background: transparent;
  padding: 3px 10px 4px;
  border-radius: 999px;
  cursor: pointer;
  margin-left: 6px;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-2); }

/* Save-for-later */
.item-save {
  position: absolute;
  top: 10px; right: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--stone-2);
  padding: 4px 6px;
  line-height: 1;
}
.item-save:hover { color: var(--ink-2); }
.item-save[aria-pressed="true"] { color: var(--signal); }
.item-save .icon::before { content: "☆"; }
.item-save[aria-pressed="true"] .icon::before { content: "★"; }
.item-save .label { position: absolute; left: -9999px; }

.saved-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-2);
}
.saved-count[hidden] { display: none; }

/* Glossary inline term */
.glossary-term {
  border-bottom: 1px dotted var(--stone-2);
  cursor: help;
  text-decoration: none;
}
.glossary-term:hover, .glossary-term:focus {
  border-bottom-color: var(--ink-2);
  background: color-mix(in oklab, var(--brand-blue, #4FA8E8) 8%, transparent);
}
.glossary-tip {
  position: absolute;
  z-index: 90;
  max-width: 320px;
  padding: 10px 12px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: 0.005em;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}
.glossary-tip.visible { opacity: 1; transform: translateY(0); }
html[data-theme="dark"] .glossary-tip { background: var(--paper-3); color: var(--ink); border: 1px solid var(--line-2); }

/* Keyboard nav focus */
.item-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Keyboard help modal */
.kbd-help-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.kbd-help {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px 28px 20px;
  max-width: 420px;
  font-size: 14px;
}
.kbd-help h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.kbd-help table { border-collapse: collapse; width: 100%; }
.kbd-help td { padding: 5px 0; vertical-align: top; }
.kbd-help kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 1px 6px;
  margin-right: 4px;
}
.kbd-help .close {
  display: inline-block;
  margin: 14px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stone);
  cursor: pointer;
  background: none; border: none; padding: 0;
}
.kbd-help .close:hover { color: var(--ink); }

.digest-section { max-width: var(--digest-max); margin: 0 auto; padding: 0 32px; }
@media (max-width: 720px) { .digest-section { padding: 0 20px; } }

/* ============== MASTHEAD ============== */
.digest-masthead {
  padding: 88px 0 28px;
  border-bottom: 1px solid var(--line);
}
.digest-masthead .row {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
}
.digest-masthead .title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
}
.digest-masthead .title::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand-gradient);
  margin-right: 10px;
  vertical-align: 1px;
}
.digest-masthead .meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--stone);
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
}
.digest-masthead .meta a { color: var(--ink-2); border-bottom: 1px solid var(--line-2); padding-bottom: 1px; }
.digest-masthead .meta a:hover { color: var(--ink); border-color: var(--ink-2); }
.digest-masthead .meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--stone-2); }

/* ============== DIGEST INTRO (only on the landing) ============== */
.digest-intro {
  padding: 56px 0 36px;
  border-bottom: 1px solid var(--line);
}
.digest-intro h2 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-size: clamp(28px, 3.8vw, 42px);
  margin: 14px 0 14px;
  max-width: 22ch;
}
.digest-intro p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 64ch;
  margin: 0;
}
.digest-intro p a {
  color: var(--ink);
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 1px;
}
.digest-intro p a:hover { border-color: var(--ink-2); }

/* ============== DAY HERO (used inline on landing and on /<date>.html) ============== */
.day-hero { padding: 48px 0 56px; }
.day-hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.04;
  font-size: clamp(34px, 5vw, 56px);
  margin: 0 0 20px;
  max-width: 22ch;
  color: var(--ink);
}
.day-hero .editors-note {
  font-family: var(--font-display);
  font-size: clamp(20px, 1.9vw, 24px);
  line-height: 1.45;
  color: var(--ink-2);
  max-width: 62ch;
  margin: 0;
}
.day-hero .stats {
  display: flex; gap: 22px; flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone);
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.day-hero .stats b { color: var(--ink); font-weight: 600; }

/* ============== CLUSTER ============== */
.cluster { padding: 44px 0; border-top: 1px solid var(--line); }
.cluster-head { margin-bottom: 22px; max-width: 64ch; }
.cluster-head h2 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.1;
  font-size: clamp(24px, 2.8vw, 32px);
  margin: 0 0 10px;
}
.cluster-head .summary {
  color: var(--stone);
  font-size: 15.5px;
  line-height: 1.55;
  margin: 0;
}
.cluster-importance {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--stone-2);
  margin-bottom: 8px;
}

/* Layout: two columns when cluster has both papers + news, single column otherwise */
.cluster-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.cluster-grid[data-cols="2"] { grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .cluster-grid[data-cols="2"] { grid-template-columns: 1fr; } }

.cluster-col { display: flex; flex-direction: column; gap: 12px; }
.cluster-col-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--stone-2);
  margin-bottom: 2px;
}

/* ============== ITEM CARD — tightened ============== */
.item-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 4px;
  padding: 16px 18px 14px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
  transition: border-color 120ms ease;
}
.item-card:hover { border-color: var(--line-2); }
.item-card[data-importance="5"] {
  border-color: var(--line-2);
  background: #fff;
}
.item-card[data-importance="5"]::before {
  content: ""; display: block;
  height: 2px; width: 36px;
  background: var(--brand-gradient);
  border-radius: 2px;
  margin-bottom: 2px;
}

.item-meta {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone);
}
.item-meta .type-badge {
  padding: 1px 6px 2px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  color: var(--ink-2);
  letter-spacing: 0.14em;
  font-size: 9.5px;
}
.item-meta .type-badge.paper { background: var(--paper-2); }
.item-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--stone-2); }

.item-title {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin: 2px 0 0;
  color: var(--ink);
}
.item-title a { color: inherit; }
.item-title a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.item-tldr { font-size: 14px; line-height: 1.5; color: var(--ink-2); margin: 0; }

.item-lab {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-top: -2px;
}

.key-numbers { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.key-num {
  display: inline-flex; align-items: baseline; gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 2px 8px;
  border-radius: 999px;
}
.key-num .label { color: var(--stone); letter-spacing: 0.06em; text-transform: uppercase; font-size: 9px; }

.item-footer {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  margin-top: 4px; padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.tag-row { display: flex; gap: 5px; flex-wrap: wrap; }
.tag-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--stone);
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  letter-spacing: 0.04em;
}
.tag-chip:hover { color: var(--ink); border-color: var(--line-2); }

.item-actions {
  display: flex; gap: 14px; align-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.item-actions a {
  color: var(--ink-2);
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
}
.item-actions a:hover { color: var(--ink); border-color: var(--ink-2); }

/* Progressive disclosure */
.item-more { margin-top: 2px; }
.item-more summary {
  list-style: none; cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone);
}
.item-more summary:hover { color: var(--ink); }
.item-more summary::-webkit-details-marker { display: none; }
.item-more summary::after { content: " +"; }
.item-more[open] summary::after { content: " −"; }
.why-it-matters { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; line-height: 1.55; }
.why-it-matters li { margin-bottom: 3px; }

/* ============== DAY SECTION (Papers / News, collapsible) ============== */
.day-section {
  border-top: 1px solid var(--line);
  padding: 36px 0 0;
}
.day-section[open] { padding-bottom: 8px; }
.day-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 0 0 28px;
}
.day-section > summary::-webkit-details-marker { display: none; }
.day-section .day-section-head {
  display: flex; align-items: baseline; gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 0;
}
.day-section .day-section-head h2 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.015em;
  font-size: clamp(28px, 3.6vw, 40px);
  line-height: 1;
  margin: 0;
  display: inline-flex; align-items: baseline; gap: 12px;
}
.day-section .day-section-head h2 .chev {
  font-family: var(--font-sans);
  font-size: 0.55em;
  color: var(--stone-2);
  transition: color 120ms ease;
}
.day-section > summary:hover .chev { color: var(--ink); }
.day-section[open] .chev::before { content: "▾"; }
.day-section:not([open]) .chev::before { content: "▸"; }
.day-section .day-section-head .count {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--stone);
}
.day-section .day-section-head .hairline {
  flex: 1; height: 1px; background: var(--line); align-self: center;
}
.day-section .day-section-head .toggle { display: none; }

/* Within a section, clusters become tighter (no top border, smaller heading) */
.day-section .cluster {
  border-top: none;
  padding: 28px 0;
  border-bottom: 1px dashed var(--line);
}
.day-section .cluster:last-child { border-bottom: none; }
.day-section .cluster-head h2 {
  font-size: clamp(20px, 2.2vw, 24px);
  margin: 0 0 6px;
}
.day-section .cluster-head .summary { font-size: 14.5px; }
.day-section .cluster-grid { grid-template-columns: 1fr; }
.day-section .cluster-col-label { display: none; }

/* Linked callout on items */
.item-linked {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone);
  display: flex; align-items: baseline; gap: 8px;
  margin-top: 2px;
}
.item-linked .arrow { color: var(--stone-2); }
.item-linked a {
  color: var(--ink-2);
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 1px;
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
}
.item-linked a:hover { color: var(--ink); border-color: var(--ink-2); }
.item-linked .badge {
  font-size: 9.5px;
  border: 1px solid var(--line-2);
  padding: 1px 5px 2px;
  border-radius: 3px;
  color: var(--ink-2);
}

/* ============== ALSO TODAY ============== */
.also-today {
  padding: 36px 0 44px;
  border-top: 1px solid var(--line);
}
.also-today h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--stone);
  font-weight: 500;
  margin: 0 0 14px;
}
.also-list { list-style: none; padding: 0; margin: 0; }
.also-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
  line-height: 1.5;
}
.also-list li:last-child { border-bottom: none; }
.also-list .badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--stone);
  margin-right: 10px;
}
.also-list a { color: var(--ink); border-bottom: 1px solid var(--line); }
.also-list a:hover { border-color: var(--ink-2); }
.also-list .sub { color: var(--stone); }

/* ============== PRIOR DAYS ============== */
.prior {
  padding: 40px 0 56px;
  border-top: 1px solid var(--line);
}
.prior h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--stone);
  font-weight: 500;
  margin: 0 0 18px;
}

.day-list { display: flex; flex-direction: column; }
.day-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 24px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  align-items: baseline;
}
.day-row:last-child { border-bottom: 1px solid var(--line); }
.day-row .date {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stone);
}
.day-row .headline {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.day-row .headline a { color: inherit; }
.day-row .headline a:hover { text-decoration: underline; text-underline-offset: 3px; }
.day-row .meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone);
  white-space: nowrap;
}
@media (max-width: 760px) {
  .day-row { grid-template-columns: 1fr; gap: 6px; }
  .day-row .meta { text-align: left; }
}

.see-more { padding: 32px 0; text-align: center; }

/* ============== ARCHIVE / TOPIC / PAPER ============== */
.archive-hero, .topic-hero, .paper-hero {
  padding: 88px 0 36px;
  border-bottom: 1px solid var(--line);
}
.archive-hero h1, .topic-hero h1, .paper-hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.025em;
  font-size: clamp(30px, 4.5vw, 50px);
  line-height: 1.06;
  margin: 8px 0 0;
}
.archive-hero p.lede, .topic-hero p.lede, .paper-hero p.lede {
  color: var(--ink-2);
  margin-top: 14px;
  max-width: 58ch;
  font-size: 16px;
  line-height: 1.55;
}

.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.filter-bar input[type="search"] {
  font-family: inherit; font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line-2); border-radius: 4px;
  background: #fff; min-width: 240px;
}
.filter-bar select {
  font-family: inherit; font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line-2); border-radius: 4px;
  background: #fff;
}

.paper-meta-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 24px;
  margin: 24px 0 0;
  font-size: 14.5px; line-height: 1.5;
}
.paper-meta-grid dt {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stone);
}
.paper-meta-grid dd { margin: 0; color: var(--ink-2); }

.story-arc { padding: 40px 0; }
.story-arc h2 { font-family: var(--font-display); font-size: 26px; margin: 0 0 18px; }
.story-arc-entry {
  padding: 16px 0;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 130px 1fr; gap: 24px;
}
.story-arc-entry:last-child { border-bottom: 1px solid var(--line); }
.story-arc-entry .when {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stone);
}

/* ============== UTIL ============== */
.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-ghost.subtle { border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost.subtle:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Print */
@media print {
  .nav, .footer, .item-more summary, .day-hero .stats, .item-actions { display: none; }
  .item-card { break-inside: avoid; border: none; padding: 0; }
  .cluster { border-top: 1px solid #000; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
