/* StepOff — Copenhagen transit-signage styling.
   Yellow is reserved for the recommended door and selected controls. */

:root {
  --yellow: #FFD447;
  --navy: #142332;
  --offwhite: #FAF9F5;
  --surface: #FFFFFF;
  --platform: #EEEBE3;
  --muted: rgba(20, 35, 50, 0.64);
  --hairline: rgba(20, 35, 50, 0.14);
  --hairline-strong: rgba(20, 35, 50, 0.28);
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--offwhite);
  color: var(--navy);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--navy);
  color: var(--offwhite);
  font-weight: 700;
  border-radius: 6px;
  text-decoration: none;
}
.skip-link:focus { top: 12px; outline: 3px solid var(--yellow); outline-offset: 2px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Every icon: same stroke weight and proportions. */
.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Masthead -------------------------------------------------------- */

.masthead {
  /* Brand navy, so the yellow logo sits on the same dark it was drawn on. */
  background: var(--navy);
  color: var(--offwhite);
  padding: 10px 16px;
}

.masthead__inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
}

.brand-logo {
  display: inline-flex;
  flex: none;
  line-height: 0;
  border-radius: 6px;
}

.brand-logo img {
  display: block;
  height: 52px;
  width: auto; /* keeps the logo's own proportions */
}

@media (min-width: 600px) {
  .brand-logo img { height: 64px; }
}

.brand-logo:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

/* Text wordmark (still used in the footer) */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--navy);
  text-decoration: none;
}

.wordmark__text {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.masthead__tagline {
  flex: 1 1 160px;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.35;
  color: rgba(250, 249, 245, 0.8);
}

/* ---- Layout ------------------------------------------------------------ */

.layout {
  max-width: 1040px;
  margin: 0 auto;
  padding: 8px 16px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

#planner { scroll-margin-top: 12px; }

@media (min-width: 880px) {
  .layout {
    grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
    gap: 40px;
    padding-top: 20px;
    align-items: start;
  }
  .result { position: sticky; top: 20px; }
}

/* ---- Steps --------------------------------------------------------------- */

.step {
  padding: 18px 0;
  border-bottom: 1px solid var(--hairline);
}

.step:last-child { border-bottom: 0; }

.step__label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--navy);
}

.step__label label { cursor: pointer; }

.step__num {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--navy);
  border-radius: 50%;
  font-size: 0.7rem;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.hint {
  margin: 8px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.hint:empty { display: none; }

/* ---- Shared control look --------------------------------------------- */

.btn-choice {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: var(--navy);
  background: var(--surface);
  border: 1.5px solid var(--hairline-strong);
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 48px;
  transition: border-color 0.12s ease, background-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-choice:hover { border-color: var(--navy); }

.btn-choice:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 2px;
}

.btn-choice[aria-pressed="true"] {
  background: var(--yellow);
  border-color: var(--navy);
  box-shadow: inset 0 0 0 0.5px var(--navy);
}

/* ---- Line buttons ------------------------------------------------------ */

.line-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.line-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 4px;
  min-height: 64px;
}

.line-badge {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  /* A white ring keeps the M2 yellow badge distinct on a selected (yellow) button. */
  box-shadow: 0 0 0 2px var(--surface);
}

.line-caption {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  color: var(--muted);
}

.line-btn[aria-pressed="true"] .line-caption { color: var(--navy); }

/* ---- Selects ------------------------------------------------------------ */

.select-wrap { position: relative; }

select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 50px;
  padding: 12px 44px 12px 14px;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 650;
  color: var(--navy);
  background: var(--surface)
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="9" viewBox="0 0 14 9"><path d="M1 1.5l6 6 6-6" stroke="%23142332" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>')
    no-repeat right 16px center;
  border: 1.5px solid var(--navy);
  border-radius: var(--radius);
}

select:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 1px;
}

select.is-empty { color: var(--muted); font-weight: 500; }

/* ---- Searchable dropdown (dropdown.js) -------------------------------------
   Replaces the browser's native menu for the arrival-station and
   exit/connection pickers. The native <select> stays in the page, hidden. */

.dd-native { display: none; }

.dd__trigger {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 650;
  text-align: left;
  color: var(--navy);
  background: var(--surface);
  border: 1.5px solid var(--navy);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.dd__trigger:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 1px;
}

.dd__trigger:disabled { opacity: 0.55; cursor: not-allowed; }
.dd__trigger.is-empty .dd__value { color: var(--muted); font-weight: 500; }

.dd__value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dd__chevron {
  flex: none;
  width: 14px;
  height: 9px;
  fill: none;
  stroke: var(--navy);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dd.is-open .dd__chevron { transform: rotate(180deg); }

/* The open menu: sits over the page below the field, so nothing shifts. */
.dd__panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  max-height: 340px; /* dropdown.js lowers this on short screens */
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(20, 35, 50, 0.14), 0 2px 6px rgba(20, 35, 50, 0.08);
}

.dd__search {
  flex: none; /* stays put while the list scrolls */
  padding: 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}

.dd__input {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  font: inherit;
  font-size: 1rem; /* 16px: stops iPhones zooming into the field */
  color: var(--navy);
  background: var(--offwhite);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
}

.dd__input::placeholder { color: var(--muted); }

.dd__input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(255, 212, 71, 0.7);
}

.dd__list {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 6px 8px 8px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  outline: none;
}

.dd__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.98rem;
  line-height: 1.3;
  color: var(--navy);
  border-radius: var(--radius);
  cursor: pointer;
}

.dd__option + .dd__option { margin-top: 1px; }
.dd__option.is-active { background: rgba(20, 35, 50, 0.06); }

.dd__option[aria-selected="true"] {
  background: var(--yellow);
  font-weight: 700;
}

/* Keyboard cursor resting on the selected row */
.dd__option[aria-selected="true"].is-active { box-shadow: inset 0 0 0 1.5px var(--navy); }

.dd__check {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--navy);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dd__empty {
  margin: 0;
  padding: 18px 14px;
  font-size: 0.92rem;
  color: var(--muted);
}

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

@media (pointer: coarse) {
  .dd__option { min-height: 44px; }
}

/* ---- Direction choices --------------------------------------------------- */

.choice-list {
  display: grid;
  gap: 8px;
}

.choice-list:empty { display: none; }

.direction-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-align: left;
  min-height: 60px;
}

.direction-btn__text { display: flex; flex-direction: column; gap: 2px; }

.direction-btn__title { font-size: 1rem; font-weight: 700; }

.direction-btn__sub { font-size: 0.84rem; color: var(--muted); }

.direction-btn[aria-pressed="true"] .direction-btn__sub { color: var(--navy); }

/* ---- Goal choices ---------------------------------------------------------- */

.goal-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.goal-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  min-height: 70px;
  font-size: 0.88rem;
  font-weight: 650;
}

.sub-goal { margin-top: 12px; }

.sub-goal__label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

/* ---- Result ------------------------------------------------------------------ */

.result {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 16px 16px 14px;
  margin-top: 8px;
}

.result__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
}

.line-chip {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex: none;
  font-size: 0.9rem;
  font-weight: 800;
}

.line-chip:empty { visibility: hidden; }

.result__titles { min-width: 0; }

.result__station {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.result__route {
  margin: 2px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.diagram-wrap {
  margin: 12px -4px 4px;
  width: calc(100% + 8px);
}

#train-diagram {
  display: block;
  width: 100%;
  height: auto;
}

/* Train diagram parts (built in app.js) */
.t-label { font-family: var(--font); fill: var(--navy); }
.t-label--small { font-size: 9px; font-weight: 600; letter-spacing: 0.04em; }
.t-label--front { font-size: 8px; font-weight: 800; letter-spacing: 0.1em; fill: #FFFFFF; }
.t-arrow { fill: none; stroke: var(--navy); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.t-rail { stroke: #CFCAC0; stroke-width: 2; }
.t-body { fill: #FBFBFA; stroke: var(--navy); stroke-width: 1.75; }
.t-roof { fill: none; stroke: #D9D5CC; stroke-width: 1; }
.t-hvac { fill: #ECE9E2; stroke: #C4BFB4; stroke-width: 1; }
.t-glass { fill: #7D8B96; }
.t-screen-front { fill: var(--navy); }
.t-screen-rear { fill: #B9B4AA; }
.t-gangway { fill: #DEDAD1; stroke: var(--navy); stroke-width: 1.25; }
.t-gangway-fold { stroke: #A9A498; stroke-width: 1; }
.t-platform { fill: var(--platform); }
.t-edge { stroke: var(--navy); stroke-width: 1.5; }
.t-door { fill: #5B6670; stroke: var(--navy); stroke-width: 1.2; transition: fill 0.15s ease; }
.t-door-split { stroke: #FAF9F5; stroke-width: 1; }
.t-zone { fill: var(--yellow); opacity: 0; transition: opacity 0.15s ease; }
.t-num-bg { fill: #FFFFFF; stroke: var(--navy); stroke-width: 1.5; transition: fill 0.15s ease; }
.t-num { font-family: var(--font); font-size: 11px; font-weight: 800; fill: var(--navy); }

.door.is-recommended .t-door { fill: var(--yellow); stroke-width: 2; }
.door.is-recommended .t-door-split { stroke: var(--navy); }
.door.is-recommended .t-zone { opacity: 0.45; }
.door.is-recommended .t-num-bg { fill: var(--yellow); stroke-width: 2; }

.t-path { fill: none; stroke: var(--navy); stroke-width: 2; stroke-dasharray: 2 5; stroke-linecap: round; }
.t-goal-bg { fill: #FFFFFF; stroke: var(--navy); stroke-width: 2; }
.t-goal-icon { color: var(--navy); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.t-goal-label { font-family: var(--font); font-size: 10px; font-weight: 700; fill: var(--navy); }

/* Instruction */

.instruction-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  min-height: 48px;
}

.door-badge {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  background: var(--yellow);
  border: 2px solid var(--navy);
  border-radius: var(--radius);
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.instruction {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.walking {
  margin: 8px 0 0;
  font-size: 0.95rem;
  line-height: 1.4;
}

.walking:empty { display: none; }

.status-badge {
  display: inline-block;
  margin: 12px 0 0;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.status-badge.demo { border: 1.5px dashed var(--navy); color: var(--navy); }
.status-badge.verified { background: var(--navy); color: var(--offwhite); }
.status-badge.survey { border: 1.5px solid var(--navy); color: var(--navy); }

.schematic-note {
  margin: 12px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---- Footer (footer.js) ---------------------------------------------------- */

.site-footer {
  margin-top: 24px;
  border-top: 1px solid var(--hairline);
  color: var(--navy);
}

.footer__inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 16px calc(24px + env(safe-area-inset-bottom));
}

.footer__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
}

@media (min-width: 340px) {
  .footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 24px; }
  .footer__brand { grid-column: 1 / -1; }
}

@media (min-width: 600px) {
  .footer__grid { gap: 32px 40px; }
}

@media (min-width: 900px) {
  .footer__grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }
  .footer__brand { grid-column: auto; max-width: 360px; }
}

.footer__wordmark .wordmark__text { font-size: 1.2rem; }
.footer__icon { width: 30px; height: 30px; border-radius: 7px; display: block; }
.footer__wordmark { min-height: 44px; }

.footer__tagline {
  margin: 10px 0 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.footer__desc {
  margin: 6px 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.footer__heading {
  margin: 0 0 6px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.footer__links { list-style: none; margin: 0; padding: 0; }

.footer__link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  font-size: 0.92rem;
  color: var(--navy);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.footer__link:hover { border-bottom-color: currentColor; }
.footer__link[aria-current="page"] { font-weight: 700; }
.footer__link:focus-visible, .footer__wordmark:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 2px;
  border-radius: 2px;
}

.footer__bottom {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  font-size: 0.8rem;
  color: var(--muted);
}

.footer__bottom p { margin: 0; }

@media (min-width: 900px) {
  .footer__bottom { flex-direction: row; justify-content: space-between; gap: 24px; }
}

/* Plain-HTML fallback shown only without JavaScript */
.footer__fallback { max-width: 1040px; margin: 0 auto; padding: 24px 16px; font-size: 0.9rem; }
.footer__fallback a { color: var(--navy); margin-right: 14px; line-height: 2.2; }

@media (max-width: 400px) {
  .line-caption { display: none; }
  .line-btn { min-height: 56px; }
  .result { padding: 14px 12px 12px; }
  .instruction { font-size: 1.08rem; }
}

/* ---- Live data additions -------------------------------------------------- */

.result__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 12px;
}

.result__meta .status-badge { margin: 0; }
.result__meta:not(:has(:not([hidden]))) { display: none; }

.time-saved {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #1E6B3A;
}

.time-saved.is-slower { color: #9A3412; }

.edit-route {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.source-note {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
