/* ------------------------------------------------------------------ */
/* Grundlag                                                            */
/* ------------------------------------------------------------------ */

:root {
  --bg: #0e1117;
  --bg-soft: #161b26;
  --panel: #1b2130;
  --panel-2: #222a3b;
  --line: #2c3548;
  --text: #eef2f9;
  --muted: #9aa6bd;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.16);
  --danger: #f2545b;
  --ok: #3ddc84;
  --radius: 16px;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI Variable Display", "Segoe UI", Inter, -apple-system, BlinkMacSystemFont,
    Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

html[data-theme='light'] {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #eef1f8;
  --line: #dde3ef;
  --text: #131a26;
  --muted: #5d6b85;
  --accent: #2f6ef0;
  --accent-soft: rgba(47, 110, 240, 0.12);
  --shadow: 0 14px 36px rgba(20, 30, 60, 0.12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(1200px 700px at 15% -10%, var(--panel-2), var(--bg) 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

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

a {
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Knapper og felter                                                   */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease,
    opacity 0.15s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--panel);
  border-color: var(--accent);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #3f7bf0;
  border-color: #3f7bf0;
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(242, 84, 91, 0.4);
}

.btn-lg {
  padding: 15px 26px;
  font-size: 1.05rem;
  border-radius: 14px;
}

.btn-icon {
  padding: 9px 11px;
}

.field {
  width: 100%;
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* ------------------------------------------------------------------ */
/* Centrerede sider (deltag / opret)                                   */
/* ------------------------------------------------------------------ */

.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 44px;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card h1 {
  font-size: 1.6rem;
}

.code-input {
  width: 100%;
  text-align: center;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  padding: 16px 10px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.spread {
  justify-content: space-between;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.footer-links {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Ordfelter (deltager)                                                */
/* ------------------------------------------------------------------ */

.word-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.word-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.word-row .num {
  width: 26px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.thanks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.badge.closed .dot {
  background: var(--danger);
}

.mini-cloud {
  height: 260px;
  width: 100%;
}

/* ------------------------------------------------------------------ */
/* Praesentation                                                       */
/* ------------------------------------------------------------------ */

.present {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  backdrop-filter: blur(8px);
}

.question {
  font-size: clamp(1.1rem, 2.2vw, 1.9rem);
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 4px 10px;
  background: transparent;
  width: 100%;
  min-width: 0;
}

.question:hover,
.question:focus {
  border-color: var(--line);
  background: var(--bg-soft);
}

.stats {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.stat b {
  color: var(--text);
  font-size: 1.1rem;
  margin-right: 2px;
}

.cloud-wrap {
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.wc-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform-origin: 50% 50%;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.wc-word {
  position: absolute;
  left: 0;
  top: 0;
  line-height: 1;
  white-space: nowrap;
  cursor: default;
  user-select: none;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    font-size 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease, color 0.4s ease;
}

.wc-enter {
  opacity: 0;
}

.wc-leave {
  opacity: 0;
  pointer-events: none;
}

@keyframes wc-bump {
  0% {
    filter: brightness(1);
  }
  35% {
    filter: brightness(1.65);
  }
  100% {
    filter: brightness(1);
  }
}

.wc-bump {
  animation: wc-bump 0.75s ease-out;
}

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.empty.hidden {
  display: none;
}

.pulse {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.7);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* Bundlinje med kode og link */
.joinbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  flex-wrap: wrap;
}

.join-step {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.join-step .n {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateY(3px);
}

.join-url {
  font-weight: 700;
  font-size: clamp(1rem, 1.6vw, 1.35rem);
}

.join-code {
  font-weight: 800;
  font-size: clamp(1.3rem, 2.4vw, 2rem);
  letter-spacing: 0.16em;
  color: var(--accent);
}

/* QR-kode i bundlinjen */
.qr-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  transition: border-color 0.15s ease, transform 0.12s ease;
}

.qr-badge:hover {
  border-color: var(--accent);
}

.qr-badge:active {
  transform: translateY(1px);
}

/* QR-koder skal staa paa hvidt for at kunne scannes - ogsaa i morkt tema. */
.qr-img {
  display: block;
  width: clamp(72px, 10vh, 124px);
  height: clamp(72px, 10vh, 124px);
  background: #fff;
  border-radius: 8px;
  padding: 4px;
}

.qr-img svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(6, 9, 16, 0.82);
  backdrop-filter: blur(6px);
  cursor: zoom-out;
}

.qr-overlay-card {
  display: flex;
  align-items: center;
  gap: 36px;
  padding: 28px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  justify-content: center;
}

.qr-big {
  width: min(58vh, 58vw, 520px);
  height: min(58vh, 58vw, 520px);
  background: #fff;
  border-radius: 12px;
  padding: 10px;
}

.qr-big svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-overlay-text {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}

.qr-overlay-text .join-url {
  font-size: clamp(1.1rem, 2.4vw, 2rem);
}

.qr-overlay-text .join-code {
  font-size: clamp(2rem, 6vw, 4.5rem);
}

@media (max-width: 720px) {
  .qr-text {
    display: none;
  }
}

/* Sidepanel */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(360px, 92vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.panel.open {
  transform: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.panel-body {
  padding: 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.word-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 42vh;
  overflow: auto;
}

.word-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
}

.word-item .txt {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.word-item .cnt {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.word-item .rm {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.word-item .rm:hover {
  color: var(--danger);
  background: rgba(242, 84, 91, 0.12);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 14, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 20;
}

.backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 18px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  font-weight: 600;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Fuldskaerm: skjul alt undtagen skyen */
body.focus .topbar .stats,
body.focus .topbar .tools {
  display: none;
}

/* I fuld skaerm samles QR, adresse og kode i midten. */
body.focus .joinbar {
  justify-content: center;
}

body.focus .joinbar .grow,
body.focus .joinbar #hidden-note {
  display: none;
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
  }
  .stats {
    order: 3;
    width: 100%;
  }
  .joinbar {
    gap: 12px;
    padding: 12px 14px;
  }
  .card {
    padding: 20px;
  }
  .code-input {
    font-size: 1.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

[hidden] {
  display: none !important;
}
