/* Theme and header controls: presentation layer, kept apart from layout and content. */
.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.header-controls .language-switch {
  flex-shrink: 0;
}
.theme-toggle {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  border-radius: 5px;
  cursor: pointer;
  line-height: 1;
  font-size: 1.4rem;
}
.theme-toggle:hover {
  border-color: var(--accent);
}
.research-method {
  margin-top: 24px;
  padding: 26px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.research-method h3 {
  font-size: 1.17rem;
  margin-bottom: 8px;
}
.research-method p,
.research-method li {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}
.research-method ol {
  padding-left: 21px;
  margin: 10px 0 0;
}
.research-method li + li {
  margin-top: 8px;
}
@media (min-width: 701px) {
  .nav-wrap {
    gap: 18px;
  }
  .nav {
    gap: clamp(8px, 1.5vw, 22px);
  }
  .header-controls {
    order: 3;
  }
}
@media (max-width: 700px) {
  .nav-wrap {
    min-height: 68px;
    gap: 8px;
  }
  .header-controls {
    gap: 7px;
  }
  .header-controls .language-switch {
    display: flex;
    align-items: center;
    padding: 3px;
    gap: 3px;
  }
  .header-controls .language-switch button {
    padding: 6px 5px;
    font-size: 0.68rem;
  }
  .theme-toggle {
    width: 35px;
    height: 35px;
    font-size: 1.14rem;
  }
  .nav-toggle {
    width: 39px;
    height: 39px;
    flex-shrink: 0;
  }
  .nav {
    background: var(--surface) !important;
    top: 68px;
  }
}
@media (max-width: 385px) {
  .brand-label {
    font-size: 0.59rem;
  }
  .brand {
    gap: 5px;
  }
  .brand-symbol {
    width: 29px;
    height: 29px;
  }
  .header-controls {
    gap: 4px;
  }
  .header-controls .language-switch button {
    padding: 5px 3px;
  }
  .theme-toggle {
    width: 30px;
    height: 34px;
  }
  .nav-toggle {
    width: 34px;
    height: 34px;
  }
}
/* Light mode: semantic tokens first, scoped overrides for pre-existing hard-coded dark colors. */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f0e8;
  --surface: #fffdf9;
  --surface-raised: #eae2d7;
  --text: #29221e;
  --muted: #65594e;
  --accent: #845028;
  --accent-light: #a36330;
  --border: #ccbbaa;
  --line: rgba(100, 74, 52, 0.23);
}
html[data-theme="light"] body {
  background:
    radial-gradient(
      ellipse at 80% 9%,
      rgba(196, 141, 82, 0.13),
      transparent 36%
    ),
    var(--bg);
}
html[data-theme="light"] .site-header {
  background: rgba(250, 247, 241, 0.96);
  border-bottom-color: var(--border);
}
html[data-theme="light"] .nav a {
  color: #43372e;
}
html[data-theme="light"] .nav .nav-contact {
  background: #f1e5d8;
  border-color: #b28d6d;
  color: #6e3c1a;
}
html[data-theme="light"] .brand-label span,
html[data-theme="light"] .hero-detail {
  color: var(--muted);
}
html[data-theme="light"] .hero-overline,
html[data-theme="light"] .hero-lead,
html[data-theme="light"] .about-grid p,
html[data-theme="light"] .project-content p {
  color: #4f443a;
}
html[data-theme="light"] .btn-secondary {
  background: #fffaf4;
  color: #3b2b20;
  border-color: #bba48e;
}
html[data-theme="light"] .btn-tertiary {
  color: #523d2b;
  border-color: #bba48e;
}
html[data-theme="light"] .btn-primary {
  background: #a96632;
  border-color: #8c542a;
  color: #fffaf3;
}
html[data-theme="light"] .btn-primary:hover {
  background: #884a22;
}
html[data-theme="light"] .hero-stats strong {
  color: var(--text);
}
html[data-theme="light"] .project-card,
html[data-theme="light"] .research-item,
html[data-theme="light"] .research-method {
  background: var(--surface);
  border-color: var(--border);
}
html[data-theme="light"] .project-meta span:last-child,
html[data-theme="light"] .project-content .source-note {
  color: #695a4e;
}
html[data-theme="light"] .tag-list li {
  color: #4d4036;
  border-color: #cbb9a7;
}
html[data-theme="light"] .approach-section {
  background: #ece5da;
  border-color: var(--border);
}
html[data-theme="light"] .footer {
  background: #eae1d5;
  border-color: var(--border);
}
html[data-theme="light"] .footer-bottom {
  color: #65594e;
}
html[data-theme="light"] .text-link,
html[data-theme="light"] .card-link {
  color: #815025;
}
html[data-theme="light"] .demo-note {
  color: #654832 !important;
}
html[data-theme="light"] .site-shell::after {
  opacity: 0.035;
}
/* Bonfire visual and project mockup artwork remain intentionally dark in both modes. */
html[data-theme="light"] .hero-art,
html[data-theme="light"] .bonfire-panel {
  color: #eee6d7;
}
html[data-theme="light"] .language-switch {
  border-color: #bba48e;
  color: #685647;
}
html[data-theme="light"] .language-switch button {
  color: #584538;
}
html[data-theme="light"] .language-switch button[aria-pressed="true"] {
  background: #915b2d;
  color: white;
}

/* Tablet navigation: collapse long desktop links before they overflow. */
@media (min-width: 701px) and (max-width: 1050px) {
  .nav-wrap {
    min-height: 68px;
    gap: 12px;
  }
  .header-controls {
    margin-left: auto;
    order: 3;
    gap: 8px;
  }
  .nav-toggle {
    display: flex;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
  }
  .nav-toggle span {
    width: 18px;
    height: 2px;
    background: var(--text);
    transition: transform 0.2s;
  }
  .nav-toggle[aria-expanded="true"] span:first-child {
    transform: translateY(4px) rotate(45deg);
  }
  .nav-toggle[aria-expanded="true"] span:last-child {
    transform: translateY(-4px) rotate(-45deg);
  }
  .nav {
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    display: none;
    padding: 20px 28px 24px;
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    max-height: calc(100dvh - 68px);
    overflow-y: auto;
  }
  .nav.is-open {
    display: flex;
  }
  .nav .nav-contact {
    text-align: center;
  }
}

/* Light theme: project illustrations stay dark, so their text must stay light. */
html[data-theme="light"] .project-visual {
  color: #eee6d7;
}
html[data-theme="light"] .visual-django .mock-user,
html[data-theme="light"] .visual-django .mock-rule {
  color: #f3e7d9;
  background: #30241e;
  border-color: #a87b55;
}
html[data-theme="light"] .visual-django .mock-user .mini-avatar {
  color: #ffffff;
  background: #675f58;
}
html[data-theme="light"] .visual-django .mock-chips span {
  color: #e2cbb5;
  border-color: #9a7559;
}
html[data-theme="light"] .visual-django .mock-arrow,
html[data-theme="light"] .visual-django .mock-rule > span {
  color: #e5a05a;
}
