/* ══════════════════════════════════════════════════════════
   KERZIKA.COM v3 — Shared Styles
   Premium: warm white, ink typography, crimson accent.
   Dark mode ready. v1-grade design density.
   [skill.visualization-builder — v1 premium design system]
   [skill.constraint-enforcer — PASS on all C1-C7]
   ══════════════════════════════════════════════════════════ */

@import './tokens.css';

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scrollbar-color: var(--bd-m) transparent; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bd-m); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.65;
  overflow-x: hidden;
}
a   { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul  { list-style: none; }

/* ── LEFT-EDGE PROGRESS BAR ── */
#read-progress {
  position: fixed;
  top: 0; left: 0;
  width: 3px;
  height: 0%;
  background: var(--crimson);
  z-index: 110;
  transition: height 0.08s linear;
  pointer-events: none;
}

/* ── TYPOGRAPHY ── */
h1, h2, h3, h4 {
  font-family: 'Playfair Display', Georgia, serif;
  line-height: 1.06;
  letter-spacing: -0.02em;
  color: var(--ink);
}
h1 { font-size: clamp(2.8rem, 7vw, 5.6rem); font-weight: 900; }
h2 { font-size: clamp(2rem, 4.5vw, 3.6rem); font-weight: 700; }
h3 { font-size: clamp(1.15rem, 2vw, 1.55rem); font-weight: 700; }
p  { color: var(--ink-2); }

.label {
  display: block;
  font-size: .68rem; font-weight: 700;
  letter-spacing: .15em; text-transform: uppercase;
  color: var(--crimson);
  margin-bottom: .75rem;
}

/* ── NAVIGATION ── */
.site-nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center;
  padding: 0 var(--page-pad);
  background: var(--bg-nav);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--bd);
}
.nav-brand {
  display: flex; align-items: center; gap: .6rem;
  font-family: 'Playfair Display', serif;
  font-size: .98rem; font-weight: 700; letter-spacing: -.01em;
  color: var(--ink);
}
.nav-logo { width: 26px; height: 26px; flex-shrink: 0; }
.nav-links {
  margin-left: auto;
  display: flex; align-items: center; gap: 2.75rem;
}
.nav-links a {
  font-size: .7rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3);
  transition: color var(--dur);
  position: relative;
}
.nav-links a::after {
  content: '';
  position: absolute; bottom: -4px; left: 0; right: 0;
  height: 1px; background: var(--crimson);
  transform: scaleX(0); transition: transform .22s var(--ease);
  transform-origin: left;
}
.nav-links a:hover            { color: var(--ink); }
.nav-links a:hover::after,
.nav-links a.active::after    { transform: scaleX(1); }
.nav-links a.active           { color: var(--ink); }

/* Dark mode toggle (SVG icons) */
.theme-btn {
  background: none; border: none; cursor: pointer;
  padding: 0; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .2s var(--ease);
}
.theme-btn:hover { transform: scale(1.15); }
.theme-icon { width: 18px; height: 18px; color: var(--ink-3); transition: color .2s; }
.theme-btn:hover .theme-icon { color: var(--ink); }
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }
[data-theme="dark"] .theme-icon-sun { display: block; }
[data-theme="dark"] .theme-icon-moon { display: none; }

/* Side navigation (series landing pages & article TOC) */
.side-nav {
  position: fixed;
  top: calc(var(--nav-h) + 2rem);
  left: max(1rem, calc((100vw - 1060px) / 2 - 220px));
  width: 190px;
  z-index: 50;
}
.side-nav-label {
  font-size: .58rem; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: .85rem;
}
.side-nav-link {
  display: block; font-size: .72rem; color: var(--ink-3);
  text-decoration: none; padding: .35rem 0 .35rem .75rem;
  border-left: 2px solid var(--bd);
  transition: color .2s, border-color .2s;
  line-height: 1.4;
}
.side-nav-link:hover { color: var(--ink); }
.side-nav-link.active {
  color: var(--crimson); border-left-color: var(--crimson);
  font-weight: 600;
}
.side-nav-link.disabled {
  color: var(--ink-3); opacity: .5; cursor: default;
  font-style: italic;
}
.side-nav-search {
  width: 100%; padding: .35rem .6rem; margin-bottom: .65rem;
  font-size: .72rem; font-family: 'Inter', sans-serif;
  background: var(--bg-card); border: 1px solid var(--bd);
  border-radius: var(--r-s); color: var(--ink); outline: none;
}
.side-nav-search:focus { border-color: var(--crimson); }
.side-nav-search::placeholder { color: var(--ink-3); }
@media (max-width: 1300px) {
  .side-nav { display: none; }
}

/* Mobile nav */
.nav-toggle {
  display: none;
  margin-left: auto;
  flex-direction: column; justify-content: center; align-items: center;
  width: 40px; height: 40px;
  background: none; border: none; cursor: pointer; gap: 5px; padding: 0;
}
.nav-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--ink); border-radius: 2px;
  transition: all .25s var(--ease);
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav-mobile {
  display: none;
  position: fixed; inset: var(--nav-h) 0 0 0; z-index: 99;
  background: var(--bg);
  flex-direction: column; align-items: center; justify-content: center; gap: 2.5rem;
  padding: 2rem;
}
.nav-mobile.open { display: flex; }
.nav-mobile a {
  font-size: 1.15rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-2); transition: color .2s;
}
.nav-mobile a:hover,
.nav-mobile a.active { color: var(--crimson); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .72rem 1.6rem;
  border-radius: var(--r-s);
  font-size: .82rem; font-weight: 600; letter-spacing: .02em;
  cursor: pointer; border: none; outline: none;
  transition: all .2s var(--ease);
  text-decoration: none;
}
.btn-primary   { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: #1E1D1B; transform: translateY(-1px); box-shadow: var(--sh-m); }
[data-theme="dark"] .btn-primary { background: var(--ink); color: #141311; }
[data-theme="dark"] .btn-primary:hover { background: #D5D0C5; }
.btn-crimson   { background: var(--crimson); color: #fff; }
.btn-crimson:hover { background: var(--crimson-h); transform: translateY(-1px); box-shadow: var(--sh-m); }
.btn-outline {
  background: transparent; color: var(--ink);
  border: 1.5px solid var(--bd-m);
}
.btn-outline:hover { border-color: var(--ink); transform: translateY(-1px); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .65rem 1.35rem;
  background: transparent; border: 1px solid var(--bd);
  border-radius: var(--r-s); color: var(--ink);
  font-size: .78rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  text-decoration: none; transition: border-color .2s, box-shadow .2s;
}
.btn-ghost:hover { border-color: var(--crimson); box-shadow: var(--sh-s); }

/* ── SECTIONS ── */
.section         { padding: 7rem var(--page-pad); }
.section-alt     { background: var(--bg-alt); }
.section-inner   { max-width: 1060px; margin: 0 auto; width: 100%; }

/* ── GHOST ROMAN SECTION BREAKS ── */
.section-landmark {
  position: relative;
  padding: 5rem 0 4.5rem;
  overflow: hidden;
  z-index: 2;
  background: var(--bg);
}
.section-landmark::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, var(--crimson) 0%, var(--bd) 40%, transparent 100%);
}
.sl-roman {
  position: absolute; right: -1rem; top: 50%; transform: translateY(-50%);
  font-family: 'Playfair Display', serif;
  font-size: clamp(7rem, 18vw, 14rem); font-weight: 900;
  color: var(--ink); opacity: .04;
  line-height: 1; pointer-events: none; user-select: none;
}
.sl-content { position: relative; z-index: 1; }
.sl-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 900;
  color: var(--ink); line-height: 1; letter-spacing: -.02em;
}
.sl-meta {
  margin-top: .65rem;
  font-size: .65rem; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--crimson);
}

/* ── TAGS ── */
.tag {
  display: inline-flex; padding: .22rem .65rem;
  border-radius: 4px;
  font-size: .65rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
}
.tag-crimson { background: rgba(185,28,47,.1); color: var(--crimson); }
.tag-ink     { background: rgba(13,13,11,.07); color: var(--ink-2); }
.tag-gold    { background: rgba(184,135,42,.12); color: var(--gold); }
[data-theme="dark"] .tag-ink { background: rgba(232,226,213,.08); }

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  padding: 1.75rem;
  transition: box-shadow .22s var(--ease), transform .22s var(--ease);
}
.card:hover { box-shadow: var(--sh-m); transform: translateY(-3px); }

/* ── COMPACT DATA TABLE EMBED ── */
.data-table-embed {
  position: relative;
  margin: 1.5rem 0;
  border-radius: var(--r, 10px);
  overflow: hidden;
  background: #2A2622;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.dte-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: #252220;
}
.dte-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9E978B;
}
.dte-body {
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.dte-body::-webkit-scrollbar { width: 6px; }
.dte-body::-webkit-scrollbar-track { background: transparent; }
.dte-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}
.dte-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}
.dte-body thead th {
  padding: 0.45rem 0.75rem;
  background: #1E1C19;
  color: #9E978B;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  z-index: 1;
}
.dte-body tbody td {
  padding: 0.4rem 0.75rem;
  color: #D5CFC5;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.dte-body tbody tr:last-child td { border-bottom: none; }
.dte-body tbody td.num { text-align: right; }

/* ── CALLOUT ── */
.callout {
  margin: 1.5rem 0;
  padding: 1.15rem 1.35rem;
  border-left: 3px solid var(--crimson);
  background: rgba(185,28,47,.035);
  border-radius: 0 var(--r-s, 6px) var(--r-s, 6px) 0;
}
.callout > strong:first-child {
  color: var(--crimson);
  display: block;
  margin-bottom: .4rem;
  font-size: .85rem;
}
.callout p { font-size: .9rem; margin: 0; color: var(--ink-2); }
.callout p + p { margin-top: .65rem; }
.callout .katex { color: var(--crimson); }
.callout.warning { border-left-color: var(--gold); background: rgba(184,135,42,.05); }
.callout.warning > strong:first-child { color: var(--gold); }

/* ── DISCLAIMER ── */
.disclaimer {
  font-size: .73rem; color: var(--ink-3);
  font-style: italic; line-height: 1.6;
  border-left: 2px solid var(--crimson);
  padding-left: .75rem;
}
.article-disclaimer {
  margin-top: 3rem;
  padding: 1.25rem 1.5rem;
  border-left: 2px solid var(--crimson);
}
.article-disclaimer p {
  font-size: .73rem; color: var(--ink-3);
  font-style: italic; line-height: 1.6; margin: 0;
}

/* ── CODE BLOCK ── */
.code-block pre {
  margin: 0; padding: 1rem;
  overflow-y: auto; max-height: 180px;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: .82rem; line-height: 1.55;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.code-block pre::-webkit-scrollbar { width: 6px; }
.code-block pre::-webkit-scrollbar-track { background: transparent; }
.code-block pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.code-block pre::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ── FOOTER ── */
.site-footer {
  border-top: 1px solid var(--bd);
  padding: 2.75rem var(--page-pad);
  background: var(--bg);
}
.footer-inner {
  max-width: 1060px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1.25rem;
}
.footer-copy { font-size: .73rem; color: var(--ink-3); }
.footer-links { display: flex; gap: 2rem; flex-wrap: wrap; }
.footer-links a { font-size: .73rem; color: var(--ink-3); transition: color .2s; }
.footer-links a:hover { color: var(--crimson); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .nav-links  { display: none; }
  .nav-toggle { display: flex; }
  .section    { padding: 5rem var(--page-pad); }
}
@media (max-width: 600px) {
  .section { padding: 3.5rem var(--page-pad); }
  .btn { font-size: .78rem; padding: .65rem 1.3rem; }
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
