/* ==========================================================================
   Hyttelogg – designsystem
   Fargetokener styrer hele uttrykket; endre dem her for å bytte tema.
   ========================================================================== */

:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #ece7dc;
  --text: #1d2420;
  --text-muted: #66706a;
  --border: rgba(29, 36, 32, 0.08);
  --primary: #2f6b4f;
  --primary-contrast: #ffffff;
  --primary-soft: #dcebe2;
  --accent: #d9822b;
  --danger: #b4423a;
  --shadow-sm: 0 1px 2px rgba(20, 30, 25, 0.06), 0 1px 3px rgba(20, 30, 25, 0.04);
  --shadow-lg: 0 10px 30px rgba(20, 30, 25, 0.14), 0 2px 8px rgba(20, 30, 25, 0.06);
  --topbar-bg: rgba(244, 241, 234, 0.8);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181a;
    --surface: #1d2326;
    --surface-2: #262e31;
    --text: #e9ece8;
    --text-muted: #9aa5a0;
    --border: rgba(255, 255, 255, 0.07);
    --primary: #6fbf93;
    --primary-contrast: #0f1a14;
    --primary-soft: #23382d;
    --accent: #f0a456;
    --danger: #e3776e;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --topbar-bg: rgba(20, 24, 26, 0.78);
  }
}

:root[data-theme="dark"] {
  --bg: #14181a;
  --surface: #1d2326;
  --surface-2: #262e31;
  --text: #e9ece8;
  --text-muted: #9aa5a0;
  --border: rgba(255, 255, 255, 0.07);
  --primary: #6fbf93;
  --primary-contrast: #0f1a14;
  --primary-soft: #23382d;
  --accent: #f0a456;
  --danger: #e3776e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --topbar-bg: rgba(20, 24, 26, 0.78);
}

/* ---------- Grunnstiler ---------- */

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

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

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Layout ---------- */

.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: var(--safe-top);
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: 720px;
  margin: 0 auto;
  height: 56px;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand__logo { width: 32px; height: 32px; border-radius: 9px; }
.brand__title { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }

.status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.content {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) calc(var(--tabbar-h) + var(--safe-bottom) + var(--space-6));
  outline: none;
}

/* ---------- Tab bar ---------- */

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
}

.tabbar__item {
  flex: 0 1 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.tabbar__item svg { width: 22px; height: 22px; }
.tabbar__item[aria-current="page"] { color: var(--primary); }

/* ---------- Seksjoner og kort ---------- */

.section-title {
  margin: var(--space-5) var(--space-1) var(--space-2);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.section-title:first-child { margin-top: var(--space-2); }

.list { display: flex; flex-direction: column; gap: var(--space-2); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

.empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
}

.empty__emoji { font-size: 2.6rem; margin-bottom: var(--space-2); }
.empty h2 { margin: 0 0 var(--space-1); font-size: 1.1rem; color: var(--text); }
.empty p { margin: 0; }

.skeleton {
  height: 74px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

/* ---------- Innstillinger ---------- */

.settings { padding: 0; overflow: hidden; }

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
}

.setting + .setting { border-top: 1px solid var(--border); }
.setting__text strong { display: block; font-weight: 600; }
.setting__text small { color: var(--text-muted); }

/* ---------- Skjema ---------- */

.field { display: block; margin-bottom: var(--space-4); }
.field__label { display: block; margin-bottom: 6px; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }

.field input:not([type="checkbox"]),
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 0.2s, background 0.2s;
}

.field input:focus,
.field textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.field textarea { resize: vertical; min-height: 80px; }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.chip[aria-checked="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }

.switch-row { display: flex; align-items: center; justify-content: space-between; margin: var(--space-2) 0 var(--space-4); font-weight: 500; }

.switch {
  appearance: none;
  position: relative;
  flex: none;
  width: 50px;
  height: 30px;
  margin: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s var(--ease);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s var(--ease);
}

.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Knapper ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 46px;
  padding: 0 var(--space-5);
  border: 0;
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s, background 0.2s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: var(--primary-contrast); }
.btn--ghost { background: var(--surface-2); color: var(--text); }
.btn--block { width: 100%; }
.btn--lg { min-height: 58px; font-size: 1.05rem; border-radius: 18px; }
.btn--lg svg { width: 22px; height: 22px; }
.btn--danger {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}

/* ---------- Bottom sheet (dialog) ---------- */

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.sheet[open] { animation: sheet-up 0.3s var(--ease); }
.sheet::backdrop { background: rgba(10, 15, 12, 0.45); backdrop-filter: blur(2px); }

.sheet__body { padding: var(--space-3) var(--space-5) calc(var(--space-5) + var(--safe-bottom)); }
.sheet__handle { width: 40px; height: 5px; margin: 0 auto var(--space-4); border-radius: 999px; background: var(--surface-2); }
.sheet__title { margin: 0 0 var(--space-4); font-size: 1.25rem; }
.sheet__text { margin: calc(-1 * var(--space-2)) 0 var(--space-5); color: var(--text-muted); }
.sheet__actions { display: grid; grid-template-columns: 1fr 2fr; gap: var(--space-3); }

@media (min-width: 640px) {
  .sheet { margin: auto; border-radius: var(--radius-lg); }
  .sheet[open] { animation: pop 0.25s var(--ease); }
}

/* ---------- Hytta: hero og stor knapp ---------- */

.hero {
  text-align: center;
  padding: var(--space-6) var(--space-2) var(--space-5);
}

.hero__kicker {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
}

.hero__title { margin: var(--space-1) 0 0; font-size: clamp(1.7rem, 7vw, 2.2rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.hero__sub { margin: var(--space-2) 0 0; color: var(--text-muted); }
.hero__hint { margin: var(--space-5) 0 0; font-size: 0.85rem; color: var(--text-muted); }

.big-button {
  position: relative;
  width: min(68vw, 260px);
  aspect-ratio: 1;
  margin: var(--space-6) auto 0;
  border: 0;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--primary) 70%, #fff) 0%, var(--primary) 60%);
  color: var(--primary-contrast);
  box-shadow:
    0 18px 40px color-mix(in srgb, var(--primary) 40%, transparent),
    inset 0 -6px 16px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  -webkit-user-select: none;
  user-select: none;
}

.big-button svg { width: 64px; height: 64px; stroke-width: 1.8; }
.big-button__label { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; padding: 0 var(--space-4); }
.big-button:hover { transform: translateY(-2px); }
.big-button:active { transform: scale(0.96); }
.big-button:disabled { cursor: progress; }

.big-button__ring {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--primary) 35%, transparent);
  animation: ring 2.4s var(--ease) infinite;
  pointer-events: none;
}

.big-button.is-busy .big-button__ring { animation-duration: 0.9s; }
.big-button.is-busy svg { animation: bob 1s ease-in-out infinite; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
}

.pill--sm { padding: 2px 10px; font-size: 0.75rem; }

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 60%, transparent);
  animation: pulse 1.8s infinite;
}

.hero--active { padding-top: var(--space-5); }
.hero--active .hero__title { margin-top: var(--space-3); }

.duration {
  margin: var(--space-4) 0 0;
  font-size: clamp(2.4rem, 12vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

/* ---------- Vær ---------- */

.card--weather { margin-bottom: var(--space-5); }
.card__label { margin: 0 0 var(--space-3); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.card__foot { margin: var(--space-4) 0 0; padding-top: var(--space-3); border-top: 1px solid var(--border); font-size: 0.88rem; }

.weather { display: flex; align-items: center; gap: var(--space-4); }
.weather--empty { color: var(--text-muted); }
.weather__icon { font-size: 2.8rem; line-height: 1; }
.weather__temp { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; }
.weather__text { display: flex; flex-direction: column; gap: 2px; font-size: 0.92rem; color: var(--text-muted); }
.weather__text strong { color: var(--text); font-weight: 600; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-muted); }

/* ---------- Turer ---------- */

.trip { animation: rise 0.35s var(--ease) both; }
.trip__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.trip__title { margin: 0; font-size: 1rem; font-weight: 600; }
.trip__title::first-letter { text-transform: uppercase; }
.trip__meta { margin: 2px 0 0; font-size: 0.85rem; color: var(--text-muted); }
.trip__weather { display: flex; align-items: center; gap: 6px; font-size: 1.4rem; white-space: nowrap; }
.trip__weather strong { font-size: 1rem; }
.trip__foot { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin-top: var(--space-3); font-size: 0.82rem; }

.skeleton--hero { height: 420px; border-radius: var(--radius-lg); }

/* ---------- Innlogging ---------- */

body.is-locked .tabbar { display: none; }

.login {
  max-width: 360px;
  margin: 0 auto;
  padding: var(--space-6) 0;
  text-align: center;
  animation: rise 0.35s var(--ease) both;
}

.login__logo { width: 88px; height: 88px; border-radius: 24px; box-shadow: var(--shadow-lg); }
.login__title { margin: var(--space-5) 0 var(--space-1); font-size: 1.8rem; font-weight: 800; letter-spacing: -0.02em; }
.login__sub { margin: 0 0 var(--space-6); color: var(--text-muted); }
.login__form { text-align: left; }
.login__error { margin: calc(-1 * var(--space-2)) 0 var(--space-4); color: var(--danger); font-size: 0.9rem; font-weight: 500; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 90px);
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  animation: toast-in 0.25s var(--ease);
}

/* ---------- Animasjoner ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes ring { 0% { transform: scale(0.94); opacity: 1; } 100% { transform: scale(1.12); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

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