/* Trip Planner - dark, mobile-first, no build step.
   Palette and primitives match the flight watcher site (web/styles.css) so the
   two feel like one product. */

:root {
  --bg: #0e1116;
  --surface: #171d26;
  --surface-2: #1f2833;
  --border: #2c3745;
  --border-strong: #3d4a5c;

  --text: #e9eef5;
  --muted: #aab7c7;

  --good: #6ee7a8;
  --good-bg: #12281f;
  --warn: #ffc857;
  --warn-bg: #2e2312;
  --bad: #ff8a8a;
  --bad-bg: #2e1618;
  --accent: #7cb8ff;
  --accent-bg: #14263c;
  --focus: #ffd166;

  --radius: 12px;
  --gap: 1rem;
  --maxw: 62rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Several elements below set display:flex, which would otherwise beat the
   hidden attribute's UA display:none. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

h1, h2, h3 { line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 1.75rem 0 .5rem; }
p { margin: 0 0 .75rem; }

a { color: var(--accent); }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-bg);
  color: var(--text);
  padding: .75rem 1rem;
  z-index: 20;
}
.skip-link:focus { left: .5rem; top: .5rem; }

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

/* ---------- header ---------- */

.app-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: .75rem 1rem .5rem;
}
.app-header__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.app-title {
  font-size: 1.15rem;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: .4rem;
  flex-wrap: wrap;
}
.app-title__sub {
  font-size: .75rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.lock-hint {
  max-width: var(--maxw);
  margin: .4rem auto 0;
  font-size: .8rem;
  color: var(--muted);
}

.auth {
  display: flex;
  align-items: center;
  gap: .5rem .75rem;
  flex-wrap: wrap;
}
.auth__who {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
  font-size: .8rem;
  color: var(--muted);
  max-width: 15rem;
  overflow-wrap: anywhere;
}
.auth__who strong { color: var(--text); font-weight: 700; }
.auth__dot {
  width: .55rem;
  height: .55rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--border-strong);
  border: 1px solid var(--muted);
}
.auth__dot--in { background: var(--good); border-color: var(--good); }

.gate {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  padding: .7rem .85rem;
  border: 1px solid var(--border-strong);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-bg);
  font-size: .85rem;
}
.gate > span:nth-child(2) { flex: 1 1 14rem; min-width: 0; }

/* ---------- layout ---------- */

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.toolbar--tight { margin: 1rem 0 .75rem; }

.status {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1rem;
  min-height: 1.35rem;
  font-size: .85rem;
  color: var(--muted);
}
.status:empty { min-height: .5rem; }

.app-footer {
  border-top: 1px solid var(--border);
  padding: 1rem;
  color: var(--muted);
  font-size: .8rem;
}
.app-footer p { max-width: var(--maxw); margin: 0 auto; }

.note {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  margin: 0 0 1.25rem;
  padding: .65rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: .82rem;
}
.note strong { color: var(--text); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .55rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--border-strong); }
.btn--primary[disabled]:hover { background: var(--accent); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a1420;
}
.btn--primary:hover { background: #9ecbff; }

.btn--ghost { background: transparent; }

.btn--danger {
  background: transparent;
  border-color: var(--bad);
  color: var(--bad);
}
.btn--danger:hover { background: var(--bad-bg); border-color: var(--bad); }

.btn--small {
  min-height: 40px;
  padding: .4rem .7rem;
  font-size: .875rem;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  margin-bottom: .5rem;
  padding: .4rem .2rem;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
.back-btn:hover { text-decoration: underline; }

/* ---------- trip cards ---------- */

.cards {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

.card {
  border: 1px solid var(--border);
  border-left: 5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
}
.card--good { border-left-color: var(--good); }
.card--warn { border-left-color: var(--warn); }
.card--bad  { border-left-color: var(--bad); }
.card--off  { opacity: .68; border-left-color: var(--border-strong); }

.card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
}
.card__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  overflow-wrap: anywhere;
}
.card__meta {
  color: var(--muted);
  font-size: .875rem;
  margin: .25rem 0 .6rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--good { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.badge--warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.badge--bad  { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad); }
.badge--neutral { background: var(--surface-2); color: var(--muted); border-color: var(--border-strong); }

.card__error {
  margin: .6rem 0 0;
  padding: .5rem .65rem;
  border-radius: 8px;
  background: var(--bad-bg);
  border: 1px solid var(--bad);
  color: var(--text);
  font-size: .8rem;
  overflow-wrap: anywhere;
}

.card__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .9rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.card__checked { color: var(--muted); font-size: .8rem; margin: 0; }
.card__actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* Inline delete confirmation inside a trip card. */
.confirm {
  margin: .75rem 0 0;
  padding: .8rem;
  border: 1px solid var(--bad);
  background: var(--bad-bg);
  border-radius: var(--radius);
  font-size: .875rem;
}
.confirm p { margin: 0 0 .6rem; }
.confirm__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- destination chips ---------- */

.chips {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin: 0 0 .5rem;
  padding: 0;
  list-style: none;
}
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: .35rem;
  padding: .25rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-size: .78rem;
}
.chip__code { font-weight: 800; letter-spacing: .04em; }
.chip__city { color: var(--muted); }
.chip__drive { color: var(--warn); font-weight: 600; }
.chip--more { color: var(--muted); border-style: dashed; }
.chip--out { border-color: var(--bad); color: var(--bad); }

/* ---------- resolution panel ---------- */

.resolve {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--accent);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-bg);
}
.resolve__heading { margin: 0 0 .5rem; font-size: 1rem; }
.resolve__kind {
  display: inline-flex;
  gap: .35rem;
  align-items: center;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 0 0 .5rem;
}
.resolve__fail {
  border: 1px solid var(--bad);
  background: var(--bad-bg);
  border-radius: 8px;
  padding: .7rem .8rem;
  margin: 0 0 .5rem;
}
.resolve__list { margin: .25rem 0 .75rem; padding-left: 1.1rem; font-size: .85rem; color: var(--muted); }
.resolve__list strong { color: var(--text); }

/* ---------- forms ---------- */

form { margin: 0; }
h2 + form, h2 + .gate { margin-top: 1rem; }
/* The gate sits between the heading and the form and is hidden when signed
   in, so the heading needs its own breathing room. */
#new-heading { margin-bottom: 1.1rem; }

.field { margin: 0 0 1rem; }
.field-row { display: grid; gap: 0 1rem; grid-template-columns: 1fr 1fr; }
.field-row--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .35rem;
}
.optional { font-weight: 400; color: var(--muted); }

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"] {
  width: 100%;
  min-height: 46px;
  padding: .55rem .7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1rem; /* keeps iOS from zooming on focus */
}
input::placeholder { color: #7c8a9c; }
input[aria-invalid="true"] { border-color: var(--bad); background: #1a1214; }

.help { font-size: .8rem; color: var(--muted); margin: .3rem 0 0; }

.field-err {
  font-size: .8rem;
  color: var(--bad);
  margin: .3rem 0 0;
  font-weight: 600;
}
.field-err:empty { display: none; }

.nights {
  margin: -.25rem 0 1rem;
  font-size: .85rem;
  color: var(--muted);
}
.nights:empty { display: none; }
.nights strong { color: var(--text); }

.form-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}
.form-actions:empty { display: none; }

input:disabled {
  cursor: not-allowed;
  color: var(--muted);
  border-color: var(--border);
  border-style: dashed;
  background: var(--surface);
}
input:disabled::placeholder { color: #5b6675; }
.field:has(input:disabled) label,
.field:has(input:disabled) .help { color: #7c8a9c; }

/* ---------- callouts / alerts / placeholders ---------- */

.alert {
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin: 0 0 1rem;
  border: 1px solid var(--border);
  font-size: .9rem;
}
.alert p { margin: 0 0 .5rem; }
.alert p:last-child { margin-bottom: 0; }
.alert--bad  { background: var(--bad-bg);  border-color: var(--bad); }
.alert--good { background: var(--good-bg); border-color: var(--good); }
.alert--warn { background: var(--warn-bg); border-color: var(--warn); }

.placeholder {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: var(--muted);
  font-size: .9rem;
}
.placeholder__title { color: var(--text); font-weight: 700; font-size: 1rem; }
.placeholder p:last-child { margin-bottom: 0; }

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  vertical-align: -2px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

.explain {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: .5rem .85rem;
  margin: 0 0 1rem;
  font-size: .85rem;
  color: var(--muted);
}
.explain summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  min-height: 32px;
  display: flex;
  align-items: center;
}
.explain p { margin: .5rem 0 .25rem; }
.explain strong { color: var(--text); }

/* ---------- deals ---------- */

.detail-heading { font-size: 1.45rem; margin: .25rem 0; overflow-wrap: anywhere; }
.detail-meta { color: var(--muted); font-size: .9rem; margin-bottom: .5rem; }
.deals-count { margin: 0; font-size: .85rem; color: var(--muted); }

.deals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--gap);
}

.deal {
  border: 1px solid var(--border);
  border-left: 5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
}
.deal--top { border-left-color: var(--good); }
.deal--strong { border-left-color: var(--accent); }
.deal--mid { border-left-color: var(--warn); }

.deal__top {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}
.deal__ident { flex: 1 1 12rem; min-width: 0; }
.deal__rank {
  font-size: .75rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: .05em;
}
.deal__name {
  font-size: 1.1rem;
  font-weight: 700;
  margin: .1rem 0 .25rem;
  overflow-wrap: anywhere;
}
.deal__sub {
  margin: 0;
  font-size: .8rem;
  color: var(--muted);
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  align-items: baseline;
}
.deal__sub .dot { color: var(--border-strong); }

/* Phone: the score sits on its own row under the hotel name, so read it as a
   row - big number on the left, band label pushed to the right. */
.score {
  flex: 1 1 100%;
  display: flex;
  align-items: baseline;
  gap: .4rem;
  margin: .5rem 0 0;
}
.score__value { display: inline-flex; align-items: baseline; gap: .15rem; }
.score__num {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.score__of { font-size: .75rem; color: var(--muted); font-weight: 600; }
.score__band { margin-left: auto; }

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem .75rem;
  margin: .85rem 0 0;
  padding: .75rem 0 0;
  border-top: 1px solid var(--border);
}
.metric { margin: 0; }
.metric__label {
  display: block;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
}
.metric__value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.metric__aside { font-size: .75rem; color: var(--muted); font-weight: 500; }
.metric--points .metric__value { color: var(--good); }

.why {
  margin: .85rem 0 0;
  padding: .7rem .8rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .82rem;
}
.why__lead { margin: 0 0 .5rem; }
.why__lead strong { color: var(--text); }
.bars { display: grid; gap: .45rem; margin: 0; }
.bar { display: grid; grid-template-columns: 7.5rem 1fr; gap: .5rem; align-items: center; font-size: .75rem; }
.bar__label { color: var(--muted); }
.bar__track {
  position: relative;
  height: .6rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  overflow: hidden;
}
.bar__fill { display: block; height: 100%; background: var(--accent); }
.bar__fill--points { background: var(--good); }
.bar__num { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 700; }

.deal__actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: .9rem;
}
.deal__book {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .55rem 1rem;
  border-radius: var(--radius);
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #0a1420;
  font-weight: 700;
  text-decoration: none;
  flex: 1 1 12rem;
}
.deal__book:hover { background: #9ecbff; }
.deal__observed { font-size: .75rem; color: var(--muted); margin: 0; }

/* ---------- wider screens ---------- */

@media (min-width: 46rem) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-title { font-size: 1.35rem; }
  h2 { font-size: 1.4rem; }
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .deal__book { flex: 0 0 auto; }
  .score {
    flex: 0 0 auto;
    display: block;
    text-align: right;
    min-width: 6rem;
    margin: 0;
  }
  .score__value { display: block; }
  .score__num { font-size: 2.1rem; }
  .score__band { display: inline-flex; margin: .3rem 0 0; }
  .auth__who { max-width: 24rem; }
}

@media (max-width: 30rem) {
  /* Give the email the full row width so it stops breaking mid-domain. */
  .auth { width: 100%; justify-content: space-between; }
  .auth__who { max-width: none; flex: 1 1 auto; }
}

@media (max-width: 26rem) {
  .field-row { grid-template-columns: 1fr; }
  .field-row--three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 .5rem; }
  .field-row--three input { padding-left: .45rem; padding-right: .25rem; }
  .bar { grid-template-columns: 6.5rem 1fr; }
}

@media (prefers-contrast: more) {
  .card, .deal, .placeholder, .alert, .explain, .why { border-color: #fff; }
}
