/* ==========================================================================
   hubmasters.club — Reading Room + Argument Index
   Pure HTML/CSS/JS • System fonts • Editorial column system
   ========================================================================== */

/* --------------------------------------------------------------------------
   TOKENS — spacing, widths, typography, surfaces, borders
   -------------------------------------------------------------------------- */
:root {
  /* Spacing scale (editorial readability) */
  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-s: 1rem;
  --space-m: 1.5rem;
  --space-l: 2rem;
  --space-xl: 2.5rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 5rem;

  /* Width tokens — D4 container system */
  --w-narrow: min(42rem, 90vw);   /* Wn: essay body */
  --w-base: min(56rem, 92vw);     /* Wb */
  --w-wide: min(72rem, 94vw);     /* Ww */
  --w-inset: min(18rem, 85vw);    /* Wi: aside/panel */
  --w-canvas: 100%;               /* Wf */

  /* Typography scale */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --text-xs: 0.8125rem;
  --text-s: 0.875rem;
  --text-base: 1rem;
  --text-m: 1.125rem;
  --text-l: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2rem;
  --text-hero: 2.25rem;
  --line-tight: 1.25;
  --line-normal: 1.5;
  --line-relaxed: 1.65;
  --line-loose: 1.75;

  /* Surfaces */
  --surface-page: #faf9f7;
  --surface-panel: #f5f4f2;
  --surface-elevated: #fff;
  --surface-muted: #e8e6e3;
  --ink-primary: #1a1a1a;
  --ink-secondary: #444;
  --ink-muted: #666;
  --ink-subtle: #888;
  --accent: #2c5282;
  --accent-hover: #1a365d;
  --border-subtle: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.14);

  /* Radii (low — editorial) */
  --radius-s: 2px;
  --radius-m: 4px;
  --radius-panel: 6px;

  /* Transitions */
  --ease-out: 0.2s ease-out;
}

/* --------------------------------------------------------------------------
   BASE — reset, box-sizing, typography defaults
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: var(--line-relaxed);
  color: var(--ink-primary);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   TYPOGRAPHY — headings, body, utility
   -------------------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: var(--line-tight);
  margin: 0 0 var(--space-s) 0;
}
h1 { font-size: var(--text-hero); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-l); }
h4 { font-size: var(--text-m); }

p { margin: 0 0 var(--space-m) 0; }
p:last-child { margin-bottom: 0; }

.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: var(--space-xs);
}
.dek { font-size: var(--text-m); color: var(--ink-secondary); line-height: var(--line-relaxed); }

/* Readable text block (strict width) */
.readable { max-width: var(--w-narrow); }

/* --------------------------------------------------------------------------
   LAYOUT — grid, containers (D3 editorial_columns_system)
   -------------------------------------------------------------------------- */
.page { min-height: 100vh; display: flex; flex-direction: column; }

.container {
  width: 100%;
  max-width: var(--w-base);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-m);
  padding-right: var(--space-m);
}
.container--narrow { max-width: var(--w-narrow); }
.container--wide { max-width: var(--w-wide); }

/* Section spacing — D4 BT2 spacer_buffer_transition */
.section { padding-top: var(--space-3xl); padding-bottom: var(--space-3xl); }
.section--compact { padding-top: var(--space-2xl); padding-bottom: var(--space-2xl); }
.section--hero { padding-top: var(--space-2xl); padding-bottom: var(--space-2xl); }

/* 10-col content-focused grid (base) */
.grid-10 {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: var(--space-xl);
  align-items: start;
}
@media (max-width: 768px) {
  .grid-10 { grid-template-columns: 1fr; gap: var(--space-l); }
}

/* Hero: main + thesis map aside — SG6 aside_track_grammar */
.hero-grid {
  display: grid;
  grid-template-columns: 1fr minmax(0, var(--w-inset));
  gap: var(--space-2xl);
  align-items: start;
}
@media (max-width: 768px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-grid .thesis-map-panel { order: 2; }
}

/* Argument index: category blocks */
.index-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-l);
}
@media (max-width: 900px) { .index-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .index-grid { grid-template-columns: 1fr; } }

/* Pressure points: evidence panels stack */
.panels-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-m);
}
@media (max-width: 768px) { .panels-grid { grid-template-columns: 1fr; } }

/* About: content + aside — CL4 aside_to_inline_panel */
.about-grid {
  display: grid;
  grid-template-columns: 1fr minmax(0, var(--w-inset));
  gap: var(--space-2xl);
  align-items: start;
}
@media (max-width: 768px) {
  .about-grid { grid-template-columns: 1fr; }
  .about-grid .aside-notes { order: 2; }
}

/* Article layout: body + sidenotes */
.article-grid {
  display: grid;
  grid-template-columns: 1fr minmax(0, var(--w-inset));
  gap: var(--space-2xl);
  align-items: start;
}
@media (max-width: 768px) {
  .article-grid { grid-template-columns: 1fr; }
  .article-grid .thesis-map-side { order: 2; }
}

/* --------------------------------------------------------------------------
   COMPONENTS — header, utility strip, thesis map, chips, blocks
   -------------------------------------------------------------------------- */

/* Header — compact, quiet */
.site-header {
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-s) 0;
}
.site-header .container { max-width: var(--w-wide); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-s); }
.site-logo { font-family: var(--font-sans); font-weight: 600; font-size: var(--text-m); color: var(--ink-primary); }
.site-logo:hover { text-decoration: none; color: var(--ink-primary); }

/* Reading Room utility strip */
.util-strip {
  font-family: var(--font-sans);
  font-size: var(--text-s);
  display: flex; flex-wrap: wrap; gap: var(--space-m); align-items: center;
}
.util-strip a { color: var(--ink-muted); }
.util-strip a:hover { color: var(--ink-primary); }
.util-strip [aria-current="page"] { color: var(--ink-primary); font-weight: 500; }

/* Thesis map panel (hero + article) */
.thesis-map-panel,
.thesis-map-side {
  background: var(--surface-panel);
  border-radius: var(--radius-panel);
  padding: var(--space-m);
  border: 1px solid var(--border-subtle);
}
.thesis-map-panel h3,
.thesis-map-side h3 {
  font-size: var(--text-s);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: var(--space-s);
}
.thesis-map-panel .takeaways,
.thesis-map-side .takeaways { display: flex; flex-direction: column; gap: var(--space-2xs); }
.thesis-map-panel .takeaway-chip,
.thesis-map-side .takeaway-chip {
  display: block;
  font-size: var(--text-s);
  padding: var(--space-2xs) var(--space-xs);
  background: var(--surface-elevated);
  border-radius: var(--radius-s);
  border-left: 3px solid var(--accent);
  color: var(--ink-primary);
  transition: background var(--ease-out);
}
.thesis-map-panel .takeaway-chip:hover,
.thesis-map-side .takeaway-chip:hover { background: var(--surface-muted); text-decoration: none; color: var(--ink-primary); }
.thesis-map-panel .panel-footer,
.thesis-map-side .panel-footer {
  margin-top: var(--space-m);
  padding-top: var(--space-s);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--ink-subtle);
}

/* Collapsible thesis map (mobile): collapsed by default; button toggles */
.thesis-map-side.is-collapsed .takeaways { display: none; }
.thesis-map-toggle { display: none; }
@media (max-width: 768px) {
  .thesis-map-toggle {
    display: block;
    width: 100%;
    font-family: var(--font-sans);
    font-size: var(--text-s);
    padding: var(--space-xs);
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-s);
    cursor: pointer;
    text-align: left;
    margin-bottom: var(--space-xs);
  }
  .thesis-map-side .takeaways { display: flex; flex-direction: column; }
  .thesis-map-side.is-collapsed .takeaways { display: none; }
}

/* Micro nav row (under hero) */
.micro-nav {
  display: flex; flex-wrap: wrap; gap: var(--space-m); margin-top: var(--space-l);
  font-family: var(--font-sans); font-size: var(--text-s);
}
.micro-nav a { font-weight: 500; }

/* Argument index — category block */
.index-block {
  background: var(--surface-panel);
  border-radius: var(--radius-panel);
  padding: var(--space-m);
  border: 1px solid var(--border-subtle);
}
.index-block h3 { font-size: var(--text-m); margin-bottom: var(--space-2xs); }
.index-block .why { font-size: var(--text-s); color: var(--ink-muted); margin-bottom: var(--space-s); }
.index-block ul { list-style: none; padding: 0; margin: 0; }
.index-block li { margin-bottom: var(--space-2xs); }
.index-block li:last-child { margin-bottom: 0; }
.index-block a { font-size: var(--text-s); }

/* Featured essay snippet rows — T7 case_snippet_rows */
.featured-entry {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-panel);
  padding: var(--space-xl);
  margin-bottom: var(--space-l);
}
.featured-entry .row { margin-bottom: var(--space-m); }
.featured-entry .row:last-child { margin-bottom: 0; }
.featured-entry .label { font-family: var(--font-sans); font-size: var(--text-xs); color: var(--ink-muted); margin-bottom: var(--space-3xs); }
.featured-entry h2 { margin-bottom: var(--space-2xs); }
.featured-entry .meta { font-size: var(--text-s); color: var(--ink-muted); margin-bottom: var(--space-s); }

/* Evidence panel (pressure points) */
.evidence-panel {
  background: var(--surface-panel);
  border-radius: var(--radius-m);
  padding: var(--space-m);
  border: 1px solid var(--border-subtle);
  min-height: 0;
}
.evidence-panel h3 { font-size: var(--text-m); margin-bottom: var(--space-2xs); }
.evidence-panel p { font-size: var(--text-s); margin-bottom: var(--space-s); }
.evidence-panel a { font-size: var(--text-s); font-weight: 500; }

/* Archive row — resource_rows_with_meta */
.archive-list { list-style: none; padding: 0; margin: 0; }
.archive-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-m);
  align-items: baseline;
  padding: var(--space-s) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.archive-item:last-child { border-bottom: none; }
@media (max-width: 600px) {
  .archive-item { grid-template-columns: 1fr; gap: var(--space-2xs); }
}
.archive-item .title { font-weight: 500; }
.archive-item .meta-row { font-family: var(--font-sans); font-size: var(--text-xs); color: var(--ink-muted); }
.archive-item.archive-item--utility { background: var(--surface-panel); padding: var(--space-m); border-radius: var(--radius-m); margin-top: var(--space-s); }

/* CTA block — split_cta_text_action */
.cta-block {
  background: var(--surface-panel);
  border-radius: var(--radius-panel);
  padding: var(--space-xl);
  border: 1px solid var(--border-subtle);
}
.cta-block .cta-text { margin-bottom: var(--space-m); }
.cta-block .cta-text h2 { margin-bottom: var(--space-2xs); }
.cta-block .cta-actions { display: flex; flex-wrap: wrap; gap: var(--space-m); align-items: center; }
.cta-block .cta-actions a { font-weight: 500; }

/* Aside notes (about / operator) */
.aside-notes {
  background: var(--surface-panel);
  border-radius: var(--radius-panel);
  padding: var(--space-m);
  border: 1px solid var(--border-subtle);
}
.aside-notes h3 { font-size: var(--text-s); margin-bottom: var(--space-xs); }
.aside-notes p { font-size: var(--text-s); }

/* Footer */
.site-footer {
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-sans);
  font-size: var(--text-s);
  color: var(--ink-muted);
}
.site-footer .container { max-width: var(--w-wide); }
.footer-nav { display: flex; flex-wrap: wrap; gap: var(--space-m); margin-bottom: var(--space-s); }
.footer-nav a { color: var(--ink-muted); }
.footer-copy { font-size: var(--text-xs); }

/* Breadcrumb bar */
.breadcrumb-bar {
  font-family: var(--font-sans);
  font-size: var(--text-s);
  padding: var(--space-xs) 0;
  margin-bottom: var(--space-m);
}
.breadcrumb-bar a { color: var(--ink-muted); }
.breadcrumb-bar [aria-current="page"] { color: var(--ink-primary); }

/* Article intro (post template) */
.article-intro { margin-bottom: var(--space-2xl); padding-bottom: var(--space-xl); border-bottom: 1px solid var(--border-subtle); }
.article-intro .meta-row { font-family: var(--font-sans); font-size: var(--text-s); color: var(--ink-muted); margin-top: var(--space-s); }

/* Sidenotes in article body */
.sidenote {
  font-size: var(--text-s);
  color: var(--ink-muted);
  margin: var(--space-s) 0;
  padding-left: var(--space-m);
  border-left: 2px solid var(--border-strong);
}
.sidenote ref { font-weight: 600; color: var(--ink-secondary); }

/* Related arguments */
.related-section h2 { margin-bottom: var(--space-m); }
.related-section ul { list-style: none; padding: 0; margin: 0; }
.related-section li { margin-bottom: var(--space-s); padding-left: var(--space-m); border-left: 3px solid var(--accent); }
.related-section a { font-weight: 500; }

/* --------------------------------------------------------------------------
   SECTIONS — section-specific overrides
   -------------------------------------------------------------------------- */
.section--hero .container { max-width: var(--w-base); }
.section--index .container,
.section--panels .container,
.section--archive .container { max-width: var(--w-wide); }
.section--about .container { max-width: var(--w-narrow); }
.section--about .about-grid { max-width: var(--w-narrow); margin-left: auto; margin-right: auto; }

/* --------------------------------------------------------------------------
   UTILITIES
   -------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.no-wrap { white-space: nowrap; }

/* Mobile nav toggle (for hamburger) */
.nav-toggle { display: none; }
@media (max-width: 600px) {
  .nav-toggle {
    display: block;
    background: none;
    border: none;
    padding: var(--space-xs);
    cursor: pointer;
    font-size: var(--text-l);
  }
  .util-strip { display: none; }
  .util-strip.is-open { display: flex; position: absolute; top: 100%; left: 0; right: 0; background: var(--surface-elevated); padding: var(--space-m); border-bottom: 1px solid var(--border-subtle); flex-direction: column; }
}
