/* Response-speed section of the landing page (en/ and ja/index.html) and the hero badge that links to it.
   The section is a dark band like the demo section. Its tabs, race and results are drawn by speed-section.js
   from latency-data.js. */

/* Hero badge */
.speed-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  margin-bottom: 20px;
  padding: 4px 16px 4px 4px;
  border: 1px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(90deg, #0094de, #a6e99a) border-box;
  box-shadow: 0 6px 20px rgba(0, 148, 222, 0.14);
  color: #000b0f;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  text-decoration: none;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.speed-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(0, 148, 222, 0.22);
}
.speed-badge:focus-visible {
  outline: 2px solid #0094de;
  outline-offset: 3px;
}
.speed-badge-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, #007dbc, #0094de 45%, #89d8ff);
  color: #fff;
}
.speed-badge-icon svg {
  width: 14px;
  height: 14px;
}
.speed-badge-arrow {
  flex: none;
  transition: transform 0.2s ease;
}
.speed-badge:hover .speed-badge-arrow {
  transform: translateX(3px);
}
/* Small phones keep the badge on one line */
@media (max-width: 374px) {
  .speed-badge {
    gap: 8px;
    padding: 3px 14px 3px 3px;
    font-size: 12px;
  }
  .speed-badge-icon {
    width: 24px;
    height: 24px;
  }
}

/* Marks in running text, in a Latin face: Japanese fonts draw † full width */
.speed-sym {
  font-family: Arial, 'Helvetica Neue', sans-serif;
}
/* Japanese text with <wbr> between phrases breaks only there */
.speed-phrases {
  word-break: keep-all;
  overflow-wrap: anywhere;
}

/* The section */
#speed {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin-bottom: 48px;
  background: #0c0b24;
  color: #fff;
  font-family: 'Noto Sans JP', sans-serif;
  /* Japanese lines break between phrases where the browser supports it */
  word-break: auto-phrase;
}
#speed *,
#speed *::before,
#speed *::after {
  box-sizing: border-box;
}
/* Glow behind the race and a faint grid */
#speed::before,
#speed::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
#speed::before {
  background:
    radial-gradient(46% 58% at 76% 42%, rgba(0, 148, 222, 0.26), transparent 72%),
    radial-gradient(34% 44% at 4% 100%, rgba(166, 233, 154, 0.12), transparent 70%);
}
#speed::after {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(70% 80% at 72% 40%, #000 15%, transparent 75%);
  mask-image: radial-gradient(70% 80% at 72% 40%, #000 15%, transparent 75%);
}

#speed .speed-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 56px 24px 48px;
}
#speed .speed-layout {
  display: grid;
  gap: 32px;
}

#speed .speed-eyebrow {
  margin: 0 0 16px;
  font-family: Switzer, sans-serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  color: #38b6f5;
}
#speed .speed-title {
  margin: 0 0 20px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.01em;
}
#speed .speed-grad {
  background: linear-gradient(90deg, #1ea7ef 0%, #89d8ff 55%, #b9f0b1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#speed .speed-lead {
  max-width: 34em;
  margin: 0;
  font-size: 16px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.76);
}

/* Test tabs: one card per test with DigiSelf's time */
#speed .speed-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 28px;
}
#speed .speed-stat {
  position: relative;
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  padding: 12px 12px 14px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
/* 1px frame; the demo panels' gradient when selected */
#speed .speed-stat::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.12);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
#speed .speed-stat:hover {
  background: rgba(255, 255, 255, 0.07);
}
#speed .speed-stat[aria-selected='true'] {
  background: rgba(0, 148, 222, 0.14);
}
#speed .speed-stat[aria-selected='true']::before {
  background: linear-gradient(90deg, #0094de, #daf3ff);
}
#speed .speed-stat-label {
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.76);
}
#speed .speed-stat-value {
  font-family: Switzer, sans-serif;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.86);
}
#speed .speed-stat[aria-selected='true'] .speed-stat-num {
  background: linear-gradient(90deg, #4cc3ff, #daf3ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#speed .speed-stat-unit {
  margin-left: 0.12em;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.5em;
  font-weight: 500;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.76);
}
#speed .speed-stat-next {
  font-size: 11px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.6);
}

/* Race */
#speed .speed-race {
  position: relative;
  min-width: 0;
  padding: 20px 16px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
}
#speed .speed-race-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
#speed .speed-race-def {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.76);
}
/* "Shorter is better" wraps as a whole */
#speed .speed-race-def span {
  display: inline-block;
}
#speed .speed-replay {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
#speed .speed-replay:hover {
  background: rgba(255, 255, 255, 0.1);
}
#speed .speed-replay svg {
  width: 14px;
  height: 14px;
}
#speed .speed-stat:focus-visible,
#speed .speed-replay:focus-visible,
#speed .speed-more summary:focus-visible {
  outline: 2px solid #4cc3ff;
  outline-offset: 3px;
}

#speed .speed-chart {
  position: relative;
}
#speed .speed-gridlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#speed .speed-gridlines span {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.06);
}
#speed .speed-lanes {
  position: relative;
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
#speed .speed-lane {
  display: grid;
  gap: 7px;
  border-radius: 4px;
}
#speed .speed-lane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  line-height: 1.4;
}
#speed .speed-lane-name {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
  color: rgba(255, 255, 255, 0.76);
}
#speed .speed-lane-time {
  font-family: Switzer, sans-serif;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.4);
  transition: color 0.2s ease;
}
#speed .speed-lane.is-done .speed-lane-time {
  color: rgba(255, 255, 255, 0.8);
}
#speed .speed-lane.is-self .speed-lane-name,
#speed .speed-lane.is-self .speed-lane-time {
  color: #fff;
  font-weight: 700;
}
#speed .speed-lane-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}
#speed .speed-lane-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-radius: inherit;
  background: rgba(196, 207, 255, 0.34);
}
#speed .speed-lane.is-self .speed-lane-bar {
  background: linear-gradient(90deg, #0071a8, #0094de 45%, #89d8ff);
  box-shadow: 0 0 18px rgba(0, 148, 222, 0.6);
}
/* DigiSelf's finish: a ring at the end of its bar and a "1st" chip */
#speed .speed-lane.is-self .speed-lane-bar::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -3px;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border-radius: 50%;
  background: #daf3ff;
  box-shadow: 0 0 12px rgba(137, 216, 255, 0.9);
  opacity: 0;
  transform: scale(0.4);
  transition:
    opacity 0.2s ease,
    transform 0.3s cubic-bezier(0.2, 0.9, 0.2, 1.4);
}
#speed .speed-lane.is-self.is-done .speed-lane-bar::after {
  opacity: 1;
  transform: scale(1);
  animation: speed-ping 1.4s ease-out 0.15s 2;
}
#speed .speed-first {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 8px 1px 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #4cc3ff, #daf3ff);
  color: #0c0b24;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity 0.2s ease,
    transform 0.35s cubic-bezier(0.2, 0.9, 0.2, 1.4);
}
#speed .speed-first svg {
  width: 11px;
  height: 11px;
}
#speed .speed-lane.is-done .speed-first {
  opacity: 1;
  transform: scale(1);
}
@keyframes speed-ping {
  0% {
    box-shadow:
      0 0 12px rgba(137, 216, 255, 0.9),
      0 0 0 0 rgba(137, 216, 255, 0.55);
  }
  100% {
    box-shadow:
      0 0 12px rgba(137, 216, 255, 0.9),
      0 0 0 14px rgba(137, 216, 255, 0);
  }
}

#speed .speed-axis {
  position: relative;
  height: 16px;
  margin-top: 12px;
  font-family: Switzer, sans-serif;
  font-size: 11px;
  line-height: 16px;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
}
#speed .speed-axis span {
  position: absolute;
  top: 0;
  white-space: nowrap;
  transform: translateX(-50%);
}
#speed .speed-axis span:first-child {
  transform: none;
}
#speed .speed-axis span:last-child {
  transform: translateX(-100%);
}

/* All results and how they were measured */
#speed .speed-notes {
  margin-top: 32px;
  font-size: 12px;
  line-height: 1.75;
  color: rgba(255, 255, 255, 0.62);
}
#speed .speed-notes p {
  max-width: 980px;
  margin: 0 0 6px;
}
#speed .speed-more summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  list-style: none;
}
#speed .speed-more summary::-webkit-details-marker {
  display: none;
}
#speed .speed-more summary::after {
  content: '';
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}
#speed .speed-more[open] summary::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}
#speed .speed-more summary:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
#speed .speed-table-wrap {
  margin: 12px 0 10px;
  overflow-x: auto;
}
#speed .speed-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
  font-variant-numeric: tabular-nums;
}
#speed .speed-table caption {
  padding-bottom: 8px;
  text-align: left;
  color: rgba(255, 255, 255, 0.62);
}
#speed .speed-table th,
#speed .speed-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
  vertical-align: top;
}
#speed .speed-table thead th {
  border-bottom-color: rgba(255, 255, 255, 0.24);
  font-weight: 700;
  color: #fff;
}
#speed .speed-table thead th span {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.6);
}
#speed .speed-table tbody th {
  font-weight: 500;
}
#speed .speed-table tr.is-self th,
#speed .speed-table tr.is-self td {
  background: rgba(0, 148, 222, 0.18);
  color: #fff;
  font-weight: 700;
}
#speed .speed-table .is-na {
  color: rgba(255, 255, 255, 0.45);
}

@media (min-width: 480px) {
  #speed .speed-race {
    padding: 24px 24px 18px;
  }
}
@media (max-width: 479px) {
  #speed .speed-stat-next,
  #speed .speed-axis .is-minor {
    display: none;
  }
  /* The replay button shows its icon only, leaving the width to the definition */
  #speed .speed-replay {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
  }
  #speed .speed-replay span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}
@media (min-width: 640px) {
  #speed .speed-title {
    font-size: 34px;
  }
  #speed .speed-stat {
    padding: 14px 16px 16px;
  }
  #speed .speed-stat-label {
    font-size: 13px;
  }
  #speed .speed-stat-value {
    font-size: 30px;
  }
  #speed .speed-stat-next {
    font-size: 12px;
  }
  #speed .speed-race-def {
    font-size: 14px;
  }
}
@media (min-width: 768px) {
  #speed {
    margin-bottom: 80px;
  }
}
@media (min-width: 1024px) {
  #speed .speed-inner {
    padding: 96px 24px 72px;
  }
  #speed .speed-title {
    font-size: 40px;
    line-height: 1.35;
  }
  #speed .speed-lead {
    font-size: 17px;
  }
  #speed .speed-stat-value {
    font-size: 36px;
  }
  #speed .speed-race {
    padding: 32px 36px 24px;
  }
  #speed .speed-lanes {
    gap: 16px;
  }
  #speed .speed-lane-head {
    font-size: 15px;
  }
}
/* Wide screens: the intro and the tabs beside the race */
@media (min-width: 1280px) {
  #speed .speed-layout {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    /* Top-aligned, so the race keeps its place when a test has fewer services */
    align-items: start;
    gap: 56px;
  }
  /* The tabs stack, number first */
  #speed .speed-stats {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 36px;
  }
  #speed .speed-stat {
    grid-template-columns: 150px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 16px;
    padding: 16px 22px;
  }
  #speed .speed-stat-value {
    grid-row: 1 / 3;
    grid-column: 1;
    font-size: 42px;
  }
  #speed .speed-stat-label {
    grid-row: 1;
    grid-column: 2;
    align-self: end;
    font-size: 16px;
    font-weight: 500;
    color: #fff;
  }
  #speed .speed-stat-next {
    grid-row: 2;
    grid-column: 2;
    align-self: start;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .speed-badge,
  .speed-badge-arrow,
  #speed .speed-first,
  #speed .speed-lane.is-self .speed-lane-bar::after {
    transition: none;
  }
  #speed .speed-lane.is-self.is-done .speed-lane-bar::after {
    animation: none;
  }
}
