/* Snyder speed test. Every colour, shadow and font is a brandOS token from assets/brand/*.css;
   data-brand="snyder" and the resolved data-theme on <html> select the palette. */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--brandOS-font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--brandOS-text-primary);
  background: radial-gradient(1100px 520px at 50% -180px, color-mix(in oklch, var(--brandOS-brand) 14%, transparent), transparent 70%), var(--brandOS-background-primary);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition:
    background-color 0.3s,
    color 0.3s;
}

a {
  color: inherit;
}

button,
select {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--brandOS-border-focus);
  outline-offset: 3px;
}

.visually-hidden,
.copy-buffer {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 20px 28px;
}

/* Header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  border-radius: var(--brandOS-radius-sm);
}

.brand-logo {
  display: block;
}

.brand-logo svg {
  display: block;
  width: auto;
  height: 34px;
}

.brand-logo-on-dark,
[data-theme='dark'] .brand-logo-on-light {
  display: none;
}

[data-theme='dark'] .brand-logo-on-dark {
  display: block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.server-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 36px;
  padding: 0 6px 0 14px;
  border: 1px solid var(--brandOS-border-subtle);
  border-radius: var(--brandOS-radius-full);
  background: var(--brandOS-background-elevated);
  color: var(--brandOS-text-secondary);
}

.server-picker select {
  min-width: 0;
  max-width: 260px;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--brandOS-text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  cursor: pointer;
}

.server-picker select:disabled {
  cursor: default;
}

.server-picker svg,
.icon-btn svg,
.btn-secondary svg,
.metric-label svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.server-picker svg {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--brandOS-brand);
}

.icon-btn {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--brandOS-border-subtle);
  border-radius: var(--brandOS-radius-full);
  background: var(--brandOS-background-elevated);
  color: var(--brandOS-text-primary);
  cursor: pointer;
  transition: border-color 0.2s;
}

.icon-btn:hover {
  border-color: var(--brandOS-brand);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-sun,
[data-theme='dark'] .icon-moon {
  display: none;
}

[data-theme='dark'] .icon-sun {
  display: block;
}

/* Panels */

.panel {
  border: 1px solid var(--brandOS-border-subtle);
  border-radius: 20px;
  background: var(--brandOS-background-elevated);
  box-shadow: var(--brandOS-shadow-md);
  padding: 28px;
  transition:
    background-color 0.3s,
    border-color 0.3s;
}

.test {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  align-items: center;
  gap: 40px;
}

/* Gauge: the arc and the active phase share currentColor. */

.gauge {
  position: relative;
  width: 100%;
  max-width: 370px;
  margin: 0 auto;
  aspect-ratio: 1;
  color: var(--brandOS-brand);
  transition: color 0.4s;
}

.gauge[data-phase='upload'] {
  color: var(--brandOS-dataviz-cat-4);
}

.gauge[data-phase='ping'] {
  color: var(--brandOS-dataviz-cat-2);
}

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

.gauge-track,
.gauge-value {
  fill: none;
  stroke-width: 18;
  stroke-linecap: round;
}

.gauge-track {
  stroke: var(--brandOS-border-subtle);
}

.gauge-value {
  stroke: currentColor;
  stroke-dasharray: 100 100;
  stroke-dashoffset: 100;
  transition:
    stroke-dashoffset 0.35s ease-out,
    opacity 0.2s;
}

[data-theme='dark'] .gauge-value {
  filter: drop-shadow(0 0 10px color-mix(in oklch, currentColor 45%, transparent));
}

.gauge-value.is-empty {
  opacity: 0;
}

.gauge-ticks line {
  stroke: var(--brandOS-border-default);
  stroke-width: 2;
  stroke-linecap: round;
}

.gauge-ticks text {
  fill: var(--brandOS-text-tertiary);
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
}

.gauge-readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 4%;
  pointer-events: none;
}

.gauge-phase {
  color: var(--brandOS-text-secondary);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.gauge-number {
  color: var(--brandOS-text-primary);
  font-family: var(--brandOS-font-heading);
  font-size: clamp(46px, 11vw, 66px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.08;
}

.gauge-unit {
  color: var(--brandOS-text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.start-btn {
  position: absolute;
  left: 50%;
  bottom: 4%;
  min-width: 150px;
  height: 46px;
  padding: 0 24px;
  transform: translateX(-50%);
  border: 1.5px solid transparent;
  border-radius: var(--brandOS-radius-full);
  background: var(--brandOS-interactive-primary);
  color: var(--brandOS-text-on-primary);
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in oklch, var(--brandOS-interactive-primary) 35%, transparent);
  transition:
    background-color 0.2s,
    color 0.2s,
    border-color 0.2s,
    box-shadow 0.2s;
}

.start-btn:hover:not(:disabled) {
  background: var(--brandOS-interactive-primary-hover);
}

.start-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.start-btn.is-running {
  border-color: var(--brandOS-border-default);
  background: var(--brandOS-background-elevated);
  color: var(--brandOS-text-primary);
  box-shadow: none;
}

.start-btn.is-running:hover {
  border-color: var(--brandOS-text-secondary);
  background: var(--brandOS-background-tertiary);
}

/* Results */

.details {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.status {
  min-height: 1.5em;
  margin: 0;
  color: var(--brandOS-text-secondary);
  font-size: 15px;
  font-weight: 500;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--brandOS-background-tertiary);
  transition:
    border-color 0.25s,
    box-shadow 0.25s,
    background-color 0.3s;
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--brandOS-text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.metric-label svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.4;
}

.metric-value {
  margin-top: 6px;
  color: var(--brandOS-text-primary);
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.metric-unit {
  margin-left: 5px;
  color: var(--brandOS-text-secondary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}

.metric-bar {
  height: 4px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: var(--brandOS-radius-full);
  background: var(--brandOS-border-subtle);
}

.metric-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 0.3s linear;
}

/* Per-metric accents: download uses the brand colour, upload and latency two dataviz categories. */

.metric-dl .metric-label svg {
  color: var(--brandOS-brand);
}

.metric-dl .metric-bar span {
  background: var(--brandOS-brand);
}

.metric-dl.is-active {
  border-color: color-mix(in oklch, var(--brandOS-brand) 55%, transparent);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--brandOS-brand) 14%, transparent);
}

.metric-ul .metric-label svg {
  color: var(--brandOS-dataviz-cat-4);
}

.metric-ul .metric-bar span {
  background: var(--brandOS-dataviz-cat-4);
}

.metric-ul.is-active {
  border-color: color-mix(in oklch, var(--brandOS-dataviz-cat-4) 55%, transparent);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--brandOS-dataviz-cat-4) 14%, transparent);
}

:is(.metric-ping, .metric-jitter) .metric-label svg {
  color: var(--brandOS-dataviz-cat-2);
}

:is(.metric-ping, .metric-jitter) .metric-bar span {
  background: var(--brandOS-dataviz-cat-2);
}

:is(.metric-ping, .metric-jitter).is-active {
  border-color: color-mix(in oklch, var(--brandOS-dataviz-cat-2) 55%, transparent);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--brandOS-dataviz-cat-2) 14%, transparent);
}

.connection {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px 20px;
  margin: 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--brandOS-border-subtle);
}

.connection dt {
  color: var(--brandOS-text-tertiary);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.connection dd {
  margin: 3px 0 0;
  color: var(--brandOS-text-primary);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--brandOS-border-subtle);
  border-radius: 10px;
  background: var(--brandOS-background-elevated);
  color: var(--brandOS-text-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.2s,
    opacity 0.2s;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--brandOS-brand);
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-secondary svg {
  width: 16px;
  height: 16px;
}

/* Links */

.links {
  display: grid;
  gap: 24px;
  margin-top: 20px;
}

.link-group h2 {
  margin: 0 0 12px;
  color: var(--brandOS-text-secondary);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 10px;
}

.tile {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--brandOS-border-subtle);
  border-radius: 12px;
  background: var(--brandOS-background-elevated);
  color: var(--brandOS-text-primary);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  transition:
    border-color 0.2s,
    transform 0.2s,
    box-shadow 0.2s;
}

/* Third-party logos keep their own colours, so they sit on a light chip in both themes. */
.tile-icon {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--brandOS-border-subtle);
  border-radius: 8px;
  background: var(--brandOS-gray-050);
}

.tile-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.tile-label {
  flex: 1;
  min-width: 0;
}

.tile:hover {
  border-color: var(--brandOS-brand);
  box-shadow: 0 4px 14px color-mix(in oklch, var(--brandOS-brand) 14%, transparent);
  transform: translateY(-1px);
}

/* Footer */

.footer {
  margin-top: auto;
  padding-top: 30px;
  color: var(--brandOS-text-tertiary);
  font-size: 13px;
  text-align: center;
}

.footer p {
  margin: 3px 0;
}

.footer a {
  color: var(--brandOS-text-secondary);
}

/* Dark theme: navy surfaces for this page only. The Snyder profile's dark greys are neutral, so the
   brand colour is mixed into black. Mix in OKLab: OKLCH would interpolate hue from the brand blue
   to black's 0° and turn the surfaces purple. Every colour still derives from brandOS tokens. */

[data-theme='dark'] body {
  background:
    radial-gradient(1100px 520px at 50% -180px, color-mix(in oklab, var(--brandOS-brand) 22%, transparent), transparent 70%), color-mix(in oklab, var(--brandOS-brand) 18%, var(--brandOS-gray-1000));
}

[data-theme='dark'] :is(.panel, .server-picker, .icon-btn, .tile, .btn-secondary, .start-btn.is-running) {
  border-color: color-mix(in oklab, var(--brandOS-brand) 34%, var(--brandOS-gray-1000));
  background: color-mix(in oklab, var(--brandOS-brand) 24%, var(--brandOS-gray-1000));
}

[data-theme='dark'] :is(.metric, .start-btn.is-running:hover) {
  background: color-mix(in oklab, var(--brandOS-brand) 30%, var(--brandOS-gray-1000));
}

[data-theme='dark'] .connection {
  border-color: color-mix(in oklab, var(--brandOS-brand) 34%, var(--brandOS-gray-1000));
}

[data-theme='dark'] .metric-bar {
  background: color-mix(in oklab, var(--brandOS-brand) 36%, var(--brandOS-gray-1000));
}

[data-theme='dark'] .gauge-track {
  stroke: color-mix(in oklab, var(--brandOS-brand) 36%, var(--brandOS-gray-1000));
}

/* Responsive */

@media (max-width: 860px) {
  .test {
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .gauge {
    max-width: 340px;
  }
}

@media (max-width: 560px) {
  .page {
    padding: 16px 14px 22px;
  }

  .topbar {
    margin-bottom: 16px;
  }

  .brand-logo svg {
    height: 26px;
  }

  .server-picker select {
    max-width: 150px;
    font-size: 12px;
  }

  .panel {
    padding: 20px 16px;
    border-radius: 16px;
  }

  .metrics {
    gap: 10px;
  }

  .metric {
    padding: 12px 13px;
  }

  .metric-value {
    font-size: 24px;
  }

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

  .tile {
    font-size: 13px;
  }
}

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