/* JE Chat – taktikktavla.
   Hvit magnettavle i aluminiumsramme, svake banelinjer, tusj i rødt og blått. */

@font-face {
  font-family: "Marker";
  src: url("/static/fonts/permanent-marker-latin-400-normal.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Atkinson";
  src: url("/static/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Atkinson";
  src: url("/static/fonts/atkinson-hyperlegible-latin-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Atkinson";
  src: url("/static/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-display: swap;
}

:root {
  --board: #F8FAFB;
  --line: #D3E0E8;
  --tray: #E4E8EB;
  --frame: #B6BEC5;
  --frame-dark: #7D8790;
  --ink: #1B2431;
  --ink-soft: #4F5B69;
  --blue: #1D4EAF;
  --red: #CC2A2A;
  --green: #12804A;
  --amber: #C98A0B;

  --marker: "Marker", "Comic Sans MS", cursive;
  --body: "Atkinson", system-ui, -apple-system, "Segoe UI", sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --step-0: 1rem;      /* 16 */
  --step-1: 1.125rem;  /* 18 */
  --step-2: 1.5rem;    /* 24 */
  --step-3: 2.25rem;   /* 36 */
  --step-4: 3.375rem;  /* 54 */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--tray);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- ramme ---------- */

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  height: 100dvh;
}
.shell > * { min-width: 0; }

.rail {
  padding: var(--s5) var(--s5) var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  overflow-y: auto;
}

.wordmark {
  font-family: var(--marker);
  font-weight: 400;
  font-size: var(--step-4);
  line-height: 1;
  margin: 0;
  color: var(--red);
  transform: rotate(-3deg);
  transform-origin: left bottom;
  letter-spacing: 0.01em;
}
.tagline { margin: var(--s3) 0 0; color: var(--ink-soft); font-size: 0.9375rem; max-width: 22ch; }

/* magneter */
.magnet {
  --c: var(--blue);
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, white) 0 18%, var(--c) 46%, color-mix(in srgb, var(--c) 75%, black) 100%);
  box-shadow: 0 2px 3px rgba(27, 36, 49, 0.35);
  flex: none;
}
.magnet-sm { width: 16px; height: 16px; }
.magnet-red { --c: var(--red); }
.magnet-green { --c: var(--green); }
.magnet-amber { --c: var(--amber); }
.magnet-grey { --c: var(--frame-dark); }

.status {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4);
  background: var(--board);
  border-radius: 6px;
  border: 1px solid var(--frame);
}
.status .magnet { margin-top: 4px; }
.status strong { display: block; font-size: 0.9375rem; }
.status span:not(.magnet) { display: block; font-size: 0.8125rem; color: var(--ink-soft); }

.group { border: 0; padding: 0; margin: 0; }
.group legend { font-weight: 700; font-size: 0.9375rem; margin-bottom: var(--s2); padding: 0; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  border: 1px solid var(--frame);
  background: var(--board);
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
  cursor: pointer;
  font-size: 0.9375rem;
}
.chip::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  background: transparent; border: 2px dashed var(--frame-dark);
}
.chip[aria-pressed="true"] { border-color: var(--blue); color: var(--blue); font-weight: 700; }
.chip[aria-pressed="true"]::before {
  border: 0;
  background: radial-gradient(circle at 35% 30%, #8FA9DD 0 18%, var(--blue) 46%, #123274 100%);
  box-shadow: 0 1px 2px rgba(27, 36, 49, 0.35);
}

.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--frame); border-radius: 8px; overflow: hidden; background: var(--board); }
.seg { border: 0; background: transparent; padding: 10px 8px; cursor: pointer; font-size: 0.9375rem; }
.seg + .seg { border-left: 1px solid var(--frame); }
.seg[aria-pressed="true"] { background: var(--ink); color: var(--board); font-weight: 700; }

.machine { font-size: 0.875rem; color: var(--ink-soft); margin-top: auto; }
.machine p { margin: 0; }
.machine span { color: var(--ink); font-weight: 700; }

.rail-actions { display: flex; gap: var(--s4); }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 0.9375rem; }

/* ---------- tavla ---------- */

.board {
  position: relative;
  margin: var(--s4) var(--s4) var(--s4) 0;
  background: var(--board);
  border: 10px solid var(--frame);
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--frame-dark), 0 1px 0 #fff, 0 8px 22px rgba(27, 36, 49, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Banelinjer tegnet i bakgrunnen: midtlinje, midtsirkel og to 16-metere. */
.pitch-lines {
  position: absolute; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1050 680' preserveAspectRatio='none'%3E%3Cg fill='none' stroke='%23D3E0E8' stroke-width='3'%3E%3Crect x='30' y='30' width='990' height='620'/%3E%3Cline x1='525' y1='30' x2='525' y2='650'/%3E%3Ccircle cx='525' cy='340' r='92'/%3E%3Crect x='30' y='138' width='165' height='404'/%3E%3Crect x='855' y='138' width='165' height='404'/%3E%3Crect x='30' y='248' width='55' height='184'/%3E%3Crect x='965' y='248' width='55' height='184'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100% 100%;
  opacity: 0.9;
}

.hero, .thread, .composer { position: relative; }

.hero {
  flex: 1;
  overflow-y: auto;
  padding: var(--s7) var(--s6) var(--s5);
  display: flex; flex-direction: column; align-items: flex-start;
  max-width: 900px;
}
.hero[hidden] { display: none; }

.play { width: min(460px, 100%); height: auto; margin-bottom: var(--s4); }
.play-o circle { stroke: var(--blue); }
.play-x path { stroke: var(--red); }
.play-arrow { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.play-arrow.pass { stroke-dasharray: 10 9; }
.play-head { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.play-goal { fill: none; stroke: var(--ink-soft); stroke-width: 3; }

@media (prefers-reduced-motion: no-preference) {
  .play-arrow.run { stroke-dasharray: 260; stroke-dashoffset: 260; animation: draw 1.1s 0.5s ease-out forwards; }
  .play-head { opacity: 0; animation: appear 0.2s 1.55s forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes appear { to { opacity: 1; } }
}

.hero-title {
  font-family: var(--marker); font-weight: 400;
  font-size: var(--step-3); line-height: 1.15;
  color: var(--blue);
  margin: 0 0 var(--s3);
  max-width: 20ch;
}
.hero-sub { margin: 0 0 var(--s5); max-width: 60ch; color: var(--ink-soft); font-size: var(--step-1); }

.suggestions { display: flex; flex-wrap: wrap; gap: var(--s3); max-width: 760px; }
.suggestion {
  position: relative;
  text-align: left;
  background: #fff;
  border: 1px solid var(--frame);
  border-radius: 4px;
  padding: var(--s3) var(--s4) var(--s3) var(--s6);
  cursor: pointer;
  max-width: 340px;
  box-shadow: 0 1px 2px rgba(27, 36, 49, 0.08);
}
.suggestion::before {
  content: ""; position: absolute; left: 10px; top: 14px;
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #F0A3A3 0 18%, var(--red) 46%, #7C1414 100%);
  box-shadow: 0 1px 2px rgba(27, 36, 49, 0.4);
}
.suggestion:hover { border-color: var(--ink-soft); }

/* ---------- samtalen ---------- */

.thread {
  list-style: none; margin: 0;
  flex: 1; overflow-y: auto;
  padding: var(--s6) var(--s6) var(--s5);
  display: flex; flex-direction: column; gap: var(--s5);
}
.thread:empty { display: none; }

.msg { display: grid; grid-template-columns: 28px 1fr; gap: var(--s3); max-width: 780px; }
.msg .magnet { margin-top: 3px; }
.msg-user { align-self: flex-end; }
.msg-user .bubble {
  background: #fff;
  border: 1px solid var(--frame);
  border-radius: 4px;
  padding: var(--s3) var(--s4);
  color: var(--blue);
  white-space: pre-wrap;
}
.who { font-weight: 700; font-size: 0.875rem; color: var(--ink-soft); display: block; margin-bottom: 2px; }

.answer { max-width: 68ch; }
.answer h2, .answer h3 {
  font-family: var(--marker); font-weight: 400; color: var(--red);
  font-size: var(--step-2); line-height: 1.2; margin: var(--s2) 0 var(--s3);
}
.answer h3 { font-size: var(--step-1); color: var(--ink); }
.answer p { margin: 0 0 var(--s3); }
.answer ul, .answer ol { margin: 0 0 var(--s3); padding-left: 1.3em; }
.answer li { margin-bottom: var(--s1); }
.answer li::marker { color: var(--red); }
.answer a { color: var(--blue); }
.answer code { background: var(--tray); padding: 1px 5px; border-radius: 3px; font-size: 0.9em; }
.cite {
  display: inline-block; min-width: 1.4em;
  font-size: 0.75em; font-weight: 700; line-height: 1.4;
  text-align: center; text-decoration: none;
  color: #fff !important; background: var(--blue);
  border-radius: 999px; padding: 0 5px; vertical-align: 0.25em;
}

.typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); opacity: 0.35; }
@media (prefers-reduced-motion: no-preference) {
  .typing i { animation: bounce 1s infinite; }
  .typing i:nth-child(2) { animation-delay: 0.15s; }
  .typing i:nth-child(3) { animation-delay: 0.3s; }
  @keyframes bounce { 40% { opacity: 1; transform: translateY(-3px); } }
}
.wait-note { color: var(--ink-soft); font-size: 0.9375rem; margin: 0; }

.sources { margin: var(--s3) 0 0; padding: var(--s3) 0 0; border-top: 1px dashed var(--frame); font-size: 0.875rem; }
.sources summary { cursor: pointer; color: var(--ink-soft); }
.sources ol { margin: var(--s2) 0 0; padding-left: 1.6em; }
.sources li { margin-bottom: 2px; }
.sources a { color: var(--blue); }

.meta { margin: var(--s2) 0 0; font-size: 0.8125rem; color: var(--ink-soft); }
.error { color: var(--red); font-weight: 700; }

/* ---------- øktplan ---------- */

.okt { max-width: 760px; }
.okt-head h2 { font-family: var(--marker); font-weight: 400; color: var(--red); font-size: var(--step-3); line-height: 1.1; margin: 0 0 var(--s2); }
.okt-facts { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin: 0 0 var(--s4); padding: 0; list-style: none; color: var(--ink-soft); }
.okt-facts b { color: var(--ink); }

.timeline { display: flex; height: 30px; border-radius: 4px; overflow: hidden; margin: 0 0 var(--s5); border: 1px solid var(--frame); }
.timeline span { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 0.8125rem; font-weight: 700; min-width: 0; overflow: hidden; white-space: nowrap; padding: 0 4px; }
.t-oppvarming { background: var(--amber); }
.t-ovelse { background: var(--blue); }
.t-spill { background: var(--green); }
.t-avslutning { background: var(--red); }

.drills { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s4); counter-reset: drill; }
.drill {
  counter-increment: drill;
  display: grid; grid-template-columns: 220px 1fr; gap: var(--s4);
  background: #fff; border: 1px solid var(--frame); border-radius: 6px;
  padding: var(--s4);
  break-inside: avoid;
}
.drill-sketch svg { width: 100%; height: auto; display: block; }
.drill h3 { font-family: var(--body); font-weight: 700; color: var(--ink); font-size: var(--step-1); margin: 0 0 var(--s1); }
.drill h3::before { content: counter(drill) ". "; color: var(--red); font-family: var(--marker); font-weight: 400; }
.drill .mins { color: var(--ink-soft); font-size: 0.875rem; margin: 0 0 var(--s2); }
.drill p { margin: 0 0 var(--s2); }
.drill ul { margin: 0 0 var(--s2); padding-left: 1.2em; }
.drill .label { font-weight: 700; }
.okt-tip { margin: var(--s4) 0 0; padding: var(--s3) var(--s4); background: #FFF6D8; border-left: 4px solid var(--amber); border-radius: 0 4px 4px 0; }
.okt-actions { margin-top: var(--s3); display: flex; gap: var(--s4); }

/* ---------- skrivefeltet ---------- */

.composer {
  display: flex; gap: var(--s3); align-items: flex-end;
  padding: var(--s3) var(--s5) var(--s5);
  background: linear-gradient(to top, var(--board) 70%, transparent);
}
.composer textarea {
  flex: 1; resize: none;
  min-height: 52px; max-height: 200px;
  padding: 14px var(--s4);
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  line-height: 1.4;
}
.send {
  border: 0; border-radius: 8px;
  background: var(--red); color: #fff;
  font-weight: 700;
  padding: 0 var(--s5);
  height: 52px;
  cursor: pointer;
  box-shadow: 0 2px 0 #8E1A1A;
}
.send:active { transform: translateY(1px); box-shadow: 0 1px 0 #8E1A1A; }
.send:disabled { background: var(--frame-dark); box-shadow: none; cursor: wait; }

/* ---------- tilgangskode ---------- */

.gate { border: 0; padding: 0; background: transparent; max-width: 420px; width: calc(100% - 32px); }
.gate::backdrop { background: rgba(27, 36, 49, 0.55); }
.gate-card {
  position: relative;
  background: var(--board);
  border: 8px solid var(--frame);
  border-radius: 12px;
  padding: var(--s6) var(--s5) var(--s5);
}
.gate-card > .magnet { position: absolute; top: -14px; left: 50%; margin-left: -11px; }
.gate-card h2 { font-family: var(--marker); font-weight: 400; color: var(--blue); font-size: var(--step-2); margin: 0 0 var(--s2); }
.gate-card p { margin: 0 0 var(--s4); color: var(--ink-soft); }
.gate-card label { display: block; font-weight: 700; margin-bottom: var(--s1); }
.gate-card input {
  width: 100%; padding: 12px var(--s3);
  border: 2px solid var(--ink); border-radius: 6px; background: #fff;
  font-size: var(--step-1); letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: var(--s2);
}
.gate-error { color: var(--red) !important; font-weight: 700; min-height: 1.5em; margin-bottom: var(--s3) !important; }
.gate-card .send { width: 100%; }

/* ---------- mobil ---------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { padding: var(--s3) var(--s3) 0; gap: var(--s3); overflow: visible; min-width: 0; }
  .group { min-width: 0; }
  .hero-title { font-size: var(--step-2); }
  .hero-sub { font-size: var(--step-0); }
  .play { width: 70%; }
  .brand { display: flex; align-items: baseline; gap: var(--s3); }
  .wordmark { font-size: var(--step-3); }
  .tagline { display: none; }
  .status { padding: var(--s2) var(--s3); align-items: center; }
  .status .magnet { margin-top: 0; }
  .status span:not(.magnet) { display: none; }
  .group legend { display: none; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .chip { white-space: nowrap; }
  .machine { display: none; }
  .rail-actions { position: absolute; top: var(--s4); right: var(--s3); }
  .rail { position: relative; }
  .board { margin: var(--s3); border-width: 6px; }
  .hero { padding: var(--s5) var(--s4); }
  .thread { padding: var(--s4); }
  .composer { padding: var(--s2) var(--s3) var(--s3); }
  .send { padding: 0 var(--s4); }
  .drill { grid-template-columns: 1fr; }
  .drill-sketch { max-width: 280px; }
}

/* ---------- utskrift av økt ---------- */

@media print {
  body { background: #fff; }
  .rail, .composer, .hero, .msg-user, .sources, .meta, .okt-actions, .pitch-lines { display: none !important; }
  .shell { display: block; height: auto; }
  .board { border: 0; box-shadow: none; margin: 0; overflow: visible; }
  .thread { overflow: visible; padding: 0; }
  .msg { display: block; }
  .msg .magnet, .who { display: none; }
  .msg:not(.printing) { display: none; }
  .drill { border-color: #999; }
}
