/* ═══════════════════════════════════════════════════════════
   davidjivan.net — shared stylesheet
   warm reader aesthetic
   ═══════════════════════════════════════════════════════════ */

/* ─── TOKENS ────────────────────────────────────────────── */
:root {
  --bg:         #faf8f4;
  --surface:    #f3f0ea;
  --surface-hi: #ebe6dd;
  --border:     #e0dbd0;
  --border-hi:  #c4beb0;
  --text:       #1a1a1a;
  --text-dim:   #8c8780;
  --text-hi:    #111;
  --accent:     #8b5e3c;
  --accent-dim: #c4a882;
  --accent-bright: #6b3a1f;
  --font-body:  "Charter", "Georgia", "Bitstream Charter", "Times New Roman", serif;
  --font-ui:    -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  --dur: 0.15s;
  --max-w: 640px;
  --pad-x: 24px;
}

/* ─── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
button { font: inherit; border: none; background: none; cursor: pointer; }
a { text-decoration: none; color: inherit; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.8;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
}

::selection {
  background: #d4c4b0;
  color: #1a1a1a;
}

/* ─── READING PROGRESS BAR ───────────────────────────────── */
#reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: var(--accent);
  z-index: 100;
  transition: width 0.1s linear;
}

/* ─── READING CONTROLS ───────────────────────────────────── */
#reader-controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 16px;
  z-index: 99;
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--font-ui);
}

#reader-controls button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 40px;
  height: 36px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur);
}

#reader-controls button:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--accent-dim);
}

#reader-controls button:active {
  transform: scale(0.95);
  transition: transform 0.05s;
}

#reader-controls .ctrl-label {
  font-size: 13px;
  color: var(--text-dim);
  min-width: 44px;
  text-align: center;
}

#reader-controls .ctrl-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 8px;
}

/* ─── BANNER (homepage) ──────────────────────────────────── */
.banner { display: none; }

/* ─── DISCLAIM LIST ──────────────────────────────────────── */
.disclaim-list {
  list-style: none;
  margin: 2em 0;
  padding: 0;
}

.disclaim-list li {
  padding: 0.5em 0;
  border-bottom: 1px solid var(--border);
  font-style: italic;
  color: var(--text-dim);
}

.disclaim-list li::before { content: none; }
.disclaim-list li em { color: var(--text); font-style: normal; }

/* ─── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px var(--pad-x);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: 15px;
}

.topbar--sticky {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 248, 244, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.topbar-logo {
  font-weight: 600;
  color: var(--text-hi);
  letter-spacing: -0.01em;
}

.topbar-url {
  color: var(--text-dim);
  font-size: 13px;
}

.topbar-back {
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 5px;
  transition: all var(--dur);
}

.topbar-back:hover {
  color: var(--text);
  background: var(--surface);
}

/* ─── HERO (homepage) ────────────────────────────────────── */
.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px var(--pad-x) 32px;
}

.hero-prompt {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.hero-prompt::before { content: none; }

.hero-title {
  font-size: 2.4rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}

.cursor { display: none; }

.hero-sub {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--text-dim);
  line-height: 1.7;
  margin-top: 20px;
  max-width: 520px;
}

/* ─── HOME MENU ──────────────────────────────────────────── */
.menu {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 32px var(--pad-x);
}

.menu:first-of-type { padding-top: 0; }

.menu-label {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 20px;
}

/* ─── POST LIST (homepage) ───────────────────────────────── */
.post-list { display: flex; flex-direction: column; gap: 2px; }

.post-card {
  display: block;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  transition: all var(--dur);
}

.post-card:hover {
  background: var(--surface);
  margin: 0 calc(-1 * var(--pad-x));
  padding-left: var(--pad-x);
  padding-right: var(--pad-x);
  border-color: var(--accent-dim);
}

.post-card .post-title {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-hi);
  line-height: 1.5;
}

.post-card .post-meta {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ─── POST PAGE HEADER ───────────────────────────────────── */
.post-header {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 32px var(--pad-x) 0;
}

.post-eyebrow {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.post-eyebrow::before { content: none; }

.post-header .post-title {
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text-hi);
  margin-bottom: 8px;
}

.post-header .post-meta {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-dim);
}

/* ─── ARTICLE ────────────────────────────────────────────── */
.article {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px var(--pad-x) 120px;
}

.article p {
  margin-bottom: 1.2em;
  line-height: 1.8;
}

.article p:first-child {
  font-size: 1.05em;
  color: #111;
}

.article h2 {
  font-family: var(--font-ui);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2.8em 0 0.5em;
  color: var(--text-hi);
  letter-spacing: -0.005em;
}

.article h2::before { content: none; }

.article blockquote {
  margin: 1.6em 0;
  padding-left: 1.2em;
  border-left: 2px solid var(--accent-dim);
  color: #555;
  font-style: italic;
}

.article blockquote p {
  margin-bottom: 0.6em;
}

.article em { font-style: italic; }
.article strong { font-weight: 600; color: #111; }

.article a:not(.card) {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-dim);
  text-underline-offset: 3px;
  transition: all var(--dur);
}

.article a:not(.card):hover {
  color: var(--accent-bright);
  text-decoration-color: var(--accent);
}

.article a:not(.card) em,
.article a:not(.card) strong { color: inherit; }

/* ─── DIVIDER ────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}

/* ─── POST FOOTER ────────────────────────────────────────── */
.post-footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--pad-x) 48px;
  font-family: var(--font-ui);
}

.author-line {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.back-link {
  font-size: 13px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--dur);
}

.back-link:hover { color: var(--text); }
.back-link::before { content: '\2190'; color: var(--accent-dim); }

/* ─── TOC ────────────────────────────────────────────────── */
.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin: 2em 0;
  font-family: var(--font-ui);
}

.toc-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toc-item { font-size: 14px; }
.toc-item a { color: var(--text); transition: color var(--dur); }
.toc-item a:hover { color: var(--accent); }

.toc-num {
  color: var(--text-dim);
  font-size: 12px;
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

/* ─── CALLBACK CARDS ─────────────────────────────────────── */
.article > .callout,
.article > .cards,
.article > .hinge,
.article > .timeline,
.article > .disclaim-list,
.article > .text-cards,
.article > .parallel-box,
.article > .parallel-list,
.article > .channel-list,
.article > .flag-card,
.article > .transmission-box,
.article > .toc,
.article > .toggle,
.article > blockquote {
  margin: 2em 0;
}

/* ─── SECTION / KICKER ───────────────────────────────────── */
.section {
  margin: 4em 0 2em;
  padding-top: 2em;
  border-top: 1px solid var(--border);
}

.kicker {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.kicker::before { content: none; }

.section-title {
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text-hi);
  letter-spacing: -0.01em;
  margin-bottom: 0.5em;
}

.section-title em { color: var(--accent); font-style: italic; }

.lede {
  font-size: 1.05em;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 2em;
}

.lede strong { color: var(--text); font-weight: 500; }

/* ─── HINGE (side-by-side comparison) ────────────────────── */
.hinge {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.hinge-cell {
  background: var(--bg);
  padding: 24px;
  transition: background var(--dur);
}

.hinge-cell:hover { background: var(--surface); }

.hinge-tag {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.hinge-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
}

.hinge-cell:first-child .hinge-title { color: var(--text-hi); }
.hinge-cell:last-child .hinge-title { color: var(--accent); }

.hinge-body {
  font-size: 0.92em;
  color: var(--text-dim);
  line-height: 1.6;
}

.hinge-body em { color: var(--text); font-style: italic; }

.hinge-cap {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 12px;
}

/* ─── CARDS (thinker/source grid) ─────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  transition: all var(--dur);
}

.card:hover {
  border-color: var(--accent-dim);
  background: var(--surface-hi);
}

.card-who {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-hi);
  margin-bottom: 2px;
}

.card-year {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.card-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.card-body {
  font-size: 0.92em;
  color: var(--text-dim);
  line-height: 1.6;
}

.card-body em { color: var(--text); }

.card-quote {
  font-style: italic;
  color: #555;
  font-size: 0.92em;
  line-height: 1.6;
  margin-top: 8px;
}

/* ─── TIMELINE ───────────────────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tl-item {
  display: flex;
  gap: 16px;
  padding: 10px 0 10px 20px;
  border-left: 1px solid var(--border);
  position: relative;
  transition: all var(--dur);
}

.tl-item::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 16px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-hi);
  transition: all var(--dur);
}

.tl-item--active::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.tl-when {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-dim);
  min-width: 80px;
  padding-top: 2px;
}

.tl-who {
  font-weight: 600;
  font-size: 0.95em;
  margin-bottom: 2px;
}

.tl-item--active .tl-who { color: var(--accent); }

.tl-body {
  font-size: 0.88em;
  color: var(--text-dim);
  line-height: 1.5;
  flex: 1;
}

/* ─── CALLOUT ────────────────────────────────────────────── */
.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 22px;
  font-size: 0.94em;
  line-height: 1.6;
  color: var(--text-dim);
}

.callout--accent {
  border-left: 3px solid var(--accent);
}

.callout strong { color: var(--text); }

/* ─── THESIS ─────────────────────────────────────────────── */
.thesis {
  text-align: center;
  font-size: 1.2rem;
  font-style: italic;
  color: var(--text-hi);
  line-height: 1.5;
  padding: 2em 1em;
  max-width: 560px;
  margin: 2em auto;
}

/* ─── COLOPHON ───────────────────────────────────────────── */
.colophon {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 48px;
}

/* ─── SCROLL REVEAL ──────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.in { opacity: 1; transform: translateY(0); }

/* ─── TOGGLE ─────────────────────────────────────────────── */
.toggle {
  display: flex;
  gap: 4px;
  font-family: var(--font-ui);
}

.toggle-btn {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 6px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  transition: all var(--dur);
}

.toggle-btn:hover { color: var(--text); border-color: var(--border-hi); }

.toggle--active .toggle-btn,
.toggle-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ─── TEXT CARDS / PARALLEL / CHANNEL / FLAG ─────────────── */
.text-cards, .parallel-list, .channel-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.text-cards .card,
.parallel-list .card,
.channel-list .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}

.parallel-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
}

.flag-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 22px;
}

.transmission-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 600px) {
  body { font-size: 17px; }

  .topbar { padding: 18px 18px; }

  .hero-title { font-size: 1.8rem; }
  .hero-sub { font-size: 1rem; }
  .hero { padding: 32px 18px 24px; }

  .menu { padding: 24px 18px; }

  .post-header { padding: 24px 18px 0; }
  .post-header .post-title { font-size: 1.5rem; }

  .article { padding: 32px 18px 110px; }
  .article h2 { font-size: 1rem; }

  .post-footer { padding: 0 18px 48px; }

  .cards, .text-cards, .parallel-list, .channel-list {
    grid-template-columns: 1fr;
  }

  .hinge { grid-template-columns: 1fr; }

  .tl-item { flex-direction: column; gap: 4px; }
  .tl-when { min-width: auto; }

  .thesis { font-size: 1.05rem; padding: 1.5em 0.5em; }

  #reader-controls { padding: 8px 12px; gap: 2px; }
  #reader-controls button { width: 36px; height: 32px; font-size: 14px; }
  #reader-controls .ctrl-label { min-width: 40px; font-size: 12px; }
}

/* ─── PRINT ──────────────────────────────────────────────── */
@media print {
  #reading-progress, #reader-controls { display: none; }
  body { background: #fff; color: #000; font-size: 14px; }
  .article { padding: 0; max-width: none; }
  .topbar, .post-footer { display: none; }
}
