/* Life – biografen i fickan. Svarta filmband, sammetsröd ridå. Filmen själv är ren: bara bild och ljud. */
@font-face {
  font-family: 'Young Serif';
  src: url('../fonts/young-serif.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #16120f;
  --band: #000;
  --ivory: #efe6d2;
  --dim: #9a8f7c;
  --velvet: #8f2c24;
  --brass: #c9a45c;
  --line: rgba(239, 230, 210, 0.14);
  --serif: 'Young Serif', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--ink); color: var(--ivory); }
body { margin: 0; font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }

.film { display: grid; grid-template-rows: auto 1fr auto; height: 100svh; min-height: 480px; background: var(--band); }

.bar { padding: 12px 18px; padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
.bar-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: max(12px, env(safe-area-inset-top)); flex-wrap: wrap; }
.brand { font-family: var(--serif); font-size: 1.15rem; letter-spacing: 0.01em; }
.brand small { font-family: var(--sans); font-size: 0.75rem; color: var(--dim); margin-left: 6px; }

.meters { display: flex; gap: 14px; font-size: 0.78rem; color: var(--dim); }
.meter { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.meter b { font-weight: 500; }
.meter em { font-style: normal; color: var(--ivory); }
.meter i { width: 6px; height: 18px; border-radius: 3px; background: linear-gradient(to top, var(--brass) calc(var(--l, 0) * 100%), rgba(239, 230, 210, 0.15) 0); }

.screen { position: relative; overflow: hidden; background: #0b0908; }
.screen video, .screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
body[data-state="idle"] video { opacity: 0; }

.intro { position: absolute; inset: 0; display: grid; place-content: center; justify-items: start; gap: 14px; padding: 28px; max-width: 34rem; margin: 0 auto;
  background: radial-gradient(120% 90% at 50% 100%, rgba(143, 44, 36, 0.35), transparent 60%); }
.intro[hidden] { display: none; }
.intro h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.1rem, 8vw, 3.4rem); line-height: 1.05; margin: 0; }
.intro p { margin: 0; color: var(--ivory); max-width: 30rem; }
.intro .fine { font-size: 0.82rem; color: var(--dim); }
.go { background: var(--velvet); border: 0; border-radius: 999px; padding: 14px 26px; font-size: 1.05rem; font-weight: 600; letter-spacing: 0.01em; }
.go:disabled { opacity: 0.6; }
.photo { font-size: 0.9rem; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.photo input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo:focus-within { outline: 2px solid var(--brass); outline-offset: 3px; }

.loading { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.8)); }
.loading[hidden] { display: none; }
.loading p { margin: 0 0 8px; font-size: 0.9rem; }
.track { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.track span { display: block; height: 100%; width: 0; background: var(--brass); transition: width 0.3s; }

.bar-bottom { text-align: center; padding-bottom: max(16px, env(safe-area-inset-bottom)); min-height: 7.2rem; display: grid; align-content: center; gap: 4px; }
.subtitle { font-family: var(--serif); font-size: clamp(1.6rem, 6.5vw, 2.4rem); line-height: 1.15; margin: 0; color: #f7e9a8; text-shadow: 0 1px 0 #000; }
.score { margin: 0; color: var(--dim); font-style: italic; font-size: 0.95rem; }
body[data-energy="high"] .subtitle { letter-spacing: 0.01em; }

.deck { max-width: 44rem; margin: 0 auto; padding: 28px 20px 64px; display: grid; gap: 34px; }
.deck h2 { font-family: var(--serif); font-weight: 400; font-size: 1.35rem; margin: 0 0 4px; }
.hint { margin: 0 0 12px; color: var(--dim); font-size: 0.88rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button, .row button { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 0.9rem; }
.chips button[aria-pressed="true"], .row button[aria-pressed="true"] { background: var(--ivory); color: var(--ink); border-color: var(--ivory); }

.top { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.top li { display: grid; grid-template-columns: 9.5rem 1fr 3rem; align-items: center; gap: 10px; font-size: 0.92rem; }
.top li i { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--brass) var(--w), var(--line) 0); }
.top li b { font-weight: 500; text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.top li.is-current span { color: #f7e9a8; }

.loglist { list-style: none; margin: 0 0 14px; padding: 0; font-size: 0.82rem; color: var(--dim); max-height: 16rem; overflow: auto; font-variant-numeric: tabular-nums; }
.loglist li { padding: 5px 0; border-bottom: 1px solid var(--line); }
.loglist li:first-child { color: var(--ivory); }
.row { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 520px) {
  .meters { gap: 10px; font-size: 0.72rem; }
  .brand small { display: none; }
  .top li { grid-template-columns: 7.5rem 1fr 2.6rem; }
}
@media (prefers-reduced-motion: reduce) { .track span { transition: none; } }

/* Kontroller: musik, sång, inspelning */
.controls { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.controls[hidden] { display: none; }
.controls button { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-size: 0.92rem; display: inline-flex; align-items: center; gap: 8px; }
.controls button[aria-pressed="true"] { background: var(--ivory); color: var(--ink); border-color: var(--ivory); }
.controls button:disabled { opacity: 0.55; cursor: default; }
.controls .rec { border-color: var(--velvet); }
.controls .rec::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--velvet); }
body.is-recording .controls .rec { background: var(--velvet); color: var(--ivory); border-color: var(--velvet); }
body.is-recording .controls .rec::before { background: var(--ivory); border-radius: 2px; }
.voice { width: 5px; height: 14px; border-radius: 3px; background: linear-gradient(to top, currentColor calc(var(--l, 0) * 100%), rgba(128, 128, 128, 0.3) 0); }
#sjung[aria-pressed="false"] .voice { display: none; }
.hint-line { margin: 6px 0 0; min-height: 1.2em; font-size: 0.82rem; color: var(--dim); }
body.is-recording .bar-top { box-shadow: inset 0 -2px 0 var(--velvet); }

.film-klar video { width: 100%; max-height: 70svh; background: #000; border-radius: 6px; margin: 8px 0 12px; }
.film-klar .save { color: var(--ivory); align-self: center; padding: 8px 6px; text-underline-offset: 3px; }
.controls .egen { position: relative; border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-size: 0.92rem; cursor: pointer; }
.controls .egen[aria-pressed="true"] { background: var(--brass); color: var(--ink); border-color: var(--brass); }
.controls .egen input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.controls .egen:focus-within { outline: 2px solid var(--brass); outline-offset: 3px; }
#egen-bort { padding: 9px 12px; }

.sprak { background: transparent; color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; font: inherit; font-size: 0.78rem; margin-left: 8px; }
.sprak:focus-visible { outline: 2px solid var(--brass); }
.sprak option { color: #000; }
/* Filmen är huvudsaken: Spela in är den tydligaste knappen */
.controls .rec { background: var(--velvet); color: var(--ivory); border-color: var(--velvet); font-weight: 600; }
.controls .rec::before { background: var(--ivory); }

/* Startläget: bara märket och en knapp */
.intro { justify-items: center; text-align: center; align-content: center; gap: 18px; overflow-y: auto; }
.wordmark { position: relative; font-family: var(--serif); font-size: clamp(3.5rem, min(22vw, 20vh), 8rem); line-height: 1; margin: 0 0 8px; color: #f3e7c4; }
.wordmark i { position: absolute; top: 0.12em; right: -0.32em; width: 0.17em; height: 0.17em; border-radius: 50%; background: #c0392b; }
.intro .fine { margin-top: 4px; }
body[data-state="idle"] .meters { visibility: hidden; }
body[data-state="idle"] .bar-top .brand { visibility: hidden; }
body[data-state="idle"] .meters { display: none; }

/* Mer-panelen */
.controls #mer-knapp { border-style: dashed; }
.mer { width: min(36rem, 100vw - 24px); max-height: 86svh; padding: 0 20px 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--ink); color: var(--ivory); overflow: auto; }
.mer::backdrop { background: rgba(0, 0, 0, 0.6); }
.mer > * + * { margin-top: 26px; }
.mer-huvud { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 16px 0 10px; background: var(--ink); z-index: 1; }
.mer h2 { font-family: var(--serif); font-weight: 400; font-size: 1.25rem; margin: 0 0 4px; }
.mer-huvud h2 { font-size: 1.5rem; }
.stang { background: transparent; border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; font-size: 1.3rem; line-height: 1; }
.falt { display: grid; gap: 4px; margin: 10px 0; font-size: 0.85rem; color: var(--dim); }
.falt select, .falt input { background: #221c17; color: var(--ivory); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: inherit; font-size: 0.95rem; }
.detaljer summary { cursor: pointer; color: var(--dim); font-size: 0.9rem; padding: 6px 0; }
.detaljer > div { margin-top: 18px; }
.mer .stop { display: block; width: 100%; background: transparent; border: 1px solid var(--velvet); color: var(--ivory); border-radius: 999px; padding: 12px; }
.mer .stop[hidden] { display: none; }
.meter[hidden] { display: none; }

/* Karaoke */
.controls #karaoke[hidden], .controls #text-knapp[hidden] { display: none; }
.controls #karaoke { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-size: 0.92rem; }
.controls #karaoke[aria-pressed="true"], .controls #text-knapp[aria-pressed="true"] { background: var(--brass); color: var(--ink); border-color: var(--brass); }
.sangtext { position: absolute; left: 0; right: 0; bottom: 18px; padding: 0 16px; text-align: center; pointer-events: none; }
.sangtext[hidden] { display: none; }
.sangtext p { margin: 0; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85); }
.sangtext .nu { font-weight: 700; font-size: clamp(1.3rem, 5.5vw, 2rem); color: #fff; }
.sangtext .nasta { font-size: clamp(0.95rem, 4vw, 1.2rem); color: rgba(255, 255, 255, 0.7); margin-top: 4px; }

/* Mina filmer och filmrutan */
.film-klar video { display: block; width: 100%; max-height: 60svh; background: #000; border-radius: 8px; margin: 4px 0 14px; }
.mina-lista { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.mina-lista li { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.mina-lista span { flex: 1; color: var(--ivory); }
.mina-lista button { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 0.85rem; }
.mina-lista .bort { color: var(--dim); }
#cam[hidden] { display: none; }
body[data-state="photo"] .meters { display: none; }

/* Vad händer? */
.tema-falt { width: min(22rem, 86vw); background: rgba(0, 0, 0, 0.45); color: var(--ivory); border: 1px solid var(--line); border-radius: 999px; padding: 11px 16px; font: inherit; font-size: 0.95rem; text-align: center; }
.tema-falt::placeholder { color: var(--dim); }
.tema-falt:focus { outline: 2px solid var(--brass); outline-offset: 2px; }
.tema-forslag { margin: -6px 0 0; min-height: 1.1em; font-size: 0.85rem; color: var(--brass); }
.tema-rad { position: absolute; top: 10px; left: 0; right: 0; display: grid; justify-items: center; gap: 4px; padding: 0 12px; z-index: 2; }
.tema-rad[hidden] { display: none; }
.tema-rad .tema-falt { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tema-rad .tema-forslag { margin: 0; text-shadow: 0 1px 4px #000; }
.controls [hidden] { display: none !important; }
@media (max-width: 520px) { body:not([data-state="idle"]) .sprak { display: none; } }

/* Paus under inspelning */
.controls .paus[aria-pressed="true"] { background: var(--ivory); color: #000; border-color: var(--ivory); }
body.is-paused .bar-top { box-shadow: inset 0 -2px 0 var(--ivory); }
body.is-paused .screen video, body.is-paused .screen canvas { filter: grayscale(.7) brightness(.6); }

/* Länk till utrustningen i Mer-panelen */
.mer .tillbehor { display: block; margin-top: 10px; color: var(--brass); font-size: 0.9rem; text-underline-offset: 3px; }

/* Lansering 2026-11-19: löftesrad, hjälplänk och Om-sektionen under appen */
.intro .lofte { font-family: var(--sans); font-weight: 500; font-size: clamp(1.02rem, 4.4vw, 1.25rem); line-height: 1.35; margin: -6px 0 4px; color: var(--ivory); max-width: 22rem; }
.hjalp-lank { font-size: 0.82rem; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }
.om { max-width: 40rem; margin: 0 auto; padding: 48px 22px 64px; color: var(--ivory); }
.om h2 { font-family: var(--serif); font-weight: 400; font-size: 1.7rem; line-height: 1.15; margin: 0 0 14px; }
.om h3 { font-size: 1rem; margin: 28px 0 6px; }
.om p { margin: 0 0 10px; color: #d8cfbb; }
.om a { color: var(--brass); }
.om-lankar { margin-top: 28px !important; font-size: 0.92rem; }
body:not([data-state="idle"]) .om { display: none; }
.om h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 8vw, 2.8rem); line-height: 1.1; margin: 8px 0 16px; }
.hjalp-sida .om h2 { font-family: var(--sans); font-weight: 600; font-size: 1.15rem; margin: 34px 0 8px; }
.om ul, .om ol { margin: 0 0 10px; padding-left: 1.3rem; color: #d8cfbb; }
.om li { margin-bottom: 6px; }
.om strong { color: var(--ivory); }
