/* ==========================================================================
   GoZen Host Speed Test — Endpoint Styles (Real Gauge)
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* --- Background layers -------------------------------------------------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, var(--glow-top) 0%, transparent 70%),
    radial-gradient(ellipse 50% 30% at 20% 80%, var(--glow-bottom-left) 0%, transparent 60%),
    radial-gradient(ellipse 40% 25% at 85% 70%, var(--glow-bottom-right) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
  z-index: 0;
}

:root,
[data-theme="light"] {
  --glow-top: rgba(30, 58, 138, 0.07);
  --glow-bottom-left: rgba(59, 130, 246, 0.04);
  --glow-bottom-right: rgba(124, 58, 237, 0.03);
  --grid-color: rgba(30, 58, 138, 0.03);
  --accent-line: linear-gradient(90deg, transparent, var(--brand-primary), var(--brand-blue), transparent);
  --btn-glow: rgba(30, 58, 138, 0.25);
  --result-bg: rgba(255, 255, 255, 0.7);
  --result-border: rgba(30, 58, 138, 0.08);
  --gauge-track: rgba(30, 58, 138, 0.08);
  --gauge-face: rgba(255, 255, 255, 0.5);
  --gauge-face-border: rgba(30, 58, 138, 0.06);
  --gauge-tick-color: rgba(30, 58, 138, 0.18);
  --gauge-tick-major: rgba(30, 58, 138, 0.28);
  --gauge-label-color: rgba(30, 58, 138, 0.45);
}

[data-theme="dark"] {
  --glow-top: rgba(59, 130, 246, 0.08);
  --glow-bottom-left: rgba(124, 58, 237, 0.05);
  --glow-bottom-right: rgba(59, 130, 246, 0.03);
  --grid-color: rgba(59, 130, 246, 0.025);
  --accent-line: linear-gradient(90deg, transparent, var(--brand-blue), #7C3AED, transparent);
  --btn-glow: rgba(59, 130, 246, 0.3);
  --result-bg: rgba(26, 34, 54, 0.7);
  --result-border: rgba(59, 130, 246, 0.08);
  --gauge-track: rgba(148, 163, 184, 0.07);
  --gauge-face: rgba(16, 23, 42, 0.7);
  --gauge-face-border: rgba(59, 130, 246, 0.06);
  --gauge-tick-color: rgba(148, 163, 184, 0.12);
  --gauge-tick-major: rgba(148, 163, 184, 0.25);
  --gauge-label-color: rgba(148, 163, 184, 0.45);
}

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

img { max-width: 100%; height: auto; display: block; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}


/* --- Layout ------------------------------------------------------------- */
.page-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 700px;
  margin-inline: auto;
  padding-inline: var(--space-xl);
}

.page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}


/* ==========================================================================
   Header — matched to gozenhosting.com
   ========================================================================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-xl);
  gap: var(--space-xl);
}

.header__brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.header__logo { height: 38px; width: auto; }

[data-theme="dark"] .header__logo--light { display: none; }
[data-theme="light"] .header__logo--dark,
:root:not([data-theme="dark"]) .header__logo--dark { display: none; }

/* Navigation links */
.header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-2xl);
}

.header__link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--duration-fast) ease;
}

.header__link:hover {
  color: var(--color-text);
  text-decoration: none;
}

/* Right-side actions */
.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex-shrink: 0;
}

.header__cta {
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary-text);
  background: var(--color-primary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration-fast) ease;
}

.header__cta:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}

.theme-toggle:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle__sun, .theme-toggle__moon { display: none; }

[data-theme="light"] .theme-toggle__moon,
:root:not([data-theme="dark"]) .theme-toggle__moon { display: block; }
[data-theme="dark"] .theme-toggle__sun { display: block; }


/* ==========================================================================
   Speed Test
   ========================================================================== */
.speedtest {
  padding: var(--space-xl) 0 var(--space-3xl);
}

.speedtest__heading {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.speedtest__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-3xl);
  letter-spacing: -0.04em;
  color: var(--color-text);
  line-height: var(--leading-tight);
}

/* --- Server Badge ------------------------------------------------------- */
.speedtest__server-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0 auto var(--space-2xl);
  padding: 6px var(--space-lg) 6px var(--space-md);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--result-bg);
  border: 1px solid var(--result-border);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.speedtest__server-badge svg {
  width: 14px;
  height: 14px;
  color: var(--color-accent);
  flex-shrink: 0;
}

.speedtest__server-badge strong {
  font-weight: 600;
  color: var(--color-text);
}


/* ==========================================================================
   Gauge — 240° arc, real gauge style
   ========================================================================== */
.gauge-wrapper {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.gauge {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 460px;
}

.gauge__svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

/* Inner gauge face — subtle circle behind the button */
.gauge__face {
  fill: var(--gauge-face);
  stroke: var(--gauge-face-border);
  stroke-width: 1;
}

/* Track arc */
.gauge__track {
  stroke: var(--gauge-track);
}

/* Fill arc — gradient stroke, glow filter */
.gauge__fill {
  stroke: url(#grad-dl);
  stroke-dasharray: 628;
  stroke-dashoffset: 628;
  transition: stroke-dashoffset 0.15s ease-out;
}

/* Tick marks (generated by JS) */
.gauge__tick {
  stroke: var(--gauge-tick-color);
  stroke-width: 1;
  stroke-linecap: round;
}

.gauge__tick--major {
  stroke: var(--gauge-tick-major);
  stroke-width: 2;
}

.gauge__tick--mid {
  stroke: var(--gauge-tick-color);
  stroke-width: 1.5;
}

.gauge__tick--minor {
  stroke: var(--gauge-tick-color);
  stroke-width: 0.8;
}

/* Tick labels */
.gauge__tick-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  fill: var(--gauge-label-color);
}


/* --- Gauge center overlay ----------------------------------------------- */
.gauge__center {
  position: absolute;
  /* Center point matches SVG circle center: (200/400, 190/280) */
  top: 67.8%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.gauge__start-btn {
  pointer-events: auto;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-primary-text);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-top: var(--space-sm);
  box-shadow:
    0 0 0 3px var(--color-bg),
    0 0 0 5px var(--color-primary),
    0 0 40px var(--btn-glow);
}

.gauge__start-btn:hover {
  background: var(--color-primary-hover);
  box-shadow:
    0 0 0 3px var(--color-bg),
    0 0 0 5px var(--color-primary-hover),
    0 0 56px var(--btn-glow);
}

.gauge__start-btn[data-state="running"] {
  width: 72px;
  height: 72px;
  font-size: var(--text-sm);
  background: var(--brand-error);
  box-shadow:
    0 0 0 3px var(--color-bg),
    0 0 0 5px var(--brand-error),
    0 0 32px rgba(239, 68, 68, 0.25);
}

.gauge__start-btn[data-state="finished"] {
  background: var(--brand-success);
  box-shadow:
    0 0 0 3px var(--color-bg),
    0 0 0 5px var(--brand-success),
    0 0 40px rgba(16, 185, 129, 0.25);
}

/* Live value display above button */
.gauge__live-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  min-height: 14px;
}

.gauge__live-value {
  font-family: var(--font-mono);
  font-size: var(--text-4xl);
  font-weight: 700;
  line-height: 1;
  color: var(--color-text);
  min-height: 40px;
}

.gauge__live-unit {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  min-height: 16px;
}


/* --- Accent Line -------------------------------------------------------- */
.speedtest__divider {
  height: 1px;
  background: var(--accent-line);
  margin-bottom: var(--space-3xl);
  border: none;
}


/* ==========================================================================
   Results Grid
   ========================================================================== */
.speedtest__results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.speedtest__metric {
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
  border-radius: var(--radius-md);
  background: var(--result-bg);
  border: 1px solid var(--result-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.speedtest__metric--active {
  border-color: var(--color-accent);
}

.speedtest__metric-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.speedtest__metric-value {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.speedtest__metric-unit {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.speedtest__metric-progress {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--color-track);
  margin-top: var(--space-lg);
  overflow: hidden;
}

.speedtest__metric-progress-fill {
  height: 100%;
  border-radius: 2px;
  width: 0%;
}

.speedtest__metric--download .speedtest__metric-value { color: var(--color-download); }
.speedtest__metric--download .speedtest__metric-progress-fill { background: var(--color-download); }
.speedtest__metric--upload .speedtest__metric-value { color: var(--color-upload); }
.speedtest__metric--upload .speedtest__metric-progress-fill { background: var(--color-upload); }
.speedtest__metric--ping .speedtest__metric-value { color: var(--color-ping); }
.speedtest__metric--ping .speedtest__metric-progress-fill { background: var(--color-ping); }
.speedtest__metric--jitter .speedtest__metric-value { color: var(--color-jitter); }
.speedtest__metric--jitter .speedtest__metric-progress-fill { background: var(--color-jitter); }


/* --- Client IP ---------------------------------------------------------- */
.speedtest__client-info {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.speedtest__client-ip {
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
}


/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  padding: var(--space-xl) var(--space-xl) var(--space-2xl);
  text-align: center;
}

.footer__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  flex-wrap: wrap;
}

.footer__sep { color: var(--color-border); }
.footer__inner a { color: var(--color-text-muted); }
.footer__inner a:hover { color: var(--color-text); text-decoration: none; }

.footer__brand-link {
  font-weight: 600;
  color: var(--color-text-secondary) !important;
}


/* ==========================================================================
   Responsive — Mobile-first touch-target compliance
   ========================================================================== */

/* --- Tablet (≤ 768px) --------------------------------------------------- */
@media (max-width: 768px) {
  .container { max-width: 560px; }
  .gauge { max-width: 400px; }
  .header__nav { display: none; }
}

/* --- Mobile (≤ 600px) --------------------------------------------------- */
@media (max-width: 600px) {
  .container { padding-inline: var(--space-lg); }

  .header__inner { padding: var(--space-md) var(--space-lg); }
  .header__logo { height: 30px; }
  .header__cta { padding: 6px 14px; font-size: var(--text-xs); }

  .speedtest { padding: var(--space-lg) 0 var(--space-2xl); }
  .speedtest__title { font-size: var(--text-2xl); }
  .speedtest__heading { margin-bottom: var(--space-md); }
  .speedtest__server-badge { margin-bottom: var(--space-xl); }

  .gauge { max-width: 320px; }
  .gauge-wrapper { margin-bottom: var(--space-xl); }

  .gauge__start-btn {
    width: 80px;
    height: 80px;
    font-size: var(--text-sm);
  }

  .gauge__start-btn[data-state="running"] {
    width: 64px;
    height: 64px;
  }

  .gauge__live-value { font-size: var(--text-2xl); }

  .speedtest__divider { margin-bottom: var(--space-2xl); }

  .speedtest__results { gap: var(--space-md); }

  .speedtest__metric {
    padding: var(--space-lg) var(--space-md);
  }

  .speedtest__metric-value { font-size: var(--text-xl); }

  /* Touch targets: ensure all tappable elements are ≥ 44x44 */
  .theme-toggle {
    width: 44px;
    height: 44px;
  }

  .footer__inner { gap: var(--space-md); }
}

/* --- Small Mobile (≤ 380px) --------------------------------------------- */
@media (max-width: 380px) {
  .container { padding-inline: var(--space-md); }

  .speedtest__title { font-size: var(--text-xl); }
  .header__cta { display: none; }

  .gauge { max-width: 260px; }

  .gauge__start-btn {
    width: 68px;
    height: 68px;
    font-size: 0.75rem;
  }

  .gauge__start-btn[data-state="running"] {
    width: 56px;
    height: 56px;
  }

  .gauge__live-value { font-size: var(--text-xl); }

  .speedtest__results { gap: var(--space-sm); }

  .speedtest__metric {
    padding: var(--space-md) var(--space-sm);
  }

  .speedtest__metric-value { font-size: var(--text-lg); }
  .speedtest__metric-label { font-size: 0.5625rem; }
}

/* --- Landscape mobile --------------------------------------------------- */
@media (max-height: 500px) and (orientation: landscape) {
  .speedtest { padding: var(--space-md) 0 var(--space-lg); }
  .speedtest__heading { margin-bottom: var(--space-sm); }
  .speedtest__server-badge { margin-bottom: var(--space-md); }
  .gauge-wrapper { margin-bottom: var(--space-md); }
  .gauge { max-width: 280px; }
  .speedtest__divider { margin-bottom: var(--space-lg); }
}
