/* ================================================================
   Kippi Design System v2.0
   Tokens, reset, base styles og gjenbrukbare komponenter
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

/* ─── Design tokens ───────────────────────────────────────── */
:root {
  /* Bakgrunnssjikt */
  --bg:          #070e1b;
  --surface-1:   #0c1525;
  --surface-2:   #111e30;
  --surface-3:   #172438;

  /* Primærfarge (indigo) */
  --primary:        #6c5fff;
  --primary-light:  #9b8fff;
  --primary-dim:    rgba(108, 95, 255, 0.15);
  --primary-glow:   rgba(108, 95, 255, 0.35);

  /* Semantiske farger */
  --gold:        #fbbf24;
  --gold-dim:    rgba(251, 191, 36, 0.15);
  --green:       #34d399;
  --green-dim:   rgba(52, 211, 153, 0.15);
  --red:         #f87171;
  --red-dim:     rgba(248, 113, 113, 0.15);
  --cyan:        #38bdf8;
  --cyan-dim:    rgba(56, 189, 248, 0.15);

  /* Tekst */
  --text-1:      #e8edf8;
  --text-2:      #8892aa;
  --text-3:      #3d4d65;

  /* Kanter */
  --border:      rgba(255, 255, 255, 0.07);
  --border-2:    rgba(255, 255, 255, 0.13);

  /* Typografi */
  --font-body:    'Manrope', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;

  /* Spacing (4px-skala) */
  --s1: 4px;   --s2: 8px;   --s3: 12px;  --s4: 16px;
  --s5: 20px;  --s6: 24px;  --s8: 32px;  --s10: 40px;
  --s12: 48px; --s16: 64px; --s20: 80px;

  /* Avrunding */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-full: 9999px;

  /* Skygger */
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);

  /* Overganger */
  --ease:   cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 140ms;
  --t-base: 240ms;
  --t-slow: 400ms;

  /* Layout */
  --max-w:    1200px;
  --header-h: 64px;
}

/* ─── Reset ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg  { display: block; max-width: 100%; }
a         { color: inherit; text-decoration: none; }
button    { cursor: pointer; border: none; background: none; font: inherit; touch-action: manipulation; }
ul, ol    { list-style: none; }
input     { font: inherit; }

/* ─── Typografi ───────────────────────────────────────────── */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text-1);
}

/* ─── Layout ──────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--s6);
}

/* ─── Knapper ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s3) var(--s5);
  border-radius: var(--r-full);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97) !important; }

.btn--primary {
  background: var(--primary);
  color: #fff;
}
.btn--primary:hover {
  filter: brightness(1.14);
  box-shadow: 0 4px 20px var(--primary-glow);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border: 1.5px solid var(--border-2);
}
.btn--ghost:hover {
  color: var(--text-1);
  border-color: var(--primary);
  background: var(--primary-dim);
}
.btn-share { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; background: none; border: none; cursor: pointer; font-family: inherit; font-size: .82rem; font-weight: 600; color: var(--muted, #6b7a99); padding: 8px 0; transition: color .15s; }
.btn-share:hover { color: var(--text, #e8eaf0); }
.btn-share svg { flex-shrink: 0; }

/* ── Streak-badge ─────────────────────────────────────────────── */
.streak-badge {
  font-size: .72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 99px;
  letter-spacing: .01em;
  transition: color .3s, background .3s;
}
.streak-badge--active  { background: rgba(34,197,94,.15);  color: #22c55e; }
.streak-badge--warning { background: rgba(245,158,11,.15); color: #f59e0b; }
.streak-badge--danger  { background: rgba(239,68,68,.15);  color: #ef4444; }

.btn--sm  { padding: var(--s2) var(--s4); font-size: 0.82rem; }
.btn--lg  { padding: var(--s4) var(--s8); font-size: 1rem; }
.btn--full { width: 100%; }

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* ─── Merkelapper (badges) ────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--s3);
  border-radius: var(--r-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--text-2);
}

/* ─── Kort (base) ─────────────────────────────────────────── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s6);
}

/* ─── Inndatafelt ─────────────────────────────────────────── */
.input {
  width: 100%;
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-size: 1rem;
  transition: border-color var(--t-fast) var(--ease);
}

.input::placeholder { color: var(--text-3); }

.input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface-3);
}

/* ─── PIN-inndatafelt ─────────────────────────────────────── */
.pin-inputs {
  display: flex;
  gap: var(--s3);
  justify-content: center;
}

.pin-input {
  width: 52px;
  height: 60px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  transition: border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}

.pin-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface-3);
}

.pin-input.filled {
  border-color: var(--primary);
  color: var(--primary-light);
}

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(4, 8, 16, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: var(--s8);
  width: 100%;
  max-width: 400px;
  transform: translateY(16px) scale(0.97);
  transition: transform var(--t-base) var(--ease);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal__title {
  font-size: 1.3rem;
  margin-bottom: var(--s2);
}

.modal__sub {
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: var(--s6);
}

/* ─── Feilmelding ─────────────────────────────────────────── */
.error-msg {
  font-size: 0.82rem;
  color: var(--red);
  min-height: 1.2em;
  text-align: center;
}

/* ─── Toppliste (scoreboard) ──────────────────────────────── */
.scoreboard-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}

.scoreboard-row:hover { background: var(--surface-2); }

.scoreboard-row__rank {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-3);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.scoreboard-row__rank--gold   { color: var(--gold); }
.scoreboard-row__rank--silver { color: #94a3b8; }
.scoreboard-row__rank--bronze { color: #b87333; }

.scoreboard-row__name {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
}

.scoreboard-row__score {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-2);
  font-size: 0.9rem;
}

/* ─── Divider ─────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--s6) 0;
}

/* ─── Fokus ───────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--r-full);
}

/* ─── Brukerbrikke (header, innlogget) ───────────────────── */
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.user-chip__name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-1);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--t-fast);
}
a.user-chip__name:hover { color: var(--primary-light); }

/* ─── Tilstandsklasser ────────────────────────────────────── */
.hidden   { display: none !important; }
.sr-only  {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
