/* wa-lint: skip */
/* ==========================================================================
   Playground Modal — TL;DR-card i blog-tekst der åbner lys modal med
   interaktivt værktøj. Lys, sitet-native æstetik (Figtree, brand-teal +
   orange accent). Erstatter mørk GitHub-stil og fjerner scroll-i-scroll.
   ========================================================================== */

/* ---------- INLINE TL;DR-CARD (i 740px læsekolonne) ---------- */
.playground-card {
  display: block;
  width: 100%;
  margin: var(--space-xl) 0;
  padding: var(--space-l) var(--space-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 6px solid var(--brand-accent);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: box-shadow 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.playground-card:hover,
.playground-card:focus-visible {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  outline: none;
}

.playground-card:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 3px;
}

.playground-card__pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 3px 10px;
  background: rgb(230, 236, 238); /* lys teal-tonet */
  color: var(--brand-primary);
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 var(--space-m) 0;
}

.playground-card__pill svg {
  width: 12px;
  height: 12px;
}

.playground-card__title {
  display: block;
  margin: 0 0 var(--space-s) 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -0.01em;
}

.playground-card__pitch {
  display: block;
  margin: 0 0 var(--space-l) 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.playground-card__preview {
  display: block;
  width: 100%;
  margin: 0 0 var(--space-l) 0;
  border-radius: var(--radius-sm);
  background: rgb(241, 245, 249); /* tydeligere baggrund så hvide paneler står frem */
  border: 1px solid var(--border);
  overflow: hidden;
  aspect-ratio: 16 / 7;
}

.playground-card__preview svg {
  width: 100%;
  height: 100%;
  display: block;
}

.playground-card__footer {
  display: flex;
  align-items: center;
  gap: var(--space-m);
  flex-wrap: wrap;
}

.playground-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.65em 1.2em;
  background: var(--brand-primary);
  color: rgb(255, 255, 255);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.playground-card:hover .playground-card__cta,
.playground-card:focus-visible .playground-card__cta {
  background: var(--brand-primary-hover);
}

.playground-card__cta-arrow {
  transition: transform 0.2s ease;
}

.playground-card:hover .playground-card__cta-arrow {
  transform: translateX(3px);
}

.playground-card__meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ---------- LYS MODAL ---------- */
.playground-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  background: rgba(49, 79, 89, 0.55); /* teal-tonet, ikke sort */
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.playground-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.playground-modal__shell {
  position: relative;
  width: min(1100px, 100%);
  height: min(800px, 100%);
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px);
  transition: transform 0.2s ease;
}

.playground-modal.is-open .playground-modal__shell {
  transform: translateY(0);
}

/* 4px teal accent-stripe foroven — sitet-signatur */
.playground-modal__shell::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--brand-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 1;
}

.playground-modal__header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-m);
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  z-index: 2;
}

.playground-modal__title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playground-modal__open-new {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.4em 0.8em;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.playground-modal__open-new:hover,
.playground-modal__open-new:focus-visible {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  outline: none;
}

.playground-modal__close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 0;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.playground-modal__close:hover,
.playground-modal__close:focus-visible {
  border-color: var(--brand-accent);
  color: var(--brand-accent);
  background: rgba(184, 90, 58, 0.08);
  outline: none;
}

.playground-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--bg);
  position: relative;
}

.playground-modal__iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Body scroll lock når modal er åben */
body.has-playground-open {
  overflow: hidden;
}

/* Skjul custom-cursor og brug native cursor mens modal er åben.
   Custom-cursor får ikke mousemove-events fra inden i iframen, så den
   bliver "låst" ved iframens kant. Native cursor fungerer på tværs af
   iframe-grænser. */
body.has-playground-open .cursor {
  display: none !important;
}

body.has-playground-open,
body.has-playground-open * {
  cursor: auto !important;
}

body.has-playground-open .playground-card,
body.has-playground-open .playground-modal__close,
body.has-playground-open .playground-modal__open-new,
body.has-playground-open a,
body.has-playground-open button {
  cursor: pointer !important;
}

body.has-playground-open input,
body.has-playground-open textarea {
  cursor: text !important;
}

/* ---------- MOBIL (<720px) ---------- */
@media (max-width: 720px) {
  .playground-card {
    padding: var(--space-l) var(--space-m);
  }

  .playground-card__preview {
    aspect-ratio: 4 / 3;
  }

  .playground-card__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .playground-card__cta {
    justify-content: center;
  }

  .playground-modal {
    padding: 0;
    background: var(--bg); /* fuldskærm — ingen backdrop */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .playground-modal__shell {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  .playground-modal__shell::before {
    border-radius: 0;
  }

  .playground-modal__header {
    padding: 14px 16px 12px;
  }

  .playground-modal__open-new {
    display: none; /* meget plads-presset på mobil */
  }
}

/* Brug 100dvh hvor det er understøttet (iOS Safari bottom-bar) */
@supports (height: 100dvh) {
  @media (max-width: 720px) {
    .playground-modal__shell {
      height: 100dvh;
    }
  }
}

/* Print: skjul */
@media print {
  .playground-card,
  .playground-modal {
    display: none !important;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .playground-card,
  .playground-card__cta,
  .playground-card__cta-arrow,
  .playground-modal,
  .playground-modal__shell {
    transition: none;
  }
}
