/* Warm Ink — shared tokens + base (S192-addendum, token reskin of Direction C)
   Ground: warm paper. Print-grade sans for display/body, mono reserved for
   tabular data, code voice, and record rows (worktable, resume entries,
   listings). One accent: brick red. Hard rules as texture, radius 0. */
:root {
  /* ------------ Radius (single token — near-brutalist, hard edges) ------------ */
  --radius: 0;

  /* ------------ Ground ------------ */
  --paper:        #f5efe4;  /* page background, warm paper */
  --surface:      #ece4d4;  /* elevated panel / table-head row / hover state */
  --surface-2:    #e3d9c5;  /* stronger surface — chips, stat cells */

  /* ------------ Ink ------------ */
  --ink:          #201a14;  /* primary text + structural rules, 15.05:1 on paper */
  --ink-2:        #4a4238;  /* secondary text, 8.62:1 on paper */
  --ink-3:        #655d50;  /* tertiary/dim — darkened from #6b6255 (5.24:1 on paper but only 4.28:1 on --surface-2 stat cells, below AA); now 5.67:1 on paper, 4.64:1 on --surface-2 */
  --line:         var(--ink);          /* bold structural rule */
  --line-soft:    #d8cfc0;              /* soft internal divider (decorative only, not sole info carrier) */

  /* ------------ Accent (ONE signal color) ------------ */
  --accent:       #9e2b25;  /* brick red, 6.49:1 on paper */
  --accent-hover: #7e211c;

  /* ------------ Type stacks ------------ */
  --font-display: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-body:    var(--font-display);
  --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* ------------ Type scale — dense, print-grade ------------ */
  --fs-display:   clamp(2rem, 3.6vw, 2.75rem); /* ceiling eased 3.25->2.75rem so "Product marketing manager" fits one line at 901-1920px (Chris #1) */
  --fs-h2:        clamp(1.25rem, 2vw, 1.5rem);
  --fs-h3:        1rem;
  --fs-body:      0.9375rem;
  --fs-small:     0.8125rem;
  --fs-micro:     0.6875rem;

  --lh-display:   1.08;
  --lh-heading:   1.2;
  --lh-body:      1.55;
  --lh-tight:     1.35;

  --tracking-display: -0.01em;
  --tracking-mono:    0.04em;
  --tracking-kicker:  0.08em;

  --prose-max: 640px;

  /* ------------ Legacy variable mapping (compat layer — resume.html /
     resume-pt.html reference these names directly; repoint values only,
     do not rename call sites) ------------ */
  --bg:           var(--paper);
  --bg-1:         var(--surface);
  --bg-2:         var(--surface-2);
  --fg:           var(--ink);
  --fg-2:         var(--ink-2);
  --fg-3:         var(--ink-3);
  --fg-4:         var(--ink-3);
  --border:       var(--line);
  --accent-dim:   #c08a86; /* muted accent for inactive tag borders, still legible */
  --gutter:       clamp(20px, 4vw, 48px);
  --max:          1320px;
  --max-doc:      1120px;
  --col-gap:      24px;

  --text-primary:   var(--ink);
  --text-secondary: var(--ink-2);
  --text-dim:       var(--ink-3);
  --text-body:      var(--ink-2);
  --text-mute:      var(--ink-3);
  --bg-primary:     var(--paper);
  --bg-surface:     var(--surface);
  --bg-secondary:   var(--surface);
  --bg-elevated:    var(--surface-2);
  --border-card:    var(--line-soft);
  --border-subtle:  var(--line-soft);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}
*,*::before,*::after { box-sizing: border-box; }
html,body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: var(--lh-body);
  letter-spacing: 0;
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { text-wrap: balance; font-family: var(--font-display); }
::selection { background: var(--accent); color: var(--paper); }
.mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }

/* Prose / article legibility. Article-body exception (Chris #4): long-form
   reading scale beats the dense-grid defaults here on purpose, so this is the
   ONE place these values live now (every posts/*.html override + the
   build-blog.mjs template deleted, this rule is the only source of truth). */
.prose-body,
.post-main,
article .body,
.writing-body {
  max-width: 720px;
  font-size: 1.0625rem;
  font-weight: 400;
  line-height: 1.75;
  letter-spacing: 0;
  color: var(--ink-2);
}
.prose-body p + p,
.post-main p + p,
article .body p + p,
.writing-body p + p {
  margin-top: 1.4em;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); position: relative; z-index: 1; }
.wrap-doc { max-width: var(--max-doc); margin: 0 auto; padding: 0 var(--gutter); position: relative; z-index: 1; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topbar .inner {
  max-width: var(--max); margin: 0 auto; padding: 14px var(--gutter);
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 32px;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 12px; }
.brand .sq { width: 12px; height: 12px; background: var(--accent); }
.brand b { color: var(--ink); font-weight: 600; letter-spacing: 0; }
.brand span.path { color: var(--ink-3); }
.topbar nav { display: flex; gap: 26px; justify-self: center; font-family: var(--font-body); font-size: 13px; letter-spacing: 0; color: var(--ink-2); }
.topbar nav a { padding: 6px 0; position: relative; transition: color 150ms ease; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.active { color: var(--accent); }
.topbar nav a.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent); }
.topbar .status { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--ink-2); text-transform: uppercase; letter-spacing: var(--tracking-mono); }
.topbar .status .flag { width: 7px; height: 7px; background: var(--accent); flex: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 18px; font-family: var(--font-body); font-size: 13px;
  letter-spacing: 0; font-weight: 500;
  border: 1px solid var(--ink); color: var(--ink);
  background: var(--paper); transition: background 120ms ease, color 120ms ease;
}
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn.ghost:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* Section frame */
.section { border-bottom: 1px solid var(--line); position: relative; z-index: 1; }
.section > .wrap, .section > .wrap-doc { padding-top: clamp(40px, 7vh, 88px); padding-bottom: clamp(40px, 7vh, 88px); }
.sec-head {
  display: grid; grid-template-columns: auto 1fr;
  gap: 24px; align-items: end;
  padding-bottom: 16px; margin-bottom: 36px;
  border-bottom: 2px solid var(--ink);
}
.sec-head .kicker { font-family: var(--font-body); font-size: var(--fs-micro); letter-spacing: var(--tracking-kicker); text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.sec-head h2 { font-family: var(--font-display); font-size: var(--fs-h2); letter-spacing: var(--tracking-display); line-height: var(--lh-heading); margin: 0; font-weight: 600; color: var(--ink); }
.sec-head h2 .dim { color: var(--ink-3); font-weight: 400; }
@media (max-width: 720px) {
  .sec-head { grid-template-columns: 1fr; }
  /* Work's kept kicker (the only one left after the eyebrow-cap pass) would stack
     above h2 and add a row the kicker-less sections don't have. Hide it at mobile
     so every section's sec-head is the same rhythm; h2 alone still names the
     section (Chris #3). */
  .sec-head .kicker { display: none; }
}

.skip-link { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.skip-link:focus { position: fixed; top: 8px; left: 8px; padding: 12px 18px; background: var(--accent); color: var(--paper); z-index: 100; }

/* Keyboard focus polish */
a:focus-visible, button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Card chrome — flat, hard-edged, no blur ───────────────────────── */

.fx-stat-card {
  background: var(--surface-2);
  border: 1px solid var(--ink);
}

/* Zone 4 — Article cards: flat, hard-edged */
.fx-article-grid {
  display: grid;
  gap: 1px;
  background: var(--ink);
  border: 1px solid var(--ink);
}
.fx-article-grid--featured { grid-template-columns: repeat(3, 1fr); }
.fx-article-grid--all { grid-template-columns: repeat(3, 1fr); }

.fx-article-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 340px;
  border: none;
  background-color: var(--paper);
  transition: background-color 160ms ease;
  text-decoration: none;
  color: inherit;
}
.fx-article-card:hover {
  background-color: var(--surface);
}
.fx-article-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.fx-article-card .cover {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-2);
  border-bottom: 1px solid var(--ink);
  flex-shrink: 0;
}
.fx-article-card .cover[data-fallback="true"] {
  overflow: hidden;
  background: var(--surface-2);
}
.fx-article-card .cover[data-fallback="true"]::before {
  content: "Selected / writing";
  position: absolute;
  top: 16px;
  left: 18px;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  color: var(--accent);
}
.fx-article-card .cover[data-fallback="true"]::after {
  content: attr(data-fallback-label);
  position: absolute;
  right: 18px;
  bottom: 14px;
  left: 18px;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 3.4rem);
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: -0.045em;
  color: var(--ink);
}

.fx-article-card .text-panel {
  position: relative;
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.fx-article-card .eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  color: var(--ink-3);
}
.fx-article-card .title {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: var(--lh-heading);
  letter-spacing: -0.005em;
  color: var(--ink);
}
.fx-article-card .desc {
  font-family: var(--font-body);
  font-size: var(--fs-small);
  line-height: var(--lh-body);
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fx-article-card .meta {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-mono);
  color: var(--ink-3);
  margin-top: auto;
}
.fx-article-card .arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-mono);
  color: var(--ink-2);
  text-transform: uppercase;
  transition: color 200ms ease;
}
.fx-article-card:hover .arrow {
  color: var(--accent);
}

/* View-more link below carousel */
.fx-article-more {
  display: flex;
  justify-content: center;
  margin-top: 32px;
}
.fx-view-more {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border: 1px solid var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  letter-spacing: 0;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}
.fx-view-more:hover {
  background-color: var(--ink);
  color: var(--paper);
}
.fx-view-more .arrow {
  transition: transform 200ms ease;
}
.fx-view-more:hover .arrow {
  transform: translateX(4px);
}

/* Responsive */
@media (max-width: 1024px) {
  .fx-article-grid--featured { grid-template-columns: repeat(2, 1fr); }
  .fx-article-grid--all { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .fx-article-grid--featured { grid-template-columns: 1fr; }
  .fx-article-grid--all { grid-template-columns: 1fr; }
  .fx-article-card { min-height: 300px; }
  .fx-article-card .cover { aspect-ratio: 16 / 9; }
}

/* Zone 5 — Footer */
.fx-footer {
  background: var(--paper);
  padding: 48px 32px 40px;
  border-top: 2px solid var(--ink);
  margin-top: 88px;
}
.fx-footer .masthead {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 20px;
  font: 600 12px/1 var(--font-body);
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-2);
}
.fx-footer .masthead .brand { color: var(--ink); }
.fx-footer .masthead .sep { color: var(--ink-3); }
.fx-footer .masthead a {
  color: var(--ink-2); text-decoration: none;
  transition: color 160ms ease;
}
.fx-footer .masthead a:hover { color: var(--accent); }
.fx-footer .meta {
  margin-top: 18px;
  font: 400 12px/1.5 var(--font-body);
  letter-spacing: 0; color: var(--ink-3);
}

/* ─── Portrait — plain, real photography, no CRT/glitch chrome ────── */
.portrait-frame { position: relative; overflow: hidden; background: var(--surface-2); border: 1px solid var(--ink); }
.portrait-frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  filter: grayscale(0.15) contrast(1.04);
}
.portrait-frame .tag {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: var(--tracking-mono);
  text-transform: uppercase; color: var(--paper);
  background: var(--ink); padding: 3px 7px;
}

/* ─── /blog.html + /posts/*.html page styles ───────────────────────── */
.page-writing { background-color: var(--paper); }

.writing-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 48px;
  background-color: var(--paper);
}
.writing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 40px;
  font-family: var(--font-body);
  font-size: var(--fs-small);
  letter-spacing: 0;
  text-transform: none;
}
.writing-nav a {
  color: var(--ink-2);
  text-decoration: none;
  transition: color 200ms ease;
}
.writing-nav a:hover { color: var(--ink); }
.writing-back .arrow {
  display: inline-block;
  margin-right: 4px;
  transition: transform 200ms ease;
}
.writing-back:hover .arrow { transform: translateX(-4px); }

.writing-hero {
  max-width: var(--prose-max);
  margin-bottom: 32px;
}
.writing-hero .kicker {
  font-family: var(--font-body);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-kicker);
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 600;
  margin-bottom: 14px;
}
.writing-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.4vw, 2.5rem);
  font-weight: 700;
  line-height: var(--lh-display);
  letter-spacing: var(--tracking-display);
  color: var(--ink);
  margin: 0 0 14px 0;
}
.writing-hero .lede {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: var(--lh-body);
  color: var(--ink-2);
  margin: 0;
}

.writing-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-pill {
  padding: 3px 7px;
  border: 1px solid var(--ink);
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-mono);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 200ms ease, color 200ms ease, background 200ms ease;
}
.filter-pill:hover {
  color: var(--ink);
  background: var(--surface);
}
.filter-pill.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.filter-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.writing-main {
  padding: 48px 0 88px;
}

@media (max-width: 720px) {
  .writing-nav { flex-wrap: wrap; gap: 16px; padding-bottom: 28px; }
  .writing-hero { margin-bottom: 28px; }
  .writing-main { padding: 32px 0 48px; }
}

/* ─── Responsive fixes (carried from prior baseline) ────────────────── */

@media (max-width: 720px) {
  .topbar .inner { grid-template-columns: auto 1fr auto; gap: 12px; }
  .topbar nav { gap: 14px; font-size: 12px; }
}
@media (max-width: 400px) {
  .topbar .status { display: none; }
  .topbar .inner { grid-template-columns: auto 1fr; }
}

@media (max-width: 900px) {
  .worktable .row.head span:nth-child(n+3) { display: none; }
}

@media (max-width: 540px) {
  .hero h1 { font-size: clamp(30px, 9vw, 44px); }
}

@media (max-width: 540px) {
  .contact-list a { grid-template-columns: 16px 1fr auto; gap: 10px; }
  .contact-list .k { display: none; }
}

/* ─── Interactive polish ────────────────────────────────────────────── */

/* Solid accent underline on hover (record-row title links) — motivated:
   confirms interactivity on a row that has no other hover affordance. */
.worktable .row .title a { position:relative; }
.worktable .row .title a::after { content:""; position:absolute; left:0; right:100%; bottom:-3px; height:2px; background:var(--accent); transition:right .3s var(--ease-out); }
@media (hover:hover) and (pointer:fine) { .worktable .row:hover .title a::after { right:0; } }

/* Scroll-driven reveal — progressive enhancement, base state fully visible.
   Worktable rows are excluded (AR-flagged S192 defect): the table IS the
   content, not decoration, so it must never depend on scroll-timeline
   entry firing. Without a scroll event (at-rest render, screenshot/capture
   contexts, a row already in view on load), `animation: ... both` pins the
   `from` keyframe (opacity:0) permanently. Rows render statically instead. */
@supports (animation-timeline: view()) {
  .section .sec-head {
    animation: reveal-in linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 50%;
  }
  @keyframes reveal-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .section .sec-head { animation: none; opacity: 1; transform: none; }
  .worktable .row .title a::after { transition: none; }
}

/* Cross-document view transitions — portrait continuity only */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 200ms; }
/* view-transition-name: only ONE element per page may carry this name.
   index.html hero portrait: .hero .portrait.portrait-frame
   resume.html head portrait: .head-portrait img (scoped per-page in each file) */

/* Hero proof-of-work strip (impeccable live round 1, variant 3 accepted by Gabe) */
.hero .client-strip {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  color: var(--ink-3);
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  margin-top: 24px;
}
