/* Better Games: the midnight transit map. Enamel navy, porcelain stations, one ink per line and
   an amber LED sign for the next stop. */

@font-face {
  font-family: Barlow;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/barlow-400.woff2') format('woff2');
}
@font-face {
  font-family: Barlow;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/barlow-600.woff2') format('woff2');
}
@font-face {
  font-family: Barlow;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/barlow-700.woff2') format('woff2');
}
@font-face {
  font-family: Barlow;
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/barlow-800.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Semi Condensed';
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/barlow-semi-condensed-600.woff2') format('woff2');
}
@font-face {
  font-family: Doto;
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/doto-800.woff2') format('woff2');
}

:root {
  color-scheme: dark;
  --ground: #0c1a33;
  --panel: #10223f;
  --raised: #1b3158;
  --edge: #26395a;
  --ink: #f3f5f8;
  --muted: #a7b6cc;
  --porcelain: #f7f8fa;
  --board: #05080f;
  --led: #ffb43a;
  --led-soft: #d4bf98;
  --signal: #cf3a2d;
  --signal-hover: #b93024;
  --sumbreak: #2fbf8f;
  --patches: #e5483a;
  --tango: #f2b632;
  --font: Barlow, ui-sans-serif, system-ui, sans-serif;
  --font-label: 'Barlow Semi Condensed', Barlow, ui-sans-serif, sans-serif;
  --font-led: Doto, 'Barlow Semi Condensed', ui-monospace, monospace;
  --page: min(1328px, calc(100% - 2 * var(--gutter)));
  --gutter: 56px;
  font-family: var(--font);
  color: var(--ink);
  background: var(--ground);
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--edge) var(--ground);
}
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
}
main {
  flex: 1 0 auto;
  width: var(--page);
  margin: 0 auto;
  padding: 30px 0 56px;
}
a {
  color: inherit;
}
::selection {
  background: var(--led);
  color: var(--board);
}
:focus-visible {
  outline: 2px solid var(--porcelain);
  outline-offset: 3px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--porcelain);
  color: var(--ground);
  font-weight: 700;
}
.skip:focus {
  top: 12px;
}

/* ---- Header ---- */
.site-header {
  display: flex;
  align-items: center;
  gap: 36px;
  width: var(--page);
  height: 68px;
  margin: 0 auto;
  border-bottom: 1px solid var(--edge);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.3125rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.wordmark svg {
  width: 30px;
  height: 30px;
}
.site-header nav {
  display: flex;
  gap: 4px;
}
.site-header nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 11px;
  border-radius: 6px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.site-header nav a[aria-current='page'] {
  color: var(--ink);
}
.ride-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin-left: auto;
  padding: 0 4px 0 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.ride-toggle i {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: var(--raised);
  transition: background 160ms ease-out;
}
.ride-toggle i::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition:
    transform 180ms cubic-bezier(0.3, 0.7, 0.2, 1),
    background 160ms;
}
.ride-toggle[aria-checked='true'] i {
  background: var(--sumbreak);
}
.ride-toggle[aria-checked='true'] i::after {
  background: var(--porcelain);
  transform: translateX(20px);
}
.ride-toggle[hidden] {
  display: none;
}

/* ---- Buttons ---- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button.primary {
  min-height: 58px;
  padding: 0 26px;
  border-color: var(--signal);
  background: var(--signal);
  color: var(--porcelain);
  font-weight: 800;
  font-size: 1.1875rem;
}
.button[hidden] {
  display: none;
}
.arrow {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.text-button {
  min-height: 32px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---- The carriage sign: the one place the LED voice appears ---- */
.sign {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 32px;
  padding: 26px 34px 28px;
  border: 2px solid var(--edge);
  border-radius: 14px;
  background: var(--board);
}
.sign-kicker {
  margin: 0;
  font-family: var(--font-led);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--led);
  opacity: 0.78;
}
.sign-stop {
  margin: 6px 0 0;
  font-family: var(--font-led);
  font-weight: 800;
  font-size: clamp(2.75rem, 6.4vw, 6rem);
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--led);
  overflow-wrap: anywhere;
}
.sign-note {
  margin: 12px 0 0;
  max-width: 60ch;
  font-size: 1.0625rem;
  color: var(--led-soft);
}
.sign-actions {
  display: grid;
  gap: 10px;
  min-width: 290px;
}

/* ---- The line strip: horizontal on wide screens, a vertical strip map on phones ---- */
.strip-wrap {
  position: relative;
  margin: 28px 0 26px;
}
.strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
}
.strip li {
  position: relative;
}
.strip li::before,
.strip li::after {
  content: '';
  position: absolute;
  top: 54px;
  height: 14px;
}
.strip li::before {
  left: 0;
  right: 50%;
  background: var(--in);
}
.strip li::after {
  left: 50%;
  right: 0;
  background: var(--out);
}
.strip li.is-first::before,
.strip li.is-last::after {
  display: none;
}
.strip li.is-first::after {
  border-radius: 7px 0 0 7px;
}
.strip a,
.strip .change {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 30px 62px auto;
  justify-items: center;
  align-items: center;
  padding: 4px 4px 0;
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
}
.board {
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 1.1875rem;
  letter-spacing: 0.02em;
}
.where {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}
.dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 5px solid var(--ground);
  border-radius: 50%;
  background: var(--porcelain);
  transition: transform 140ms ease-out;
}
.dot svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ground);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.is-done .dot {
  background: var(--out);
}
.is-done .board,
.is-done .where {
  color: var(--muted);
}
.is-next .dot {
  background: var(--led);
}
.strip.is-free .stop:not(.is-done) .dot {
  outline: 3px solid var(--out);
  outline-offset: 1px;
}
.strip.is-free .stop:not(.is-done) .where {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.is-next .board,
.is-next .where {
  color: var(--led);
}
.change .dot {
  width: 46px;
  height: 46px;
  border-width: 7px;
}
.change .board {
  font-size: 0.875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
/* The train: a ring that sits over the next stop and glides along the line. */
.train {
  position: absolute;
  left: -32px;
  top: -32px;
  width: 64px;
  height: 64px;
  border: 4px solid var(--led);
  border-radius: 50%;
  pointer-events: none;
}
.train[hidden] {
  display: none;
}

/* ---- Cards ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 18px;
}
.card {
  display: flex;
  flex-direction: column;
  padding: 20px 22px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: var(--panel);
}
.card h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  font-size: 1.1875rem;
  font-weight: 700;
}
.count {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
}
.rows a {
  color: var(--ink);
  text-decoration: none;
}
.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}
.rows li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 9px 0 8px;
  border-top: 1px solid var(--edge);
  font-size: 0.9375rem;
}
.rows li span:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.card-note {
  margin: 12px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.card .button.quiet {
  align-self: flex-start;
  margin-top: 14px;
}

/* ---- The lines and how it works ---- */
.lines,
.about {
  margin-top: 64px;
}
.lines h2,
.about h2 {
  margin: 0;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 2.5rem;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.section-lede {
  margin: 8px 0 22px;
  max-width: 62ch;
  color: var(--muted);
  font-size: 1.0625rem;
}
.network {
  display: grid;
  gap: 34px;
}
.route header {
  display: flex;
  align-items: center;
  gap: 14px;
}
.route header svg {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 8px;
}
.route h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
}
.route header p {
  margin: 2px 0 0;
  color: var(--muted);
}
/* A game's pages as stations on its line, labelled in station-board capitals. */
.route-stops {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}
.route-stops::before {
  content: '';
  position: absolute;
  left: 22px;
  right: 22px;
  top: 21px;
  height: 14px;
  border-radius: 7px;
  background: var(--c);
}
.route-stops a {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 4px 4px;
  text-decoration: none;
}
.station {
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.how {
  display: grid;
  gap: 12px;
  max-width: 68ch;
  margin-top: 18px;
}
.how p {
  margin: 0;
  color: var(--muted);
  font-size: 1.0625rem;
}
.how strong {
  color: var(--ink);
}
.about-note {
  margin: 18px 0 0;
  max-width: 70ch;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* ---- Footer ---- */
.site-footer {
  width: var(--page);
  margin: 0 auto;
  padding: 18px 0 max(22px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--edge);
  font-size: 0.875rem;
  color: var(--muted);
}
.site-footer p {
  margin: 0 0 8px;
  max-width: 80ch;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 20px;
}
.site-footer nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
}
.site-footer .domain {
  margin-left: auto;
}

/* ---- Your line dialog ---- */
.line-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 26px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
}
.line-dialog::backdrop {
  background: rgb(5 8 15 / 0.7);
}
.line-dialog h2 {
  margin: 0;
  font-size: 1.5rem;
}
.line-dialog p {
  margin: 4px 0 14px;
  color: var(--muted);
}
.line-edit {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}
.line-edit li {
  display: grid;
  grid-template-columns: 1fr 44px 44px;
  align-items: center;
  border-top: 1px solid var(--edge);
}
/* Each row carries its line's legend mark after the checkbox. */
.line-edit .check::after {
  content: '';
  order: -1;
  width: 18px;
  height: 6px;
  margin: 0 -2px 0 2px;
  border-radius: 3px;
  background: var(--c);
}
.line-edit .check input {
  order: -2;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  font-weight: 600;
  cursor: pointer;
}
.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--sumbreak);
}
.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-button:disabled {
  color: var(--edge);
  cursor: default;
}
.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}
.dialog-actions .button.primary {
  min-height: 48px;
  font-size: 1rem;
}

/* ---- Hover only where a fine pointer can hover ---- */
@media (hover: hover) and (pointer: fine) {
  .site-header nav a:hover,
  .button:not(.primary):hover,
  .icon-button:not(:disabled):hover {
    background: var(--raised);
    color: var(--ink);
  }
  .button.primary:hover {
    background: var(--signal-hover);
    border-color: var(--signal-hover);
  }
  .strip a:hover .dot {
    transform: scale(1.12);
  }
  .strip a:hover .board {
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  .route-stops a:hover .dot {
    transform: scale(1.12);
  }
  .route-stops a:hover .station,
  .rows a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  .site-footer nav a:hover,
  .text-button:hover {
    color: var(--ink);
  }
}

/* ---- Narrower screens ---- */
@media (max-width: 1080px) {
  .cards {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 760px) {
  :root {
    --gutter: 18px;
  }
  .site-header {
    flex-wrap: wrap;
    gap: 0 10px;
    height: auto;
    padding-top: 8px;
  }
  .site-header nav {
    order: 3;
    width: 100%;
    margin: 0 -11px;
    overflow-x: auto;
  }
  .ride-toggle {
    margin-left: auto;
  }
  .route-stops {
    grid-auto-flow: row;
  }
  .route-stops::before {
    left: 15px;
    right: auto;
    top: 22px;
    bottom: 22px;
    width: 14px;
    height: auto;
  }
  .route-stops a {
    grid-template-columns: 44px 1fr;
    justify-items: start;
    align-items: center;
    gap: 14px;
    padding: 5px 0;
  }
  .route-stops .dot {
    justify-self: center;
  }
  .ride-toggle span {
    font-size: 0.875rem;
  }
  main {
    padding-top: 18px;
  }
  .sign {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 20px 20px 22px;
  }
  .sign-kicker {
    font-size: 1.25rem;
  }
  .sign-actions {
    min-width: 0;
  }
  .strip {
    grid-auto-flow: row;
  }
  .strip li::before,
  .strip li::after {
    top: auto;
    left: 15px;
    right: auto;
    width: 14px;
    height: 50%;
  }
  .strip li::before {
    top: 0;
  }
  .strip li::after {
    top: 50%;
  }
  .strip li.is-first::after {
    border-radius: 7px 7px 0 0;
  }
  .strip a,
  .strip .change {
    grid-template-columns: 44px 1fr;
    grid-template-rows: auto auto;
    justify-items: start;
    column-gap: 14px;
    min-height: 62px;
    padding: 6px 0;
  }
  .strip .dot {
    grid-column: 1;
    grid-row: 1 / span 2;
    justify-self: center;
  }
  .strip .board,
  .strip .where {
    grid-column: 2;
  }
  .strip .where {
    align-self: start;
  }
  .strip .board {
    align-self: end;
  }
  .where {
    text-align: left;
  }
  .lines h2,
  .about h2 {
    font-size: 2rem;
  }
  .site-footer .domain {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
@media (forced-colors: active) {
  .dot,
  .train {
    border-color: CanvasText;
  }
  .strip li::before,
  .strip li::after,
  .route-stops::before {
    forced-color-adjust: none;
    background: CanvasText;
  }
}
