/*
 * KHAELOR
 * File: website/public/styles.css
 * Description: Single stylesheet for the KHAELOR documentation site — dark default, light variant, terminal-calm aesthetic.
 *
 * Author: Simon-Pierre Boucher
 * Contact: contact@spboucher.ai
 */

/* ───────────────────────── tokens ───────────────────────── */

/* Khaelis — obsidian + magma. The ember flows through the whole site (TUI v2 §1). */
:root {
  --bg: #0b0e14;
  --bg-alt: #10141d;
  --bg-code: #0e121a;
  --bg-inline: #171c28;
  --border: #202636;
  --border-soft: #181d2a;
  --text: #c9d1e3;
  --text-strong: #eceff4;
  --dim: #8b93a5;
  --dimmer: #5b657a;
  --accent: #ff6b35;
  --accent2: #ffb86b;
  --teal: #2dd4bf;
  --accent-soft: rgba(255, 107, 53, 0.12);
  --teal-soft: rgba(45, 212, 191, 0.1);
  --success: #7ee787;
  --warning: #f0b429;
  --error: #ff5c57;
  --ember-gradient: linear-gradient(100deg, #ff6b35 0%, #ffb86b 55%, #ff6b35 100%);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

/* Legendary light — warm paper + ink + ember. Terminal blocks stay obsidian:
   the contrast between a bright modern page and dark living terminals IS the look. */
html[data-theme="light"] {
  --bg: #faf8f3;
  --bg-alt: #ffffff;
  --bg-code: #f3efe7;
  --bg-inline: #eee8dd;
  --border: #e5ddce;
  --border-soft: #ede7da;
  --text: #3b362e;
  --text-strong: #1c1811;
  --dim: #6f695e;
  --dimmer: #9d968a;
  --accent: #d84a10;
  --accent2: #b06718;
  --teal: #0d7c72;
  --accent-soft: rgba(216, 74, 16, 0.08);
  --teal-soft: rgba(13, 124, 114, 0.08);
  --success: #3f7d18;
  --warning: #92650a;
  --error: #c23a55;
  --ember-gradient: linear-gradient(100deg, #d84a10 0%, #e8862e 55%, #d84a10 100%);
  --shadow: 0 1px 2px rgba(28, 24, 17, 0.05), 0 10px 30px rgba(28, 24, 17, 0.08);
  color-scheme: light;
}
html[data-theme="light"] .card { box-shadow: var(--shadow); border-color: var(--border-soft); }
html[data-theme="light"] .termwrap { box-shadow: 0 2px 6px rgba(28, 24, 17, 0.12), 0 18px 48px rgba(28, 24, 17, 0.18); }
html[data-theme="light"] .pitch { box-shadow: var(--shadow); }
html[data-theme="light"] .site-header { background: color-mix(in srgb, #faf8f3 82%, transparent); }

/* ───────────────────────── base ───────────────────────── */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  color: var(--text-strong);
  line-height: 1.25;
  font-weight: 650;
  margin: 2.2em 0 0.6em;
}
h1 { font-size: 1.9rem; margin-top: 0.5em; }
h2 { font-size: 1.35rem; padding-bottom: 0.35em; border-bottom: 1px solid var(--border-soft); }
h3 { font-size: 1.08rem; }
h4 { font-size: 0.95rem; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }

h2 a.anchor, h3 a.anchor {
  color: var(--dimmer);
  margin-left: 0.4em;
  opacity: 0;
  font-weight: 400;
}
h2:hover a.anchor, h3:hover a.anchor { opacity: 1; }

p.lead { font-size: 1.1rem; color: var(--dim); }

hr { border: none; border-top: 1px solid var(--border-soft); margin: 2.5rem 0; }

/* ───────────────────────── code ───────────────────────── */

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg-inline);
  padding: 0.14em 0.38em;
  border-radius: 4px;
  color: var(--text-strong);
}

pre {
  position: relative;
  background: var(--bg-code);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  line-height: 1.55;
  margin: 1.1rem 0;
}
pre code {
  background: none;
  padding: 0;
  font-size: 0.83rem;
  color: var(--text);
  display: block;
}

pre .copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--dim);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease;
}
pre:hover .copy-btn, pre .copy-btn:focus { opacity: 1; }
pre .copy-btn:hover { color: var(--text-strong); border-color: var(--dim); }
pre .copy-btn.copied { color: var(--success); border-color: var(--success); }

/* terminal-flavored blocks (transcripts, panels) */
pre.term {
  background: #0a0d13;
  border-color: #1d2330;
  color: #c6cdda;
}
html[data-theme="light"] pre.term {
  background: #14181f;
  border-color: #14181f;
  color: #c6cdda;
}
pre.term code { color: inherit; }

.t-dim { color: #6b7280; }
.t-accent { color: #7aa2f7; }
.t-ok { color: #9ece6a; }
.t-warn { color: #e0af68; }
.t-err { color: #f7768e; }
.t-b { font-weight: 700; color: #eceff4; }

/* ───────────────────────── layout ───────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
}
.site-header .inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.7rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1.6rem;
}
.wordmark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.22em;
  color: var(--text-strong);
}
.wordmark:hover { text-decoration: none; color: var(--accent); }
.wordmark .glyph { color: var(--accent); margin-right: 0.45em; }

.site-header nav { display: flex; gap: 1.2rem; margin-left: auto; align-items: center; }
.site-header nav a {
  color: var(--dim);
  font-size: 0.88rem;
}
.site-header nav a:hover { color: var(--text-strong); text-decoration: none; }
.site-header nav a.active { color: var(--text-strong); }

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--dim);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.28rem 0.6rem;
  cursor: pointer;
}
#theme-toggle:hover { color: var(--text-strong); border-color: var(--dim); }

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.4rem 4rem;
}

/* docs two-column */
.docs-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 4.2rem;
  padding-top: 2rem;
  font-size: 0.87rem;
  max-height: calc(100vh - 4.2rem);
  overflow-y: auto;
}
.sidebar .group {
  margin-bottom: 1.4rem;
}
.sidebar .group-title {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dimmer);
  margin-bottom: 0.5rem;
}
.sidebar a {
  display: block;
  color: var(--dim);
  padding: 0.24rem 0.6rem;
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
}
.sidebar a:hover { color: var(--text-strong); text-decoration: none; }
.sidebar a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.content { padding-top: 2rem; min-width: 0; }
.content > :first-child { margin-top: 0; }

@media (max-width: 860px) {
  .docs-layout { grid-template-columns: 1fr; gap: 0; }
  .sidebar { position: static; max-height: none; border-bottom: 1px solid var(--border-soft); padding-bottom: 1rem; }
  .sidebar .group { margin-bottom: 0.8rem; }
}

/* ───────────────────────── tables ───────────────────────── */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2rem 0;
  font-size: 0.88rem;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
th {
  color: var(--dim);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
td code { white-space: nowrap; }
td.wrap code { white-space: normal; }

kbd {
  font-family: var(--mono);
  font-size: 0.78em;
  background: var(--bg-inline);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.1em 0.45em;
  color: var(--text-strong);
  white-space: nowrap;
}

/* ───────────────────────── callouts ───────────────────────── */

.note, .warn {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  padding: 0.7rem 1.1rem;
  margin: 1.2rem 0;
  font-size: 0.92rem;
}
.warn {
  border-left-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 9%, transparent);
}
.note > :first-child, .warn > :first-child { margin-top: 0; }
.note > :last-child, .warn > :last-child { margin-bottom: 0; }

/* ───────────────────────── hero (index) ───────────────────────── */

.hero {
  padding: 5rem 0 3rem;
  max-width: 780px;
}
.hero .kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.28em;
  color: var(--accent);
  margin-bottom: 1.2rem;
}
.hero h1 {
  font-size: 2.6rem;
  margin: 0 0 0.9rem;
  letter-spacing: -0.015em;
}
.hero p.tagline {
  font-size: 1.18rem;
  color: var(--dim);
  margin: 0 0 2.2rem;
  max-width: 620px;
}
.hero .principle {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--dimmer);
  margin-top: 1.6rem;
}

.install-line {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.95rem 1.2rem;
  font-family: var(--mono);
  font-size: 0.92rem;
  max-width: 640px;
}
.install-line .prompt { color: var(--success); user-select: none; }
.install-line code { background: none; padding: 0; flex: 1; overflow-x: auto; white-space: nowrap; }
.install-line button {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--dim);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  flex-shrink: 0;
}
.install-line button:hover { color: var(--text-strong); border-color: var(--dim); }
.install-line button.copied { color: var(--success); border-color: var(--success); }

.hero .cta-row { margin-top: 1.3rem; display: flex; gap: 1.4rem; font-size: 0.9rem; }

/* feature grid */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 1rem;
  margin: 2.5rem 0;
}
.feature {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  background: var(--bg-alt);
}
.feature .glyph {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.95rem;
}
.feature h3 { margin: 0.4rem 0 0.35rem; font-size: 0.98rem; }
.feature p { margin: 0; font-size: 0.86rem; color: var(--dim); }

.section-title {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--dimmer);
  margin: 3.5rem 0 1rem;
}

/* footer */
.site-footer {
  border-top: 1px solid var(--border-soft);
  margin-top: 2rem;
}
.site-footer .inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.6rem 1.4rem;
  display: flex;
  gap: 1.5rem;
  font-size: 0.82rem;
  color: var(--dimmer);
  flex-wrap: wrap;
}
.site-footer a { color: var(--dim); }

/* prev/next pager */
.pager {
  display: flex;
  justify-content: space-between;
  margin-top: 3.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.9rem;
  gap: 1rem;
}
.pager .label { display: block; font-size: 0.72rem; color: var(--dimmer); text-transform: uppercase; letter-spacing: 0.08em; }
.pager .next { text-align: right; margin-left: auto; }

@media (max-width: 640px) {
  .hero { padding-top: 3rem; }
  .hero h1 { font-size: 2rem; }
  body { font-size: 15px; }
}

/* ───────────────────────── v2 "Terminal Cinema" additions ───────────────────────── */

/* Ember gradient wordmark + headings — the signature. */
.g-ember {
  background: var(--ember-gradient);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: emberflow 6s linear infinite;
}
@keyframes emberflow {
  from { background-position: 0% 0; }
  to { background-position: 200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .g-ember { animation: none; }
  .breath { animation: none !important; }
}

/* Phase ribbon (the cockpit, TUI v2 §3). */
.phase-ribbon {
  display: inline-flex;
  gap: 0.6rem;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.phase-ribbon .active { color: var(--accent); font-weight: 700; }
.phase-ribbon .done { color: var(--dimmer); text-decoration: line-through; }
.phase-ribbon .todo { color: var(--dimmer); }
.phase-ribbon .sep { color: var(--dimmer); }

/* Terminal mock accents */
.term .t-ember { color: var(--accent); }
.term .t-glow { color: var(--accent2); }
.term .t-teal { color: var(--teal); }
.term .t-ok { color: var(--success); }
.term .t-err { color: var(--error); }
.term .t-warn { color: var(--warning); }

/* Design-panel mock: bordered, breathing while pending. */
.term.panel { border: 1px solid rgba(255, 107, 53, 0.45); }
.breath { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { border-color: rgba(255, 107, 53, 0.35); }
  50% { border-color: rgba(255, 184, 107, 0.75); }
}

/* Feature grid v2 */
.grid3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.4rem 0 2.6rem;
}
.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-alt);
  padding: 1.1rem 1.2rem;
}
.card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.98rem;
  color: var(--text-strong);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.card h3 .glyph { color: var(--accent); font-family: var(--mono); }
.card p { margin: 0; font-size: 0.88rem; color: var(--dim); line-height: 1.55; }
.card code { font-size: 0.8rem; }
.card:hover { border-color: rgba(255, 107, 53, 0.45); }

/* The pitch band */
.pitch {
  margin: 3rem 0;
  padding: 2rem 1.6rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--bg-alt);
}
.pitch p { margin: 0 0 0.8rem; font-size: 1.05rem; color: var(--text-strong); line-height: 1.65; }
.pitch p:last-child { margin: 0; }
.pitch .motto { color: var(--accent2); font-family: var(--mono); font-size: 0.92rem; }

/* Context gauge mock */
.gauge { font-family: var(--mono); color: var(--teal); }
.gauge.hot { color: var(--error); }

/* Comparison table accent */
table.vs td:first-child { color: var(--text-strong); }

/* ───────────────────────── legendary pass: terminal windows, gallery, hero glow ───────────────────────── */

/* Terminal window chrome — every mock reads as a living terminal. */
.termwrap {
  border: 1px solid #1d2330;
  border-radius: 12px;
  overflow: hidden;
  background: #0a0d13;
  margin: 1.1rem 0;
}
.termbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  background: #0e121a;
  border-bottom: 1px solid #171c28;
}
.termbar .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.termbar .dot.r { background: #ff5f57; }
.termbar .dot.y { background: #febc2e; }
.termbar .dot.g { background: #28c840; }
.termbar .title {
  margin-left: 0.55rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #5b657a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.termwrap pre.term, .termwrap pre {
  border: none;
  border-radius: 0;
  margin: 0;
  background: #0a0d13;
}

/* The interface gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.2rem;
  margin: 1.4rem 0 2.6rem;
  align-items: start;
}
.gallery figure { margin: 0; min-width: 0; }
.gallery .termwrap { margin: 0; }
.gallery figcaption {
  font-size: 0.84rem;
  color: var(--dim);
  padding: 0.55rem 0.2rem 0;
  line-height: 1.5;
}
.gallery figcaption b { color: var(--text-strong); font-weight: 600; }
@media (max-width: 880px) { .gallery { grid-template-columns: 1fr; } }

/* Hero glow — the magma under the obsidian. */
.hero { position: relative; }
.hero::before {
  content: "";
  position: absolute;
  top: -6rem;
  left: -12%;
  width: 70%;
  height: 22rem;
  background: radial-gradient(closest-side, rgba(255, 107, 53, 0.14), transparent 72%);
  pointer-events: none;
  z-index: -1;
}
html[data-theme="light"] .hero::before {
  background: radial-gradient(closest-side, rgba(216, 74, 16, 0.10), transparent 72%);
}

/* Stats band under the hero */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2.2rem;
  margin: 2.4rem 0 0.6rem;
}
.stats .stat b {
  display: block;
  font-family: var(--mono);
  font-size: 1.45rem;
  color: var(--text-strong);
  line-height: 1.2;
}
.stats .stat span {
  font-size: 0.78rem;
  color: var(--dimmer);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Palette / selector mocks */
.term .sel { background: rgba(255, 107, 53, 0.18); color: #eceff4; }
.term .match { color: #ff6b35; font-weight: 700; }
.term .cursor { background: #c9d1e3; color: #0a0d13; }

/* Intra-line diff emphasis */
.term .d-add { background: rgba(126, 231, 135, 0.16); }
.term .d-del { background: rgba(255, 92, 87, 0.16); }
.term .d-add-hi { background: rgba(126, 231, 135, 0.42); color: #eceff4; }
.term .d-del-hi { background: rgba(255, 92, 87, 0.42); color: #eceff4; }
