/* The homepage is a teleprompter. Colors mirror the app's DesignSystem package. */

:root {
  --stage-top: #1d2129;
  --stage-bottom: #12141a;
  --ink: #f5f5f4;
  --ink-2: rgba(245, 245, 244, 0.62);
  --accent: #e8b64c;
  --on-accent: #202321;
  --pointer: #62a3f2;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-line: rgba(255, 255, 255, 0.1);

  --reading: 38vh;
  --prompt-size: clamp(28px, 4vw, 50px);
  --col: 880px;
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  color-scheme: dark;
}

@supports (height: 1svh) {
  :root {
    --reading: 38svh;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--stage-bottom);
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--stage-top), var(--stage-bottom)) fixed;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  padding: 8px 14px;
  background: #fff;
  color: #202321;
  border-radius: 8px;
  z-index: 20;
}

.skip:focus {
  left: 8px;
}

.col {
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Header */

.bar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: linear-gradient(180deg, rgba(29, 33, 41, 0.96) 55%, rgba(29, 33, 41, 0));
}

.bar .col {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img {
  width: 30px;
  height: 30px;
  border-radius: 7px;
}

.bar nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 15px;
}

.bar nav a:not(.button) {
  color: var(--ink-2);
  text-decoration: none;
}

.bar nav a:not(.button):hover {
  color: var(--ink);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 26px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 650;
  text-decoration: none;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.button:hover {
  filter: brightness(1.05);
}

.button:active {
  transform: scale(0.98);
}

.button svg {
  width: 20px;
  height: 20px;
}

.button-small {
  min-height: 36px;
  padding: 0 16px;
  font-size: 14px;
}

/* The reading line, with the app icon's pointer */

.reading-line {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--reading);
  z-index: 3;
  height: calc(var(--prompt-size) * 1.6);
  transform: translateY(-50%);
  background: rgba(98, 163, 242, 0.1);
  border-top: 1px solid rgba(98, 163, 242, 0.22);
  border-bottom: 1px solid rgba(98, 163, 242, 0.22);
  pointer-events: none;
}

.reading-line .col {
  position: relative;
  height: 100%;
}

.pointer {
  position: absolute;
  left: var(--gutter);
  top: 50%;
  width: clamp(22px, 2.6vw, 30px);
  height: clamp(22px, 2.6vw, 30px);
  transform: translateY(-50%);
}

/* Dims the lines that are not being read */

.fade {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(29, 33, 41, 0.94) 0,
    rgba(28, 32, 40, 0.6) calc(var(--reading) - 16vh),
    rgba(27, 30, 38, 0) calc(var(--reading) - 3vh),
    rgba(22, 25, 31, 0) calc(var(--reading) + 14vh),
    rgba(20, 22, 28, 0.6) 68vh,
    rgba(18, 20, 26, 0.97) 84vh,
    rgba(18, 20, 26, 0.97) 100vh
  );
  transition: opacity 0.6s ease;
}

.is-ended .fade {
  opacity: 0;
}

/* The script */

.script {
  position: relative;
  z-index: 1;
  padding-top: calc(var(--reading) - var(--prompt-size) * 0.675);
  padding-left: calc(var(--gutter) + clamp(34px, 4vw, 46px));
  font-size: var(--prompt-size);
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.012em;
  transition: transform 0.35s ease;
}

.script p {
  margin: 0 0 0.9em;
  text-wrap: pretty;
}

.script em {
  font-style: normal;
  color: var(--accent);
}

.is-mirrored .script {
  transform: scaleX(-1);
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.3em;
  border-radius: 0.22em;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-bottom-width: 3px;
  font-family: inherit;
  font-size: 0.78em;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  vertical-align: 0.06em;
}

.wpm-live {
  font-variant-numeric: tabular-nums;
}

/* Keyboard and touch wording */

.touch-only {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .touch-only {
    display: inline;
  }

  .keys-only {
    display: none;
  }
}

/* The end: call to action and footer */

.finale {
  position: relative;
  z-index: 4;
  padding-top: 0.4em;
  /* Just enough room for the button to stop on the reading line. */
  padding-bottom: max(96px, calc(100vh - var(--reading) - 250px));
  padding-left: calc(var(--gutter) + clamp(34px, 4vw, 46px));
}

.finale .lede {
  margin: 20px 0 0;
  max-width: 30em;
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.5;
}

.finale footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 48px;
  color: var(--ink-2);
  font-size: 14px;
}

.finale footer a {
  color: var(--ink-2);
  text-decoration: none;
}

.finale footer a:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* Transport, like the app's controls */

.transport {
  display: none;
}

.js .transport {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(720px, calc(100% - 2 * var(--gutter)));
  transform: translateX(-50%);
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(36, 40, 49, 0.78);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.6);
}

.ctl {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.ctl:hover {
  background: var(--glass);
}

.ctl svg {
  width: 20px;
  height: 20px;
}

.ctl[aria-pressed="true"] {
  background: rgba(232, 182, 76, 0.18);
  color: var(--accent);
}

.play {
  width: 46px;
  height: 46px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 19px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.play:hover {
  background: var(--accent);
  filter: brightness(1.05);
}

.speed {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 0 6px;
}

.speed input {
  --fill: 40%;
  flex: 1;
  min-width: 0;
  height: 28px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.speed input::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0 var(--fill), rgba(255, 255, 255, 0.2) var(--fill) 100%);
}

.speed input::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0 var(--fill), rgba(255, 255, 255, 0.2) var(--fill) 100%);
}

.speed input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.speed input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.speed output {
  flex: none;
  min-width: 64px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hint {
  margin: 0;
  color: rgba(245, 245, 244, 0.45);
  font-size: 12.5px;
  letter-spacing: 0.01em;
  text-align: center;
}

.hint kbd {
  border-color: rgba(255, 255, 255, 0.22);
  border-bottom-width: 2px;
  font-size: 11px;
  padding: 0 5px;
}

@media (max-width: 820px) {
  .hint-lead {
    display: none;
  }
}

@media (hover: none) and (pointer: coarse) {
  .hint {
    display: none;
  }
}

@media (max-width: 420px) {
  .controls {
    gap: 4px;
    padding: 6px 8px;
  }

  .ctl {
    width: 36px;
    height: 36px;
  }

  .speed output {
    min-width: 54px;
  }
}
