/* ==========================================================================
   TravelGoblin – stil
   Designprinciper och komponenter beskrivs i docs/DESIGN.md.
   Inspiration: Tallink Silja-appen – mörk havsblå botten, vita kantiga
   paneler, grön accent, stora tydliga siffror.
   ========================================================================== */

:root {
  /* Färger */
  --bg: #0f2c3c;           /* mörk havsblå bakgrund */
  --bg-2: #173d51;
  --bg-line: #2c5669;      /* tidslinjens linje */
  --card: #ffffff;
  --card-2: #f3f6f7;       /* fält / sekundär yta */
  --ink: #142430;          /* text */
  --muted: #5b6b75;
  --faint: #8a979f;
  --line: #e2e8eb;
  --accent: #0c8670;       /* länkar, knappar ("ÄNDRA →") */
  --accent-ink: #086352;
  --accent-soft: #e3f3ef;
  --lime: #9bd13b;         /* "NU" och pågående */
  --lime-ink: #3d5a0c;
  --warn: #c98a00;
  --warn-soft: #fff4d6;
  --danger: #cc3b33;
  --danger-soft: #fde7e5;
  --on-dark: #ffffff;
  --on-dark-muted: #a9c0cb;

  /* Form */
  --radius: 4px;
  --radius-lg: 10px;
  --gutter: 10px;          /* luft mellan kort och skärmkant, som i Tallink-appen */
  --maxw: 560px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 6px 18px rgba(0, 0, 0, .14);

  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
body.no-scroll { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
#app { max-width: var(--maxw); margin: 0 auto; padding-bottom: calc(40px + var(--safe-bottom)); }

.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .04em; font-weight: 700; }

/* ---------- Knappar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 0; border-radius: var(--radius);
  font-weight: 800; font-size: 15px; letter-spacing: .02em; text-decoration: none;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:active { background: var(--accent-ink); }
.btn--ghost { background: var(--accent-soft); color: var(--accent-ink); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--ghost-danger { background: transparent; color: var(--danger); }
.btn--block { display: flex; width: 100%; }
.btn--big { min-height: 56px; font-size: 16px; }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row .btn { flex: 1; }

.link-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none;
  color: var(--accent); font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
}
.round-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .92); color: var(--ink); box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.round-btn--dark { background: var(--bg-2); color: var(--on-dark); box-shadow: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: var(--card-2); color: var(--accent-ink);
}
.icon-btn--small { width: 28px; height: 28px; margin-left: 6px; vertical-align: middle; }
.icon-btn--small .icon { width: 15px; height: 15px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 10px;
  border: 1px solid var(--accent); border-radius: 99px; background: #fff; color: var(--accent-ink);
  font-size: 13px; font-weight: 700;
}
.chip-btn:disabled { opacity: .6; }

/* ---------- Etiketter (chips) ---------- */
.chip {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
}
.chip--now { background: var(--lime); color: var(--lime-ink); }
.chip--next { background: var(--accent); color: #fff; }
.chip--ok { background: var(--accent-soft); color: var(--accent-ink); }
.chip--info { background: #e6eef3; color: #2a4a5c; }
.chip--warn { background: var(--warn-soft); color: #7a5300; }
.chip--danger { background: var(--danger); color: #fff; }
.chip--light { background: rgba(255, 255, 255, .92); color: var(--ink); }
.chip--muted { background: rgba(0, 0, 0, .45); color: #fff; }

/* ---------- Kort (paneler) ---------- */
.card {
  position: relative;
  margin: 0 var(--gutter);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 12px;
}
.card[data-action] { cursor: pointer; }
.card[data-action]:active { transform: scale(.995); }
.card__head { display: flex; align-items: center; gap: 8px; min-height: 24px; margin-bottom: 12px; }
.card__type {
  display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.card__type .icon { color: var(--accent); width: 20px; height: 20px; }
.card__code { font-size: 13px; font-weight: 800; color: var(--ink); letter-spacing: .03em; }
.card__chips { margin-left: auto; display: flex; gap: 6px; }
.card__title { font-size: 21px; font-weight: 700; line-height: 1.2; }
.card__sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card__note { margin-top: 6px; color: var(--ink); white-space: pre-wrap; }
.card__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line);
}
.card__actions { display: flex; gap: 18px; margin-left: auto; }
.card__updated { display: inline-flex; align-items: center; gap: 4px; color: var(--faint); font-size: 12px; }
.card__updated .icon { width: 14px; height: 14px; }

/* Tillstånd */
.card.is-past { opacity: .62; box-shadow: none; }
.card.is-past:hover { opacity: .9; }
.card.is-current { box-shadow: 0 0 0 3px var(--lime), var(--shadow); }
.card.is-next { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.card--note { background: #fbfaf3; }

/* Resväg (flyg/tåg/båt/buss): Från ⇄ Till */
.route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; }
.route__end { display: flex; flex-direction: column; min-width: 0; }
.route__end--right { text-align: right; }
.route__label { font-size: 12px; color: var(--muted); font-weight: 600; }
.route__time { font-size: 34px; font-weight: 800; line-height: 1.05; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.route__place { font-size: 17px; font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.route__date { font-size: 13px; color: var(--muted); }
.route__mid { display: flex; flex-direction: column; align-items: center; padding-top: 22px; min-width: 64px; position: relative; }
.route__line { position: absolute; top: 37px; left: 0; right: 0; border-top: 2px dotted var(--line); }
.route__icon {
  position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: #fff; border: 1px solid var(--line); color: var(--accent);
}
.route__dur { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.time-old { color: var(--faint); font-size: 20px; font-weight: 600; }
.time-new { color: var(--warn); }

/* Stora datum (boende/hyrbil) */
.bigdates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.bigdate { border-top: 1px solid var(--line); padding-top: 10px; }
.bigdate + .bigdate { border-left: 1px solid var(--line); padding-left: 12px; }
.bigdate__label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.bigdate__row { display: flex; align-items: center; gap: 8px; }
.bigdate__day { font-size: 54px; font-weight: 800; line-height: .9; letter-spacing: -.03em; color: var(--ink); }
.bigdate__meta { font-size: 14px; line-height: 1.25; color: var(--ink); font-weight: 500; }
.bigdate__empty { font-size: 32px; color: var(--faint); }

/* Händelse (restaurang/aktivitet) */
.event { display: flex; gap: 16px; align-items: flex-start; }
.event__time { display: flex; flex-direction: column; min-width: 78px; }
.event__clock { font-size: 30px; font-weight: 800; line-height: 1.05; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.event__until { font-size: 13px; color: var(--muted); }
.event__main { min-width: 0; padding-top: 3px; }

/* Faktarutor: bokningsnummer, säte, vagn … */
.facts {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px;
  margin: 14px 0 0; padding: 12px; background: var(--card-2); border-radius: var(--radius);
}
.fact { min-width: 0; }
.fact--wide { grid-column: span 2; }
.fact dt { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.fact dd { display: flex; align-items: center; margin: 2px 0 0; font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }

.extras { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.extra {
  display: flex; align-items: flex-start; gap: 8px; padding: 6px 0;
  color: var(--accent-ink); font-size: 14px; font-weight: 600; text-decoration: none;
}
.extra .icon { margin-top: 1px; }
.extra--note { color: var(--ink); font-weight: 400; white-space: pre-wrap; }

/* ---------- Startsida ---------- */
.apphead {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 16px 14px; color: var(--on-dark);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -.01em; }
.brand__icon { color: var(--lime); width: 28px; height: 28px; }
.home__list { display: flex; flex-direction: column; gap: 12px; padding: 0 var(--gutter); }
.home__list > .card { margin: 0; }

.tripcard {
  position: relative; display: block; height: 190px; overflow: hidden; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--bg-2), #24607a); color: #fff; text-decoration: none; box-shadow: var(--shadow);
}
.tripcard--past { filter: saturate(.6); }
.tripcard__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tripcard__shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 35%, rgba(5, 25, 36, .82)); }
.tripcard__chip { position: absolute; top: 12px; right: 12px; }
.tripcard__text { position: absolute; left: 16px; right: 16px; bottom: 14px; display: flex; flex-direction: column; }
.tripcard__name { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; text-shadow: 0 1px 8px rgba(0,0,0,.35); }
.tripcard__meta { font-size: 14px; color: rgba(255,255,255,.88); margin-top: 2px; }

.intro { padding: 22px 18px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.intro__title { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.intro p { color: var(--muted); }

/* ---------- Resans omslag (hero) ---------- */
.hero {
  position: relative; height: calc(300px + var(--safe-top)); overflow: hidden; color: #fff;
  background: linear-gradient(135deg, var(--bg-2), #24607a);
}
.hero__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero__shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.28) 0, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 45%, rgba(8, 30, 42, .85) 100%); }
.hero__bar { position: absolute; top: calc(12px + var(--safe-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; }
.hero__text { position: absolute; left: 18px; right: 18px; bottom: 50px; }
.hero__title { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; text-shadow: 0 2px 12px rgba(0,0,0,.35); }
.hero__meta { margin-top: 4px; font-size: 15px; color: rgba(255,255,255,.9); }
.hero__credit { position: absolute; right: 8px; bottom: 32px; font-size: 10px; color: rgba(255,255,255,.7); text-decoration: none; }

.trip__body { position: relative; margin-top: -26px; }

/* ---------- Statuskort: var är jag? ---------- */
.status { padding: 18px 16px 16px; }
.status__top { display: flex; align-items: center; justify-content: space-between; }
.status__kicker {
  display: flex; align-items: center; gap: 8px; color: var(--muted);
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.status__title { font-size: 24px; font-weight: 800; letter-spacing: -.01em; margin-top: 4px; }
.status__text { color: var(--muted); margin: 6px 0 14px; }
.status__big { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 12px; }
.status__num { font-size: 64px; font-weight: 800; line-height: .95; letter-spacing: -.04em; }
.status__unit { font-size: 18px; font-weight: 600; color: var(--muted); }
.status__now, .status__next {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  border: 0; background: none; padding: 12px 0 0; margin-top: 12px; border-top: 1px solid var(--line);
}
.status__label { font-size: 12px; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.status__what { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; }
.status__what .icon { color: var(--accent); }
.status__when { font-size: 14px; color: var(--muted); }
.status--live { box-shadow: 0 0 0 3px var(--lime), var(--shadow); }
.status--live .status__now .status__label { color: var(--lime-ink); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 0 rgba(155, 209, 59, .7); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(155, 209, 59, 0); } 100% { box-shadow: 0 0 0 0 rgba(155, 209, 59, 0); } }

/* ---------- Tidslinjen ---------- */
.timeline { position: relative; padding-top: 4px; }

/* (+) mellan korten: en kort lodrät linje med en rund knapp på */
.adder { position: relative; display: flex; justify-content: center; align-items: center; height: 44px; }
.adder::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 2px solid var(--bg-line); }
.adder__btn {
  position: relative; display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border-radius: 50%; border: 2px solid var(--bg-line); background: var(--bg); color: var(--on-dark-muted);
  transition: transform .15s, background .15s, color .15s;
}
.adder__btn .icon { width: 16px; height: 16px; }
.adder__btn:hover, .adder__btn:focus-visible { background: var(--accent); border-color: var(--accent); color: #fff; transform: scale(1.1); }
.adder--labeled { height: 80px; gap: 10px; }
.adder--labeled .adder__btn { width: 48px; height: 48px; background: var(--accent); border-color: var(--accent); color: #fff; }
.adder--labeled .adder__label { position: relative; color: var(--on-dark); font-weight: 700; background: var(--bg); padding: 0 6px; }

/* Dagrubrik */
.day {
  display: flex; align-items: baseline; gap: 10px; margin: 8px var(--gutter) 10px; padding: 0 4px;
  color: var(--on-dark); font-size: 18px; font-weight: 700;
}
.day__date::first-letter { text-transform: uppercase; }
.day__num { font-size: 12px; font-weight: 800; color: var(--on-dark-muted); text-transform: uppercase; letter-spacing: .1em; }
.day__today { margin-left: auto; font-size: 11px; font-weight: 800; color: var(--lime); text-transform: uppercase; letter-spacing: .1em; }
.day--past { color: var(--on-dark-muted); }

/* Liten rad för t.ex. utcheckning */
.endmark {
  display: flex; align-items: center; gap: 10px; margin: 0 var(--gutter); padding: 10px 14px;
  border: 1px dashed var(--bg-line); border-radius: var(--radius); color: var(--on-dark); font-size: 14px; cursor: pointer;
}
.endmark .icon { color: var(--lime); }
.endmark__time { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.endmark.is-past { opacity: .55; }

/* NU-markör */
.now { position: relative; display: flex; align-items: center; gap: 8px; margin: 6px var(--gutter); scroll-margin: 120px; }
.now::after { content: ""; flex: 1; height: 2px; background: var(--lime); border-radius: 2px; }
.now__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px rgba(155, 209, 59, .25); }
.now__label { color: var(--lime); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

/* ---------- Formulär ---------- */
.editor { min-height: 100vh; background: var(--card-2); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 80px 1fr 80px; align-items: center;
  padding: calc(8px + var(--safe-top)) 8px 8px; background: var(--bg); color: var(--on-dark);
}
.topbar__btn { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--on-dark-muted); font-weight: 600; text-align: left; }
.topbar__btn--strong { color: var(--lime); font-weight: 800; text-align: right; }
.topbar__title { display: flex; flex-direction: column; align-items: center; font-weight: 800; text-align: center; line-height: 1.2; }
.topbar__title small { font-weight: 500; font-size: 12px; color: var(--on-dark-muted); }
.topbar__icon { color: var(--lime); }
.form { padding: 16px 14px 40px; display: flex; flex-direction: column; gap: 14px; }
.form__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; }
.field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field--half { grid-column: span 1; }
.field label, .field legend, .field > span { font-size: 13px; font-weight: 700; color: var(--muted); padding: 0; }
.req { color: var(--danger); }
.input {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #cfd8dd; border-radius: var(--radius);
  background: #fff; font-size: 16px; /* 16px hindrar iPhone från att zooma in */
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.input--big { font-size: 20px; font-weight: 700; min-height: 56px; }
textarea.input { resize: vertical; min-height: 84px; }
.dt { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }
.dt .input { min-width: 0; -webkit-appearance: none; appearance: none; }
.form__hint { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.form-inline { display: flex; flex-direction: column; gap: 14px; }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- Bottom sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(4, 18, 26, .55); opacity: 0; transition: opacity .22s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: var(--maxw); margin: 0 auto; max-height: 88vh; overflow: auto;
  background: #fff; border-radius: 16px 16px 0 0; padding: 8px 18px calc(22px + var(--safe-bottom));
  transform: translateY(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet-wrap.is-open .sheet-backdrop { opacity: 1; }
.sheet-wrap.is-open .sheet { transform: none; }
.sheet__grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet__title { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.sheet__text { color: var(--muted); }

.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.type-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 6px;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; font-weight: 700; font-size: 14px;
}
.type-tile .icon { width: 30px; height: 30px; color: var(--accent); }
.type-tile:active { background: var(--accent-soft); }

.menu { display: flex; flex-direction: column; }
.menu__item {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 4px; border: 0;
  border-bottom: 1px solid var(--line); background: none; font-weight: 600; text-align: left; cursor: pointer;
}
.menu__item .icon { color: var(--accent); }
.menu__item small { margin-left: auto; color: var(--faint); font-weight: 500; }
.menu__item--danger, .menu__item--danger .icon { color: var(--danger); }
.tip { margin-top: 16px; padding: 12px 14px; background: var(--accent-soft); border-radius: var(--radius); font-size: 14px; color: var(--accent-ink); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); z-index: 100; max-width: calc(100% - 32px);
  transform: translate(-50%, 20px); opacity: 0; transition: all .25s;
  padding: 12px 16px; border-radius: var(--radius-lg); background: #10222d; color: #fff; font-weight: 600; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
.toast--warn { background: #5a3f00; }
.toast--danger { background: var(--danger); }

.error { margin-top: 40px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* Liten skärm (t.ex. iPhone SE) */
@media (max-width: 360px) {
  .route__time { font-size: 28px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .bigdate__day { font-size: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
