/* ===========================================================================
   Holiday Tracker — theme
   ---------------------------------------------------------------------------
   THE ONLY FILE THAT KNOWS WHERE YOU ARE GOING.
   Swap this file for a different trip; nothing else in the app changes.

   Palette: Hoi An at dusk — lacquer, lantern amber, celadon jade, terracotta.
   =========================================================================== */

:root {
  /* -- surfaces (dark is primary) ---------------------------------------- */
  --bg:            #13100f;   /* lacquer, red-black rather than grey-black   */
  --surface:       #1c1715;
  --surface-2:     #262019;
  --surface-sunk:  #0e0c0b;
  --line:          #362d26;
  --line-soft:     #2a221d;

  /* -- ink ---------------------------------------------------------------- */
  --ink:           #f2e9dd;
  --ink-dim:       #b5a695;
  --ink-faint:     #7d7063;

  /* -- accents ------------------------------------------------------------ */
  --amber:         #e8a733;   /* lantern light                               */
  --amber-soft:    #f5cd7e;
  --amber-glow:    rgba(232, 167, 51, .18);
  --jade:          #5fa38b;   /* celadon — settled, paid, done               */
  --jade-soft:     #8fc4b0;
  --jade-glow:     rgba(95, 163, 139, .16);
  --terracotta:    #c96f4a;   /* cost, attention                             */
  --terracotta-soft:#e09a7b;

  /* -- semantic ----------------------------------------------------------- */
  --accent:        var(--amber);
  --good:          var(--jade);
  --warn:          var(--terracotta);
  --on-accent:     #221703;

  /* -- type --------------------------------------------------------------- */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body:    'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-num:     'Inter', system-ui, sans-serif;

  /* -- metrics ------------------------------------------------------------ */
  --gutter:        16px;
  --radius:        14px;
  --radius-sm:     9px;
  --tap:           44px;        /* minimum comfortable touch target          */
  --rail:          18px;        /* x-position of the route line              */
  --shadow:        0 2px 10px rgba(0,0,0,.35);
  --shadow-lift:   0 8px 28px rgba(0,0,0,.45);
  --ease:          cubic-bezier(.22,.61,.36,1);
}

/* -- light mode: paper and ink, same palette ------------------------------ */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:           #f6f0e6;
    --surface:      #fffaf2;
    --surface-2:    #f1e7d8;
    --surface-sunk: #ebe0cf;
    --line:         #ddcdb4;
    --line-soft:    #e8dbc6;
    --ink:          #241c16;
    --ink-dim:      #6b5c4d;
    --ink-faint:    #9a8a78;
    --amber:        #b87512;
    --amber-soft:   #d99a35;
    --amber-glow:   rgba(184, 117, 18, .13);
    --jade:         #3d7a64;
    --jade-soft:    #5c9a82;
    --jade-glow:    rgba(61, 122, 100, .12);
    --terracotta:   #a8502c;
    --on-accent:    #fffaf2;
    --shadow:       0 2px 10px rgba(80,60,35,.10);
    --shadow-lift:  0 8px 28px rgba(80,60,35,.16);
  }
}

:root[data-theme="light"] {
  --bg:           #f6f0e6;
  --surface:      #fffaf2;
  --surface-2:    #f1e7d8;
  --surface-sunk: #ebe0cf;
  --line:         #ddcdb4;
  --line-soft:    #e8dbc6;
  --ink:          #241c16;
  --ink-dim:      #6b5c4d;
  --ink-faint:    #9a8a78;
  --amber:        #b87512;
  --amber-soft:   #d99a35;
  --amber-glow:   rgba(184, 117, 18, .13);
  --jade:         #3d7a64;
  --jade-soft:    #5c9a82;
  --jade-glow:    rgba(61, 122, 100, .12);
  --terracotta:   #a8502c;
  --on-accent:    #fffaf2;
  --shadow:       0 2px 10px rgba(80,60,35,.10);
  --shadow-lift:  0 8px 28px rgba(80,60,35,.16);
}

/* ===========================================================================
   Base
   =========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; background: none; border: none; }

h1, h2, h3 { margin: 0; font-weight: 600; }

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

/* ===========================================================================
   Header — karst ridgeline
   =========================================================================== */

.app-header {
  position: relative;
  padding: 26px var(--gutter) 0;
  background: linear-gradient(175deg, var(--surface-2), var(--bg) 70%);
  overflow: hidden;
}

.app-header__inner {
  position: relative;
  z-index: 2;
  max-width: 760px;
  margin: 0 auto;
}

.app-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.05;
}

.app-desc {
  margin-top: 5px;
  color: var(--ink-dim);
  font-size: 13.5px;
}

/* The limestone ridge. Texture, not decoration — kept very low contrast. */
.karst {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  width: 100%;
  height: 46px;
  display: block;
  opacity: .5;
  pointer-events: none;
  z-index: 1;
}
.karst path { fill: var(--bg); }
.karst .ridge-far  { fill: var(--surface); opacity: .55; }
.karst .ridge-near { fill: var(--bg); }

/* ===========================================================================
   Stat strip
   =========================================================================== */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border-block: 1px solid var(--line-soft);
}

@media (min-width: 620px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}

.stat {
  background: var(--surface);
  padding: 13px 14px 14px;
  min-height: 74px;
}

.stat__label {
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}

.stat__value {
  margin-top: 3px;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.stat__value--accent { color: var(--amber); }

.stat__sub {
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--ink-dim);
}

/* ===========================================================================
   Tabs — bottom-anchored on phones, where thumbs are
   =========================================================================== */

.tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px 8px;
  min-height: var(--tap);
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  transition: color .18s var(--ease);
}

.tab svg { width: 21px; height: 21px; }
.tab[aria-selected="true"] { color: var(--amber); }
.tab[aria-selected="true"] svg { filter: drop-shadow(0 0 7px var(--amber-glow)); }

/* ===========================================================================
   Container
   =========================================================================== */

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.panel { padding-top: 18px; }
.panel[hidden] { display: none; }

.section-title {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 26px 0 10px;
}

/* ===========================================================================
   Itinerary — the route
   =========================================================================== */

/* Location ribbon: the line passes through it */
.place {
  position: relative;
  margin: 26px 0 12px;
  padding: 9px 14px 9px 40px;
  background: linear-gradient(90deg, var(--amber-glow), transparent 75%);
  border-left: 2px solid var(--amber);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.place__name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.place__meta {
  font-size: 11.5px;
  color: var(--ink-dim);
  margin-top: 1px;
}

.place svg {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--amber);
}

/* -- day ------------------------------------------------------------------ */

.day {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.day--open {
  border-color: var(--line);
  box-shadow: var(--shadow-lift);
}

.day--today { border-color: var(--amber); }

.day__banner {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  text-align: left;
  min-height: var(--tap);
}

.day__icon {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--amber);
}
.day__icon svg { width: 21px; height: 21px; }

/* These are spans inside a span, so they need explicit block display. */
.day__num, .day__line, .day__badges { display: block; }

.day__num {
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 650;
}

.day__date { color: var(--ink-dim); font-weight: 500; }

.day__line {
  font-family: var(--font-display);
  font-size: 15.5px;
  line-height: 1.3;
  margin-top: 2px;
}

.day__know {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-dim);
  display: flex;
  gap: 5px;
  align-items: baseline;
}
/* without an explicit size an inline SVG expands to fill the flex line */
.day__know svg {
  width: 12px; height: 12px;
  flex: none;
  color: var(--ink-faint);
  position: relative; top: 1px;
}

.day__chev {
  color: var(--ink-faint);
  transition: transform .25s var(--ease);
}
.day--open .day__chev { transform: rotate(90deg); }

.day__badges { display: flex; gap: 5px; margin-top: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--ink-dim);
}
.badge svg { width: 12px; height: 12px; }
.badge--warn { color: var(--terracotta); background: color-mix(in srgb, var(--terracotta) 14%, transparent); }

/* -- the unfolding body --------------------------------------------------- */

.day__body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s var(--ease);
}
.day--open .day__body { grid-template-rows: 1fr; }

.day__bodyInner {
  overflow: hidden;
  min-height: 0;
}

.timeline {
  position: relative;
  padding: 2px 14px 14px calc(var(--rail) + 26px);
  border-top: 1px solid var(--line-soft);
}

/* the route line itself */
.timeline::before {
  content: '';
  position: absolute;
  left: calc(var(--rail) + 8px);
  top: 12px; bottom: 18px;
  width: 2px;
  background: linear-gradient(var(--line), var(--line-soft));
}

.item {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  padding: 11px 0;
  width: 100%;
  text-align: left;
  min-height: var(--tap);
}

.item + .item { border-top: 1px solid var(--line-soft); }

/* node on the line */
.item::before {
  content: '';
  position: absolute;
  left: calc(-26px + 3px);
  top: 18px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
  z-index: 1;
}

.item--travel::before { border-color: var(--amber); background: var(--amber); }
.item--stay::before   { border-color: var(--jade); background: var(--jade); }

/* travel breaks the line — a journey is a transition, and should look like one */
.item--travel::after {
  content: '';
  position: absolute;
  left: -24px;
  top: 4px; bottom: 4px;
  width: 6px;
  background: var(--surface);
}

.item__time {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.item__time--none { color: var(--ink-faint); font-weight: 500; }

.item__what {
  font-size: 14.5px;
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 7px;
}
.item__what svg { width: 15px; height: 15px; color: var(--ink-faint); flex: none; }

.item__meta {
  display: block;
  font-size: 12px;
  color: var(--ink-dim);
  margin-top: 2px;
}

.item__cost {
  display: block;
  font-size: 12px;
  color: var(--terracotta);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.item--pending { opacity: .55; }

.day__add {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding: 0 14px 14px calc(var(--rail) + 26px);
}

.add-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 99px;
  border: 1px dashed var(--line);
  color: var(--ink-dim);
  transition: color .16s, border-color .16s;
}
.add-btn:hover { color: var(--amber); border-color: var(--amber); }
.add-btn svg { width: 13px; height: 13px; }

/* ===========================================================================
   Money
   =========================================================================== */

.money-total {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  margin-bottom: 14px;
}

.money-total__value {
  font-size: 32px;
  font-weight: 680;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}

.owed {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 14px;
}
.owed strong { color: var(--amber); }
.owed--settled strong { color: var(--jade); }

.cat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line-soft);
  width: 100%;
  text-align: left;
}

.cat__icon {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--amber);
  flex: none;
}
.cat__icon svg { width: 17px; height: 17px; }

.cat__name { display: block; font-weight: 600; font-size: 14px; }
.cat__sub { display: block; font-size: 11.5px; color: var(--ink-dim); }
.bar { display: block; }
.cat__value {
  margin-left: auto;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 5px;
  border-radius: 99px;
  background: var(--surface-sunk);
  overflow: hidden;
  margin-top: 7px;
}
/* inline spans ignore height, so this must be a block */
.bar__fill { display: block; height: 100%; background: var(--amber); border-radius: 99px; }
.bar__fill--jade { background: var(--jade); }

/* ===========================================================================
   Checklist
   =========================================================================== */

.check-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line-soft);
}

.check-row__what { font-size: 14px; }
.check-row--done .check-row__what { color: var(--ink-faint); text-decoration: line-through; }

.check-head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  padding: 0 2px 7px;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 650;
}
.check-head span:not(:first-child) { width: 46px; text-align: center; }

.box {
  width: 46px;
  display: grid;
  place-items: center;
  min-height: var(--tap);
}

.box__inner {
  width: 24px; height: 24px;
  border-radius: 7px;
  border: 2px solid var(--line);
  display: grid; place-items: center;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.box__inner svg { width: 14px; height: 14px; color: var(--on-accent); opacity: 0; transition: opacity .16s; }

.box--on .box__inner { background: var(--jade); border-color: var(--jade); }
.box--on .box__inner svg { opacity: 1; }

.box--na { opacity: .22; pointer-events: none; }
.box--na .box__inner { border-style: dashed; }

/* ===========================================================================
   Status, empties, dialogs
   =========================================================================== */

.status {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lift);
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.35;
  text-align: left;
  max-width: calc(100vw - 32px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.status--show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.status--error { border-color: var(--terracotta); color: var(--terracotta-soft); }

.spinner {
  width: 13px; height: 13px;
  border: 2px solid var(--line);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--ink-faint);
}
.empty__title {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--ink-dim);
  margin-bottom: 5px;
}

/* -- sheet-style dialog --------------------------------------------------- */

dialog.sheet {
  border: none;
  padding: 0;
  background: transparent;
  /* the UA stylesheet sets dialog{color:CanvasText}, which beats inheritance */
  color: var(--ink);
  max-width: 100%;
  width: 100%;
  margin: auto auto 0;
}
dialog.sheet::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }

.sheet__panel {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  padding: 8px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
  max-width: 620px;
  margin: 0 auto;
}

@media (min-width: 620px) {
  dialog.sheet { margin: auto; max-width: 620px; }
  .sheet__panel { border-radius: 18px; border: 1px solid var(--line); }
}

/* full-width flex item, but the visible pill is drawn small and centred */
.sheet__grab { margin: 6px 0 14px; }
.sheet__grab::after {
  content: '';
  display: block;
  width: 36px; height: 4px;
  border-radius: 99px;
  background: var(--line);
  margin: 0 auto;
}

.sheet__title {
  font-family: var(--font-display);
  font-size: 19px;
  margin-bottom: 14px;
}

.field { margin-bottom: 13px; }
.field__label {
  display: block;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 650;
  margin-bottom: 5px;
}

.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 16px;            /* 16px stops iOS zooming on focus */
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-glow);
}
.field textarea { min-height: 74px; resize: vertical; }

/* The form is a wrapping flex row so half-width fields pair up cleanly
   (leave date / leave time) instead of relying on inline-block whitespace. */
.sheet__panel { display: flex; flex-wrap: wrap; column-gap: 8px; }
.sheet__panel > * { flex: 1 1 100%; min-width: 0; }
.field--half { flex: 1 1 calc(50% - 4px); }

.field--check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
}
.field--check input { width: 21px; height: 21px; accent-color: var(--jade); }
.field--check label { font-size: 14px; }

.sheet__actions {
  display: flex;
  gap: 9px;
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line-soft);
}

.btn {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius-sm);
  font-weight: 650;
  font-size: 14.5px;
  min-height: var(--tap);
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn--primary { background: var(--amber); color: var(--on-accent); }
.btn--ghost { border: 1px solid var(--line); color: var(--ink-dim); flex: 0 0 auto; padding-inline: 18px; }
.btn--danger { color: var(--terracotta); border: 1px solid var(--line); flex: 0 0 auto; padding-inline: 16px; }

/* ===========================================================================
   Motion
   =========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
