/* Banetavla: redigeringsvisning, banen, tidslinjen og presentasjonsmodus. */

.editor {
  display: grid; grid-template-columns: 232px minmax(0, 1fr) 320px;
  min-height: calc(100vh - var(--top-h));
}
.editor-tools, .editor-meta {
  background: var(--panel); padding: 20px 16px; display: flex; flex-direction: column; gap: 20px;
  position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top, 0px)); height: calc(100vh - var(--top-h)); overflow-y: auto;
}
.editor-tools { border-right: 1px solid var(--line); }
.editor-meta { border-left: 1px solid var(--line); padding: 22px 20px; }
.editor-tools section { display: flex; flex-direction: column; gap: 8px; }
.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 64px; padding: 6px 4px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer;
  font-size: 11px; font-weight: 600; color: var(--fg-2); text-align: center; line-height: 1.2;
}
.tool:hover { border-color: var(--accent); color: var(--fg); background: var(--surface-2); }
.tool svg .token-label { font-family: var(--font-display); }
.editor-tools .seg { width: 100%; }
.editor-tools .seg button { padding: 0 4px; font-size: 11px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 11px; background: var(--line-strong); transition: background 0.15s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.switch.on { background: var(--accent); }
.switch.on .knob { left: 19px; }
.sel-section { flex: 1; }
.sel-box { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); }
.sel-head { display: flex; align-items: center; gap: 8px; }
.hint.keys { font-size: 11px; }

.editor-main { min-width: 0; padding: 18px var(--gutter) 28px; display: flex; flex-direction: column; gap: 14px; }
.editor-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px; }
.editor-crumb { flex-wrap: wrap; }
.editor-step { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.step-label { font-family: var(--font-display); font-weight: 700; font-size: 28px; text-transform: uppercase; color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums; }
.step-name-input {
  flex: 1; min-width: 0; background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--fg); padding: 2px 6px;
  font-family: var(--font-display); font-weight: 600; font-size: 28px; text-transform: uppercase;
}
.step-name-input:hover { border-color: var(--line); }
.step-name-input:focus { outline: none; border-color: var(--accent); }
.editor-actions { display: flex; gap: 6px; }

.board-wrap { position: relative; }
.board {
  position: relative; border-radius: var(--r-lg); overflow: hidden; background: var(--grass);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.pitch-svg { display: block; width: 100%; height: clamp(320px, calc(100vh - 330px), 860px); user-select: none; -webkit-user-select: none; }
.board.editable .pitch-svg { touch-action: none; }
/* Flomlys: lysere midt på banen, mørkere mot kantene */
.board::after, .drill-thumb::after, .block-thumb::after, .picker-thumb::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 55%, rgba(0, 0, 0, 0.34) 100%);
}
.block-thumb, .picker-thumb { position: relative; }
.token-label { font-family: var(--font-display); pointer-events: none; }
.token.interactive { cursor: grab; }
.token.interactive:active { cursor: grabbing; }

.timeline { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.play-btn {
  width: 52px; height: 52px; flex-shrink: 0; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: 0 0 0 6px rgba(200, 245, 96, 0.14);
}
.play-btn:hover { box-shadow: 0 0 0 8px rgba(200, 245, 96, 0.2); }
.play-btn.big { width: 60px; height: 60px; }
.step-chips { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.step-chip {
  position: relative; overflow: hidden; flex: 1 0 104px; max-width: 220px; min-height: 52px; padding: 6px 12px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--muted); cursor: pointer; text-align: left;
}
.step-chip.on { border-color: var(--accent); background: var(--surface-2); color: var(--fg); }
.step-num { font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.step-chip.on .step-num { color: var(--accent); }
.step-name { font-size: 12px; font-weight: 600; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-fill { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); width: 0; }
.timeline-actions { display: flex; flex-direction: column; gap: 4px; }
.icon-toggle { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.icon-toggle.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; font-size: 12px; color: var(--fg-2); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.lg { display: inline-block; width: 28px; height: 8px; }
.lg-run { background: repeating-linear-gradient(90deg, #fff 0 5px, transparent 5px 9px); height: 2px; }
.lg-pass { background: var(--accent); height: 3px; border-radius: 2px; }
.lg-drib { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='8'%3E%3Cpath d='M0 4 L3 1 L7 7 L11 1 L15 7 L19 1 L23 7 L28 3' fill='none' stroke='white' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat; }

.meta-form { display: flex; flex-direction: column; gap: 14px; }
.meta-actions { display: flex; flex-direction: column; gap: 6px; margin-top: auto; padding-top: 8px; }
.meta-actions .btn { justify-content: flex-start; }

/* Presentasjonsmodus */
.present-info, .present-exit { display: none; }
body.presenting .app-top,
body.presenting .editor-tools,
body.presenting .editor-meta,
body.presenting .editor-head,
body.presenting .timeline-actions,
body.presenting .legend { display: none; }
body.presenting .editor { grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
body.presenting .editor-main { padding: 16px; }
body.presenting .pitch-svg { height: calc(100vh - 120px); }
body.presenting .present-exit { display: inline-flex; position: absolute; top: 14px; right: 14px; }
body.presenting .present-info {
  display: flex; flex-direction: column; gap: 6px; position: absolute; top: 14px; left: 14px; max-width: 340px;
  padding: 14px 16px; border-radius: var(--r); background: rgba(11, 17, 32, 0.82); backdrop-filter: blur(6px); pointer-events: none;
}
.present-info h2 { font-size: 26px; }
.present-info p { font-size: 12px; color: var(--fg-2); }
.present-info ol { margin: 4px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.45; }

@media (max-width: 1180px) {
  .editor { grid-template-columns: 220px minmax(0, 1fr); }
  .editor-meta { grid-column: 1 / -1; position: static; height: auto; border-left: 0; border-top: 1px solid var(--line); }
  .meta-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
  .meta-form .title-input { grid-column: 1 / -1; }
  .meta-actions { flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 860px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor-tools { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; overflow-x: auto; gap: 16px; padding: 12px 16px; }
  .editor-tools section { flex-shrink: 0; }
  .editor-tools .tool-grid { grid-template-columns: repeat(5, 64px); }
  .editor-tools .sel-section { width: 240px; }
  .editor-tools .hint.keys { display: none; }
  .editor-main { order: -1; padding-inline: 12px; }
  .editor-head { grid-template-columns: minmax(0, 1fr) auto; }
  .editor-step { grid-column: 1 / -1; grid-row: 2; }
  .step-label, .step-name-input { font-size: 22px; }
  .pitch-svg { height: auto; aspect-ratio: 1.45; }
  .timeline { flex-wrap: wrap; }
  .step-chips { order: 3; flex-basis: 100%; }
  .meta-form { grid-template-columns: minmax(0, 1fr); }
  .editor-actions .btn span { display: none; }
}

.live-board .pitch-svg { height: auto; aspect-ratio: 1.45; max-height: 70vh; }

/* Handlinger */
.board.targeting, .board.targeting .token { cursor: crosshair !important; }
.target-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 3; pointer-events: none;
  padding: 8px 14px; border-radius: 999px; background: rgba(11, 17, 32, 0.88); color: var(--fg);
  font-size: 13px; font-weight: 700; border: 1px solid var(--accent); white-space: nowrap;
}
.action-list { display: flex; flex-direction: column; gap: 6px; }
.action-btn {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--fg); font-size: 13px; font-weight: 600; cursor: pointer; text-align: left;
}
.action-btn:hover { border-color: var(--accent); background: var(--surface-2); }
.move-glyph { flex-shrink: 0; }
.target-box { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 9px; border: 1px solid var(--accent); background: var(--accent-soft); font-size: 13px; }
.applied-box { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 9px; background: var(--accent-soft); font-size: 12px; color: var(--fg-2); }
.type-seg { width: 100%; }
.target-hint.soft { border-color: var(--line-strong); color: var(--fg-2); font-weight: 600; }
.board.draw-mode .token.interactive { cursor: crosshair; }
.drag-seg { width: 100%; }
.drag-seg button { font-size: 11px; padding: 0 6px; }
