/* ============================================================================
   Telespor messequiz — stilark
   Bygget på Telespor designsystem 2026 (Brand Guideline)
   ========================================================================= */

@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("assets/fonts/Montserrat-var.woff2") format("woff2");
}

:root {
  /* Primærpalett */
  --ts-green: #4f5e51;
  --ts-cream: #fbfae1;
  --ts-orange: #eb5b27;
  /* Sekundær */
  --ts-green-soft: #5a645e;
  --ts-green-deep: #363c37;
  --ts-offwhite: #fffeef;
  /* Avledede toner */
  --ts-green-tint: #6e7d70;
  --ts-green-wash: #e8ebe4;
  --ts-cream-dim: #f1f0d8;
  --ts-orange-dim: #d24e1e;

  --text-heading: var(--ts-green-deep);
  --text-body: var(--ts-green-deep);
  --text-muted: var(--ts-green-soft);
  --surface-page: var(--ts-offwhite);
  --surface-card: #ffffff;
  --border-subtle: #e3e2d2;
  --border-strong: #c9c8b6;

  --status-ok: #3f8a4f;
  --status-info: #3d6fb4;
  --status-warn: var(--ts-orange);
  --status-critical: #c92f2f;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgba(54, 60, 55, .06), 0 4px 16px rgba(54, 60, 55, .08);
  --shadow-raised: 0 2px 6px rgba(54, 60, 55, .1), 0 12px 32px rgba(54, 60, 55, .14);

  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --duration-base: 200ms;

  --font-sans: "Montserrat", "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--text-body);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
}

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

/* Fjellgrafikken som bunntekstur på alle skjermer */
.mountains {
  position: fixed;
  inset: auto 0 0 0;
  height: clamp(180px, 34vh, 430px);
  background: url("assets/img/gronne-fjell.svg") no-repeat bottom center;
  background-size: 100% 100%;
  opacity: .2;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 62%);
  mask-image: linear-gradient(to bottom, transparent, #000 62%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- skjermer */
.screen {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
.screen.is-active {
  display: flex;
  animation: fade-in var(--duration-base) var(--ease-out);
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.pad {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 3.2vh, 40px) clamp(20px, 4vw, 48px);
}

/* -------------------------------------------------------------------- logo */
.logo { height: clamp(34px, 5vh, 52px); width: auto; display: block; }
.logo--sm { height: 30px; }

/* --------------------------------------------------------------- typografi */
h1, h2, h3 { color: var(--text-heading); margin: 0; letter-spacing: -.01em; }
.display { font-size: clamp(34px, 5.4vw, 60px); font-weight: 800; line-height: 1.04; }
.h2      { font-size: clamp(24px, 3.2vw, 34px); font-weight: 700; line-height: 1.15; }
.lead    { font-size: clamp(16px, 1.7vw, 20px); line-height: 1.55; color: var(--text-muted); margin: 0; }
.overline {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ts-orange); margin: 0;
}
.fine { font-size: 13px; line-height: 1.5; color: var(--text-muted); }

/* ----------------------------------------------------------------- knapper */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  padding: 16px 34px;
  font-size: clamp(16px, 1.6vw, 19px);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--duration-base) var(--ease-out),
              border-color var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out);
}
.btn:active { transform: scale(.985); }
.btn:focus-visible { outline: 3px solid var(--ts-orange); outline-offset: 3px; }

.btn--primary { background: var(--ts-orange); color: #fff; }
.btn--primary:hover { background: var(--ts-orange-dim); }
.btn--primary:disabled { background: var(--border-strong); color: #fff; cursor: not-allowed; }

.btn--secondary { background: transparent; color: var(--ts-green); border-color: var(--ts-green); }
.btn--secondary:hover { background: var(--ts-green-wash); }

.btn--lg { padding: 20px 48px; font-size: clamp(18px, 2vw, 22px); }

.btn--ghost {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 14px; font-weight: 600; padding: 10px 14px;
  border-radius: var(--radius-pill); cursor: pointer;
}
.btn--ghost:hover { background: var(--ts-green-wash); color: var(--ts-green-deep); }

/* =============================================================== STARTSIDE */
#screen-start .pad {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; gap: clamp(16px, 2.6vh, 30px);
}
.start-head { display: flex; align-items: center; gap: 18px; }
.start-actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.prize-card {
  display: inline-flex; align-items: center;
  background: var(--ts-cream);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  max-width: 640px;
}
.prize-card p {
  margin: 0;
  font-size: clamp(15px, 1.4vw, 18px);
  font-weight: 700;
  line-height: 1.45;
  color: var(--ts-green-deep);
}

/* ==================================================================== QUIZ */
.quiz-top {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px clamp(20px, 4vw, 48px) 0;
  width: min(1100px, 100%); margin: 0 auto;
}
.counter { font-size: 14px; font-weight: 700; color: var(--text-muted); letter-spacing: .04em; }

.progress {
  width: min(1100px, 100%); margin: 12px auto 0;
  padding: 0 clamp(20px, 4vw, 48px);
  display: flex; gap: 6px;
}
.progress span {
  flex: 1; height: 6px; border-radius: var(--radius-pill);
  background: var(--border-subtle);
  transition: background var(--duration-base) var(--ease-out);
}
.progress span.is-done { background: var(--ts-green); }
.progress span.is-now  { background: var(--ts-orange); }

#screen-quiz .pad {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; gap: clamp(16px, 3vh, 32px);
  min-height: 0;
}

.question {
  font-size: clamp(22px, 3.1vw, 38px);
  font-weight: 700; line-height: 1.2; text-align: center;
  max-width: 26ch; margin: 0 auto;
  text-wrap: balance;
}

.timer {
  margin: 0 auto; font-size: 14px; font-weight: 700; color: var(--ts-orange);
  letter-spacing: .06em; text-transform: uppercase;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(12px, 1.8vw, 20px);
}
.options[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.options[data-count="3"] { grid-template-columns: repeat(3, 1fr); }

.tile {
  display: flex; align-items: center; gap: 16px;
  text-align: left;
  background: var(--surface-card);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: clamp(16px, 2.4vh, 26px) clamp(16px, 2vw, 24px);
  min-height: clamp(76px, 13vh, 116px);
  font-size: clamp(15px, 1.7vw, 21px);
  font-weight: 600; line-height: 1.3;
  cursor: pointer;
  transition: border-color var(--duration-base) var(--ease-out),
              background var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out);
}
.tile:hover:not(:disabled) { border-color: var(--ts-green-tint); }
.tile:active:not(:disabled) { transform: scale(.99); }
.tile:focus-visible { outline: 3px solid var(--ts-orange); outline-offset: 3px; }
.tile:disabled { cursor: default; }

.tile .num {
  flex: none;
  width: clamp(34px, 4.4vh, 42px); height: clamp(34px, 4.4vh, 42px);
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: var(--ts-green-wash);
  color: var(--ts-green);
  font-size: clamp(15px, 1.6vw, 19px);
  font-weight: 800;
  transition: background var(--duration-base) var(--ease-out),
              color var(--duration-base) var(--ease-out);
}
.tile .label { flex: 1; }
.tile .mark  { flex: none; width: 26px; height: 26px; opacity: 0; transition: opacity 150ms var(--ease-out); }

.tile.is-picked {
  background: var(--ts-orange);
  border-color: var(--ts-orange);
  color: #fff;
  box-shadow: var(--shadow-raised);
}
.tile.is-picked .num { background: rgba(255, 255, 255, .92); color: var(--ts-orange-dim); }
/* Brukes kun når showAnswerFeedback er slått på i config.js */
.tile.is-correct, .tile.is-wrong { color: var(--text-body); }
.tile.is-correct .num, .tile.is-wrong .num { background: var(--ts-green-wash); color: var(--ts-green); }
.tile.is-correct { border-color: var(--status-ok); background: #f1f7f1; }
.tile.is-correct .mark { opacity: 1; color: var(--status-ok); }
.tile.is-wrong { border-color: var(--status-critical); background: #fdf2f2; }
.tile.is-wrong .mark { opacity: 1; color: var(--status-critical); }
.tile.is-dim { opacity: .45; }

/* ================================================================= SKJEMA */
#screen-form .pad { flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 0; overflow-y: auto; }
.form-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: clamp(22px, 3.4vh, 40px);
}
.fields {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: clamp(12px, 2vh, 20px);
  margin: clamp(16px, 2.6vh, 28px) 0;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field--wide { grid-column: 1 / -1; }
.field label { font-size: 14px; font-weight: 700; color: var(--text-heading); }
.field label .opt { font-weight: 500; color: var(--text-muted); }
.field input {
  background: var(--ts-offwhite);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 17px;
  user-select: text;
  transition: border-color var(--duration-base) var(--ease-out);
}
.field input:focus { outline: none; border-color: var(--ts-orange); }
.field input.is-invalid { border-color: var(--status-critical); background: #fdf2f2; }
.field .err { margin: 0; font-size: 13px; font-weight: 600; color: var(--status-critical); }
.field .err:empty { display: none; }

.consent {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--ts-cream);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
}
.consent input { flex: none; width: 26px; height: 26px; accent-color: var(--ts-orange); margin: 1px 0 0; }
.consent span { font-size: 14px; line-height: 1.5; }
.consent.is-invalid { border-color: var(--status-critical); }

.form-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-top: clamp(16px, 2.6vh, 26px); flex-wrap: wrap;
}

/* ============================================================== TAKKESIDE */
#screen-done .pad {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  gap: clamp(14px, 2.4vh, 26px);
}
.score-ring {
  display: grid; place-items: center;
  width: clamp(120px, 17vh, 168px); height: clamp(120px, 17vh, 168px);
  border-radius: 50%;
  border: 8px solid var(--ts-green);
  background: var(--ts-cream);
}
.score-ring strong { font-size: clamp(34px, 5vh, 50px); font-weight: 800; line-height: 1; color: var(--ts-green-deep); }
.score-ring small { font-size: 13px; font-weight: 700; color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; }

/* =================================================================== annet */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, calc(100% + 40px));
  visibility: hidden;
  background: var(--ts-green-deep); color: var(--ts-offwhite);
  border-radius: var(--radius-pill); padding: 14px 26px;
  font-size: 15px; font-weight: 600;
  box-shadow: var(--shadow-raised);
  z-index: 50;
  transition: transform 260ms var(--ease-out);
}
.toast.is-visible { transform: translate(-50%, 0); visibility: visible; }

.toast--success {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 34px;
  font-size: clamp(16px, 1.7vw, 20px);
  background: var(--ts-green);
}
.toast--success svg { flex: none; width: 26px; height: 26px; color: var(--ts-cream); }

.corner {
  position: fixed; top: 0; right: 0; z-index: 40;
  width: 90px; height: 90px; opacity: 0; cursor: default;
}

[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;
}

/* Stående nettbrett / mobil */
@media (max-width: 760px), (orientation: portrait) and (max-width: 1100px) {
  .options { grid-template-columns: 1fr; }
  .options[data-count="3"] { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  .question { max-width: 100%; }
  .tile { min-height: 68px; }
}

/* Lav høyde (liggende nettbrett) */
@media (max-height: 620px) {
  .tile { min-height: 62px; }
  .mountains { opacity: .1; }
}

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