/* Cedana — Theme system (dark default + light variant)
 * Layered ON TOP of colors_and_type.css.
 * Mono-first, sharp corners, single saturated note (cedana blue).
 *
 * - [data-theme="dark"] (or :root with no attr) → near-black + cedana blue
 * - [data-theme="light"]                        → off-white paper + cedana blue
 *
 * Light theme is bespoke: paper-warm background, ink + blue accents,
 * inverted ASCII visualizations (not just inverted colors).
 */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;500;600;700&display=swap");

/* ---------- DARK (default) ---------- */
:root,
:root[data-theme="dark"] {
  /* Surfaces — near-black */
  --bg-0:        #08090A;
  --bg-1:        #0B0D0E;
  --bg-2:        #101314;
  --bg-3:        #16191B;
  --bg-hover:    #1B1F22;

  /* Surface for crit/positive panels */
  --surface-bad:  rgba(232, 0, 0, 0.05);
  --surface-good: rgba(24, 42, 251, 0.06);

  /* Hairlines */
  --rule:        #1F2326;
  --rule-strong: #2C3134;
  --rule-blue:   #182AFB;

  /* Text */
  --fg-0: #E7E7E7;
  --fg-1: #C6C6C6;
  --fg-2: #8B9396;
  --fg-3: #5C6366;

  /* Accents */
  --accent:      #4D5DFF;       /* slightly lifted on dark for contrast */
  --accent-2:    #2B44FF;
  --accent-tint: rgba(77, 93, 255, 0.12);
  --accent-glow: rgba(77, 93, 255, 0.4);

  --bad:         #FF3B3B;
  --bad-tint:    rgba(255, 59, 59, 0.10);
  --good:        #4DBE86;
  --warn:        #F5B400;

  /* Type */
  --font-mono:   "Berkeley Mono", "GT America Mono", "IBM Plex Mono",
                 ui-monospace, "SF Mono", Menlo, monospace;
  --font-display: var(--font-mono);
  --font-ui:      var(--font-mono);
  --font-body:    var(--font-mono);

  --radius-button: 0;
  --radius-card:   0;

  /* Background grid pattern */
  --grid-dot: rgba(255,255,255,0.045);
  --grid-line: rgba(255,255,255,0.025);

  /* Cursor / button text on accent */
  --on-accent: #ffffff;
}

/* ---------- LIGHT (bespoke) ---------- */
:root[data-theme="light"] {
  /* Surfaces — crisp white page, cool light-grey cards */
  --bg-0:        #FFFFFF;       /* page — pure white */
  --bg-1:        #F4F5F7;       /* alt section / card surface — cool light grey */
  --bg-2:        #ECEEF2;       /* nested card head / input fill */
  --bg-3:        #E3E6EC;       /* deeper nested */
  --bg-hover:    #DDE1E8;

  --surface-bad:  rgba(220, 38, 38, 0.05);
  --surface-good: rgba(26, 43, 229, 0.05);

  /* Hairlines */
  --rule:        #DDE1E8;       /* soft cool grey */
  --rule-strong: #0A0A0A;       /* near-black hairline for emphasis */
  --rule-blue:   #1A2BE5;

  /* Text */
  --fg-0: #0A0A0A;              /* heading / hard ink */
  --fg-1: #1A1A1A;              /* body */
  --fg-2: #4B5563;              /* secondary / muted */
  --fg-3: #8A92A0;              /* tertiary / mono labels */

  /* Accents — saturated cobalt blue */
  --accent:      #1A2BE5;
  --accent-2:    #0F1FC8;
  --accent-tint: rgba(26, 43, 229, 0.08);
  --accent-glow: rgba(26, 43, 229, 0.30);

  --bad:         #DC2626;       /* status red — failure mode pip */
  --bad-tint:    rgba(220, 38, 38, 0.08);
  --good:        #16A34A;
  --warn:        #B45309;

  --grid-dot: rgba(10,10,40,0.06);
  --grid-line: rgba(10,10,40,0.035);

  --on-accent: #ffffff;
}

/* ---------- Smooth theme switch ---------- */
:root {
  transition: background-color 360ms ease;
}
html, body { background: var(--bg-0); color: var(--fg-0); }

body {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg-1);
  letter-spacing: 0;
  transition: background-color 360ms ease, color 360ms ease;
}

/* ---------- Headings ---------- */
h1, .h1 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 64px;
  line-height: 1.02;
  letter-spacing: -1.5px;
  color: var(--fg-0);
  margin: 0;
}
h2, .h2 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.6px;
  color: var(--fg-0);
  margin: 0;
}
h3, .h3 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 18px;
  line-height: 1.25;
  color: var(--fg-0);
  margin: 0;
}
p, .body { color: var(--fg-1); font-size: 14px; line-height: 1.6; }
.lead { color: var(--fg-1); font-size: 16px; line-height: 1.55; max-width: 64ch; }

a { color: var(--accent); text-decoration: none; transition: color 200ms; }

/* Light-theme print-style heavy underlines */
:root[data-theme="light"] h1,
:root[data-theme="light"] h2,
:root[data-theme="light"] h3 { color: var(--fg-0); }

/* ---------- Mono kicker ---------- */
.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.kicker::before {
  content: "";
  width: 8px; height: 8px;
  background: var(--accent);
  display: inline-block;
}

/* ---------- Unified Hover System ----------
 * Three flavors, one motion vocabulary:
 *
 *   .btn / .btn--solid / .btn--ghost — sharp ASCII chevron, fill swap
 *   .nav-link                        — bottom hairline grow + color
 *   .card-hoverable                  — top hairline grow + tint + slight rise
 *   a.text-link                      — corner-bracket bookend animation
 *
 * All transitions use cubic-bezier(.2,.7,.2,1) at 220–280ms.
 * Hover styling is identical across themes — only colors change via vars.
 */

/* Buttons */
.btn, .btn--solid, .btn--ghost, .btn--invert {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  height: 40px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 0;
  cursor: pointer;
  overflow: hidden;
  transition: color 220ms cubic-bezier(.2,.7,.2,1),
              border-color 220ms cubic-bezier(.2,.7,.2,1);
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 320ms cubic-bezier(.2,.7,.2,1);
  z-index: -1;
}
.btn > * { position: relative; z-index: 1; }
.btn::after {
  content: "→";
  font-weight: 400;
  display: inline-block;
  position: relative;
  z-index: 1;
  transition: transform 280ms cubic-bezier(.2,.7,.2,1);
}
.btn:hover { color: var(--on-accent); border-color: var(--accent); }
.btn:hover::before { transform: scaleX(1); }
.btn:hover::after { transform: translateX(4px); }

.btn--solid {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.btn--solid::before { background: var(--accent-2); }
.btn--solid:hover { color: var(--on-accent); border-color: var(--accent-2); }

.btn--ghost {
  border-color: var(--rule-strong);
  color: var(--fg-1);
}
.btn--ghost::before { background: var(--fg-0); }
.btn--ghost:hover { color: var(--bg-0); border-color: var(--fg-0); }

/* Text-links — corner brackets */
.text-link {
  position: relative;
  font-family: var(--font-mono);
  color: var(--accent);
  padding: 2px 4px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  text-decoration: none;
  transition: color 220ms;
}
.text-link::before,
.text-link::after {
  content: "";
  position: absolute;
  width: 6px; height: 6px;
  border-color: currentColor;
  opacity: 0;
  transition: opacity 220ms, transform 220ms cubic-bezier(.2,.7,.2,1);
}
.text-link::before {
  top: 0; left: 0;
  border-top: 1px solid;
  border-left: 1px solid;
  transform: translate(4px, 4px);
}
.text-link::after {
  bottom: 0; right: 0;
  border-bottom: 1px solid;
  border-right: 1px solid;
  transform: translate(-4px, -4px);
}
.text-link:hover::before,
.text-link:hover::after { opacity: 1; transform: translate(0,0); }

/* Card hover — accent border + top rule grow + slight rise */
.card-hoverable {
  position: relative;
  transition: border-color 240ms cubic-bezier(.2,.7,.2,1),
              background 240ms cubic-bezier(.2,.7,.2,1),
              transform 280ms cubic-bezier(.2,.7,.2,1);
}
.card-hoverable::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 1px;
  background: var(--accent);
  transition: width 360ms cubic-bezier(.2,.7,.2,1);
  z-index: 2;
}
.card-hoverable:hover {
  background: var(--accent-tint) !important;
  transform: translateY(-2px);
}
.card-hoverable:hover::before { width: 100%; }
.card-hoverable .card-arrow {
  position: absolute;
  bottom: 18px; right: 22px;
  font-family: var(--font-mono);
  color: var(--fg-3);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 240ms, transform 240ms cubic-bezier(.2,.7,.2,1), color 220ms;
  z-index: 2;
}
.card-hoverable:hover .card-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent);
}

/* ---------- Section helpers ---------- */
.section { padding: 96px 0; border-top: 1px solid var(--rule); }
.container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 32px; }

.tag-header {
  display: grid;
  grid-template-columns: 56px auto 1fr;
  align-items: center;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--fg-2);
  text-transform: uppercase;
  margin-bottom: 32px;
}
.tag-header .num {
  color: var(--accent);
  border: 1px solid var(--rule-strong);
  text-align: center;
  padding: 4px 0;
  font-weight: 500;
  background: var(--bg-2);
}
.tag-header .rule { height: 1px; background: var(--rule); }

.ascii-rule {
  font-family: var(--font-mono);
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
  letter-spacing: 0;
  font-size: 12px;
}

/* ---------- Background grid ---------- */
.bg-grid {
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
}
.bg-graph {
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ---------- Theme toggle widget ---------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rule-strong);
  background: var(--bg-2);
  padding: 0;
  height: 28px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.theme-toggle button {
  background: transparent;
  border: 0;
  padding: 0 10px;
  height: 100%;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--fg-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 200ms;
}
.theme-toggle button.is-active { color: var(--on-accent); }
.theme-toggle .knob {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  background: var(--accent);
  transition: transform 280ms cubic-bezier(.2,.7,.2,1);
  z-index: 0;
}
.theme-toggle[data-active="light"] .knob { transform: translateX(100%); }
.theme-toggle button { position: relative; z-index: 1; }
