/* Consent + legal overlay shell — Foundation SSOT */
:root {
  --z-overlay: 12000;
}
/* Consent + modal chrome (ambient: platform/shared/styles/ambient.css) */

body.consent-open,
body.app-prompt-open {
  overflow: hidden;
}

.consent-overlay--prompt {
  z-index: var(--z-overlay);
}

.consent-overlay--prompt .consent-card {
  max-width: min(28rem, calc(100vw - 2.5rem));
}

.consent-overlay--prompt .consent-title {
  line-height: 1.45;
}

.consent-overlay--prompt .consent-actions .btn-primary,
.consent-overlay--prompt .consent-actions .btn-ghost {
  width: 100%;
}

#consent-root {
  position: relative;
  z-index: 400;
}

#app-root.consent-blocked {
  pointer-events: none;
  user-select: none;
}

.consent-overlay--permissions {
  z-index: var(--z-overlay);
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--song-wall-height) + 1.35rem)
    1rem
    calc(5.75rem + env(safe-area-inset-bottom, 0px))
    1rem;
  background: rgba(10, 22, 40, 0.22);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: none;
}

.consent-overlay--permissions .consent-card {
  pointer-events: auto;
}

body.consent-open .song-wall-root {
  z-index: 410;
}

/* Modals — skjul chrome der ellers ligger over overlays og stjæler klik */
body.consent-open .contact-fab,
body.consent-open .team-chat-fab,
body.consent-open .donate-fab,
body.consent-open .links-panel-fab,
body.consent-open #app-toolbar,
body.consent-open .site-footer,
body.result-overlay-open .contact-fab,
body.result-overlay-open .team-chat-fab,
body.result-overlay-open .donate-fab,
body.result-overlay-open .links-panel-fab,
body.result-overlay-open #app-toolbar,
body.result-overlay-open .site-footer,
body.donation-overlay-open .contact-fab,
body.donation-overlay-open .team-chat-fab,
body.donation-overlay-open .donate-fab,
body.donation-overlay-open .links-panel-fab,
body.donation-overlay-open #app-toolbar,
body.donation-overlay-open .site-footer,
body.links-panel-open .contact-fab,
body.links-panel-open .team-chat-fab,
body.links-panel-open .donate-fab,
body.links-panel-open .links-panel-fab,
body.links-panel-open #app-toolbar,
body.links-panel-open .site-footer,
body.rhymes-overlay-open .contact-fab,
body.rhymes-overlay-open .team-chat-fab,
body.rhymes-overlay-open .donate-fab,
body.rhymes-overlay-open .links-panel-fab,
body.rhymes-overlay-open #app-toolbar,
body.rhymes-overlay-open .site-footer,
body.identity-overlay-open .contact-fab,
body.identity-overlay-open .team-chat-fab,
body.identity-overlay-open .donate-fab,
body.identity-overlay-open .links-panel-fab,
body.identity-overlay-open #app-toolbar,
body.identity-overlay-open .site-footer,
body.alignment-modal-open .contact-fab,
body.alignment-modal-open .team-chat-fab,
body.alignment-modal-open .donate-fab,
body.alignment-modal-open .links-panel-fab,
body.alignment-modal-open #app-toolbar,
body.alignment-modal-open .site-footer,
body.alignment-details-open .contact-fab,
body.alignment-details-open .team-chat-fab,
body.alignment-details-open .donate-fab,
body.alignment-details-open .links-panel-fab,
body.alignment-details-open #app-toolbar,
body.alignment-details-open .site-footer,
body.app-prompt-open .contact-fab,
body.app-prompt-open .team-chat-fab,
body.app-prompt-open .donate-fab,
body.app-prompt-open .links-panel-fab,
body.app-prompt-open #app-toolbar,
body.app-prompt-open .site-footer,
body.cover-config-open .contact-fab,
body.cover-config-open .team-chat-fab,
body.cover-config-open .donate-fab,
body.cover-config-open .links-panel-fab,
body.cover-config-open #app-toolbar,
body.cover-config-open .site-footer,
body.has-contact-open .contact-fab,
body.has-contact-open .team-chat-fab,
body.has-contact-open .donate-fab,
body.has-contact-open .links-panel-fab,
body.has-contact-open #app-toolbar,
body.has-contact-open .site-footer,
body.legal-overlay-open .contact-fab,
body.legal-overlay-open .team-chat-fab,
body.legal-overlay-open .donate-fab,
body.legal-overlay-open .links-panel-fab,
body.legal-overlay-open #app-toolbar,
body.legal-overlay-open .site-footer,
body.result-details-open .contact-fab,
body.result-details-open .team-chat-fab,
body.result-details-open .donate-fab,
body.result-details-open .links-panel-fab,
body.result-details-open #app-toolbar,
body.result-details-open .site-footer,
body.is-loading #app-toolbar,
body.is-loading .site-footer {
  visibility: hidden;
  pointer-events: none;
}

body.consent-open .song-wall-root {
  z-index: 410;
}

.consent-card {
  max-height: min(92vh, 40rem);
  overflow-y: auto;
  padding: 1.5rem 1.5rem 1.35rem;
  text-align: left;
}

.consent-card.consent-card--permissions {
  display: flex;
  flex-direction: column;
  max-width: min(44rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - var(--song-wall-height) - 7.5rem - env(safe-area-inset-bottom, 0px));
  padding: 0.85rem 1rem 0.7rem;
  overflow: hidden;
}

.consent-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  margin-bottom: 0.35rem;
}

.consent-card--permissions .consent-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.consent-card--permissions .consent-lang-row {
  margin: 0;
  flex-shrink: 0;
}

.consent-card--permissions .consent-intro {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  line-height: 1.38;
  flex-shrink: 0;
}

.consent-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.consent-optional-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.consent-footer {
  flex-shrink: 0;
  padding-top: 0.4rem;
  margin-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.consent-card--permissions .consent-privacy-link {
  margin: 0 0 0.4rem;
  font-size: 0.76rem;
}

.consent-card--permissions .consent-actions {
  margin-top: 0;
  gap: 0.35rem;
}

.consent-card--permissions .consent-accept,
.consent-card--permissions .consent-essential {
  min-height: 2.125rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.consent-card--permissions .consent-section {
  margin-bottom: 0;
}

.consent-card--permissions .consent-section--required {
  padding: 0.45rem 0.55rem;
  margin-bottom: 0.4rem;
}

.consent-card--permissions .consent-required-badge {
  margin-bottom: 0.25rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.62rem;
}

.consent-card--permissions .consent-section-title {
  font-size: 0.8rem;
  margin-bottom: 0.1rem;
}

.consent-card--permissions .consent-section-detail {
  font-size: 0.72rem;
  line-height: 1.35;
}

.consent-card--permissions .consent-section-row {
  gap: 0.45rem;
}

.consent-card--permissions .consent-checkbox {
  margin-top: 0.12rem;
  transform: scale(0.92);
  transform-origin: top left;
}

.consent-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.consent-intro {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}

.consent-lang-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.consent-lang-btn {
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
}

.consent-lang-btn.is-active {
  color: var(--bg);
  border-color: var(--accent);
  background: var(--accent);
}

.consent-overlay--legal {
  z-index: 400;
  padding: 0.75rem;
  align-items: center;
  pointer-events: auto;
  isolation: isolate;
}

body.legal-overlay-open #consent-root .consent-overlay {
  pointer-events: none;
}

body.legal-overlay-open .consent-overlay--legal {
  pointer-events: auto;
}

.consent-card--legal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(56rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  overflow: hidden;
  padding: 0.75rem 1rem 0.65rem;
}

.consent-card--legal .consent-title {
  font-size: 1.05rem;
  margin: 0;
}

.legal-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  pointer-events: auto;
}

.legal-overlay-title {
  margin: 0;
  flex: 1;
}

.legal-overlay-close {
  flex-shrink: 0;
  position: relative;
  z-index: 4;
  min-height: 2rem;
  min-width: 4.5rem;
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  pointer-events: auto;
  cursor: pointer;
}

.legal-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 1;
}

.consent-card--legal:not(.has-details-open) .legal-scroll {
  overflow-y: auto;
}

.legal-footer {
  flex-shrink: 0;
  padding-top: 0.45rem;
  margin-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.legal-body {
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text-primary, #e8e4df);
}

.legal-body h1 {
  font-size: 1.15rem;
  margin: 0 0 0.75rem;
}

.legal-body h2 {
  font-size: 1rem;
  margin: 1.35rem 0 0.5rem;
  text-transform: none;
  letter-spacing: normal;
  opacity: 1;
}

.legal-body h3 {
  font-size: 0.92rem;
  margin: 1rem 0 0.4rem;
}

.legal-body p,
.legal-body li {
  margin: 0 0 0.65rem;
}

.legal-body ul,
.legal-body ol {
  margin: 0 0 0.85rem;
  padding-left: 1.25rem;
}

.legal-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.legal-body a {
  color: var(--accent);
}

.legal-loading,
.legal-error {
  color: var(--muted);
}

/* Plain summary — mobile: single column, scroll */
.legal-body--plain {
  font-size: 0.84rem;
  line-height: 1.45;
}

.legal-plain-hero {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.legal-plain-intro p {
  margin: 0 0 0.4rem;
}

.legal-plain-intro p:last-child {
  margin-bottom: 0;
}

.legal-plain-grid {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.legal-plain-section {
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.legal-plain-section h2 {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 0 0 0.3rem;
  opacity: 0.72;
}

.legal-plain-section p,
.legal-plain-section li {
  margin: 0 0 0.28rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

.legal-plain-section ul {
  margin: 0;
  padding-left: 1rem;
}

.legal-plain-section--highlights {
  background: rgba(201, 168, 124, 0.1);
  border-color: rgba(201, 168, 124, 0.28);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
}

.legal-plain-section--highlights h2 {
  opacity: 0.9;
  color: var(--accent);
}

.legal-plain-section--highlights ul {
  margin: 0.15rem 0 0.25rem;
}

.legal-plain-section--highlights li {
  font-size: 0.81rem;
  margin-bottom: 0.2rem;
}

.legal-plain-section--highlights li strong {
  font-weight: 600;
}

.legal-details-toggle-wrap {
  margin: 0;
  padding: 0;
  border: none;
}

.legal-details-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-height: 2.125rem;
  padding: 0.38rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  text-align: left;
}

.legal-details-toggle:hover {
  background: rgba(201, 168, 124, 0.12);
  border-color: rgba(201, 168, 124, 0.35);
}

.legal-details-toggle__chevron {
  font-size: 0.58rem;
  opacity: 0.85;
  transition: transform 0.2s ease;
}

.legal-details-toggle.is-open .legal-details-toggle__chevron {
  transform: rotate(180deg);
}

.legal-details-panel {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border);
}

.legal-details-panel__heading {
  font-size: 0.72rem;
  margin: 0 0 0.45rem;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.legal-body--full {
  font-size: 0.8rem;
  line-height: 1.48;
  max-height: min(38vh, 20rem);
  overflow-y: auto;
}

.legal-body--full h1 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.legal-body--full h2 {
  font-size: 0.88rem;
  margin: 0.85rem 0 0.35rem;
}

/* Desktop: one viewport for plain layer */
@media (min-width: 52rem) and (min-height: 32rem) {
  .consent-overlay--legal {
    padding: 0.65rem 1rem;
  }

  .consent-card--legal {
    max-height: calc(100dvh - 1.25rem);
    padding: 0.65rem 1.1rem 0.55rem;
  }

  .consent-card--legal:not(.has-details-open) .legal-scroll {
    overflow: hidden;
  }

  .legal-body--plain {
    font-size: 0.8rem;
    line-height: 1.38;
  }

  .legal-plain-hero {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 0.65rem 0.85rem;
    align-items: stretch;
    margin-bottom: 0.45rem;
  }

  .legal-plain-intro {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .legal-plain-intro p {
    font-size: 0.79rem;
    margin-bottom: 0.35rem;
  }

  .legal-plain-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.55rem;
  }

  .legal-plain-section {
    padding: 0.38rem 0.5rem;
  }

  .legal-plain-section h2 {
    font-size: 0.64rem;
    margin-bottom: 0.22rem;
  }

  .legal-plain-section p,
  .legal-plain-section li {
    font-size: 0.74rem;
    line-height: 1.35;
    margin-bottom: 0.18rem;
  }

  .legal-plain-section--highlights li {
    font-size: 0.75rem;
  }

  .legal-plain-section--wide {
    grid-column: 1 / -1;
    padding: 0.35rem 0.5rem;
  }

  .legal-plain-section--wide p {
    margin: 0;
    font-size: 0.74rem;
  }

  .legal-overlay-header {
    margin-bottom: 0.4rem;
  }

  .legal-footer {
    padding-top: 0.35rem;
    margin-top: 0.25rem;
  }

  .consent-card--legal.has-details-open .legal-body--full {
    max-height: min(42vh, 22rem);
  }
}

@media (max-width: 51.99rem) {
  .consent-card--legal {
    max-height: calc(100dvh - 1rem);
  }
}

.consent-privacy-link {
  display: block;
  width: 100%;
  margin: 0.5rem 0 0.25rem;
  padding: 0;
  border: none;
  background: none;
  font-size: 0.82rem;
  color: var(--accent);
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

.consent-privacy-link:hover {
  opacity: 0.85;
}

@media (min-width: 52rem) {
  .consent-overlay:not(.consent-overlay--session):not(.consent-overlay--legal):not(.consent-overlay--permissions) {
    padding: 0.5rem 0.85rem;
    overflow: hidden;
  }

  .consent-overlay--permissions {
    padding:
      calc(var(--song-wall-height) + 1.5rem)
      0.85rem
      calc(5.5rem + env(safe-area-inset-bottom, 0px))
      0.85rem;
    overflow: hidden;
  }

  .consent-card.consent-card--permissions {
    max-width: min(46rem, calc(100vw - 1.5rem));
    max-height: calc(100dvh - var(--song-wall-height) - 7.25rem - env(safe-area-inset-bottom, 0px));
    padding: 0.65rem 0.9rem 0.55rem;
  }

  .consent-card--permissions .consent-top {
    margin-bottom: 0.25rem;
  }

  .consent-card--permissions .consent-intro {
    margin-bottom: 0.35rem;
    font-size: 0.74rem;
    line-height: 1.32;
  }

  .consent-card--permissions .consent-body {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: 0.45rem 0.6rem;
    overflow: hidden;
    align-items: stretch;
  }

  .consent-card--permissions .consent-section--required {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin-bottom: 0;
    padding: 0.4rem 0.5rem;
  }

  .consent-card--permissions .consent-required-badge {
    margin-bottom: 0.2rem;
  }

  .consent-card--permissions .consent-section--required .consent-section-title {
    margin-bottom: 0.15rem;
  }

  .consent-optional-grid {
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    min-height: 0;
  }

  .consent-card--permissions .consent-section {
    padding: 0.32rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    background: rgba(0, 0, 0, 0.12);
  }

  .consent-card--permissions .consent-section-row {
    gap: 0.4rem;
    align-items: flex-start;
  }

  .consent-card--permissions .consent-section-title {
    font-size: 0.76rem;
    margin-bottom: 0.05rem;
  }

  .consent-card--permissions .consent-section-detail {
    font-size: 0.68rem;
    line-height: 1.32;
  }

  .consent-card--permissions .consent-checkbox {
    margin-top: 0.08rem;
    transform: scale(0.88);
  }

  .consent-card--permissions .consent-footer {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.35rem 0.75rem;
    padding-top: 0.3rem;
    margin-top: 0.28rem;
  }

  .consent-card--permissions .consent-privacy-link {
    margin: 0;
    text-align: left;
    justify-self: start;
  }

  .consent-card--permissions .consent-actions {
    flex-direction: row;
    justify-content: flex-end;
    gap: 0.35rem;
    width: auto;
  }

  .consent-card--permissions .consent-accept,
  .consent-card--permissions .consent-essential {
    width: auto;
    min-width: 7.5rem;
    min-height: 2rem;
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }
}

@media (min-width: 52rem) and (max-height: 32rem) {
  .consent-card--permissions .consent-body {
    overflow-y: auto;
  }
}

@media (max-width: 51.99rem) {
  .consent-card--permissions {
    max-height: calc(100dvh - 1rem);
  }

  .consent-card--permissions .consent-body {
    overflow-y: auto;
  }
}

.consent-section {
  display: block;
  margin-bottom: 0.85rem;
  cursor: pointer;
}

.consent-section--required {
  cursor: default;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
}

.consent-required-badge {
  display: inline-block;
  margin-bottom: 0.45rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(201, 168, 124, 0.45);
  border-radius: 4px;
}

.consent-section--required .consent-section-title {
  margin-top: 0;
}

.consent-section-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}

.consent-checkbox {
  margin-top: 0.2rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.consent-section-title {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.2rem;
}

.consent-section-detail {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.consent-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.consent-accept {
  width: 100%;
}

.consent-essential {
  width: 100%;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
  padding: 0.5rem;
}

.consent-essential:hover {
  color: var(--accent);
}

.consent-mic-icon {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  position: relative;
}

.consent-mic-icon::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 42%;
  width: 0.55rem;
  height: 1.1rem;
  transform: translate(-50%, -50%);
  border-radius: 0.35rem;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.consent-mic-icon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 62%;
  width: 1.25rem;
  height: 0.65rem;
  transform: translateX(-50%);
  border: 2px solid var(--accent);
  border-top: none;
  border-radius: 0 0 0.6rem 0.6rem;
}

.consent-mic-browser-note {
  margin: 0 0 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
}

.consent-mic-dictation-note {
  margin: -0.35rem 0 1rem;
  padding: 0 0 0 2.15rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.consent-overlay:not(.consent-overlay--session) .consent-mic-dictation-note {
  margin-top: -0.5rem;
  padding-left: 0.15rem;
}

.consent-mic-error {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: #e8a090;
  line-height: 1.4;
}
