/* ==========================================================================
   pedalon-trips engine — app.css
   Mobile-first. Strict spacing scale + ≥44px tap targets so nothing drifts.
   Color/font tokens below are DEFAULTS; theme.js overrides them per trip.
   ========================================================================== */

:root {
  /* palette (overridden at runtime by theme.js) */
  --sea: #1a4d6e;  --sea-light: #4a9fc8;  --foam: #cfe8f3;
  --sand: #f5efe6; --sand-dark: #e8ddd0;
  --sunset: #e8904a; --night: #0d1f2d;
  --text: #1c2b38; --muted: #6b8499; --white: #ffffff;
  --border: rgba(26, 77, 110, .14);
  --ok: #1f7a4a; --warn: #b5793a; --danger: #b3402f;

  /* spacing scale — the antidote to "off by a bit" */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --r-sm: 8px; --r: 14px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(13, 31, 45, .06), 0 1px 3px rgba(13, 31, 45, .08);
  --shadow: 0 2px 8px rgba(13, 31, 45, .08), 0 8px 24px rgba(13, 31, 45, .07);
  --shadow-lg: 0 12px 40px rgba(13, 31, 45, .18);

  --font-heading: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --tap: 44px;                 /* WCAG min target */
  --maxw: 760px;               /* phone-app feel, centered on big screens */
  --header-h: 56px;
  --tabbar-h: calc(60px + env(safe-area-inset-bottom, 0px));

  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px; line-height: 1.55;
  color: var(--text);
  background: var(--sand);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
img { max-width: 100%; display: block; }
a { color: var(--sea); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 600; line-height: 1.12; margin: 0; letter-spacing: .2px; }
:focus-visible { outline: 2px solid var(--sea-light); outline-offset: 2px; border-radius: var(--r-sm); }

/* ----- app shell ------------------------------------------------------- */
#app { min-height: 100vh; }
.screen {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--sp-4) calc(var(--tabbar-h) + var(--sp-6));
}
.screen--flush { padding-left: 0; padding-right: 0; }
.section { margin-top: var(--sp-6); }
.section > h2 {
  font-size: 1.5rem; margin-bottom: var(--sp-3);
  display: flex; align-items: baseline; gap: var(--sp-2);
}
.eyebrow {
  font-family: var(--font-body); font-size: .72rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.muted { color: var(--muted); }
.lead { font-size: 1.05rem; color: var(--text); }

/* ----- top header ------------------------------------------------------ */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-4);
  background: color-mix(in srgb, var(--sand) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header__title { font-size: 1.18rem; font-weight: 600; }
.app-header__back {
  min-width: var(--tap); height: var(--tap); margin-left: calc(var(--sp-2) * -1);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: var(--sea); border-radius: var(--r-pill);
}
.app-header__back:active { background: var(--sand-dark); }

/* ----- bottom tab bar -------------------------------------------------- */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; justify-content: center; gap: var(--sp-1);
  padding: 6px var(--sp-2) calc(6px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--white) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
.tab-bar__item {
  flex: 1 1 0; max-width: 120px; min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 4px; border-radius: var(--r);
  color: var(--muted); transition: color .15s var(--ease);
}
.tab-bar__icon { font-size: 1.3rem; line-height: 1; }
.tab-bar__label { font-size: .66rem; font-weight: 600; letter-spacing: .02em; }
.tab-bar__item[aria-current="page"] { color: var(--sea); }
.tab-bar__item[aria-current="page"] .tab-bar__icon { transform: translateY(-1px); }

/* ----- hero ------------------------------------------------------------ */
.hero {
  position: relative; border-radius: 0 0 var(--r-xl) var(--r-xl);
  overflow: hidden; color: var(--white);
  margin-bottom: var(--sp-4);
  min-height: 280px; display: flex; align-items: flex-end;
}
.hero__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero__scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(13,31,45,.05) 0%, rgba(13,31,45,.15) 45%, rgba(13,31,45,.82) 100%);
}
.hero__body { position: relative; padding: var(--sp-5) var(--sp-4) var(--sp-5); width: 100%; }
.hero__title { font-size: clamp(2.2rem, 9vw, 3.2rem); font-weight: 600; }
.hero__sub { margin-top: var(--sp-1); font-size: 1rem; opacity: .92; }
.hero__meta { margin-top: var(--sp-3); display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* ----- chips / badges -------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-pill);
  font-size: .76rem; font-weight: 600; line-height: 1;
  background: color-mix(in srgb, var(--white) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--white) 30%, transparent);
}
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 600; line-height: 1;
  background: var(--sand-dark); color: var(--text);
}
.badge--ok { background: color-mix(in srgb, var(--ok) 15%, var(--white)); color: var(--ok); }
.badge--tbd { background: color-mix(in srgb, var(--warn) 16%, var(--white)); color: var(--warn); }
.badge--unconfirmed { background: color-mix(in srgb, var(--sunset) 18%, var(--white)); color: var(--warn); }
.badge--star { background: color-mix(in srgb, var(--sunset) 16%, var(--white)); color: var(--dusk, #9a4e20); }
.badge--who { background: color-mix(in srgb, var(--sea) 12%, var(--white)); color: var(--sea); }
.price-level { font-weight: 700; color: var(--sea); letter-spacing: 1px; }

/* ----- generic card ---------------------------------------------------- */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card + .card { margin-top: var(--sp-3); }

/* ----- place card ------------------------------------------------------ */
.place-card { display: block; color: inherit; }
.place-card:active { transform: scale(.99); }
.place-card__media { aspect-ratio: 16/10; background: var(--sand-dark); position: relative; }
.place-card__media img { width: 100%; height: 100%; object-fit: cover; }
.place-card__kicker {
  position: absolute; top: var(--sp-2); left: var(--sp-2);
  background: color-mix(in srgb, var(--night) 72%, transparent); color: var(--white);
  padding: 4px 9px; border-radius: var(--r-pill); font-size: .68rem; font-weight: 600;
  letter-spacing: .04em; backdrop-filter: blur(4px);
}
.place-card__body { padding: var(--sp-3) var(--sp-4) var(--sp-4); }
.place-card__name { font-size: 1.3rem; }
.place-card__sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.place-card__row { margin-top: var(--sp-3); display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

/* ----- segmented control ---------------------------------------------- */
.segmented {
  display: flex; gap: 3px; padding: 3px;
  background: var(--sand-dark); border-radius: var(--r-pill);
  position: sticky; top: calc(var(--header-h)); z-index: 40; margin: var(--sp-4) 0;
}
.segmented__btn {
  flex: 1; min-height: 38px; border-radius: var(--r-pill);
  font-size: .82rem; font-weight: 600; color: var(--muted);
  transition: all .18s var(--ease);
}
.segmented__btn[aria-selected="true"] { background: var(--white); color: var(--sea); box-shadow: var(--shadow-sm); }

/* ----- accordion ------------------------------------------------------- */
.acc__head {
  width: 100%; min-height: var(--tap);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); text-align: left;
}
.acc__chev { margin-left: auto; transition: transform .25s var(--ease); color: var(--muted); font-size: 1.1rem; }
.acc[open] .acc__chev, .acc--open .acc__chev { transform: rotate(90deg); }
.acc__panel { padding: 0 var(--sp-4) var(--sp-4); }

/* ----- section tabs (place detail, scroll-spy) ------------------------- */
.section-tabs {
  position: sticky; top: var(--header-h); z-index: 40;
  display: flex; gap: var(--sp-1); overflow-x: auto; scrollbar-width: none;
  padding: var(--sp-2) var(--sp-4);
  background: color-mix(in srgb, var(--sand) 90%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  scroll-snap-type: x proximity;
}
.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs__btn {
  white-space: nowrap; min-height: 36px; padding: 0 var(--sp-3);
  border-radius: var(--r-pill); font-size: .82rem; font-weight: 600; color: var(--muted);
}
.section-tabs__btn[aria-current="true"] { background: var(--sea); color: var(--white); }

/* ----- detail content -------------------------------------------------- */
.detail-hero { position: relative; aspect-ratio: 4/3; max-height: 56vh; background: var(--sand-dark); }
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero__grad { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(13,31,45,.78)); }
.detail-hero__cap { position: absolute; bottom: var(--sp-4); left: var(--sp-4); right: var(--sp-4); color: var(--white); }
.detail-hero__name { font-size: clamp(1.8rem, 7vw, 2.6rem); }
.detail-section { scroll-margin-top: calc(var(--header-h) + 52px); padding-top: var(--sp-5); }
.detail-section > h3 { font-size: 1.35rem; margin-bottom: var(--sp-3); }

.stat-bar { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; padding: var(--sp-4) 0; }
.stat-bar::-webkit-scrollbar { display: none; }
.stat { flex: 0 0 auto; min-width: 92px; padding: var(--sp-3); background: var(--white); border: 1px solid var(--border); border-radius: var(--r); text-align: center; }
.stat__v { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 600; color: var(--sea); }
.stat__l { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.pill-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.pill { padding: 6px 12px; border-radius: var(--r-pill); background: var(--sand-dark); font-size: .82rem; }
.bullets { margin: 0; padding-left: 1.1rem; }
.bullets li { margin: var(--sp-1) 0; }

.fact-list { display: grid; gap: var(--sp-2); }
.fact { display: grid; grid-template-columns: 116px 1fr; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px dashed var(--border); }
.fact__k { color: var(--muted); font-size: .82rem; font-weight: 600; }
.fact__v { font-size: .94rem; }

/* contact / action buttons */
.actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.btn {
  min-height: var(--tap); padding: 0 var(--sp-4);
  display: inline-flex; align-items: center; gap: var(--sp-2);
  border-radius: var(--r-pill); font-weight: 600; font-size: .9rem;
  background: var(--white); border: 1px solid var(--border); color: var(--sea);
}
.btn--primary { background: var(--sea); color: var(--white); border-color: var(--sea); }
.btn--ghost { background: transparent; }
.btn:active { transform: scale(.98); }

/* ----- gallery + lightbox --------------------------------------------- */
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
.gallery__item { aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--sand-dark); }
.gallery__item img { width: 100%; height: 100%; object-fit: cover; }
.gallery__item:first-child { grid-column: 1 / -1; aspect-ratio: 16/10; }
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(8,18,26,.96);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.lightbox img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: var(--r-sm); }
.lightbox__cap { color: #e7eef3; font-size: .85rem; margin-top: var(--sp-3); padding: 0 var(--sp-5); text-align: center; }
.lightbox__close { position: absolute; top: calc(env(safe-area-inset-top,0) + var(--sp-3)); right: var(--sp-3); width: var(--tap); height: var(--tap); border-radius: var(--r-pill); background: rgba(255,255,255,.14); color: #fff; font-size: 1.4rem; }
.lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); width: var(--tap); height: var(--tap); border-radius: var(--r-pill); background: rgba(255,255,255,.14); color: #fff; font-size: 1.6rem; display: flex; align-items: center; justify-content: center; }
.lightbox__nav--prev { left: var(--sp-2); } .lightbox__nav--next { right: var(--sp-2); }

/* ----- home / today ---------------------------------------------------- */
.countdown { text-align: center; padding: var(--sp-5) 0; }
.countdown__n { font-family: var(--font-heading); font-size: 4rem; font-weight: 600; color: var(--sea); line-height: 1; }
.today-card { padding: var(--sp-4); }
.next-up { border-left: 3px solid var(--sunset); padding-left: var(--sp-3); }

/* ----- itinerary ------------------------------------------------------- */
.day { border-bottom: 1px solid var(--border); }
.day__date { font-family: var(--font-heading); font-size: 1.25rem; }
.day__sun { margin-left: auto; font-size: .8rem; color: var(--muted); }
.timeline { display: grid; gap: var(--sp-1); }
.tl-event { border-radius: var(--r); }
.tl-item { display: grid; grid-template-columns: 52px 1fr auto; gap: var(--sp-2); align-items: start; padding: var(--sp-2) 0; }
.tl-item--exp { cursor: pointer; border-radius: var(--r-sm); }
.tl-item--exp:active { background: var(--sand); }
.tl-time { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 3px; }
.tl-main { min-width: 0; }
.tl-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-icon { font-size: 1.1rem; }
.tl-title { font-weight: 600; }
.tl-sub { font-size: .85rem; color: var(--muted); margin-top: 1px; }
.tl-chev { color: var(--muted); font-size: 1.1rem; padding-top: 2px; transition: transform .2s var(--ease); }
.tl-item.open .tl-chev { transform: rotate(90deg); }
.tl-note { margin: 0 0 var(--sp-2) 52px; font-size: .82rem; color: var(--warn); font-weight: 500; }
.tl-connector { padding: 2px 0 2px 52px; color: var(--muted); font-size: .8rem; font-style: italic; }
.tl-drawer { padding: var(--sp-1) var(--sp-2) var(--sp-3) 52px; }
.tl-detail { margin: 0 0 var(--sp-2); font-size: .9rem; }
.tl-links { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.tl-link { min-height: 38px; padding: 0 13px; font-size: .8rem; }
.tl-place-link { margin-top: var(--sp-2); min-height: 38px; padding: 0 14px; font-size: .82rem; }

/* weather hourly graph (today) */
.wx-graph { width: 100%; height: auto; margin-top: var(--sp-3); display: block; }
.wxg-t { fill: var(--text); font: 600 11px var(--font-body); }
.wxg-h { fill: var(--muted); font: 500 9px var(--font-body); }
.wxg-now { stroke: var(--sea-light); stroke-width: 1; stroke-dasharray: 3 3; }
.wxg-dot { fill: var(--sunset); }
.wx-graph-title { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: var(--sp-3); }

/* ----- info / budget / packing ---------------------------------------- */
.row-list { display: grid; gap: var(--sp-1); }
.brow { display: flex; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px dashed var(--border); }
.brow__amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.paid { color: var(--ok); } .tbc { color: var(--warn); }
.check { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); }
.check__box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.check--done .check__box { background: var(--ok); border-color: var(--ok); color: #fff; }
.check--done .check__label { text-decoration: line-through; color: var(--muted); }

/* offline banner */
.offline-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--sp-2)); z-index: 70; background: var(--night); color: #fff; padding: 8px 16px; border-radius: var(--r-pill); font-size: .8rem; box-shadow: var(--shadow-lg); }

/* install (add-to-home-screen) hint */
.install-hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--sp-2)); z-index: 70; display: flex; align-items: center; gap: var(--sp-2); max-width: calc(100% - 24px); background: var(--white); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: var(--r-pill); padding: 7px 7px 7px 16px; font-size: .82rem; }
.install-hint__btn { background: var(--sea); color: #fff; border-radius: var(--r-pill); padding: 0 14px; min-height: 36px; font-weight: 600; font-size: .8rem; }
.install-hint__x { width: 34px; height: 34px; border-radius: var(--r-pill); color: var(--muted); flex: 0 0 auto; }

/* loading / empty */
.center-msg { text-align: center; color: var(--muted); padding: var(--sp-8) var(--sp-4); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--sea); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto var(--sp-3); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- weather widget -------------------------------------------------- */
.wx { padding: var(--sp-4); margin-top: var(--sp-4); }
.wx-head { display: flex; align-items: center; justify-content: space-between; }
.wx-toggle { display: flex; gap: 2px; background: var(--sand-dark); border-radius: var(--r-pill); padding: 2px; }
.wx-unit { min-width: 40px; min-height: 32px; border-radius: var(--r-pill); font-size: .78rem; font-weight: 600; color: var(--muted); }
.wx-unit.on { background: var(--white); color: var(--sea); box-shadow: var(--shadow-sm); }
.wx-now { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-3) 0; }
.wx-emoji { font-size: 2.4rem; }
.wx-temp { font-family: var(--font-heading); font-size: 2.6rem; font-weight: 600; color: var(--sea); }
.wx-meta { font-size: .92rem; }
.wx-strip { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; }
.wx-strip::-webkit-scrollbar { display: none; }
.wx-day { flex: 0 0 auto; min-width: 58px; text-align: center; padding: var(--sp-2); border-radius: var(--r); background: var(--sand); }
.wx-day.on { background: color-mix(in srgb, var(--sea) 12%, var(--white)); }
.wx-dow { font-size: .72rem; color: var(--muted); font-weight: 600; }
.wx-demoji { font-size: 1.3rem; margin: 2px 0; }
.wx-hl { font-weight: 600; font-size: .86rem; }
.wx-lo { font-size: .8rem; }

/* email-added reservations woven into the itinerary */
.res-added { border-top: 1px dashed var(--border); margin-top: var(--sp-2); padding-top: var(--sp-2); }

@media (min-width: 760px) {
  .gallery { grid-template-columns: repeat(3, 1fr); }
  .hero { border-radius: var(--r-xl); margin-top: var(--sp-4); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
