/* Sangkort – en leketøys-jukeboks for småbarn.
   Barna trykker på store kort for å spille sanger. Voksne holder inne
   låsen i hjørnet i 3 sekunder for å legge til og endre kort. */

/* ---------- Farger og tema ---------- */
:root {
  color-scheme: light dark;
  --bg:     light-dark(#ffd84d, #1f1c40);
  --dot:    light-dark(#ffcb1f, #2a2655);
  --ink:    light-dark(#2a1a00, #fff6d6);
  --panel:  light-dark(#fffaf0, #2b2850);
  --line:   light-dark(#eadbb8, #48447a);
  --soft:   light-dark(#7a6640, #c9c2ee);
  --btn:    light-dark(#2a1a00, #ffd84d);
  --btnink: light-dark(#fff, #1f1c40);
  --field:  light-dark(#fff, #1f1c40);
  --font: "Baloo 2", system-ui, sans-serif;
}
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark]  { color-scheme: dark; }

/* ---------- Grunnlag ---------- */
* { box-sizing: border-box; min-width: 0; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg) radial-gradient(var(--dot) 3px, transparent 3.5px) 0 0 / 34px 34px;
  color: var(--ink);
  font: 17px/1.5 var(--font);
  overflow-x: clip;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* ---------- Kortveggen ---------- */
.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(230px, 40vw), 1fr));
  gap: clamp(16px, 3vw, 32px);
  padding: clamp(18px, 3.5vw, 44px);
  padding-bottom: 110px;
  min-height: 100vh;
  align-content: center;
  max-width: 1240px;
  margin: 0 auto;
}

.card {
  --c: #ef476f;
  --shade: color-mix(in srgb, var(--c) 68%, #000);
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 34px;
  background: radial-gradient(120% 90% at 30% 15%, color-mix(in srgb, var(--c) 80%, #fff), var(--c) 60%);
  color: #fff;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px;
  overflow: hidden;
  box-shadow: inset 0 4px 0 rgba(255,255,255,.35), 0 12px 0 var(--shade), 0 22px 26px rgba(60,30,0,.22);
  transition: transform .09s, box-shadow .09s;
}
.card:active {
  transform: translateY(10px);
  box-shadow: inset 0 4px 0 rgba(255,255,255,.35), 0 2px 0 var(--shade), 0 6px 10px rgba(60,30,0,.2);
}
.card:focus-visible { outline: 5px solid var(--ink); outline-offset: 5px; }

.card .pic {
  font-size: clamp(64px, 11vw, 124px);
  line-height: 1;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,.15));
}
.card .pic img {
  display: block;
  width: clamp(80px, 14vw, 160px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 20px;
}
.card .name {
  font-weight: 800;
  font-size: clamp(20px, 2.6vw, 28px);
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
  text-wrap: balance;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* Equalizer-strekene og fremdriftslinjen vises bare mens kortet spiller */
.card .eq { position: absolute; top: 18px; right: 20px; display: none; gap: 5px; align-items: flex-end; height: 30px; }
.card .eq i { width: 7px; border-radius: 4px; background: #fff; animation: eq .9s ease-in-out infinite; }
.card .eq i:nth-child(2) { animation-delay: -.3s; }
.card .eq i:nth-child(3) { animation-delay: -.6s; }

.card .progress { position: absolute; left: 22px; right: 22px; bottom: 18px; height: 9px; border-radius: 9px; background: rgba(0,0,0,.2); display: none; }
.card .progress i { display: block; height: 100%; width: 0; border-radius: 9px; background: #fff; }

.card.playing { animation: bob 1.2s ease-in-out infinite; }
.card.playing .eq { display: flex; }
.card.playing .progress { display: block; }

@keyframes eq  { 0%, 100% { height: 8px; } 50% { height: 30px; } }
@keyframes bob { 0%, 100% { transform: rotate(-1.5deg) scale(1.02); } 50% { transform: rotate(1.5deg) scale(1.02); } }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  background: var(--panel);
  border-radius: 34px;
  padding: 40px 24px;
  box-shadow: 0 12px 0 var(--line);
}
.empty b { display: block; font-size: clamp(30px, 5vw, 46px); line-height: 1.05; }
.empty p { margin: 8px auto 0; max-width: 34em; color: var(--soft); }

/* ---------- Voksenlåsen (hold inne) ---------- */
.lock {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  /* --progress (0–1) fyller ringen mens knappen holdes inne */
  background: conic-gradient(var(--ink) calc(var(--progress, 0) * 1turn), color-mix(in srgb, var(--ink) 14%, transparent) 0);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: .55;
  touch-action: none;
}
.lock span { width: 48px; height: 48px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; }
.lock svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }

/* ---------- Dialoger ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(20,12,0,.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  user-select: text;
  -webkit-user-select: text;
}
.overlay.open { display: flex; }

.sheet {
  background: var(--panel);
  color: var(--ink);
  border-radius: 26px;
  width: min(720px, 100%);
  padding: clamp(18px, 3vw, 30px);
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  margin: auto 0;
}
.sheet h2 { margin: 0; font-size: 32px; line-height: 1.05; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.bar.center { justify-content: center; }
.bar.end { margin: 8px 0 0; }
.button-group { display: flex; gap: 8px; flex-wrap: wrap; }

.gate { max-width: 420px; text-align: center; }
.gate .question { font-size: 44px; font-weight: 800; margin: 6px 0; }

/* ---------- Knapper og skjema ---------- */
.btn {
  font: 700 17px/1 var(--font);
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.btn.primary { background: var(--btn); color: var(--btnink); border-color: var(--btn); }
.btn.small { min-height: 44px; padding: 8px 12px; font-size: 15px; }
.btn:disabled { opacity: .4; }
.btn:focus-visible, input:focus-visible { outline: 3px solid #3a86ff; outline-offset: 2px; }

fieldset { border: 2px solid var(--line); border-radius: 18px; padding: 16px; margin: 0 0 16px; }
legend { font-weight: 800; font-size: 20px; padding: 0 6px; }
.label { display: block; font-weight: 700; margin: 10px 0 6px; }
input[type=text] {
  width: 100%;
  font: 500 18px var(--font);
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--field);
  color: var(--ink);
}
input[type=file] { font: inherit; width: 100%; }

.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.picker button {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 12px;
  border: 2px solid transparent;
  background: light-dark(#f3ead6, #1f1c40);
  font-size: 26px;
  cursor: pointer;
}
.picker button[aria-pressed=true] { border-color: var(--ink); background: light-dark(#fff, #48447a); }
.picker .color { border-radius: 50%; }
.picker button img, .card-list .swatch img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; }
.picker .color[aria-pressed=true] { box-shadow: 0 0 0 3px var(--panel), 0 0 0 6px var(--ink); }

.msg { min-height: 1.5em; color: var(--soft); margin: 8px 0 0; }
.msg.error { color: light-dark(#b3001b, #ff8fa3); }
.help { color: var(--soft); font-size: 16px; }
.help ol { padding-left: 22px; margin: 6px 0; }

/* ---------- Kortlisten i voksenmodus ---------- */
.card-list { list-style: none; margin: 0 0 18px; padding: 0; border-top: 2px solid var(--line); }
.card-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 2px solid var(--line); flex-wrap: wrap; }
.card-list .swatch { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 28px; flex: none; }
.card-list .title { flex: 1 1 140px; font-weight: 700; line-height: 1.2; }
.card-list .actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 600px) {
  .wall { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { border-radius: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .card.playing { animation: none; }
  .card .eq i { animation: none; height: 20px; }
}
