/* ==========================================================================
   NetSpeedly — stylesheet
   Identity: a cobalt instrument panel with a signal-yellow needle.
   One typeface (Archivo, variable width): expanded for readings,
   normal width for reading text.
   ========================================================================== */

@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-var.woff2") format("woff2-variations"), url("../fonts/archivo-var.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --cobalt: #1f3ee0;
  --cobalt-2: #1731b8;
  --cobalt-3: #0f2287;
  --signal: #ffd23f;
  --mint: #6fe3c1;
  --paper: #f4f6fb;
  --surface: #ffffff;
  --ink: #0c1838;
  --ink-2: #2a3557;
  --muted: #5a6482;
  --line: #d8deeb;
  --line-2: #c3cbdd;
  --good: #128a5e;
  --ok: #a46200;
  --bad: #c7253e;
  --focus: #ffb000;
  --on-cobalt: #ffffff;
  --on-cobalt-2: rgba(255, 255, 255, .72);
  --on-cobalt-3: rgba(255, 255, 255, .22);
  --radius: 12px;
  --font: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --wrap: 1160px;
  --head: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --cobalt: #1a2fae;
  --cobalt-2: #15268c;
  --cobalt-3: #0d1a66;
  --paper: #0a1230;
  --surface: #101b45;
  --ink: #e8ecf8;
  --ink-2: #c6cde2;
  --muted: #9aa4c4;
  --line: #22305f;
  --line-2: #2f3f78;
  --good: #4fd59f;
  --ok: #f2b544;
  --bad: #ff6f86;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--head) + 12px); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
p { margin: 0 0 1em; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.15; font-stretch: 112%; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem); font-weight: 800; }
h2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); font-weight: 760; }
h3 { font-size: 1.15rem; font-weight: 720; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--signal); color: #0c1838; padding: 10px 14px; border-radius: 8px; font-weight: 700; }
.skip:focus { top: 10px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 100; height: var(--head);
  background: var(--cobalt); color: var(--on-cobalt);
  border-bottom: 1px solid var(--on-cobalt-3);
}
.top .wrap { height: 100%; display: flex; align-items: center; gap: 20px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-stretch: 118%; font-size: 1.2rem; letter-spacing: -.01em; }
.logo svg { width: 32px; height: 32px; flex: none; }
.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: .95rem; color: var(--on-cobalt-2); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--on-cobalt); background: rgba(255, 255, 255, .1); }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; flex: none;
  border-radius: 10px; border: 1px solid var(--on-cobalt-3); background: transparent; color: var(--on-cobalt); cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }
.menu-btn { display: none; }
@media (max-width: 900px) {
  .menu-btn { display: inline-grid; }
  .nav {
    position: fixed; inset: var(--head) 0 auto 0; flex-direction: column; align-items: stretch; gap: 0;
    padding: 8px 16px 18px; background: var(--cobalt-2); border-bottom: 1px solid var(--on-cobalt-3);
    margin: 0; display: none;
  }
  body.nav-open .nav { display: flex; }
  .nav a { padding: 13px 10px; font-size: 1.05rem; }
  .top-actions { margin-left: auto; }
}
.top-actions { display: flex; gap: 8px; }

/* ---------- instrument panel (hero) ---------- */
.panel { background: var(--cobalt); color: var(--on-cobalt); padding: 34px 0 30px; position: relative; overflow: hidden; }
.panel::before {
  /* faint graticule, like the face of a measuring instrument */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 32px 32px;
}
.panel > .wrap { position: relative; }
.panel-head { max-width: 680px; margin-bottom: 18px; }
.panel-head h1 { color: #fff; margin-bottom: 6px; }
.panel-head p { color: var(--on-cobalt-2); margin: 0; font-size: 1.05rem; }

.console { display: grid; grid-template-columns: minmax(0, 470px) minmax(0, 1fr); gap: 40px; align-items: center; }
@media (max-width: 900px) { .console { grid-template-columns: minmax(0, 1fr); gap: 18px; } }

.dial { position: relative; width: 100%; max-width: 470px; margin: 0 auto; aspect-ratio: 1 / .9; }
.dial svg { width: 100%; height: 100%; overflow: visible; }
.dial .track { fill: none; stroke: var(--cobalt-3); stroke-width: 22; stroke-linecap: round; }
.dial .fill { fill: none; stroke: var(--signal); stroke-width: 22; stroke-linecap: round; transition: stroke .3s; }
.dial.up .fill { stroke: var(--mint); }
.dial .tick { stroke: rgba(255,255,255,.55); stroke-width: 2; }
.dial .tick.minor { stroke: rgba(255,255,255,.25); stroke-width: 1.5; }
.dial .tick-label { fill: var(--on-cobalt-2); font: 600 15px var(--font); font-stretch: 110%; }
.dial .needle { stroke: #fff; stroke-width: 6; stroke-linecap: round; }
.dial.idle .needle-g { opacity: .35; }

.dial-center { position: absolute; left: 0; right: 0; top: 55.5%; transform: translateY(-50%); display: grid; place-items: center; text-align: center; pointer-events: none; }
.dial-center > * { pointer-events: auto; }
.start {
  width: clamp(138px, 40vw, 184px); height: clamp(138px, 40vw, 184px); border-radius: 50%; cursor: pointer;
  background: var(--signal); color: #0c1838; border: 0;
  font: 800 clamp(1.1rem, .9rem + 1vw, 1.45rem)/1.05 var(--font); font-stretch: 120%; padding: 0 12px;
  box-shadow: 0 0 0 10px rgba(255, 210, 63, .18), 0 0 0 22px rgba(255, 210, 63, .07);
  transition: transform .15s, box-shadow .2s;
}
.start small { display: block; margin-top: 6px; font-size: .78rem; font-weight: 600; font-stretch: 100%; opacity: .75; }
.start:hover { transform: scale(1.03); box-shadow: 0 0 0 12px rgba(255, 210, 63, .24), 0 0 0 26px rgba(255, 210, 63, .09); }
.start:active { transform: scale(.98); }
.start:focus-visible { outline: 4px solid #fff; outline-offset: 6px; }
@media (prefers-reduced-motion: no-preference) {
  .start.ready { animation: breathe 2.8s ease-in-out infinite; }
  @keyframes breathe { 50% { box-shadow: 0 0 0 14px rgba(255, 210, 63, .22), 0 0 0 30px rgba(255, 210, 63, .06); } }
}
.reading { display: grid; gap: 2px; justify-items: center; }
.reading .phase { font-weight: 650; color: var(--on-cobalt-2); font-size: .95rem; }
.reading .num { font-weight: 800; font-stretch: 125%; font-size: clamp(2.8rem, 2rem + 3.5vw, 4.4rem); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.reading .unit { font-weight: 600; color: var(--on-cobalt-2); }
.stop-btn {
  margin-top: 12px; background: transparent; color: #fff; border: 1px solid var(--on-cobalt-3);
  border-radius: 999px; padding: 6px 16px; font: 600 .88rem var(--font); cursor: pointer;
}
.stop-btn:hover { background: rgba(255,255,255,.1); }

/* readouts */
.readouts { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--on-cobalt-3); }
.ro { padding: 16px 16px 16px 0; border-bottom: 1px solid var(--on-cobalt-3); min-width: 0; }
.ro + .ro { padding-left: 18px; border-left: 1px solid var(--on-cobalt-3); }
.ro:nth-child(3) { padding-left: 0; border-left: 0; }
.ro .lbl { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--on-cobalt-2); font-size: .95rem; }
.ro .lbl i { width: 10px; height: 10px; border-radius: 50%; background: var(--signal); flex: none; }
.ro.up .lbl i { background: var(--mint); }
.ro.lat .lbl i { background: #fff; }
.ro .val { font-weight: 800; font-stretch: 125%; font-size: clamp(1.6rem, 1rem + 3vw, 2.9rem); line-height: 1.1; font-variant-numeric: tabular-nums; margin-top: 4px; white-space: nowrap; }
.ro .val small { font-size: max(.42em, 13px); font-weight: 600; font-stretch: 100%; color: var(--on-cobalt-2); margin-left: 4px; letter-spacing: 0; }
.ro .val.empty { opacity: .45; font-weight: 500; }
.ro .sub { color: var(--on-cobalt-2); font-size: .88rem; margin-top: 2px; }
.ro.active .val { color: var(--signal); }
.ro.up.active .val { color: var(--mint); }

.trace { margin-top: 18px; height: 120px; position: relative; border-radius: 10px; background: rgba(4, 12, 60, .25); }
.trace canvas { width: 100%; height: 100%; }
.trace .legend { position: absolute; right: 12px; top: 8px; display: flex; gap: 14px; font-size: .8rem; color: var(--on-cobalt-2); font-weight: 600; }
.trace .legend span { display: inline-flex; align-items: center; gap: 6px; }
.trace .legend i { width: 14px; height: 3px; border-radius: 2px; background: var(--signal); }
.trace .legend .u i { background: var(--mint); }

.conn { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-top: 16px; }
.conn > div { padding: 2px 16px; border-left: 1px solid var(--on-cobalt-3); min-width: 0; }
.conn > div:first-child { padding-left: 0; border-left: 0; }
.conn .k { color: var(--on-cobalt-2); font-size: .82rem; font-weight: 600; }
.conn .v { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) {
  .conn { grid-template-columns: 1fr 1fr; row-gap: 10px; }
  .conn > div:nth-child(3) { padding-left: 0; border-left: 0; grid-column: 1 / -1; }
}

.panel-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: rgba(4, 12, 60, .3); }
.seg button { border: 0; background: transparent; color: var(--on-cobalt-2); font: 650 .85rem var(--font); padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--cobalt-3); }
.note { color: var(--on-cobalt-2); font-size: .85rem; margin: 0; }

.error { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: #fff; color: #9b1730; font-weight: 600; font-size: .95rem; }

/* ---------- buttons (paper areas) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: 650 .95rem var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn-primary:hover { background: var(--cobalt-2); border-color: var(--cobalt-2); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .88rem; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- sections on paper ---------- */
.section { padding: 56px 0; }
.section + .section { padding-top: 0; }
.lede { color: var(--muted); font-size: 1.05rem; max-width: 640px; }

.verdict { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 40px; }
@media (max-width: 900px) { .verdict { grid-template-columns: minmax(0, 1fr); gap: 28px; } }
.uses { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.uses li { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.uses .name { font-weight: 700; }
.uses .why { grid-column: 1 / -1; color: var(--muted); font-size: .92rem; }
.badge { font-weight: 700; font-size: .85rem; padding: 3px 10px; border-radius: 999px; border: 1.5px solid currentColor; white-space: nowrap; align-self: start; }
.badge.good { color: var(--good); }
.badge.ok { color: var(--ok); }
.badge.bad { color: var(--bad); }

.grade-box { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 22px; }
.grade { display: flex; align-items: center; gap: 18px; margin-bottom: 12px; }
.grade b { font-size: 3.4rem; font-weight: 850; font-stretch: 125%; line-height: 1; color: var(--cobalt); min-width: 1.6em; }
:root[data-theme="dark"] .grade b { color: var(--signal); }
.grade-box p { color: var(--muted); font-size: .94rem; }
.grade-box dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 14px 0 0; font-size: .94rem; }
.grade-box dt { color: var(--muted); }
.grade-box dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.empty-state { padding: 26px; border: 1.5px dashed var(--line-2); border-radius: var(--radius); color: var(--muted); text-align: center; }

/* history */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.hist { width: 100%; border-collapse: collapse; font-size: .93rem; min-width: 620px; }
.hist th, .hist td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hist th:first-child, .hist td:first-child, .hist th:last-child, .hist td:last-child { text-align: left; }
.hist th { color: var(--muted); font-weight: 650; font-size: .85rem; background: var(--paper); }
.hist tr:last-child td { border-bottom: 0; }

/* ad slots stay collapsed until AdSense is configured */
.ad-slot { display: none; }
.ad-slot.filled { display: block; margin: 0 auto; text-align: center; min-height: 120px; }
.ad-slot.filled::before { content: "Advertisement"; display: block; font-size: .72rem; color: var(--muted); margin-bottom: 6px; }

/* ---------- long-form content ---------- */
.content { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 56px; align-items: start; }
@media (max-width: 960px) { .content { grid-template-columns: minmax(0, 1fr); gap: 32px; } }
.prose { max-width: 70ch; color: var(--ink-2); }
.prose h2 { color: var(--ink); margin-top: 1.8em; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { color: var(--ink); margin-top: 1.5em; }
.prose li { margin-bottom: .45em; }
.prose strong { color: var(--ink); }
.prose a { color: var(--cobalt); overflow-wrap: anywhere; }
:root[data-theme="dark"] .prose a { color: var(--signal); }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.4em; font-size: .95rem; }
.prose th, .prose td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font-weight: 700; color: var(--ink); border-bottom-width: 2px; }
.prose .table-scroll { overflow-x: auto; }
.prose code { font-family: inherit; font-weight: 700; background: var(--surface); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.callout { border-left: 4px solid var(--signal); background: var(--surface); padding: 14px 18px; border-radius: 0 10px 10px 0; margin: 0 0 1.4em; }

.aside { position: sticky; top: calc(var(--head) + 20px); display: grid; gap: 22px; }
@media (max-width: 960px) { .aside { position: static; } }
.aside h3 { font-size: 1rem; margin-bottom: 10px; }
.aside ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.aside li a { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 600; }
.aside li a:hover { color: var(--cobalt); }
:root[data-theme="dark"] .aside li a:hover { color: var(--signal); }

.faq details { border-bottom: 1px solid var(--line); }
.faq details:first-of-type { border-top: 1px solid var(--line); }
.faq summary { cursor: pointer; list-style: none; padding: 16px 36px 16px 0; font-weight: 700; color: var(--ink); position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 4px; top: 12px; font-size: 1.4rem; font-weight: 500; color: var(--muted); }
.faq details[open] summary::after { content: "−"; }
.faq details > div { padding: 0 0 16px; }

/* page header for inner pages */
.page-top { background: var(--cobalt); color: #fff; padding: 40px 0 34px; }
.page-top h1 { color: #fff; margin-bottom: 8px; }
.page-top p { color: var(--on-cobalt-2); margin: 0; max-width: 640px; font-size: 1.05rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 14px; font-size: .88rem; color: var(--on-cobalt-2); }
.crumbs a { color: var(--on-cobalt-2); }
.crumbs li + li::before { content: "/"; margin-right: 6px; opacity: .6; }

/* forms (calculator, contact) */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-weight: 650; font-size: .92rem; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font: 500 1rem var(--font);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(31, 62, 224, .25); }
.textarea { min-height: 160px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .two { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
@media (max-width: 560px) { .card { padding: 18px; } }
.big-out { font-weight: 800; font-stretch: 122%; font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); line-height: 1.1; color: var(--cobalt); font-variant-numeric: tabular-nums; }
:root[data-theme="dark"] .big-out { color: var(--signal); }
.ok-msg { padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--good); color: var(--ink); font-size: .94rem; }

.guide-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.guide-list li { padding: 20px 0; border-bottom: 1px solid var(--line); }
.guide-list a { font-weight: 750; font-size: 1.2rem; font-stretch: 110%; text-decoration: none; color: var(--ink); }
.guide-list a:hover { color: var(--cobalt); }
.guide-list p { margin: 6px 0 0; color: var(--muted); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); padding: 44px 0 28px; margin-top: 30px; font-size: .94rem; }
.foot-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 28px; }
@media (max-width: 820px) { .foot-grid { grid-template-columns: 1fr 1fr; } .foot-grid > :first-child { grid-column: 1 / -1; } }
.foot .logo { color: var(--ink); }
.foot .logo svg rect { fill: var(--cobalt); }
.foot p { color: var(--muted); margin-top: 12px; max-width: 34ch; }
.foot h4 { margin: 0 0 10px; font-size: .95rem; }
.foot ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.foot ul a { text-decoration: none; color: var(--ink-2); }
.foot ul a:hover { color: var(--cobalt); text-decoration: underline; }
.foot-base { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 10px; font-weight: 650; font-size: .92rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
