/*
  ksc-core.css
  KSC Shared Design System
  Owner: Kai Svensson
  Changes require Red Team signoff before deployment.
  Deploy to: /ksc/assets/ksc-core.css
  ─────────────────────────────────────────────────
*/

/* ── COLOR TOKENS ── */
:root {
  --void: #0a0a0f;
  --carbon: #111118;
  --edge: #1e1e2e;
  --edge-light: #2a2a3e;
  --text-primary: #e8e6f0;
  --text-secondary: #8b89a0;
  --void-text: #4a4860;
  --gold: #c9a84c;
  --gold-dim: rgba(201, 168, 76, 0.15);
  --gold-glow: rgba(201, 168, 76, 0.08);
  --tiferet: #d4956a;
  --green: #2e7d5e;
  --green-dim: rgba(46, 125, 94, 0.15);
  --amber: #b8860b;
  --amber-dim: rgba(184, 134, 11, 0.15);
  --red: #8b2635;
  --red-dim: rgba(139, 38, 53, 0.2);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── BASE ── */
body {
  background: var(--void);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── TYPOGRAPHY ── */
/* Serif for headings only — minimum 1.8rem, weight 700 */
h1, h2, h3,
.tier-name,
.section-heading {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.4rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.4rem; }

.mono { font-family: 'Courier New', Courier, monospace; }

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── NAVIGATION ── */
.ksc-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--carbon);
  border-bottom: 1px solid var(--edge);
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: auto;
  white-space: nowrap;
}

.nav-logo img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  opacity: 0.9;
}

.nav-items {
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.nav-items::-webkit-scrollbar { display: none; }

.nav-item {
  display: block;
  padding: 0 1rem;
  height: 52px;
  line-height: 52px;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
  border-bottom: 2px solid transparent;
}

.nav-item:hover { color: var(--text-primary); }

.nav-item.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.nav-item.audit-btn {
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 2px solid transparent;
}

.nav-item.audit-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ── LAYOUT ── */
.ksc-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ── SECTION LABEL ── */
.section-label {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--void-text);
  margin-bottom: 1.25rem;
}

/* ── CARDS / PANELS ── */
.data-panel {
  background: var(--carbon);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
}

.data-panel-label {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--void-text);
  margin-bottom: 0.35rem;
}

.data-panel-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.data-source {
  font-size: 0.68rem;
  color: var(--void-text);
  font-style: italic;
}

.data-source.stale { color: var(--amber); }

/* ── AXIS BARS ── */
.axis-row {
  background: var(--carbon);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 1rem 1.25rem;
}

.axis-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.axis-name { font-size: 0.75rem; font-weight: 400; color: var(--text-secondary); }
.axis-code { font-family: 'Courier New', Courier, monospace; color: var(--gold); font-size: 0.7rem; margin-right: 0.4rem; }
.axis-value { font-family: 'Courier New', Courier, monospace; font-size: 0.85rem; color: var(--text-primary); }

.axis-track {
  height: 6px;
  background: var(--edge);
  border-radius: 3px;
  overflow: hidden;
}

.axis-fill {
  height: 100%;
  border-radius: 3px;
  width: 0;
  background: var(--gold);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.axis-fill.warning  { background: var(--amber); }
.axis-fill.critical { background: var(--red); }
.axis-fill.mirror   { background: var(--red); }

.axis-sub { margin-top: 0.5rem; }

.axis-sub-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.axis-sub-label { font-size: 0.62rem; color: var(--void-text); min-width: 90px; }

.axis-sub-track {
  flex: 1;
  height: 4px;
  background: var(--edge);
  border-radius: 2px;
  overflow: hidden;
}

.axis-sub-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  width: 0;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
}

.axis-sub-val {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.65rem;
  color: var(--text-secondary);
  min-width: 32px;
  text-align: right;
}

.axis-d-note {
  font-size: 0.62rem;
  color: var(--void-text);
  font-style: italic;
  margin-top: 0.35rem;
}

/* ── GATE CHECKLIST ── */
.gate-list { display: flex; flex-direction: column; gap: 0.75rem; }

.gate-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.gate-checkbox {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--edge);
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gate-item.achieved { color: var(--gold); }
.gate-item.achieved .gate-checkbox {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--void);
  font-size: 0.7rem;
  font-weight: 700;
}

.gate-text { flex: 1; line-height: 1.5; }
.gate-text strong { font-weight: 400; color: var(--text-primary); }
.gate-item.achieved .gate-text strong { color: var(--gold); }

/* ── VISITOR'S MIRROR ── */
.visitors-mirror {
  width: 100%;
  background: #0e0e1a;
  border: 1px solid var(--gold);
  border-left: 4px solid var(--gold);
  border-radius: 0 4px 4px 0;
  padding: 2.5rem 2rem;
  margin: 3rem 0 0;
  text-align: center;
}

.visitors-mirror p {
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.85;
  max-width: 660px;
  margin: 0 auto;
}

.visitors-mirror p + p { margin-top: 1rem; }

/* ── AUDIT LOG ── */
.audit-panel { display: none; margin-top: 2rem; }
.audit-panel.visible { display: block; }

.audit-header {
  background: var(--carbon);
  border: 1px solid var(--edge);
  border-radius: 4px 4px 0 0;
  padding: 1.5rem;
  border-bottom: 1px solid var(--edge);
  position: relative;
}

.audit-header h2 { font-size: 1.4rem; color: var(--gold); margin-bottom: 0.5rem; }
.audit-header p { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.6; }
.audit-header p em { color: var(--void-text); }

.audit-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: none;
  border: 1px solid var(--edge);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 0.3rem 0.75rem;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: color 0.15s, border-color 0.15s;
}

.audit-close:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.audit-section {
  background: var(--carbon);
  border: 1px solid var(--edge);
  border-top: none;
  padding: 1.5rem;
}

.audit-section:last-child { border-radius: 0 0 4px 4px; }
.audit-section h3 { color: var(--text-primary); font-size: 1rem; margin-bottom: 1rem; }

.audit-finding {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 0.5rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--edge);
  font-size: 0.78rem;
}

.audit-finding:last-child { border-bottom: none; }

.finding-priority {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  border-radius: 2px;
  text-align: center;
  align-self: start;
  margin-top: 1px;
}

.finding-priority.p1       { background: var(--red-dim);   color: var(--red);   border: 1px solid var(--red); }
.finding-priority.p2       { background: var(--amber-dim); color: var(--amber); border: 1px solid var(--amber); }
.finding-priority.p3       { background: var(--gold-dim);  color: var(--gold);  border: 1px solid var(--gold); }
.finding-priority.resolved { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }

.finding-text { color: var(--text-secondary); line-height: 1.5; }
.finding-text strong { color: var(--text-primary); font-weight: 400; }

.audit-role-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.audit-role-table th { text-align: left; font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--void-text); padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--edge); }
.audit-role-table td { padding: 0.6rem 0.75rem; color: var(--text-secondary); border-bottom: 1px solid var(--edge); vertical-align: top; }
.audit-role-table tr:last-child td { border-bottom: none; }
.audit-role-table td:first-child { color: var(--text-primary); }

/* ── TIER CARDS ── */
.tier-card {
  background: var(--carbon);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 1.5rem;
  text-decoration: none;
  display: block;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.tier-card.active-tier {
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--carbon) 0%, rgba(201,168,76,0.04) 100%);
}

.tier-card.active-tier:hover {
  background: linear-gradient(135deg, var(--edge-light) 0%, rgba(201,168,76,0.08) 100%);
}

.tier-card:not(.active-tier):not(.pending):hover {
  border-color: var(--edge-light);
  background: var(--edge-light);
}

.tier-card.pending { cursor: default; opacity: 0.6; }

.tier-badge { font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--void-text); margin-bottom: 0.5rem; }
.active-tier .tier-badge { color: var(--gold); }
.tier-card h3 { font-size: 1rem; color: var(--text-primary); margin-bottom: 0.35rem; font-family: Georgia, serif; font-weight: 700; }
.pending h3 { color: var(--text-secondary); }
.tier-definition { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 0.75rem; }
.tier-meta { font-size: 0.65rem; color: var(--void-text); font-family: 'Courier New', Courier, monospace; }
.tier-here { display: inline-block; font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); border: 1px solid var(--gold); padding: 0.1rem 0.4rem; border-radius: 2px; margin-bottom: 0.5rem; }
.tier-wip { display: block; font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--void-text); margin-top: 0.75rem; }

/* ── READING TIME ── */
.reading-time {
  font-size: 0.75rem;
  color: var(--void-text);
  font-style: italic;
  margin-bottom: 1rem;
}

/* ── FAILURE ATLAS PANELS ── */
.failure-panel {
  background: var(--carbon);
  border: 1px solid var(--edge);
  border-left: 3px solid var(--red);
  border-radius: 0 4px 4px 0;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.failure-panel h4 {
  font-family: Georgia, serif;
  font-size: 0.95rem;
  color: var(--red);
  margin-bottom: 0.5rem;
}

.failure-panel p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── IDENTITY TABLE ── */
.identity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-bottom: 2rem;
}

.identity-table th {
  text-align: left;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--void-text);
  padding: 0.5rem 1rem 0.5rem 0;
  border-bottom: 1px solid var(--edge);
  font-weight: 400;
  white-space: nowrap;
  width: 160px;
}

.identity-table td {
  padding: 0.5rem 0;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--edge);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
}

.identity-table tr:last-child th,
.identity-table tr:last-child td { border-bottom: none; }

/* ── TIER SOUL SECTION ── */
.soul-section {
  background: var(--carbon);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 2rem;
  margin-bottom: 3rem;
}

.soul-section p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.8;
  max-width: 740px;
}

.soul-section p + p { margin-top: 1rem; }

/* ── FOOTER ── */
.ksc-footer {
  border-top: 1px solid var(--edge);
  padding: 1.5rem;
  margin-top: 2rem;
}

.triple-timestamp {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.ts-item { display: flex; gap: 0.35rem; align-items: center; }
.ts-label { color: var(--void-text); }
.ts-value { font-family: 'Courier New', Courier, monospace; }
.ts-value.fail { color: var(--void-text); font-style: italic; }

.footer-credit { text-align: center; font-size: 0.68rem; color: var(--void-text); }
.footer-credit a { color: var(--void-text); text-decoration: none; }
.footer-credit a:hover { color: var(--text-secondary); }

/* ── RESPONSIVE ── */
@media (max-width: 639px) {
  .triple-timestamp { flex-direction: column; align-items: center; gap: 0.35rem; }
}

/* ── MOTION ── */
@media (prefers-reduced-motion: reduce) {
  .axis-fill,
  .k-fill,
  .agi-bar-fill,
  .axis-sub-fill { transition: none; }
}

