/* ============================================================
   WiFi Sense Lab — Tema scuro, tecnico, mobile-first
   ============================================================ */

:root {
  --bg-0: #050b14;
  --bg-1: #08121f;
  --bg-2: #0a1a2f;
  --bg-3: #0f2540;
  --line: #1b3050;
  --line-soft: #122339;
  --fg: #e6f1ff;
  --fg-dim: #9bb3cc;
  --fg-mute: #6b829c;
  --accent: #22e0ff;
  --accent-2: #5cf0c2;
  --warn: #ffb547;
  --alert: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --radius: 14px;
  --radius-sm: 10px;
  --container: 1180px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 800px at 80% -10%, #0e2a4a 0%, transparent 60%),
    radial-gradient(1000px 600px at -10% 110%, #052033 0%, transparent 60%), var(--bg-0);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: "SF Pro Display", -apple-system, "Segoe UI", system-ui, sans-serif;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}
h1 { font-size: 1.15rem; font-weight: 600; }
h2 { font-size: clamp(1.5rem, 2.4vw + 1rem, 2.1rem); margin-top: 0; }
h3 { font-size: 1.05rem; color: var(--fg); }

p { margin: 0 0 1em; }
.lead { font-size: 1.05rem; color: var(--fg-dim); max-width: 70ch; }
.muted { color: var(--fg-dim); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

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

.skip-link {
  position: absolute;
  left: -1000px;
  top: 0;
  background: var(--accent);
  color: #001018;
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

.container {
  width: 100%;
  max-width: var(--container);
  padding: 0 18px;
  margin: 0 auto;
}

/* ============= Topbar ============= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: linear-gradient(180deg, rgba(8,18,31,0.92), rgba(8,18,31,0.7));
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #0b2a44, #061826);
  border: 1px solid var(--line);
  border-radius: 10px;
  flex: 0 0 auto;
}
.brand-text h1 { font-size: 1rem; line-height: 1.2; }
.brand-text .tagline { margin: 0; font-size: 0.78rem; color: var(--fg-mute); }

.topnav {
  margin-left: auto;
  display: none;
  gap: 18px;
  font-size: 0.92rem;
}
.topnav a { color: var(--fg-dim); }
.topnav a:hover { color: var(--fg); text-decoration: none; }

.install-btn { margin-left: auto; }
@media (min-width: 760px) {
  .topnav { display: flex; }
  .install-btn { margin-left: 18px; }
}

/* ============= Buttons ============= */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn:hover { background: var(--bg-3); border-color: #25446b; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #1cd9ff, #16b8d8);
  color: #001821;
  border-color: transparent;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.05); background: linear-gradient(180deg, #28e1ff, #1bc4e0); }
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--fg-dim);
}

/* ============= Sections ============= */
.section {
  padding: 56px 0;
  border-bottom: 1px solid var(--line-soft);
}
.section-intro { padding-top: 64px; }
.section-limits { padding-bottom: 32px; }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(34, 224, 255, 0.08);
  border: 1px solid rgba(34, 224, 255, 0.25);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

/* ============= Info grid ============= */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 22px;
}
.info-card {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.info-icon {
  font-size: 1.4rem;
  margin-bottom: 6px;
}
.info-card h3 { margin: 0 0 4px; }
.info-card p { margin: 0; color: var(--fg-dim); font-size: 0.95rem; }

/* ============= Simulator ============= */
.mode-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 18px;
}
.mode {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg-dim);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mode:hover { color: var(--fg); border-color: #244769; }
.mode[aria-selected="true"] {
  background: linear-gradient(180deg, rgba(34,224,255,0.15), rgba(34,224,255,0.04));
  border-color: var(--accent);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px rgba(34,224,255,0.25);
}

.sim-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 980px) {
  .sim-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
}

.canvas-wrap {
  background: linear-gradient(180deg, #06121f, #08172a);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  position: relative;
}
#roomCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  border-radius: 10px;
  background: #04101c;
}
.canvas-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  font-size: 0.83rem;
  color: var(--fg-dim);
}
.canvas-legend .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.dot-router { background: #ffd166; box-shadow: 0 0 6px #ffd166; }
.dot-person { background: #5cf0c2; }
.dot-wave { background: #22e0ff; opacity: 0.7; }

.sim-panel {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.sim-panel h3 {
  margin-top: 14px;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.sim-panel h3:first-child { margin-top: 0; }

.state-big {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--accent);
  margin: 4px 0 14px;
  padding: 10px 12px;
  background: rgba(34, 224, 255, 0.07);
  border: 1px solid rgba(34, 224, 255, 0.25);
  border-radius: var(--radius-sm);
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.state-big.alert { color: var(--alert); background: rgba(255,107,107,0.08); border-color: rgba(255,107,107,0.3); }
.state-big.warn { color: var(--warn); background: rgba(255,181,71,0.08); border-color: rgba(255,181,71,0.3); }

.metric {
  display: grid;
  grid-template-columns: 100px 1fr 56px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.metric span { font-size: 0.85rem; color: var(--fg-dim); }
.meter {
  width: 100%;
  height: 8px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.2s ease;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 14px;
  margin-bottom: 10px;
}
.metric-grid > div { display: flex; flex-direction: column; gap: 2px; }
.metric-grid span { font-size: 0.78rem; color: var(--fg-mute); text-transform: uppercase; letter-spacing: 0.04em; }
.metric-grid strong { font-family: "SF Mono", ui-monospace, monospace; font-size: 0.98rem; }

.control {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.control span { font-size: 0.85rem; color: var(--fg-dim); }
.control input[type="range"] { width: 100%; accent-color: var(--accent); }
.control-row { display: flex; gap: 8px; margin-top: 6px; }

.hint {
  font-size: 0.8rem;
  color: var(--fg-mute);
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-soft);
}

/* ============= Charts ============= */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 18px;
}
@media (min-width: 760px) {
  .chart-grid { grid-template-columns: 1fr 1fr; }
}
.chart-card {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0;
  box-shadow: var(--shadow);
}
.chart-card figcaption {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 8px;
}
.chart-card canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 600 / 160;
  display: block;
}

/* ============= Dal simulatore al reale ============= */
.section-real .steps {
  list-style: none;
  padding: 0;
  margin: 22px 0 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.step {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 14px;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.step-num {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(34,224,255,0.18), rgba(34,224,255,0.04));
  border: 1px solid rgba(34,224,255,0.35);
  color: var(--accent);
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  font-weight: 600;
  display: grid;
  place-items: center;
}
.step-body h3 {
  margin: 2px 0 6px;
  font-size: 1.02rem;
  color: var(--fg);
}
.step-body p { color: var(--fg-dim); margin-bottom: 8px; }
.step-body p:last-child { margin-bottom: 0; }
.step-list {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--fg-dim);
}
.step-list li { margin: 4px 0; }
.step-list strong { color: var(--fg); }
.step-list code,
.step-body code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: rgba(34, 224, 255, 0.08);
  border: 1px solid rgba(34, 224, 255, 0.18);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--accent);
}

.code-block {
  background: #04101c;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 10px 0;
  overflow-x: auto;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #cfe6f5;
  -webkit-overflow-scrolling: touch;
}
.code-block code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
  white-space: pre;
}
.small { font-size: 0.85rem; }

.callout-info {
  background: linear-gradient(180deg, rgba(34,224,255,0.06), rgba(34,224,255,0.02));
  border-color: rgba(34, 224, 255, 0.3);
}
.callout-info h3 { color: var(--accent); }

@media (min-width: 760px) {
  .step { grid-template-columns: 56px 1fr; padding: 18px 22px; }
  .step-num { width: 44px; height: 44px; font-size: 1.15rem; }
}

/* ============= Limiti ============= */
.limits-list {
  list-style: none;
  padding: 0;
  margin: 18px 0 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 700px) {
  .limits-list { grid-template-columns: 1fr 1fr; }
}
.limits-list li {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--fg-dim);
}
.limits-list strong { color: var(--fg); }

.callout {
  background: linear-gradient(180deg, rgba(255,181,71,0.06), rgba(255,181,71,0.02));
  border: 1px solid rgba(255,181,71,0.25);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 14px;
}
.callout h3 { margin: 0 0 4px; color: var(--warn); }
.callout p { margin: 0; color: var(--fg-dim); }

/* ============= Footer ============= */
.footer {
  padding: 24px 0 40px;
  font-size: 0.88rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#online-status.offline { color: var(--warn); }

/* ============= Motion ============= */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0s !important; transition-duration: 0s !important; }
}

/* ============= Focus visibility ============= */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
