/* Load after premium.css. The original dark palette remains the default. */
:root {
  color-scheme: dark;
  --theme-control-bg: rgba(238, 245, 248, .055);
  --theme-control-hover: rgba(238, 245, 248, .12);
  --theme-control-border: rgba(192, 210, 222, .25);
  --theme-control-ink: #e5ecee;
  --theme-focus: #a8cbec;
}

/* Keep the theme control beside the menu, independent of menu visibility. */
.site-header {
  gap: 24px;
}
.site-header > .brand {
  order: 0;
}
.site-header > nav {
  order: 1;
  margin-left: auto;
  gap: clamp(15px, 1.7vw, 24px);
}
.site-header > nav > a {
  white-space: nowrap;
}
.site-header .nav-contact {
  margin-left: 0;
}
.header-actions {
  order: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  position: relative;
  z-index: 56;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--theme-control-border);
  border-radius: 24px;
  background: var(--theme-control-bg);
  color: var(--theme-control-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045);
  font: 600 9px/1.4 var(--font);
  letter-spacing: .015em;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.theme-toggle:hover {
  background: var(--theme-control-hover);
  border-color: currentColor;
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--theme-focus);
  outline-offset: 4px;
}
.theme-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-toggle .theme-sun {
  display: initial;
}
.theme-toggle .theme-moon {
  display: none;
}
html[data-theme="light"] .theme-toggle .theme-sun {
  display: none;
}
html[data-theme="light"] .theme-toggle .theme-moon {
  display: initial;
}

/* An ivory canvas, graphite typography, and a restrained architectural red. */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f3ee;
  --surface: #fffdf9;
  --ink: #252e33;
  --muted: #5b686e;
  --line: rgba(42, 55, 61, .17);
  --red: #cb3038;
  --blue: #326d91;
  --paper: #eae7df;
  --theme-control-bg: rgba(255, 255, 255, .62);
  --theme-control-hover: rgba(228, 226, 217, .85);
  --theme-control-border: rgba(48, 63, 68, .21);
  --theme-control-ink: #39494f;
  --theme-focus: #a9202a;
}

/* Transition surfaces only. Photographs and the WebGL canvas are not filtered. */
body,
.site-header,
.site-footer,
.focus-section,
.light-section,
.technical-section,
.related-section,
.reference-card,
.contact-map-card,
.player-controls,
.scene-label,
.scene-controls,
.activity-nav a,
.activity-tags span {
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

html[data-theme="light"] .site-header {
  background: rgba(248, 246, 240, .92);
  border-bottom-color: rgba(42, 55, 61, .14);
  box-shadow: 0 3px 22px rgba(39, 51, 54, .025);
}
html[data-theme="light"] .site-header .nav-contact {
  border-color: #8e9695;
}
html[data-theme="light"] .site-header .nav-contact:hover {
  border-color: var(--red);
  color: var(--red);
}
html[data-theme="light"] .brand-grid i {
  background: #8c9697;
}
html[data-theme="light"] .brand-grid i:nth-child(3n) {
  background: #62757d;
}
html[data-theme="light"] .brand-type small {
  color: #36444a;
}
html[data-theme="light"] .skip-link {
  background: #25353d;
  color: #fffdf8;
}
html[data-theme="light"] :is(a, button, input, select, textarea, canvas, summary):focus-visible {
  outline-color: var(--theme-focus);
}
html[data-theme="light"] .button-red:hover {
  background: #b4222c;
}
html[data-theme="light"] .button-dark {
  background: #26363e;
  color: #fffdf8;
}
html[data-theme="light"] .button-dark:hover {
  background: #182a33;
}
html[data-theme="light"] .button-outline {
  color: var(--ink);
  border-color: #87938f;
}
html[data-theme="light"] .button-outline:hover {
  background: #e5e4dc;
  border-color: #54666b;
}

/* Hero and interactive model. The renderer already uses a transparent canvas. */
html[data-theme="light"] .hero-sticky {
  background:
    radial-gradient(ellipse at 77% 44%, #fffefa 0, #e7ebe6 40%, transparent 68%),
    #f5f3ed;
}
html[data-theme="light"] .hero-grid-lines {
  background: linear-gradient(90deg, transparent 49.96%, rgba(54, 76, 81, .065) 50%, transparent 50.04%);
  border-color: rgba(54, 76, 81, .075);
}
html[data-theme="light"] .hero-copy h1 em {
  color: #667575;
}
html[data-theme="light"] .hero-experience p {
  color: #57666b;
}
html[data-theme="light"] .scene-overline,
html[data-theme="light"] .scene-note {
  color: #52676f;
}
html[data-theme="light"] .scene-label {
  background: rgba(255, 254, 249, .91);
  color: #3d525a;
  border-color: rgba(57, 77, 86, .22);
  box-shadow: 0 5px 20px rgba(40, 57, 66, .055);
}
html[data-theme="light"] .pulse-dot {
  background: var(--red);
  box-shadow: 0 0 8px rgba(203, 48, 56, .25);
}
html[data-theme="light"] .scene-controls {
  background: rgba(255, 254, 250, .94);
  border-color: rgba(57, 77, 86, .25);
  box-shadow: 0 4px 18px rgba(40, 57, 66, .055);
}
html[data-theme="light"] .scene-controls button {
  color: #50656e;
}
html[data-theme="light"] .scene-controls button:hover {
  background: #e6eae6;
  color: #273b44;
}
html[data-theme="light"] .scene-controls button.active {
  background: #2a414b;
  color: #fffefa;
}
html[data-theme="light"] .build-stages button {
  color: #5e6d71;
}
html[data-theme="light"] .build-stages button.active {
  color: #25363d;
}
html[data-theme="light"] .build-stages button.active span {
  color: var(--red);
}
html[data-theme="light"] .build-progress > div {
  background: #b8c1be;
}

/* Editorial sections. */
html[data-theme="light"] .light-section,
html[data-theme="light"] .focus-section {
  background: #eae7df;
  color: #28383e;
}
html[data-theme="light"] .light-section p,
html[data-theme="light"] .focus-title > p,
html[data-theme="light"] .focus-facts p {
  color: #53636a;
}
html[data-theme="light"] .light-section .eyebrow,
html[data-theme="light"] .focus-section .eyebrow {
  color: #384b54;
}
html[data-theme="light"] .focus-title h2 span,
html[data-theme="light"] .intro-grid h2 span {
  color: #657572;
}
html[data-theme="light"] .focus-section .small-label,
html[data-theme="light"] .focus-facts > div > span,
html[data-theme="light"] .breadcrumb {
  color: #526970;
}
html[data-theme="light"] .story-year {
  color: #2a3b42;
}
html[data-theme="light"] .technical-section {
  background: #e9ebe5;
  color: var(--ink);
}
html[data-theme="light"] .drawing-preview {
  background: #fffefa;
  box-shadow: 0 8px 30px rgba(47, 57, 61, .055);
}
html[data-theme="light"] .technical-note {
  color: #57696f;
}
html[data-theme="light"] .process-strip {
  background: #e8ebe5;
}

/* Dark photographic overlays keep white labels in both themes. */
.activity-card,
.system-card,
.year-stamp,
.photo-caption,
.photo-card .photo-image > span {
  color: #fffdf8;
}
.activity-card h3,
.system-card h3,
.activity-card-top,
.activity-card-bottom {
  color: inherit;
}
html[data-theme="light"] .year-stamp {
  text-shadow: 0 2px 18px rgba(4, 18, 26, .3);
}
html[data-theme="light"] .activity-editorial-image > span {
  color: #fffdf8;
}
html[data-theme="light"] .activity-card::after {
  background: linear-gradient(180deg, #08151db3 0, #08151da6 24%, #08151d12 45%, #08151dc7 82%, #08151df2);
}
html[data-theme="light"] .photo-card img,
html[data-theme="light"] .photo-card:hover img,
html[data-theme="light"] .home-gallery img {
  filter: none;
}

/* Overview, detail navigation, and detail page body. */
html[data-theme="light"] .activity-nav a:hover,
html[data-theme="light"] .activity-nav a[aria-current] {
  color: #273a42;
  background: #e5e8e1;
}
html[data-theme="light"] .activity-nav span {
  color: #566d75;
}
html[data-theme="light"] .activity-nav a[aria-current] span {
  color: var(--red);
}
html[data-theme="light"] .activity-editorial .lead {
  color: #56676e;
}
html[data-theme="light"] .activity-tags span {
  color: #52656c;
  background: rgba(255, 254, 249, .55);
}
html[data-theme="light"] .detail-cover > div {
  color: #5c7178;
}
html[data-theme="light"] .detail-copy article > .lead {
  color: #30444d;
}
html[data-theme="light"] .light-section .feature-list li {
  border-color: rgba(42, 55, 61, .2);
}
html[data-theme="light"] .faq-list summary {
  color: #293b44;
}
html[data-theme="light"] .faq-list details[open] summary {
  color: #a92630;
}
html[data-theme="light"] .related-section {
  background: #e9e6de;
  color: var(--ink);
}
html[data-theme="light"] .related-grid a > span {
  color: #51686f;
  border-bottom-color: #91a09f;
}

/* Galleries and future reference/video content. */
html[data-theme="light"] .editorial-empty {
  background: linear-gradient(120deg, #e9e5dc, #f5f3ed);
}
html[data-theme="light"] .empty-monogram {
  color: var(--red);
}
html[data-theme="light"] .reference-card {
  background: #fffdf8;
  box-shadow: 0 6px 24px rgba(42, 55, 61, .035);
}
html[data-theme="light"] .application-grid > a > span {
  color: #586e75;
}
html[data-theme="light"] .filters button {
  color: #5a6b72;
}
html[data-theme="light"] .filters button:hover {
  background: #e7e8e0;
  color: #273d47;
}
html[data-theme="light"] .filters button.active {
  border-color: #314752;
  background: #314752;
  color: #fffefa;
}
html[data-theme="light"] .photo-card .photo-image {
  background: #e9e7df;
}
html[data-theme="light"] .photo-card .photo-title {
  color: #2a3c43;
}
html[data-theme="light"] .photo-card .photo-tag {
  color: #566b74;
}
html[data-theme="light"] .video-empty {
  color: #283c45;
}
html[data-theme="light"] .play-outline {
  border-color: #96a3a2;
}

/* Light stage chrome; media pixels and material colors remain unchanged. */
html[data-theme="light"] .experience-player {
  background:
    radial-gradient(ellipse at 50% 44%, #fffffc 0, #edf0e9 48%, transparent 85%),
    #e2e8e2;
  border-color: #bfc9c4;
}
html[data-theme="light"] .demo-badge {
  color: #4b646f;
}
html[data-theme="light"] .cutaway-toggle {
  background: rgba(255, 254, 249, .92);
  color: #354d58;
  border-color: #8b9e9f;
}
html[data-theme="light"] .cutaway-toggle[aria-pressed="true"] {
  background: #2e4652;
  color: #fffefa;
  border-color: #2e4652;
}
html[data-theme="light"] .player-controls {
  background: #f7f5ef;
  color: #2f424b;
  border-top-color: #bfc9c4;
}
html[data-theme="light"] .player-controls label,
html[data-theme="light"] .player-controls output {
  color: #4e636d;
}
html[data-theme="light"] .player-controls #reset-demo:hover {
  background: #e5e9e1;
}
html[data-theme="light"] .model-legend > span {
  color: #516971;
}
html[data-theme="light"] .model-legend i {
  box-shadow: 0 0 0 1px rgba(53, 75, 85, .19);
}

/* Contact map and footer are light surfaces, not isolated dark sections. */
html[data-theme="light"] .contact-map-card {
  background: #fffdf8;
  box-shadow: 0 10px 35px rgba(41, 57, 64, .045);
}
html[data-theme="light"] .contact-map-heading,
html[data-theme="light"] .contact-map-footer {
  color: #2e434b;
}
html[data-theme="light"] .contact-map-footer {
  border-top: 1px solid var(--line);
}
html[data-theme="light"] .contact-map {
  background: #e5e9e2;
}
html[data-theme="light"] .site-footer {
  background: #e6e3db;
  color: #26383f;
}
html[data-theme="light"] .footer-grid .eyebrow {
  color: #4c636d;
}
html[data-theme="light"] .footer-grid > div > p:not(.eyebrow) {
  color: #465d66;
}
html[data-theme="light"] .footer-bottom {
  color: #4f6670;
}

/* The media viewer intentionally stays dark for consistent image assessment. */
#lightbox {
  color-scheme: dark;
  --ink: #f1f0eb;
  --muted: #9caeb8;
  --line: rgba(196, 211, 222, .2);
}
html[data-theme="light"] #lightbox :focus-visible {
  outline-color: #a8cbec;
}

@media (min-width: 901px) and (max-width: 1280px) {
  .site-header {
    gap: 18px;
  }
  .site-header > nav {
    gap: 17px;
  }
  .site-header .nav-contact {
    padding-inline: 13px;
  }
}

@media (max-width: 1100px) {
  .theme-toggle {
    width: 40px;
    min-width: 40px;
    padding: 0;
  }
  .theme-toggle [data-theme-label] {
    display: none;
  }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .site-header {
    gap: 16px;
  }
  .site-header > nav {
    gap: 13px;
  }
  .site-header > nav > a {
    font-size: 10px;
  }
  .site-header .nav-contact {
    padding-inline: 11px;
  }
}

@media (max-width: 900px) {
  .site-header {
    justify-content: space-between;
    gap: 16px;
  }
  .header-actions {
    margin-left: auto;
    gap: 8px;
  }
  .header-actions .menu-toggle {
    flex: 0 0 auto;
    min-width: 42px;
    min-height: 42px;
    padding: 9px;
  }
  .site-header > nav {
    position: absolute;
    top: 100%;
    margin-left: 0;
    gap: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: max(35px, env(safe-area-inset-bottom));
  }
  .site-header > nav > a {
    white-space: normal;
  }
  html[data-theme="light"] .site-header > nav {
    background: rgba(247, 245, 238, .985);
    color: #273941;
    box-shadow: 0 16px 25px rgba(39, 51, 54, .055);
  }
  html[data-theme="light"] .site-header > nav .nav-contact {
    border-color: #a2aca7;
  }
}

@media (max-width: 600px) {
  .header-actions {
    gap: 4px;
  }
  .theme-toggle {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
  }
  .theme-icon {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body,
  .site-header,
  .site-footer,
  .theme-toggle,
  .focus-section,
  .light-section,
  .technical-section,
  .related-section,
  .reference-card,
  .contact-map-card,
  .player-controls,
  .scene-label,
  .scene-controls,
  .activity-nav a,
  .activity-tags span {
    transition: none;
  }
}
