/* ============================================================
   SA SpeedTest — styles.css
   TechBrew dark theme: #0a0a0a bg, #e8a020 amber accent
   ============================================================ */

:root {
  --bg: #0a0a0a;
  --card: #141414;
  --border: #1e1e1e;
  --border-light: #2a2a2a;
  --text: #fafafa;
  --muted: #a1a1aa;
  --accent: #e8a020;
  --accent-dim: rgba(232, 160, 32, 0.12);
  --accent-glow: rgba(232, 160, 32, 0.25);
  --green: #22c55e;
  --orange: #f97316;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 12px;
  --radius-lg: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --max-w: 900px;
  --transition: 0.2s ease;
}

/* ── LIGHT THEME VARIABLES ── */
:root[data-theme="light"] {
  --bg:           #ffffff;
  --card:         #f4f4f5;
  --border:       #e4e4e7;
  --border-light: #d4d4d8;
  --text:         #09090b;
  --muted:        #52525b;
  --accent:       #b8780a;
  --accent-dim:   rgba(184,120,10,.12);
  --accent-glow:  rgba(184,120,10,.25);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:           #ffffff;
    --card:         #f4f4f5;
    --border:       #e4e4e7;
    --border-light: #d4d4d8;
    --text:         #09090b;
    --muted:        #52525b;
    --accent:       #b8780a;
    --accent-dim:   rgba(184,120,10,.12);
    --accent-glow:  rgba(184,120,10,.25);
  }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== NAVIGATION (matches techbrew.co.za) ===== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(10,10,10,.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition), background var(--transition);
}
[data-theme="light"] .nav { background: rgba(255,255,255,.92); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .nav { background: rgba(255,255,255,.92); }
}

.nav.scrolled { border-bottom-color: var(--border); }

.nav__inner {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 64px;
}

.nav__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 1;
  transition: opacity var(--transition);
}

.nav__logo:hover { opacity: .8; }

.nav__logo-img {
  height: 36px;
  width: auto;
  display: block;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-left: auto;
  list-style: none;
}

.nav__links a {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--transition);
}

.nav__links a:hover { color: var(--text); }

.btn--nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-light);
  color: var(--text);
  background: transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
}

.btn--nav:hover {
  background: var(--card);
  border-color: var(--muted);
}

.nav__burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
}

.nav__burger span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--text);
  border-radius: 2px;
  transition: all var(--transition);
}

/* Container used by nav */
.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── THEME TOGGLE BUTTON ── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: none;
  border: 1px solid var(--border-light);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--card);
  color: var(--text);
  border-color: var(--muted);
}
.theme-toggle__moon { display: none; }
.theme-toggle__sun  { display: block; }
[data-theme="light"] .theme-toggle__moon { display: block; }
[data-theme="light"] .theme-toggle__sun  { display: none; }

/* Logo: invert white → black in light mode */
[data-theme="light"] .nav__logo-img { filter: invert(1); }

/* ===== AD SLOTS ===== */
.ad-slot {
  background: var(--card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70px;
  padding: 12px 20px;
  position: relative;
}

.ad-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--border-light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
}

/* Ad slots are hidden until AdSense is configured.
   Once you add your <ins> tags, the slot auto-shows via the adsbygoogle script.
   During development the .ad-slot divs are hidden by default. */
.ad-slot:not(:has(ins)):not(.ad-mid):not(.ad-bottom) {
  display: none;
}
.ad-slot.ad-mid, .ad-slot.ad-bottom {
  display: none; /* remove this line once AdSense is active */
}

/* ===== MAIN LAYOUT ===== */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px 60px;
  padding-top: 64px; /* offset for fixed nav */
}

/* ===== TEST SECTION ===== */
.test-section {
  padding: 60px 0 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.test-hero { margin-bottom: 40px; }

.test-title {
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.test-title .accent { color: var(--accent); }

.test-subtitle {
  font-size: 15px;
  color: var(--muted);
  max-width: 420px;
  margin: 0 auto;
}

/* ===== GAUGE ===== */
.gauge-container {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto 24px;
}

.gauge-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.gauge-track {
  transition: none;
}

.gauge-fill {
  transition: none;
  filter: drop-shadow(0 0 8px rgba(232, 160, 32, 0.4));
}

.gauge-speed-text {
  font-family: var(--mono);
  font-size: 52px;
  font-weight: 700;
  fill: var(--text);
  letter-spacing: -0.03em;
}

.gauge-unit-text {
  font-family: var(--mono);
  font-size: 13px;
  fill: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gauge-phase-text {
  font-family: var(--font);
  font-size: 11px;
  fill: var(--muted);
  letter-spacing: 0.02em;
}

.speed-rating {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
}

.speed-rating.hidden { display: none; }

.rating-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid currentColor;
}

.rating-slow    { color: var(--red);    background: rgba(239,68,68,0.1); }
.rating-average { color: var(--orange); background: rgba(249,115,22,0.1); }
.rating-good    { color: var(--accent); background: var(--accent-dim); }
.rating-fast    { color: var(--green);  background: rgba(34,197,94,0.1); }

/* ===== PHASE TRACK ===== */
.phase-track {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
}

.phase-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.phase-step span {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.phase-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-light);
  border: 2px solid var(--border-light);
  transition: all 0.3s ease;
}

.phase-line {
  width: 48px;
  height: 2px;
  background: var(--border-light);
  margin-bottom: 22px;
  transition: background 0.3s ease;
}

.phase-step.active .phase-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulseDot 1s ease-in-out infinite;
}

.phase-step.done .phase-dot {
  background: var(--green);
  border-color: var(--green);
}

.phase-step.done + .phase-line,
.phase-step.active + .phase-line {
  background: var(--accent);
}

@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 6px var(--accent-glow); }
  50% { box-shadow: 0 0 14px rgba(232, 160, 32, 0.5); }
}

/* ===== BUTTONS ===== */
.btn-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.btn-start {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #0a0a0a;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  padding: 14px 44px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 4px 20px rgba(232, 160, 32, 0.3);
  letter-spacing: 0.01em;
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(232, 160, 32, 0.4);
}

.btn-start:active { transform: translateY(0); }

.btn-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-retest {
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 20px;
  border: 1px solid var(--border-light);
  border-radius: 50px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.btn-retest:hover {
  color: var(--text);
  border-color: var(--muted);
}

.btn-retest.hidden { display: none; }

/* ===== RESULTS GRID ===== */
.results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 620px;
  margin-bottom: 28px;
}

.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: border-color 0.3s ease;
}

.result-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

.result-card.done {
  border-color: var(--border-light);
}

.result-icon {
  color: var(--muted);
  margin-bottom: 4px;
  transition: color 0.3s ease;
}

.result-card.active .result-icon,
.result-card.done .result-icon { color: var(--accent); }

.result-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.result-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  min-height: 28px;
}

.result-unit {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

/* ===== CONNECTION INFO ===== */
.connection-info {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 24px;
}

.conn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.conn-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.conn-value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

/* ===== SHARE BUTTONS ===== */
.share-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.share-row.hidden { display: none; }

.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 18px;
  border: 1px solid var(--border-light);
  border-radius: 50px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.btn-share:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* ===== AD SLOTS (visible version) ===== */
.ad-slot.ad-mid,
.ad-slot.ad-bottom {
  max-width: var(--max-w);
  margin: 0 auto;
  border-radius: var(--radius);
  border: 1px dashed var(--border-light);
  border-top: none;
  border-bottom: none;
}

/* ===== HISTORY ===== */
.history-section {
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

.section-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}

.history-table-wrapper { overflow-x: auto; }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table th {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.history-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}

.history-table tr:last-child td { border-bottom: none; }

/* ===== CONTENT SECTIONS ===== */
.content-section {
  padding: 60px 0;
  border-top: 1px solid var(--border);
}

.section-inner { max-width: 760px; margin: 0 auto; }

.content-intro {
  margin-bottom: 40px;
}

.content-intro h2,
.isp-section h2,
.howto-section h2 {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.content-intro p,
.isp-section p {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.7;
}

/* ===== BENCHMARK GRID ===== */
.benchmark-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 56px;
}

.benchmark-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
}

.benchmark-speed {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.benchmark-speed.slow    { color: var(--red); }
.benchmark-speed.average { color: var(--orange); }
.benchmark-speed.good    { color: var(--accent); }
.benchmark-speed.fast    { color: var(--green); }

.benchmark-label {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
}

.benchmark-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ===== ISP TABLE ===== */
.isp-section {
  margin-bottom: 56px;
}

.table-wrapper { overflow-x: auto; margin-top: 20px; }

.isp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.isp-table th {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.isp-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}

.isp-table tr:hover td { background: var(--card); }
.isp-table tr:last-child td { border-bottom: none; }

/* ===== TIPS GRID ===== */
.howto-section { margin-bottom: 20px; }

.tips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.tip-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.tip-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 8px;
}

.tip-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.tip-card p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* ===== FAQ ===== */
.faq-section {
  padding: 60px 0;
  border-top: 1px solid var(--border);
}

.faq-section h2 {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 32px;
}

.faq-list { display: flex; flex-direction: column; gap: 8px; }

.faq-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}

.faq-item[open] { border-color: var(--border-light); }

.faq-item summary {
  padding: 18px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  user-select: none;
  transition: color var(--transition);
}

.faq-item summary:hover { color: var(--accent); }

.faq-item summary::after {
  content: '+';
  font-size: 20px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform var(--transition), color var(--transition);
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
  color: var(--accent);
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item p {
  padding: 0 20px 20px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 40px 20px;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.footer-logo {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}

.footer-brand p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.footer-brand a {
  color: var(--accent);
  text-decoration: none;
}

.footer-links {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-links a:hover { color: var(--text); }

.footer-copy {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .nav__links, .btn--nav { display: none; }
  .nav__burger { display: flex; }

  .nav__links.open {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    position: absolute;
    top: 64px;
    left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 0 16px;
  }

  .nav__links.open li { width: 100%; }

  .nav__links.open a {
    display: block;
    padding: 12px 24px;
    font-size: 15px;
  }
}

@media (max-width: 640px) {
  .test-section { padding: 40px 0 28px; }

  .test-title { font-size: 24px; }

  .results-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 320px;
  }

  .benchmark-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .tips-grid {
    grid-template-columns: 1fr;
  }

  .connection-info { gap: 16px; }

  .phase-line { width: 28px; }

  .isp-table { font-size: 12px; }
  .isp-table th, .isp-table td { padding: 10px 10px; }
}

@media (max-width: 420px) {
  .results-grid { grid-template-columns: repeat(2, 1fr); }
  .benchmark-grid { grid-template-columns: repeat(2, 1fr); }
  .share-row { flex-direction: column; align-items: center; }
}
