/* Skallet: fast toppbar, faner (PC) eller bunnmeny (mobil), skjermene,
   Spillknapp-menyen og streak-kortet. Toppbaren går kant til kant, men
   innholdet i den følger sidebredden (--page-w), så alt står samlet også på
   en ultrabred skjerm. Full bredde på mobil. */

/* ---------- skjermene ---------- */
.screens { position: absolute; inset: 0; z-index: 1; }
.screen {
  position: absolute; inset: 0; padding: var(--top-h) 0 var(--nav-h);
  overflow: hidden; visibility: hidden; opacity: 0; translate: var(--from, 0) 0; pointer-events: none;
  transition: opacity .2s ease-out, translate var(--dur-base) var(--ease-base), visibility 0s linear .2s;
}
.screen.is-on { visibility: visible; opacity: 1; translate: 0 0; pointer-events: auto; transition-delay: 0s; }
.screen.is-scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.app[data-mode="kamp"] .screen { padding-bottom: 0; }
.page { max-width: var(--page-w); margin: 0 auto; padding: 28px var(--gutter) 56px; }
@media (max-width: 720px) { .page { padding-top: 18px; } }

/* ---------- toppbar ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--top-h); z-index: 40;
  background: color-mix(in oklch, var(--bg) 94%, transparent); box-shadow: 0 1px 0 var(--line);
}
.tb-inner {
  height: 100%; max-width: var(--page-w); margin: 0 auto; padding: 0 var(--gutter);
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px;
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.tb-center { display: flex; justify-content: center; min-width: 0; }

/* Spillknappen: krok-merket med XP-ring */
.logo-btn { position: relative; width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.logo-ring { position: absolute; inset: -3px; border-radius: 50%; background: var(--line); pointer-events: none;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2.5px)); mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2.5px)); }
.logo-ring::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--xp-ring);
  -webkit-mask: conic-gradient(#000 calc(var(--xp, .6) * 360deg), transparent 0); mask: conic-gradient(#000 calc(var(--xp, .6) * 360deg), transparent 0); }
.logo-btn .ico-krok { width: 23px; height: 23px; stroke-width: 2.2; }
.logo-btn .ico-krok .fill { fill: var(--accent); }
.logo-btn.gulp { animation: bump .32s var(--ease-pop); }
.logo-fish { position: absolute; left: 50%; top: 100%; width: 22px; height: 22px; margin-left: -4px; color: var(--p2); pointer-events: none; transform-origin: 50% -10px; animation: fishDangle 2.6s var(--ease-out) both; }
.logo-fish::before { content: ''; position: absolute; left: 3px; top: -12px; width: 1.5px; height: 14px; background: var(--ink-3); }
.logo-fish .ico { width: 22px; height: 22px; stroke-width: 2; rotate: -90deg; }
@keyframes fishDangle { 0% { opacity: 0; translate: 0 -16px; } 12% { opacity: 1; translate: 0 6px; } 22% { rotate: 18deg; } 34% { rotate: -14deg; } 46% { rotate: 9deg; } 58% { rotate: -5deg; } 70% { rotate: 0deg; opacity: 1; } 100% { opacity: 0; translate: 0 2px; } }
.wordmark { font: 650 22px/1 var(--font-display); letter-spacing: -.045em; text-transform: lowercase; white-space: nowrap; }
.wordmark i { font-style: normal; color: var(--accent); }

/* faner (PC) */
.tabs { position: relative; display: inline-flex; padding: 4px; border-radius: 999px; background: var(--bg-2); isolation: isolate; }
.tab { position: relative; z-index: 1; height: 38px; padding: 0 18px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; font: 600 14.5px/1 var(--font-ui); color: var(--ink-3); transition: color .2s; }
.tab .ico { width: 18px; height: 18px; }

.tab.is-on { color: var(--ink); }
.tab-ind { position: absolute; z-index: 0; top: 4px; left: 0; height: 38px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-1); will-change: transform, width; }
.tab .tab-dot { position: absolute; top: 7px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); scale: 0; transition: scale var(--dur-pop) var(--ease-pop); }
.tab.has-dot .tab-dot { scale: 1; }
.tb-match { display: none; align-items: center; gap: 10px; height: 38px; padding: 0 16px; border-radius: 999px; background: var(--ink); color: var(--bg); font: 600 14px/1 var(--font-ui); white-space: nowrap; }
.tb-match b { font: 600 13px/1 var(--font-num); opacity: .7; }
.app[data-mode="kamp"] .tabs, .app[data-mode="kaaring"] .tabs { display: none; }
.app[data-mode="kamp"] .tb-match, .app[data-mode="kaaring"] .tb-match { display: inline-flex; }

/* status: streak, Gnister, bruker */
.stat-pill { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px 0 10px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-1); font: 600 14.5px/1 var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
.stat-pill .ico { width: 19px; height: 19px; }
.streak-pill .ico-flame { color: var(--line-2); fill: none; transition: color .3s; }
.streak-pill.is-lit .ico-flame { color: var(--flame-2); fill: color-mix(in oklch, var(--flame) 70%, transparent); animation: flicker 2.4s ease-in-out infinite; transform-origin: 50% 90%; }
.streak-pill.is-blue .ico-flame { color: oklch(62% .17 245); fill: oklch(78% .12 230 / .8); }
.streak-pill:not(.is-lit) b { color: var(--ink-3); }
.streak-pill.is-holding { scale: .96; }
@keyframes flicker { 0%, 100% { scale: 1 1; rotate: 0deg; } 30% { scale: .96 1.05; rotate: -3deg; } 60% { scale: 1.03 .97; rotate: 2deg; } }
.gnist-pill .ico-gnist { color: var(--accent); }
.gnist-pill.gulp { animation: bump .3s var(--ease-pop); }
.gnist-pill.is-down-count b { color: var(--bad); }
/* profilen: figuren din helt til høyre */
.profil-btn { position: relative; width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; margin-left: 4px; }
.tab-av { position: relative; display: grid; place-items: center; flex: none; }
.tab-av .avatar-disc { box-shadow: 0 0 0 1.5px var(--line-2); background: var(--surface); transition: box-shadow .2s; }
.profil-btn.is-on .avatar-disc { box-shadow: 0 0 0 2px var(--ink); }

/* streak-kortet */
.streak-pop {
  position: absolute; top: calc(var(--top-h) + 6px); z-index: 46; width: 300px; padding: 18px; border-radius: var(--r-l);
  background: var(--surface); box-shadow: var(--shadow-2); transform-origin: 50% -10px;
}
.streak-pop[inert] { pointer-events: none; }
.sp-head { display: flex; align-items: center; gap: 12px; }
.sp-flame { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; background: color-mix(in oklch, var(--flame) 18%, var(--surface)); color: var(--flame-2); }
.sp-flame .ico { width: 30px; height: 30px; fill: color-mix(in oklch, var(--flame) 70%, transparent); }
.sp-head b { display: block; font: 650 26px/1 var(--font-num); letter-spacing: -.02em; }
.sp-head small { font: 500 13px/1.3 var(--font-ui); color: var(--ink-3); }
.sp-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 16px 0 12px; }
.sp-day { display: grid; justify-items: center; gap: 6px; font: 500 11px/1 var(--font-num); color: var(--ink-3); }
.sp-day i { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-2); display: grid; place-items: center; }
.sp-day.is-done i { background: var(--flame-2); color: oklch(99% 0 0); }
.sp-day.is-done i .ico { width: 14px; height: 14px; stroke-width: 2.6; }
.sp-day.is-today i { box-shadow: 0 0 0 2px var(--ink); }
.sp-foot { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); font: 500 13px/1.3 var(--font-ui); color: var(--ink-2); }
.sp-foot .ico { width: 16px; height: 16px; color: oklch(62% .14 235); }

/* ---------- bunnmeny (mobil) ---------- */
.bottombar { display: none; }
@media (max-width: 720px) {
  .tb-inner { grid-template-columns: auto minmax(0, 1fr); padding: 0 10px; gap: 8px; }
  .tb-center { display: none; }
  .app[data-mode="kamp"] .tb-center, .app[data-mode="kaaring"] .tb-center { display: flex; position: absolute; left: 60px; right: 214px; top: 0; height: 100%; align-items: center; justify-content: flex-start; }
  .wordmark { display: none; }
  .logo-btn { width: 38px; height: 38px; }
  .stat-pill { height: 34px; padding: 0 10px 0 8px; gap: 5px; font-size: 13.5px; box-shadow: none; background: var(--bg-2); }
  .stat-pill .ico { width: 17px; height: 17px; }
  .tb-match { height: 32px; padding: 0 12px; font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .bottombar {
    display: grid; grid-template-columns: repeat(3, 1fr); position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
    height: var(--nav-h); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in oklch, var(--bg) 96%, transparent); box-shadow: 0 -1px 0 var(--line);
    transition: translate var(--dur-base) var(--ease-base);
  }
  .app[data-mode="kamp"] .bottombar, .app[data-mode="kaaring"] .bottombar { translate: 0 110%; }
  .bb-tab { position: relative; display: grid; justify-items: center; align-content: center; gap: 4px; color: var(--ink-3); font: 600 11px/1 var(--font-ui); }
  .bb-tab .ico { width: 23px; height: 23px; }
  .profil-btn { width: 38px; height: 38px; margin-left: 0; }
  .bb-tab.is-on { color: var(--ink); }
  .bb-tab .tab-dot { position: absolute; top: 8px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); scale: 0; transition: scale var(--dur-pop) var(--ease-pop); }
  .bb-tab.has-dot .tab-dot { scale: 1; }
  .bb-ind { position: absolute; top: 0; left: 0; height: 3px; border-radius: 0 0 3px 3px; background: var(--ink); will-change: transform; }
  .streak-pop { left: 10px; right: 10px; width: auto; }
}
@media (max-width: 380px) {
  .gnist-pill { padding: 0 8px 0 6px; }
}

/* ---------- Spillknapp-menyen ---------- */
.meny-scrim { position: absolute; inset: 0; z-index: 43; display: none; }
.meny-open .meny-scrim, .pop-open .meny-scrim { display: block; }
/* på vei til en annen krok */
.app.is-leaving .screens, .app.is-leaving .bottombar { opacity: 0; transition: opacity .16s ease-out; }
/* kroken sin egen kontroll: offentlig/privat (din) eller Gå ut (andres) */
.krok-ctl { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 10px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2); font: 600 13px/1 var(--font-ui); white-space: nowrap; flex: none; }
.krok-ctl .ico { width: 15px; height: 15px; }
.krok-ctl.is-privat { color: var(--ink); }
.krok-ctl.on-dark { background: oklch(100% 0 0 / .1); color: var(--app-ink-2); }
.krok-ctl.on-dark.is-privat { color: var(--app-ink); }
/* knappene i toppbaren ligger over bakteppet: et nytt trykk på samme knapp lukker */
.meny-open .topbar, .pop-open .topbar { z-index: 45; }
.meny {
  position: absolute; top: calc(var(--top-h) + 6px); left: 12px; z-index: 44; width: min(370px, calc(100vw - 24px));
  max-height: calc(100% - var(--top-h) - 24px); overflow: auto; padding: 14px; border-radius: var(--r-l);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); transform-origin: 20px -20px;
  display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain;
}
.meny[inert] { pointer-events: none; }
.meny-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 6px; }
.meny-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--ink); color: var(--bg); flex: none; }
.meny-mark .ico { width: 24px; height: 24px; }
.meny-mark .ico .fill { fill: var(--accent); }
.meny-title { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.meny-title b { font: var(--display-weight) 19px/1.1 var(--font-display); letter-spacing: -.03em; text-transform: lowercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meny-title small { font: 500 12px/1 var(--font-num); color: var(--ink-3); }
.meny-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-s); text-align: left; background: var(--bg-2); font: 600 14.5px/1.2 var(--font-ui); }
.meny-row .ico { width: 19px; height: 19px; color: var(--ink-2); }
.meny-row small { display: block; margin-top: 3px; font: 500 12px/1.2 var(--font-ui); color: var(--ink-3); }
.meny-row .row-text { flex: 1; min-width: 0; }
.meny-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.meny-vol { display: flex; align-items: center; gap: 12px; padding: 4px 12px; }
.meny-vol .ico { width: 18px; height: 18px; color: var(--ink-3); }
.meny-vol input { flex: 1; accent-color: var(--ink); }
.meny-label { font: 500 11.5px/1 var(--font-num); text-transform: lowercase; letter-spacing: .03em; color: var(--ink-3); padding: 8px 4px 0; }
.meny .seg { width: 100%; }
.meny .seg-opt { flex: 1; justify-content: center; padding: 0 6px; font-size: 13px; }
.meny-leave { background: var(--ink); color: var(--bg); justify-content: center; }
.meny-leave .ico { color: var(--bg); }
.meny-test { display: none; flex-direction: column; gap: 8px; }
.meny-test.is-open { display: flex; }
.meny-test .btn { width: 100%; }
.meny-stepper { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.meny-stepper b { min-width: 2ch; text-align: center; font: 600 15px/1 var(--font-num); }
.meny-stepper button { width: 32px; height: 32px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-1); display: grid; place-items: center; }
.meny-stepper .ico { width: 16px; height: 16px; }
