/* Edge AI Stress Sense - project website */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f3f2ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --code-bg: #f0efea;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95;
  --seq-ink-low: #0b0b0b; --seq-ink-high: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #222220;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #9a988f;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --accent: #3987e5; --code-bg: #141413;
    --seq-1: #184f95; --seq-2: #1c5cab; --seq-3: #256abf; --seq-4: #3987e5; --seq-5: #6da7ec; --seq-6: #9ec5f4;
    --seq-ink-low: #ffffff; --seq-ink-high: #0b0b0b;
    --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #222220;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #9a988f;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --accent: #3987e5; --code-bg: #141413;
  --seq-1: #184f95; --seq-2: #1c5cab; --seq-3: #256abf; --seq-4: #3987e5; --seq-5: #6da7ec; --seq-6: #9ec5f4;
    --seq-ink-low: #ffffff; --seq-ink-high: #0b0b0b;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--page); color: var(--text-primary);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: clamp(26px, 3.2vw, 34px); letter-spacing: -.3px; }
h3 { font-size: 19px; margin-top: 1.6em; }
h4 { font-size: 15px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .7px; }
p { margin: 0 0 1em; color: var(--text-secondary); }
strong { color: var(--text-primary); }
code, pre, kbd { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .88em; }
code { background: var(--code-bg); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; border: 0; padding: 0; }
.muted { color: var(--text-muted); }

/* ---- top navigation ---- */
.nav {
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--page) 82%, transparent); border-bottom: 1px solid var(--border);
}
.nav-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 10px 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.brand svg { width: 26px; height: 26px; color: var(--accent); }
.nav-links { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { color: var(--text-secondary); font-size: 14px; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav-links a:hover { background: var(--surface-2); text-decoration: none; }
.nav-links a.active { color: var(--text-primary); background: var(--surface-2); }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-primary); border-radius: 8px;
            padding: 6px 10px; cursor: pointer; font: inherit; font-size: 14px; }
.gh { display: inline-flex; align-items: center; gap: 6px; color: var(--text-primary); font-size: 14px; white-space: nowrap; }
.gh svg { width: 18px; height: 18px; }

/* ---- layout ---- */
section { padding: 72px 24px; border-bottom: 1px solid var(--border); }
section:nth-of-type(even) { background: var(--surface-1); }
.wrap { max-width: 1100px; margin: 0 auto; }
.lead { font-size: 18px; max-width: 760px; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; } }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
section:nth-of-type(even) .card { background: var(--page); }
.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

/* ---- hero ---- */
.hero { padding: 88px 24px 72px; position: relative; overflow: hidden; }
.hero h1 { font-size: clamp(36px, 6vw, 64px); letter-spacing: -1.5px; margin-bottom: 16px; }
.hero h1 span { color: var(--accent); }
.hero .lead { font-size: clamp(17px, 2vw, 20px); }
.hero-pulse { position: absolute; right: -40px; top: 40px; width: 560px; max-width: 70%; opacity: .16; color: var(--accent); pointer-events: none; }
.hero-pulse path { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: draw 4s ease-out forwards, beat 2.6s 4s ease-in-out infinite; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes beat { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .hero-pulse path { animation: none; stroke-dashoffset: 0; } }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 40px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 10px; font-weight: 600;
       border: 1px solid var(--border); color: var(--text-primary); background: var(--surface-2); }
.btn:hover { text-decoration: none; border-color: var(--text-muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 760px) { .stats { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat .v { font-size: 32px; font-weight: 700; line-height: 1.1; }
.stat .k { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.shot { margin-top: 44px; border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); width: 100%; height: auto; display: block; }
.video { margin-top: 44px; position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow); background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-link { margin-top: 12px; font-size: 14px; color: var(--text-muted); }

/* ---- steps ---- */
.steps { counter-reset: step; display: grid; gap: 14px; grid-template-columns: repeat(5, 1fr); margin-top: 28px; }
@media (max-width: 980px) { .steps { grid-template-columns: 1fr; } }
.step { position: relative; padding-top: 44px; }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: 16px; left: 20px;
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.step h3 { font-size: 16px; margin: 0 0 6px; }
.step p { font-size: 14px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-1); }
section:nth-of-type(even) .table-wrap { background: var(--page); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
     padding: 10px 14px; border-bottom: 1px solid var(--grid); background: var(--surface-2); }
td { padding: 10px 14px; border-bottom: 1px solid var(--grid); color: var(--text-secondary); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td:first-child { color: var(--text-primary); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.hl td { background: color-mix(in srgb, var(--accent) 9%, transparent); }

/* ---- callouts ---- */
.callout { border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; padding: 14px 18px; margin: 20px 0; }
.callout.warn { border-color: var(--warning); }
.callout p:last-child { margin: 0; }
.callout .t { font-weight: 700; color: var(--text-primary); margin-bottom: 4px; display: block; }

/* ---- diagrams ---- */
.diagram { width: 100%; height: auto; display: block; margin: 8px 0; }
.dg-box { fill: var(--surface-2); stroke: var(--axis); stroke-width: 1.2; }
.dg-box.hl { stroke: var(--accent); stroke-width: 2; }
.dg-title { font: 600 14px system-ui, sans-serif; fill: var(--text-primary); }
.dg-sub { font: 12px system-ui, sans-serif; fill: var(--text-muted); }
.dg-label { font: 12px system-ui, sans-serif; fill: var(--text-secondary); }
.dg-wire { fill: none; stroke: var(--text-muted); stroke-width: 1.6; }
.dg-wire.wifi { stroke-dasharray: 5 5; stroke: var(--accent); animation: dash 1.2s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -20; } }
@media (prefers-reduced-motion: reduce) { .dg-wire.wifi { animation: none; } }
.dg-arrow { fill: var(--text-muted); }
.dg-arrow.wifi { fill: var(--accent); }
.dg-arrow.data { fill: var(--series-2); }
/* labels get a halo in the card colour so they stay readable where they cross a wire */
.dg-label { paint-order: stroke; stroke: var(--surface-1); stroke-width: 5px; stroke-linejoin: round; }
section:nth-of-type(even) .dg-label { stroke: var(--page); }
.dg-life { stroke: var(--axis); stroke-width: 1.5; stroke-dasharray: 3 4; }
.dg-msg { stroke: var(--text-secondary); stroke-width: 1.6; fill: none; }
.dg-msg.data { stroke: var(--series-2); stroke-width: 2.2; }
.dg-msg.ack { stroke: var(--series-3); }
.dg-act { fill: var(--accent); opacity: .18; }

/* ---- charts ---- */
.chart-card { padding: 18px 18px 10px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.chart-head h3 { margin: 0; font-size: 16px; }
.chart-head p { margin: 2px 0 0; font-size: 13px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-secondary); flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.tick { width: 14px; height: 2px; border-radius: 0; vertical-align: 4px; background: var(--text-primary); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font: 12px system-ui, sans-serif; fill: var(--text-muted); }
.chart .val { fill: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); }
.chart .baseline { stroke: var(--axis); }
.chart .bar { transition: opacity .15s; }
.chart .dim .bar { opacity: .35; }
.chart .dim .bar.on { opacity: 1; }
.toggle-table { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.tip { position: fixed; pointer-events: none; z-index: 50; background: var(--surface-1); border: 1px solid var(--border);
       box-shadow: var(--shadow); border-radius: 8px; padding: 7px 10px; font-size: 13px; color: var(--text-primary); }
.tip .k { color: var(--text-muted); font-size: 12px; }
.hidden { display: none !important; }

/* ---- misc ---- */
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border);
        background: var(--surface-2); color: var(--text-secondary); margin: 2px 4px 2px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--text-muted); } .kv dd { margin: 0; color: var(--text-primary); }
ul.clean { padding-left: 18px; margin: 0 0 1em; color: var(--text-secondary); }
ul.clean li { margin: 4px 0; }
footer { padding: 40px 24px; text-align: center; color: var(--text-muted); font-size: 14px; }
footer a { color: var(--text-secondary); }

/* ---- phones ---- */
@media (max-width: 700px) {
  .nav-links { display: none; }
  .nav-inner { justify-content: space-between; padding: 10px 16px; }
  section, .hero { padding-left: 16px; padding-right: 16px; }
  .stat .v { font-size: 24px; }
  .hero-pulse { display: none; }
}

/* ---- wiring illustrations ---- */
figure.wiring { margin: 28px 0; }
figure.wiring img { width: 100%; height: auto; display: block; border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); }
figure.wiring figcaption { color: var(--text-secondary); font-size: 14px; margin-top: 10px; }
