/* ============================================================
   CKB-WEB-COLOR-SCHEME-R1
   Controlled system dark-mode pilot.
   Scope in R1: Home, Event Detail, Bibliothek, Contact Form.
   No media inversion. No manual theme switch in this node.
   ============================================================ */

body[data-color-scheme="r1"] {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  body[data-color-scheme="r1"] {
    color-scheme: dark;
    --theme-bg-page: #12171b;
    --theme-bg-surface: #171d22;
    --theme-bg-elevated: #1c242a;
    --theme-text: #f3f5f6;
    --theme-text-muted: #aeb8c0;
    --theme-line: rgba(255,255,255,.15);
    --theme-line-strong: rgba(255,255,255,.76);
    --theme-hover: #202a31;
    --theme-input-bg: transparent;
    --theme-button-bg: #eef2f4;
    --theme-button-text: #11161a;
    --theme-media-outline: rgba(255,255,255,.14);
    --theme-gallery-edge: rgba(18,23,27,.72);
    --theme-gallery-edge-clear: rgba(18,23,27,0);

    background: var(--theme-bg-page);
    color: var(--theme-text);
  }

  body[data-color-scheme="r1"] .site-shell,
  body[data-color-scheme="r1"] .hero,
  body[data-color-scheme="r1"] .site-footer,
  body[data-color-scheme="r1"] .site-footer-modern,
  body[data-color-scheme="r1"] .detail-visual,
  body[data-color-scheme="r1"] .service-main,
  body[data-color-scheme="r1"] .detail-main {
    background-color: var(--theme-bg-page);
    color: var(--theme-text);
  }

  /* Home uses a light header in the approved baseline. In system dark mode,
     keep the same layout but switch to the existing white institutional lockup. */
  body[data-color-scheme="r1"] .site-header-shell:not(.is-curtain):not(.is-section) {
    background: var(--theme-bg-surface) !important;
    color: var(--theme-text) !important;
    border-bottom-color: var(--theme-line) !important;
  }
  body[data-color-scheme="r1"] .site-header-shell:not(.is-curtain):not(.is-section) .brand-lockup-full {
    display: none !important;
  }
  body[data-color-scheme="r1"] .site-header-shell:not(.is-curtain):not(.is-section) .brand-lockup-full-dark {
    display: block !important;
  }
  body[data-color-scheme="r1"] .site-header-shell:not(.is-curtain):not(.is-section) .brand-lockup-seal-only {
    display: none !important;
  }

  /* Existing deep section identity remains the same brand field. */
  body[data-color-scheme="r1"] .site-header-shell.is-section,
  body[data-color-scheme="r1"] .site-header-shell.is-curtain,
  body[data-color-scheme="r1"] .nav-curtain {
    background: var(--theme-section-bg) !important;
    color: var(--theme-section-text) !important;
  }

  /* Gallery: preserve images exactly; only adapt the white fade to the dark page. */
  body[data-color-scheme="r1"] .gallery-viewport::before {
    background: linear-gradient(90deg, var(--theme-gallery-edge), var(--theme-gallery-edge-clear));
  }
  body[data-color-scheme="r1"] .gallery-viewport::after {
    background: linear-gradient(270deg, var(--theme-gallery-edge), var(--theme-gallery-edge-clear));
  }
  body[data-color-scheme="r1"] .poster-mount img,
  body[data-color-scheme="r1"] .detail-visual img {
    outline-color: var(--theme-media-outline) !important;
  }

  /* Content surfaces and hover states. */
  body[data-color-scheme="r1"] .library-task-card:hover,
  body[data-color-scheme="r1"] .library-task-card:focus-visible,
  body[data-color-scheme="r1"] .day.has-event:hover,
  body[data-color-scheme="r1"] .day.has-event:focus-visible {
    background: var(--theme-hover) !important;
  }
  body[data-color-scheme="r1"] .footer-newsletter-col > p:not(.footer-label) {
    color: var(--theme-text-muted) !important;
  }
  body[data-color-scheme="r1"] .footer-inline-links a,
  body[data-color-scheme="r1"] .footer-newsletter-cta {
    border-bottom-color: var(--theme-line-strong) !important;
  }

  /* Forms: dark native controls without changing field structure. */
  body[data-color-scheme="r1"] .form-grid input,
  body[data-color-scheme="r1"] .form-grid select,
  body[data-color-scheme="r1"] .form-grid textarea,
  body[data-color-scheme="r1"] .registration-picker select {
    background: var(--theme-input-bg) !important;
    color: var(--theme-text) !important;
    border-bottom-color: var(--theme-line-strong) !important;
  }
  body[data-color-scheme="r1"] .form-grid select option,
  body[data-color-scheme="r1"] .registration-picker select option {
    background: var(--theme-bg-surface);
    color: var(--theme-text);
  }
  body[data-color-scheme="r1"] .primary-button {
    background: var(--theme-button-bg) !important;
    border-color: var(--theme-button-bg) !important;
    color: var(--theme-button-text) !important;
  }
  body[data-color-scheme="r1"] .primary-button:hover,
  body[data-color-scheme="r1"] .primary-button:focus-visible {
    background: #dce3e7 !important;
    border-color: #dce3e7 !important;
  }
  body[data-color-scheme="r1"] .form-prototype-state,
  body[data-color-scheme="r1"] .registration-prototype-state {
    background: rgba(255,255,255,.055) !important;
    color: var(--theme-text) !important;
    border-left-color: var(--theme-line-strong) !important;
  }

  /* Content media is authoritative artwork and must never be inverted. */
  body[data-color-scheme="r1"] img,
  body[data-color-scheme="r1"] video,
  body[data-color-scheme="r1"] iframe,
  body[data-color-scheme="r1"] svg {
    filter: none !important;
  }

  /* Let the browser draw dark scrollbars / native widgets on ready pages. */
  body[data-color-scheme="r1"] input,
  body[data-color-scheme="r1"] textarea,
  body[data-color-scheme="r1"] select,
  body[data-color-scheme="r1"] button {
    color-scheme: dark;
  }
}
