/* ============================================================
   CC-C · Consciousness, Closure & the Cosmos
   main.css — design tokens, layout, typography, components
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Instrument+Serif:ital@0;1&display=swap');

/* ── TOKENS ── */
:root {
  --bg:         #080c12;
  --surface:    #0d1320;
  --surface2:   #121926;
  --border:     #1e2d42;
  --accent:     #4a9eff;
  --accent2:    #7b5ea7;
  --accent3:    #3ecf8e;
  --gold:       #c9a84c;
  --text:       #c8d8e8;
  --text-dim:   #5a7a9a;
  --text-bright:#e8f2ff;
  --remainder:  #ff6b6b;
  --mono:       'Space Mono', monospace;
  --serif:      'DM Serif Display', serif;
  --body-serif: 'Instrument Serif', serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body-serif);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
}

/* ── STARFIELD ── */
/* Stars removed as persistent background — they imply physical
   closure (hydrogen, gravity, fusion) which is several rungs up
   the ladder. Stars appear only within the living ladder animation
   at the cosmic closure rung. */
#stars {
  display: none;
}

/* ── C-FIELD ── */
/* Invariant presence — lowest layer, everywhere, always.
   Styled entirely by c-field.js; this just ensures z-order. */
#c-field {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;          /* behind everything including stars */
  pointer-events: none;
}

.page-wrap { position: relative; z-index: 2; }

/* ── HEADER ── */
header {
  padding: 80px 40px 60px;
  max-width: 900px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.meta-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.meta-tag::before {
  content: '';
  display: inline-block;
  width: 24px; height: 1px;
  background: var(--accent);
}

h1 {
  font-family: var(--serif);
  font-size: clamp(32px, 5vw, 56px);
  color: var(--text-bright);
  line-height: 1.15;
  margin-bottom: 16px;
  font-weight: 400;
}
h1 em { color: var(--gold); font-style: italic; }

.subtitle {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* ── NAV ── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8,12,18,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 40px;
}
nav ul {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}
nav ul::-webkit-scrollbar { display: none; }
nav a {
  display: block;
  padding: 16px 20px;
  color: var(--text-dim);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.2s;
  border-bottom: 2px solid transparent;
}
nav a:hover { color: var(--text-bright); }
nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
nav a.nav-project { color: var(--gold); }
nav a.nav-project.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ── SECTIONS ── */
.section {
  max-width: 900px;
  margin: 0 auto;
  padding: 72px 40px;
  border-bottom: 1px solid var(--border);
}
.section-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent2);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
h2 {
  font-family: var(--serif);
  font-size: clamp(24px, 3vw, 36px);
  color: var(--text-bright);
  font-weight: 400;
  margin-bottom: 24px;
  line-height: 1.2;
}
p { margin-bottom: 16px; color: var(--text); }

/* ── LEXICON ── */
.lexicon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2px;
  margin-top: 32px;
}
.lex-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 28px 24px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.lex-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.3s;
  transform-origin: left;
}
.lex-card:hover::before, .lex-card.active::before { transform: scaleX(1); }
.lex-card:hover, .lex-card.active { background: var(--surface2); border-color: var(--accent); }
.lex-symbol {
  font-family: var(--serif);
  font-size: 42px;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 8px;
}
.lex-name {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.lex-desc {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.55;
  transition: all 0.3s;
}
.lex-card.active .lex-desc { color: var(--text); }
.lex-expanded {
  background: var(--surface2);
  border: 1px solid var(--accent);
  padding: 28px;
  margin-top: 16px;
  font-size: 15px;
  color: var(--text);
  line-height: 1.7;
  display: none;
}
.lex-expanded.show { display: block; animation: fadeIn 0.3s ease; }

/* ── DEMO BOX ── */
.demo-box {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 32px;
  margin-top: 32px;
}
.demo-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.demo-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.ctrl-btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.ctrl-btn:hover { border-color: var(--accent); color: var(--accent); }
.ctrl-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ── MATRIX ── */
.matrix-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
@media(max-width:600px) { .matrix-container { grid-template-columns: 1fr; } }
.matrix-wrap { display: flex; flex-direction: column; gap: 8px; }
.matrix-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
canvas.matrix-canvas {
  width: 100%;
  aspect-ratio: 1;
  image-rendering: pixelated;
}

/* ── REMAINDER TABLE ── */
.r-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}
.r-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
}
.r-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(30,45,66,0.5);
  color: var(--text);
}
.r-table tr:hover td { background: var(--surface2); }
.r-bar-cell { width: 180px; }
.r-bar-wrap { background: rgba(255,255,255,0.05); height: 6px; position: relative; }
.r-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; transition: width 0.6s ease; }
.highlight-row td { color: var(--accent3); }
.highlight-row .r-bar-fill { background: var(--accent3) !important; }

/* ── LANDSCAPE CANVAS ── */
#landscape-canvas { width: 100%; height: 300px; display: block; }
.landscape-controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

/* ── SLIDERS ── */
.slider-group { display: flex; flex-direction: column; gap: 4px; }
.slider-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  height: 4px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
}

/* ── EEG CANVAS ── */
#eeg-canvas { width: 100%; height: 200px; display: block; margin-bottom: 8px; }
.eeg-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.badge-running { color: var(--accent3); border-color: var(--accent3); }
.badge-paused  { color: var(--text-dim); border-color: var(--border); }

/* ── LADDER ── */
.ladder { margin-top: 32px; position: relative; }
.ladder-line {
  position: absolute;
  left: 32px; top: 40px; bottom: 40px;
  width: 1px;
  background: linear-gradient(to bottom, var(--gold), var(--accent2), var(--accent));
  opacity: 0.4;
}
.ladder-rung {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 20px 0;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.3s;
}
.ladder-rung:hover, .ladder-rung.active { opacity: 1; }
.rung-dot {
  width: 64px; height: 64px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--text-dim);
  transition: all 0.3s;
  background: var(--surface);
  position: relative;
  z-index: 1;
}
.ladder-rung:hover .rung-dot,
.ladder-rung.active .rung-dot {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 24px rgba(201,168,76,0.2);
}
.rung-content { flex: 1; padding-top: 8px; }
.rung-title {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--text-bright);
  margin-bottom: 6px;
}
.rung-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}
.ladder-rung.active .rung-text { max-height: 200px; color: var(--text); }

/* ── TRIAD ── */
.triad-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin-top: 32px;
}
@media(max-width:600px) { .triad-container { grid-template-columns: 1fr; } }
.triad-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 32px 24px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
}
.triad-card:hover { background: var(--surface2); border-color: var(--accent2); }
.triad-num {
  font-family: var(--serif);
  font-size: 64px;
  color: rgba(74,158,255,0.06);
  position: absolute;
  top: 10px; right: 16px;
  line-height: 1;
  pointer-events: none;
}
.triad-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent2);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.triad-heading {
  font-family: var(--serif);
  font-size: 24px;
  color: var(--text-bright);
  margin-bottom: 12px;
  font-weight: 400;
}
.triad-body { font-size: 14px; color: var(--text-dim); line-height: 1.65; }

/* ── FORMULA ── */
.formula {
  background: var(--bg);
  border-left: 3px solid var(--gold);
  padding: 18px 24px;
  margin: 20px 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.03em;
  overflow-x: auto;
}
.formula .comment { color: var(--text-dim); font-size: 11px; }

/* ── READINGS ── */
.readings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 2px;
  margin: 20px 0;
}
.reading { background: var(--surface); border: 1px solid var(--border); padding: 16px; }
.reading-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.reading-value {
  font-family: var(--mono);
  font-size: 22px;
  color: var(--accent);
  line-height: 1;
}
.reading-unit {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ── TAGS ── */
.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border: 1px solid;
  margin-right: 6px;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.tag-blue  { color: var(--accent);   border-color: var(--accent); }
.tag-green { color: var(--accent3);  border-color: var(--accent3); }
.tag-gold  { color: var(--gold);     border-color: var(--gold); }

/* ── NOTE ── */
.note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 12px;
  padding: 12px 16px;
  border-left: 2px solid var(--border);
  line-height: 1.6;
}

/* ── TOOLTIP ── */
.tooltip {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--accent);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  z-index: 1000;
  pointer-events: none;
  max-width: 240px;
  line-height: 1.5;
  display: none;
}

/* ── PROJECT MODAL ── */
.project-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(8,12,18,0.97);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.project-modal.open {
  display: block;
  animation: fadeIn 0.3s ease;
}
.project-modal-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 40px 80px;
}
.project-modal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(8,12,18,0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 16px 40px;
  margin: 0 -40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.project-modal-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.modal-close-btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 20px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close-btn:hover {
  border-color: var(--remainder);
  color: var(--remainder);
}
footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 40px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  line-height: 1.8;
}

/* ── ANIMATIONS ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.pulse { animation: pulse 2s infinite; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }
