/* Japan 2026 — trip companion
   Signature: a metro-line timeline. Each day is a coloured line; each
   activity is a station you tap to open in Maps. Grounded in the trip's
   real world — you're on trains the whole time. */

:root {
  --paper:   #FAF9F6;
  --card:    #FFFFFF;
  --ink:     #1A1A1A;
  --muted:   #6B6B6B;
  --faint:   #9A968E;
  --hair:    #E8E4DC;
  --hair-2:  #F0EDE6;

  /* line colours (Tokyo Metro-ish), one per leg */
  --Tokyo:  #1F3A93;
  --Fuji:   #1E7A46;
  --Kyoto:  #6A2C91;
  --Osaka:  #B4451A;
  --Hakone: #0E6E74;

  --c: var(--Tokyo);           /* active region colour, set per day */
  --tint: #E8EDFB;

  --r: 14px;
  --shadow: 0 1px 2px rgba(20,20,20,.05), 0 8px 24px rgba(20,20,20,.05);
  --tap: 44px;                 /* min touch target */
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
button { font: inherit; color: inherit; }

.tabular { font-variant-numeric: tabular-nums; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--hair);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 8px;
}
.appbar__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand__kicker {
  font-size: 11px; letter-spacing: .28em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
.brand__year { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.brand__jp { color: var(--faint); font-size: 13px; letter-spacing: .1em; }
.iconbtn {
  min-width: var(--tap); min-height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--hair); border-radius: 999px;
  font-size: 12px; color: var(--muted); cursor: pointer;
}
.iconbtn:active { transform: translateY(1px); }
.route {
  margin-top: 6px; font-size: 12px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center;
}
.route b { color: var(--ink); font-weight: 600; }
.route .arrow { color: var(--faint); }

/* ---------- Day rail ---------- */
.rail {
  position: sticky; top: 0; z-index: 20;               /* offset set in JS via padding of main */
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity;
  padding: 10px 16px; background: var(--paper);
  border-bottom: 1px solid var(--hair);
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.pill {
  scroll-snap-align: center; flex: 0 0 auto;
  min-width: 56px; min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 10px; border-radius: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--hair); color: var(--ink);
  transition: transform .12s ease;
}
.pill:active { transform: translateY(1px); }
.pill__n { font-weight: 800; font-size: 15px; line-height: 1; }
.pill__d { font-size: 10px; color: var(--muted); margin-top: 3px; letter-spacing: .01em; }
.pill__dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 4px; background: var(--pc, var(--muted)); }
.pill[aria-current="true"] {
  background: var(--pc); border-color: transparent; color: #fff; box-shadow: var(--shadow);
}
.pill[aria-current="true"] .pill__d { color: rgba(255,255,255,.85); }
.pill[aria-current="true"] .pill__dot { background: rgba(255,255,255,.9); }
.pill--trip .pill__n { font-size: 13px; letter-spacing: .04em; }

/* ---------- Main ---------- */
main { max-width: 720px; margin: 0 auto; padding: 16px 16px 60px; }
.view { animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px);} to { opacity:1; transform:none;} }

/* Day header band */
.dayhead {
  border-radius: var(--r); padding: 16px 18px; color: #fff;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--c) 92%, #000 0%), color-mix(in srgb, var(--c) 82%, #000 8%));
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.dayhead::after { /* faint station-ring motif */
  content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px;
  border-radius: 50%; border: 14px solid rgba(255,255,255,.10);
}
.dayhead__top { display: flex; align-items: baseline; gap: 10px; }
.dayhead__n { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.dayhead__date { font-size: 14px; font-weight: 600; opacity: .95; }
.dayhead__city { margin-top: 2px; font-size: 14px; font-weight: 600; opacity: .95; }
.dayhead__hotel {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: #fff; text-decoration: none;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28);
}
a.dayhead__hotel:active { background: rgba(255,255,255,.28); }
.dayhead__hotelpin { font-weight: 700; opacity: .9; }
.dayhead__sub { margin-top: 8px; font-size: 13px; line-height: 1.4; opacity: .92; max-width: 46ch; }

/* Timeline */
.timeline { margin: 18px 0 0; padding: 0; list-style: none; position: relative; }
.timeline::before { /* the line */
  content: ""; position: absolute; left: 74px; top: 6px; bottom: 6px; width: 4px;
  background: color-mix(in srgb, var(--c) 30%, var(--paper)); border-radius: 4px;
}
.stop { position: relative; display: grid; grid-template-columns: 62px 1fr; gap: 12px; padding: 6px 0 16px; }
.stop__time {
  text-align: right; padding-top: 2px; color: var(--c); font-weight: 700;
  font-size: 12px; line-height: 1.25; white-space: pre-line;
}
.stop__dot {
  position: absolute; left: 68px; top: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 4px solid var(--c); box-shadow: 0 0 0 3px var(--paper);
}
.stop__body {
  margin-left: 22px; background: var(--card); border: 1px solid var(--hair);
  border-radius: 12px; padding: 11px 13px; box-shadow: var(--shadow);
}
.stop__title { font-weight: 600; font-size: 15px; letter-spacing: -.01em; display: inline; }
a.stop__title { color: var(--ink); text-decoration: none; border-bottom: 2px solid var(--tint); }
a.stop__title:active { color: var(--c); }
.pin { display: inline-block; margin-left: 6px; font-size: 12px; transform: translateY(1px); opacity: .8; }
.tag {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; background: var(--tint); color: var(--c); vertical-align: middle;
}
.stop__note { margin-top: 5px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }

/* "now" emphasis (only when viewing today) */
.stop--next .stop__dot { animation: ping 1.8s ease-out infinite; }
.stop--next .stop__body { border-color: color-mix(in srgb, var(--c) 45%, var(--hair)); }
.nowflag {
  display: inline-block; margin-left: 8px; font-size: 10px; font-weight: 800; letter-spacing: .04em;
  color: #fff; background: var(--c); border-radius: 999px; padding: 1px 8px; text-transform: uppercase;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 3px var(--paper), 0 0 0 3px color-mix(in srgb, var(--c) 60%, transparent); }
  70%{ box-shadow: 0 0 0 3px var(--paper), 0 0 0 12px transparent; }
  100%{ box-shadow: 0 0 0 3px var(--paper), 0 0 0 12px transparent; }
}

.tbd { color: var(--faint); font-style: italic; padding: 26px 4px; }

/* Prev / next */
.daynav { display: flex; gap: 10px; margin-top: 22px; }
.daynav button {
  flex: 1; min-height: var(--tap); border-radius: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--hair); color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; font-weight: 600;
}
.daynav button:disabled { opacity: .4; cursor: default; }
.daynav .lab { color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------- Trip overview (whole-trip metro map) ---------- */
.tripintro { margin: 2px 2px 14px; }
.tripintro h1 { font-size: 26px; margin: 0 0 2px; letter-spacing: -.02em; }
.tripintro p { margin: 0; color: var(--muted); font-size: 13px; }
.sheetlink {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 12px;
  min-height: 40px; padding: 0 15px; border-radius: 999px; cursor: pointer;
  font-size: 13px; font-weight: 700; text-decoration: none;
  color: #fff; background: var(--Tokyo); border: 1px solid var(--Tokyo);
  box-shadow: var(--shadow);
}
.sheetlink:active { transform: translateY(1px); }
.sheetlink::before {
  content: ""; width: 15px; height: 15px; flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: center / contain no-repeat var(--sheet-ico);
  mask: center / contain no-repeat var(--sheet-ico);
}
.sheetlink__pin { font-weight: 700; opacity: .9; }
.sheetlink--ghost { background: var(--card); color: var(--ink); border-color: var(--hair); box-shadow: none; }
:root { --sheet-ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'><path d='M6 2h8l4 4v16H6z' opacity='.35'/><path d='M8 12h8v1.6H8zM8 15h8v1.6H8zM8 9h8v1.6H8z'/></svg>"); }
.spine { list-style: none; margin: 0; padding: 0; position: relative; }
.leg { position: relative; display: grid; grid-template-columns: 60px 1fr; gap: 12px; padding: 4px 0; }
.leg__rail { position: relative; }
.leg__seg { position: absolute; left: 27px; top: -4px; bottom: -4px; width: 4px; background: var(--pc); }
.leg:first-child .leg__seg { top: 14px; }
.leg:last-child  .leg__seg { bottom: calc(100% - 14px); }
.leg__dot { position: absolute; left: 21px; top: 8px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 4px solid var(--pc); box-shadow: 0 0 0 3px var(--paper); }
.leg__card {
  width: 100%; text-align: left; cursor: pointer; margin: 4px 0;
  background: var(--card); border: 1px solid var(--hair); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow); display: block;
}
.leg__card:active { transform: translateY(1px); }
.leg__top { display: flex; align-items: baseline; gap: 8px; }
.leg__n { font-weight: 800; font-size: 14px; color: var(--pc); }
.leg__date { font-size: 12px; color: var(--muted); }
.leg__city { margin-left: auto; font-size: 12px; font-weight: 700; }
.leg__focus { margin-top: 3px; font-size: 12.5px; color: var(--muted); line-height: 1.35; }

/* ---------- Settings sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20,20,20,.4); z-index: 40; display: none; }
.scrim.open { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; transform: translateY(100%);
  transition: transform .26s cubic-bezier(.2,.8,.2,1);
  background: var(--paper); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.18);
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 20px); max-width: 720px; margin: 0 auto;
}
.sheet.open { transform: none; }
.sheet__grip { width: 40px; height: 4px; border-radius: 4px; background: var(--hair); margin: 8px auto 12px; }
.sheet h2 { font-size: 16px; margin: 4px 0 2px; }
.sheet p { font-size: 12.5px; color: var(--muted); margin: 4px 0 12px; }
.field { display: block; margin: 10px 0; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; min-height: var(--tap); padding: 8px 12px; font-size: 14px;
  border: 1px solid var(--hair); border-radius: 10px; background: var(--card); color: var(--ink);
}
.sheet__actions { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1; min-height: var(--tap); border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 14px;
  border: 1px solid var(--hair); background: var(--card); color: var(--ink);
}
.btn--primary { background: var(--Tokyo); border-color: var(--Tokyo); color: #fff; }
.src-status { font-size: 12px; margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--hair-2); color: var(--muted); }
.src-status.err { background: #FCEBE7; color: #B4451A; }
.src-status.live { background: #E7F1EA; color: #1E7A46; }

/* ---------- niceties ---------- */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--c) 55%, #fff); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@media (min-width: 560px) {
  .stop { grid-template-columns: 74px 1fr; }
  .timeline::before { left: 86px; } .stop__dot { left: 80px; }
}
