/* Paleta: definita pe :root pentru tema deschisa, rescrisa pentru cea intunecata.
   Contrastele sunt tinute peste 4.5:1 pentru text si 3:1 pentru borduri. */
:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #16181d;
  --text-muted: #4c5260;
  --border: #c4c9d4;
  --border-strong: #8b93a4;
  --accent: #10457e;
  --accent-text: #ffffff;
  --focus: #b5210f;
  --soon: #0c5c2a;
  --live: #7a3b00;
  --late: #96210f;
  --early: #0b4f6c;
  --radius: 10px;
  --maxw: 62rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --surface: #1d2027;
    --surface-2: #262a33;
    --text: #f0f2f6;
    --text-muted: #b3bacb;
    --border: #404654;
    --border-strong: #6d7688;
    --accent: #9cc5f5;
    --accent-text: #10151d;
    --focus: #ffb03a;
    --soon: #7fe0a3;
    --live: #ffc978;
    --late: #ff9d8a;
    --early: #8fd4ef;
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

/* --- utilitare de accesibilitate ------------------------------------------ */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  z-index: 20;
  padding: 0.6rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--focus);
  border-radius: var(--radius);
  transition: top 120ms ease-in-out;
}

.skip-link:focus {
  top: 0.5rem;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

main:focus {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* --- structura ------------------------------------------------------------ */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-title {
  max-width: var(--maxw);
  margin: 0 auto 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.tabs {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 0.25rem;
}

.tabs a {
  display: block;
  padding: 0.6rem 1.1rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid transparent;
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0;
}

.tabs a:hover {
  background: var(--surface-2);
}

.tabs a[aria-current="page"] {
  border-bottom-color: var(--accent);
  background: var(--surface-2);
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.app-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0.25rem 0 0.75rem;
}

h2 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
}

h3 {
  font-size: 1.02rem;
  margin: 0 0 0.15rem;
}

.lede {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

/* --- controale ------------------------------------------------------------ */

.field {
  margin: 0 0 1rem;
  position: relative;
}

.field > label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="search"],
select {
  width: 100%;
  max-width: 32rem;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 8px;
}

.combo-wrap {
  position: relative;
  max-width: 32rem;
}

.combo-listbox {
  position: absolute;
  z-index: 15;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  max-height: 19rem;
  overflow-y: auto;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
}

.combo-listbox[hidden] {
  display: none;
}

.combo-listbox li {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

.combo-listbox li .opt-sub {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.combo-listbox li[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

.combo-listbox li[aria-selected="true"] .opt-sub {
  color: var(--accent-text);
}

.combo-listbox .combo-empty {
  cursor: default;
  color: var(--text-muted);
}

button {
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
}

button:hover {
  background: var(--surface-2);
}

button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 0.5rem 0 1rem;
}

.toolbar .check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.92rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem 0.9rem;
}

legend {
  font-weight: 600;
  padding: 0 0.3rem;
}

.radio-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-row label {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
}

.radio-row label:hover {
  background: var(--surface-2);
}

.radio-row input {
  margin-top: 0.3rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

.radio-row .dir-sub {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* --- carduri si liste ---------------------------------------------------- */

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}

.card > h3 a,
.card > h2 a {
  color: var(--text);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.meta {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.arrivals {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.arrivals > li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  align-items: baseline;
  padding: 0.3rem 0;
  border-top: 1px solid var(--surface-2);
}

.arrivals > li:first-child {
  border-top: 0;
}

.badge {
  display: inline-block;
  min-width: 2.6rem;
  text-align: center;
  padding: 0.15rem 0.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

.badge.line {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.eta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.eta.soon {
  color: var(--soon);
}

.clock {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.dir {
  font-weight: 600;
}

.live {
  color: var(--live);
  font-weight: 600;
}

.tag {
  font-size: 0.8rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-muted);
}

.tag.late {
  color: var(--late);
  border-color: var(--late);
  font-weight: 600;
}

.tag.early {
  color: var(--early);
  border-color: var(--early);
  font-weight: 600;
}

/* --- lista de statii pe linie -------------------------------------------- */

.line-stops {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: none;
}

.line-stops > li {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  padding: 0.6rem 0.8rem;
}

.line-stops > li:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.line-stops > li:last-child {
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

.line-stops .seq {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-weight: 700;
  text-align: right;
}

.line-stops .stop-body > a {
  font-weight: 600;
  color: var(--text);
}

.line-stops .times {
  margin: 0.15rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  align-items: baseline;
}

.line-stops .has-bus {
  border-left: 5px solid var(--live);
  padding-left: 0.5rem;
}

.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin: 0 0 1rem;
}

.notice.error {
  border-left-color: var(--focus);
}

.empty {
  color: var(--text-muted);
  font-style: italic;
}

progress {
  width: 100%;
  max-width: 24rem;
  height: 1.1rem;
}

@media (min-width: 40rem) {
  .radio-row {
    flex-direction: row;
    gap: 1.25rem;
  }
  .radio-row label {
    flex: 1;
  }
}
