/* ==========================================================================
   writing.css - shared styles for the Writing hub and article pages.
   Mirrors the homepage design tokens so new pages read as the same site.
   The homepage keeps its own inline <style>; some token duplication is
   intentional and accepted (see design spec).
   ========================================================================== */

:root {
  color-scheme: light dark;
  --bg: #f1f0ec;
  --panel: #e7e5df;
  --panel-2: #dfdcd5;
  --panel-3: #d7d3ca;
  --line: #c9c6be;
  --text: #181a1f;
  --muted: #555b63;
  --soft: #727780;
  --faint: #777b82;
  --accent: #a95f17;
  --accent-ink: #fff8ef;
  --accent-2: #7a542d;
  --accent-soft: rgba(169, 95, 23, 0.11);
  --good-soft: rgba(122, 84, 45, 0.10);
  --shadow: 0 24px 70px rgba(41, 36, 27, 0.14);
  --nav: rgba(241, 240, 236, 0.9);
  --sans: "Avenir Next", Avenir, "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --panel: #171a21;
    --panel-2: #1b1e25;
    --panel-3: #20242c;
    --line: #30343c;
    --text: #edece8;
    --muted: #a7abb2;
    --soft: #7d828b;
    --faint: #757a83;
    --accent: #dfa35c;
    --accent-ink: #17120d;
    --accent-2: #c7955b;
    --accent-soft: rgba(223, 163, 92, 0.12);
    --good-soft: rgba(199, 149, 91, 0.10);
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
    --nav: rgba(17, 19, 24, 0.9);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: var(--accent-ink); }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}

.wrap {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
}

.reading {
  width: min(720px, calc(100% - 48px));
  margin: 0 auto;
}

/* ---------- Nav ---------- */

nav {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: var(--nav);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--text);
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--sans);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.nav-links a:hover { color: var(--text); }

.nav-pill { color: var(--text); }

.nav-pill:hover { color: var(--accent); }

/* ---------- Shared type + buttons ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow:before {
  content: "";
  width: 26px;
  height: 1px;
  background: currentColor;
  opacity: 0.75;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 13px 22px;
  border-radius: 12px;
  font-size: 0.98rem;
  font-weight: 700;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.btn:hover { transform: translateY(-2px); color: inherit; }

.btn-primary {
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 12px 28px rgba(242, 182, 109, 0.20);
}

.btn-primary:hover { background: #F7C786; }

.btn-secondary {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.btn-secondary:hover {
  border-color: rgba(242, 182, 109, 0.62);
  background: var(--accent-soft);
}

/* ---------- Hub hero ---------- */

.hub-hero {
  padding: 72px 0 40px;
  border-bottom: 1px solid rgba(38, 48, 68, 0.72);
}

.hub-hero h1 {
  max-width: 16ch;
  margin-bottom: 20px;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
  font-weight: 800;
}

.hub-hero .lede {
  max-width: 62ch;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.2rem);
  line-height: 1.7;
}

/* ---------- Type filter ---------- */

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 40px 0 34px;
}

.filter-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  padding: 9px 16px;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.filter-btn:hover { color: var(--text); border-color: rgba(242, 182, 109, 0.5); }

.filter-btn[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- Card grid ---------- */

.writing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  padding-bottom: 96px;
}

.piece-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 28px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.piece-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--panel-2);
  color: inherit;
}

.piece-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.type-tag { color: var(--accent); }
.piece-card[data-type="essay"] .type-tag { color: var(--accent-2); }
.read-time { color: var(--soft); }
.scale-stage { color: var(--text); }

.piece-card h2 {
  margin-bottom: 12px;
  font-size: clamp(1.3rem, 2.6vw, 1.7rem);
  line-height: 1.18;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.piece-card p {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.6;
}

.piece-card .more {
  margin-top: auto;
  padding-top: 18px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.piece-card[hidden] { display: none; }

/* ---------- Article page ---------- */

.article {
  padding: 64px 0 40px;
}

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  color: var(--soft);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.article-back:hover { color: var(--accent); }

.article-head {
  margin-bottom: 44px;
  padding-bottom: 36px;
  border-bottom: 1px solid rgba(38, 48, 68, 0.72);
}

.article-head .piece-meta { margin-bottom: 22px; }

.article-head h1 {
  max-width: 20ch;
  margin-bottom: 20px;
  font-size: clamp(2.1rem, 5vw, 3.5rem);
  line-height: 1.06;
  letter-spacing: -0.045em;
  font-weight: 800;
}

.article-dek {
  max-width: 60ch;
  color: var(--muted);
  font-size: clamp(1.1rem, 2.2vw, 1.34rem);
  line-height: 1.6;
}

.article-body {
  font-size: 1.14rem;
  line-height: 1.78;
  color: var(--text);
}

.article-body h2 {
  margin: 48px 0 16px;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 800;
  color: var(--text);
}

.article-body h2 .step {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.article-body p { margin-bottom: 22px; }

.article-body p:first-child { margin-top: 0; }

.article-body strong { color: var(--text); font-weight: 700; }

.article-body ul { margin: 0 0 22px 1.1em; }
.article-body li { margin-bottom: 10px; }

.article-body blockquote {
  margin: 34px 0;
  padding: 4px 0 4px 22px;
  border-left: 2px solid rgba(242, 182, 109, 0.6);
  color: var(--text);
  font-size: 1.24rem;
  line-height: 1.5;
  letter-spacing: -0.02em;
  font-weight: 600;
}

/* Placeholder marker for stubs - visible while drafting, easy to find */
.fill {
  display: inline;
  padding: 1px 7px;
  border: 1px dashed rgba(242, 182, 109, 0.7);
  border-radius: 6px;
  background: rgba(242, 182, 109, 0.10);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.86em;
}

/* ---------- Article footer: more writing + CTA ---------- */

.article-foot {
  padding: 56px 0 96px;
  border-top: 1px solid rgba(38, 48, 68, 0.72);
  margin-top: 56px;
}

.article-foot h2 {
  margin-bottom: 28px;
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: -0.035em;
  font-weight: 800;
}

.more-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 52px;
}

.cta-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: clamp(28px, 5vw, 44px);
  box-shadow: var(--shadow);
}

.cta-card h3 {
  max-width: 22ch;
  margin-bottom: 14px;
  font-size: clamp(1.5rem, 3.5vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.cta-card p {
  max-width: 56ch;
  margin-bottom: 26px;
  color: var(--muted);
}

.cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

/* ---------- Footer ---------- */

footer {
  padding: 32px 0 48px;
  border-top: 1px solid rgba(38, 48, 68, 0.72);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.76rem;
}

/* ---------- Reveal on scroll ---------- */

html.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.62s ease, transform 0.62s ease;
}

html.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .writing-grid,
  .more-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .wrap { width: min(100% - 32px, 1120px); }
  .reading { width: min(100% - 32px, 720px); }
  .nav-links a:not(.nav-pill) { display: none; }
  .hub-hero { padding: 52px 0 28px; }
  .article { padding: 44px 0 32px; }
  .article-body { font-size: 1.08rem; }
}

@media (max-width: 420px) {
  .brand > span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html.js .reveal { opacity: 1; transform: none; transition: none; }
  .btn, .piece-card { transition: none; }
  .btn:hover, .piece-card:hover { transform: none; }
}
