/* ============================================================================
   Ophanim - phosphor terminal theme
   Palette and idiom ported verbatim from the app's Theme.swift:
   near-black green-shifted slate, phosphor-green primary, purple secondary,
   monospace everywhere, CRT theatrics.
   ============================================================================ */

:root {
  /* Surfaces - near-black slate, slightly green-shifted */
  --bg:             #0A0E0B;
  --surface:        #111712;
  --surface-raised: #18211A;
  --border:         #254A30;

  /* Greens - primary accent / highlight / dim */
  --accent:         #3CE07A;
  --accent-bright:  #7CFFB0;
  --accent-dim:     #2B8F52;

  /* Purples - secondary accent */
  --purple:         #B36CFF;
  --purple-bright:  #D7B0FF;
  --purple-dim:     #7E4FB8;

  /* Text */
  --text:           #CBF5D6;   /* soft green-white  */
  --text-dim:       #6FA982;   /* dim green-gray    */
  --danger:         #FF5C5C;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --maxw: 1080px;
  --radius: 6px;
  --glow: 0 0 4px;
}

/* ----------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-bright); text-shadow: var(--glow) rgba(124,255,176,.7); }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
code, kbd { font-family: var(--mono); }
::selection { background: rgba(179,108,255,.35); color: var(--accent-bright); }

/* ----------------------------------------------------------- fx canvases */
/* Three stacked, fixed full-viewport canvases driven by effects.js, mirroring
   the app's layered ZStack: rain (back) → eyes → scanlines (front overlay). */
.fx-layer {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}
#fx-rain      { opacity: .16; }
#fx-eyes      { opacity: .78; }
#fx-scanlines { z-index: 60; mix-blend-mode: screen; }
body.fx-off .fx-layer { display: none; }

/* a faint vignette so content floats above the theatrics */
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at 50% 0%, transparent 55%, rgba(0,0,0,.55) 100%);
}

/* ------------------------------------------------------------- structure */
.wrap { width: min(var(--maxw), 92vw); margin-inline: auto; }
main, header, footer, section { position: relative; z-index: 2; }

section { padding: 72px 0; }
section + section { border-top: 1px solid rgba(37,74,48,.4); }
.section-eyebrow {
  color: var(--purple-bright);
  font-size: 12px; letter-spacing: .22em; text-transform: uppercase;
  margin: 0 0 10px;
}
.section-title { font-size: clamp(22px, 3.4vw, 30px); margin: 0 0 14px; color: var(--accent-bright); text-shadow: var(--glow) rgba(124,255,176,.35); }
.section-lead { color: var(--text-dim); max-width: 70ch; margin: 0 0 36px; }

/* ------------------------------------------------------------------- nav */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
  background: rgba(10,14,11,.72);
  border-bottom: 1px solid rgba(37,74,48,.5);
}
.nav-inner { display: flex; align-items: center; gap: 18px; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand img { width: 26px; height: 26px; }
.brand b { color: var(--accent-bright); letter-spacing: .14em; }
.nav-links { display: flex; gap: 22px; margin-left: auto; align-items: center; }
.nav-links a { color: var(--text-dim); font-size: 13px; letter-spacing: .04em; }
.nav-links a:hover { color: var(--accent); }
.nav-links a.active { color: var(--accent); }
.fx-toggle {
  font: inherit; font-size: 12px; cursor: pointer;
  color: var(--accent); background: var(--surface-raised);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 9px;
}
.fx-toggle:hover { background: rgba(60,224,122,.18); }
.nav-burger { display: none; }

/* --------------------------------------------------------------- buttons */
/* TerminalButtonStyle: green outline, monospace, fills on hover/press. */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--accent);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 18px;
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: rgba(60,224,122,.18); box-shadow: var(--glow) rgba(60,224,122,.4); color: var(--accent-bright); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: rgba(60,224,122,.14); border-color: var(--accent-dim); }
.btn-purple { color: var(--purple-bright); border-color: var(--purple-dim); }
.btn-purple:hover { background: rgba(179,108,255,.18); box-shadow: var(--glow) rgba(179,108,255,.4); color: var(--purple-bright); }

/* ------------------------------------------------------------------ hero */
.hero { padding: 86px 0 64px; text-align: center; }
.hero-logo { width: 132px; height: 132px; margin: 0 auto 26px; animation: float 7s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero h1 {
  font-size: clamp(44px, 10vw, 92px);
  letter-spacing: .16em; margin: 0;
  color: var(--accent-bright);
  text-shadow: 0 0 18px rgba(124,255,176,.45), 0 0 4px rgba(124,255,176,.8);
}
.hero .tagline {
  font-size: clamp(16px, 2.4vw, 21px);
  color: var(--text); margin: 18px auto 0; max-width: 60ch;
}
.hero .sub { color: var(--text-dim); max-width: 64ch; margin: 16px auto 0; font-size: 14px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 34px; }
.hero-badges { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }
.badge {
  font-size: 11.5px; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; background: rgba(17,23,18,.6);
}
.badge b { color: var(--accent); font-weight: 600; }

/* blinking cursor used in headings/prompts */
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1.1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* ----------------------------------------------------------------- cards */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.card h3 { margin: 0 0 8px; font-size: 16px; color: var(--accent-bright); display: flex; align-items: center; gap: 9px; }
.card.alt h3 { color: var(--purple-bright); }
.card p { margin: 0; color: var(--text-dim); font-size: 14px; }
.card .ic { color: var(--accent); flex: none; }
.card.alt .ic { color: var(--purple); }
.card ul { margin: 10px 0 0; padding-left: 18px; color: var(--text-dim); font-size: 13.5px; }
.card ul li { margin: 3px 0; }

/* GroupBox label idiom */
.groupbox {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.groupbox > .gb-title { color: var(--accent-bright); font-size: 13px; font-weight: 600; margin: 0 0 12px; }

/* --------------------------------------------------------------- tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.matrix { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
table.matrix th, table.matrix td { text-align: left; padding: 11px 14px; border-bottom: 1px solid rgba(37,74,48,.5); }
table.matrix thead th { color: var(--accent-bright); font-weight: 600; background: var(--surface-raised); position: sticky; top: 0; }
table.matrix td:first-child { color: var(--text); }
table.matrix tr:last-child td { border-bottom: 0; }
table.matrix .yes { color: var(--accent); }
table.matrix .no  { color: var(--danger); }
table.matrix .partial { color: var(--purple-bright); }
.center { text-align: center; }

/* ---------------------------------------------------- terminal "window" */
/* Faithful CSS mockups of the real app UI (App Library, instrumentation,
   log viewer, rule editor) - styled to the shipping terminal theme. */
.window {
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 22px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(0,0,0,.4);
}
.titlebar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 13px;
  background: linear-gradient(var(--surface-raised), var(--surface));
  border-bottom: 1px solid var(--border);
}
.dots { display: flex; gap: 7px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.dots .r { background: #ff5f57; } .dots .y { background: #febc2e; } .dots .g { background: #28c840; }
.titlebar .title { margin-left: 8px; font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 7px; }
.titlebar .title svg { width: 14px; height: 14px; }
.win-body { padding: 0; }
.figcap { color: var(--text-dim); font-size: 12.5px; margin: 10px 2px 0; text-align: center; }
figure { margin: 0; }

/* App library mockup */
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 18px 14px; padding: 22px; }
.lib .app { text-align: center; }
.lib .app .tile {
  width: 100%; aspect-ratio: 1; border-radius: 16px;
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 26px; color: var(--bg);
  background: linear-gradient(150deg, var(--accent), var(--accent-dim));
  box-shadow: inset 0 0 12px rgba(0,0,0,.25);
}
.lib .app:nth-child(3n) .tile { background: linear-gradient(150deg, var(--purple-bright), var(--purple-dim)); }
.lib .app:nth-child(3n+2) .tile { background: linear-gradient(150deg, var(--accent-bright), var(--accent-dim)); }
.lib .app .name { font-size: 11px; color: var(--text-dim); margin-top: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* settings / toggle rows */
.settings { padding: 20px; display: grid; gap: 14px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 13px; }
.toggle-row .lbl { color: var(--text); }
.toggle-row .lbl small { display: block; color: var(--text-dim); font-size: 11.5px; }
.sw { width: 38px; height: 21px; border-radius: 999px; background: var(--surface-raised); border: 1px solid var(--border); position: relative; flex: none; }
.sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--text-dim); transition: .2s; }
.sw.on { background: rgba(60,224,122,.3); border-color: var(--accent-dim); }
.sw.on::after { left: 19px; background: var(--accent-bright); box-shadow: var(--glow) var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 11.5px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); }
.chip.on { color: var(--accent); border-color: var(--accent-dim); background: rgba(60,224,122,.12); }
.chip.purple.on { color: var(--purple-bright); border-color: var(--purple-dim); background: rgba(179,108,255,.12); }

/* log viewer mockup */
.log { font-size: 12px; padding: 14px 16px; max-height: 340px; overflow: auto; }
.log .row { display: grid; grid-template-columns: 64px 88px 1fr; gap: 12px; padding: 3px 0; border-bottom: 1px solid rgba(37,74,48,.25); white-space: nowrap; }
.log .row .t { color: var(--text-dim); }
.log .row .cat { font-weight: 600; }
.log .row .msg { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.log .cat.network { color: var(--accent); }
.log .cat.keychain { color: var(--purple-bright); }
.log .cat.crypto { color: var(--accent-bright); }
.log .cat.device { color: var(--purple); }
.log .cat.process { color: var(--text-dim); }
.log .cat.jailbreak { color: var(--danger); }
.log .disp { color: var(--purple-bright); }
.log .blocked { color: var(--danger); }

/* code blocks */
pre {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; overflow-x: auto;
  font-size: 13px; line-height: 1.6; color: var(--text);
}
pre .c { color: var(--text-dim); }   /* comment */
pre .p { color: var(--accent); }      /* prompt $ */
pre .k { color: var(--purple-bright); } /* keyword */
pre .s { color: var(--accent-bright); } /* string */
:not(pre) > code {
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; font-size: .88em; color: var(--accent);
}

/* feature bullet list (terminal style) */
.tlist { list-style: none; padding: 0; margin: 0; }
.tlist li { padding: 6px 0 6px 24px; position: relative; color: var(--text-dim); font-size: 14px; border-bottom: 1px solid rgba(37,74,48,.25); }
.tlist li::before { content: "▸"; position: absolute; left: 4px; color: var(--accent); }
.tlist li b, .tlist li strong { color: var(--text); font-weight: 600; }

/* callout */
.callout {
  border: 1px solid var(--purple-dim);
  border-left-width: 3px;
  background: rgba(179,108,255,.06);
  border-radius: var(--radius);
  padding: 16px 18px; font-size: 14px; color: var(--text);
}
.callout.warn { border-color: var(--accent-dim); border-left-color: var(--accent); background: rgba(60,224,122,.05); }
.callout b { color: var(--accent-bright); }

/* ----------------------------------------------------------------- docs */
.docs-layout { display: grid; grid-template-columns: 232px 1fr; gap: 40px; align-items: start; }
.docs-nav { position: sticky; top: 76px; font-size: 13px; max-height: calc(100vh - 92px); overflow-y: auto; }
.docs-nav .grp { color: var(--purple-bright); text-transform: uppercase; letter-spacing: .16em; font-size: 11px; margin: 18px 0 6px; }
.docs-nav a { display: block; color: var(--text-dim); padding: 4px 0 4px 12px; border-left: 1px solid rgba(37,74,48,.5); }
.docs-nav a:hover { color: var(--accent); border-left-color: var(--accent-dim); }
.docs-nav a.active { color: var(--accent); border-left-color: var(--accent); }
.docs-content { min-width: 0; }
.docs-content h2 { font-size: 24px; color: var(--accent-bright); margin: 48px 0 14px; padding-top: 8px; }
.docs-content h2:first-child { margin-top: 0; }
.docs-content h3 { font-size: 17px; color: var(--purple-bright); margin: 28px 0 10px; }
.docs-content p, .docs-content li { color: var(--text-dim); }
.docs-content p { margin: 0 0 14px; }
.docs-content strong { color: var(--text); }
.docs-content ul, .docs-content ol { padding-left: 22px; }
.docs-content ul li, .docs-content ol li { margin: 6px 0; }
.anchor { scroll-margin-top: 80px; }

/* ---------------------------------------------------------------- footer */
footer { padding: 50px 0 70px; border-top: 1px solid rgba(37,74,48,.5); color: var(--text-dim); font-size: 13px; }
.foot-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 30px; }
footer h4 { color: var(--accent-bright); font-size: 13px; margin: 0 0 12px; letter-spacing: .05em; }
footer a { color: var(--text-dim); }
footer a:hover { color: var(--accent); }
footer .muted { font-size: 12px; opacity: .8; }
.foot-links { list-style: none; padding: 0; margin: 0; }
.foot-links li { margin: 5px 0; }
.foot-bottom { margin-top: 36px; padding-top: 22px; border-top: 1px solid rgba(37,74,48,.4); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12px; }

/* ------------------------------------------------------------ utilities */
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.text-dim { color: var(--text-dim); }
.accent { color: var(--accent); } .purple { color: var(--purple-bright); }

/* ---------------------------------------------------- reduced motion / a11y */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto !important; }
}

/* ----------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-nav { position: static; max-height: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 24px; }
  .foot-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column; position: absolute; top: 58px; right: 0; left: 0;
    background: rgba(10,14,11,.97); border-bottom: 1px solid var(--border); padding: 14px 4vw; gap: 14px;
  }
  .nav-links.open a { font-size: 15px; }
  .nav-burger { display: inline-flex; margin-left: auto; background: none; border: 1px solid var(--border); color: var(--accent); border-radius: 4px; padding: 5px 9px; cursor: pointer; font: inherit; }
  .fx-toggle { margin-left: 8px; }
}
