/* LivingCode live demo. Same look as the site: steady, watchful, alive. */

:root {
  color-scheme: light;
  --bg: #F4F1EA;
  --panel: #FFFFFF;
  --line: #DDD8CC;
  --text: #14201B;
  --muted: #55625C;
  --accent: #087A50;
  --accent-strong: #06633F;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(8, 122, 80, 0.10);
  --alarm: #B8421F;
  --grid: rgba(20, 32, 27, 0.05);
  --shadow: 0 1px 2px rgba(20, 32, 27, 0.06), 0 12px 32px rgba(20, 32, 27, 0.08);
  --term-bg: #0D1110;
  --term-bar: #18201D;
  --term-text: #D6E0DB;
  --term-dim: #7E8C86;
  --term-ok: #36E2A0;
  --term-bad: #FF9A6B;
  --term-cmd: #9CC9FF;
  --term-ai: #E7C97A;
  --font-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wrap: 1120px;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0D1110;
    --panel: #151B19;
    --line: #24302C;
    --text: #E9EFEC;
    --muted: #9AA8A2;
    --accent: #36E2A0;
    --accent-strong: #5FEBB6;
    --accent-ink: #04130D;
    --accent-soft: rgba(54, 226, 160, 0.10);
    --alarm: #FF7A59;
    --grid: rgba(233, 239, 236, 0.045);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.35);
    --term-bg: #090C0B;
    --term-bar: #141A18;
  }
}

* { box-sizing: border-box; }
/* The hidden attribute always wins, even over a class that sets display. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background-color: var(--bg); color: var(--text);
  font: 400 1.0625rem/1.65 var(--font-body); -webkit-font-smoothing: antialiased;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.018em; margin: 0; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 32px; }

.bar { display: flex; align-items: center; justify-content: space-between; height: 76px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 700 1.12rem/1 var(--font-display); }
.brand:hover { color: var(--text); }
.brand svg { width: 30px; height: 30px; }
.brand svg rect { fill: var(--text); }
.brand svg path { fill: none; stroke: var(--bg); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.tag { font: 500 0.72rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 9px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 18px;
  border-radius: 999px; font: 600 0.95rem/1 var(--font-body); text-decoration: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--text); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn:focus-visible, .screen:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.intro { padding-top: clamp(28px, 6vw, 64px); }
h1 { font-size: clamp(2.4rem, 5.4vw, 4rem); line-height: 1.02; font-weight: 800; max-width: 14em; }
.accent { color: var(--accent); }
.lead { color: var(--muted); font-size: 1.15rem; max-width: 40em; margin: 20px 0 0; }
.lead.small { font-size: 1rem; margin-top: 12px; }
.note { margin: 18px 0 0; display: inline-block; padding: 8px 14px; border-radius: 10px; border: 1px dashed var(--line); background: var(--panel); color: var(--muted); font-size: 0.92rem; }

.picker { padding-top: 44px; }
.eyebrow { font: 500 0.8rem/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.card {
  display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.card:hover { transform: translateY(-3px); }
.card.live { border-color: var(--accent); }
.card h3 { font-size: 1.2rem; line-height: 1.25; }
.card p { margin: 0; color: var(--muted); font-size: 0.97rem; }
.card code { font: 400 0.82rem/1.4 var(--font-mono); color: var(--text); word-break: break-all; }
.card .btn { margin-top: auto; align-self: flex-start; }
.status { margin: 16px 0 0; font: 500 0.92rem/1.5 var(--font-mono); color: var(--muted); }
.status.warn { color: var(--alarm); }

.watch { padding-top: 28px; }
.window { border-radius: var(--radius); overflow: hidden; background: var(--term-bg); box-shadow: var(--shadow); border: 1px solid rgba(214, 224, 219, 0.1); }
.window-bar { display: flex; align-items: center; gap: 14px; height: 40px; padding: 0 16px; background: var(--term-bar); }
.lights { display: flex; gap: 8px; }
.lights i { width: 12px; height: 12px; border-radius: 50%; background: #FF5F57; }
.lights i:nth-child(2) { background: #FEBC2E; }
.lights i:nth-child(3) { background: #28C840; }
.window-title { flex: 1; min-width: 0; font: 500 0.8rem/1 var(--font-mono); color: var(--term-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font: 500 0.8rem/1 var(--font-mono); color: var(--term-dim); }

.monitor { position: relative; height: 54px; overflow: hidden; border-bottom: 1px solid rgba(214, 224, 219, 0.06); }
.trace { position: absolute; inset: 0; width: 100%; height: 100%; }
.trace path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.trace .ok { stroke: var(--term-ok); opacity: 0.85; transition: opacity 0.3s ease; }
.trace .bad { stroke: #FF7A59; opacity: 0; transition: opacity 0.25s ease; }
.trace .flow { animation: flow 2.2s linear infinite; }
.monitor.idle .trace .flow { animation-duration: 6s; }
.monitor.idle .trace .ok { opacity: 0.35; }
.monitor.fault .trace .ok { opacity: 0; }
.monitor.fault .trace .bad { opacity: 1; }
@keyframes flow { to { transform: translateX(calc(-1 * var(--period, 220px))); } }

.screen {
  margin: 0; height: 520px; overflow: auto; padding: 16px 20px 22px; color: var(--term-text);
  font: 400 0.84rem/1.65 var(--font-mono); white-space: pre-wrap; word-break: break-word;
}
.screen .step { color: #FFFFFF; font-weight: 500; }
.screen .step::before { content: "\A"; }
.screen .cmd { color: var(--term-cmd); }
.screen .ok, .screen .add { color: var(--term-ok); }
.screen .bad, .screen .del { color: var(--term-bad); }
.screen .dim { color: var(--term-dim); }
.screen .ai { color: var(--term-ai); }

.result { margin-top: 16px; padding: 20px 22px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); }
.result.no { border-left-color: var(--alarm); }
.result strong { font: 700 1.15rem/1.3 var(--font-display); }
.result p { margin: 6px 0 0; color: var(--muted); }
.result .meta { font: 400 0.82rem/1.5 var(--font-mono); }

.locks { padding-top: clamp(56px, 8vw, 96px); }
.locks h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.lock-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 22px; }
.lock { padding: 20px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.lock h3 { font-size: 1.05rem; }
.lock p { margin: 8px 0 0; color: var(--muted); font-size: 0.94rem; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 28px; padding-top: 56px; padding-bottom: 48px; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 900px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
  .lock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .bar { height: 64px; }
  .tag { display: none; }
  .lock-grid { grid-template-columns: minmax(0, 1fr); }
  .screen { height: 440px; padding: 12px 14px 16px; font-size: 0.74rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
