/* Theme toggle control (both themes) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin-left: 1rem;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  color: var(--ink-soft);
  transition: color .2s, border-color .2s, background-color .2s, transform .2s var(--ease-out);
}
.theme-toggle:hover {
  color: var(--navy);
  border-color: var(--navy);
  transform: rotate(-12deg);
}
.theme-toggle .icon-sun,
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html:not([data-theme]) .theme-toggle { display: none; }

.theme-toggle-row {
  display: flex;
  width: 100%;
  height: auto;
  margin: 0;
  padding: .875rem 0;
  justify-content: flex-start;
  gap: .65rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-size: .9375rem;
  font-weight: 500;
}
.theme-toggle-row:hover { transform: none; }

@media (max-width: 767px) {
  #theme-toggle { display: none; }
}
@media (min-width: 768px) {
  .theme-toggle-row { display: none; }
}

/* Dark theme */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0E1118;
  --bg-alt:    #141925;
  --surface:   #171D2B;
  --ink:       #E8ECF4;
  --ink-soft:  #B3BCCD;
  --muted:     #8590A6;
  --line:      #262E40;
  --navy:      #A9C1EE;
  --navy-deep: #E8ECF4;
  --navy-soft: #8DAEE8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35), 0 4px 12px rgba(0,0,0,.28);
  --shadow-md: 0 8px 28px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.5);
}

html[data-theme="dark"] .nav { background: rgba(14,17,24,.82); }
html[data-theme="dark"] .nav-mobile { background: rgba(14,17,24,.97); }

html[data-theme="dark"] .nav-cta,
html[data-theme="dark"] .btn-primary {
  box-shadow: inset 0 0 0 1px rgba(169,193,238,.22), var(--shadow-sm);
}
html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .chip:hover { background: rgba(169,193,238,.08); }

html[data-theme="dark"] #hero::before {
  background: radial-gradient(circle at center, rgba(141,174,232,.09) 0%, transparent 65%);
}
html[data-theme="dark"] #hero::after {
  background: radial-gradient(circle at center, rgba(199,191,178,.06) 0%, transparent 65%);
}
html[data-theme="dark"] .hero-photo { box-shadow: var(--shadow-lg), 0 0 0 1px rgba(232,236,244,.08); }

html[data-theme="dark"] .tag { background: rgba(141,174,232,.12); }
html[data-theme="dark"] .tag-accent { background: rgba(141,174,232,.22); color: var(--ink); }
html[data-theme="dark"] .project-card:hover { border-color: rgba(169,193,238,.35); }

html[data-theme="dark"] #contact { background: #0A0D14; }
html[data-theme="dark"] #contact .section-label { color: rgba(255,255,255,.62); }
html[data-theme="dark"] .footer-copy { color: rgba(255,255,255,.6); }

html[data-theme="dark"] .modal-scrim { background: rgba(3,5,9,.8); }
html[data-theme="dark"] .modal-panel {
  box-shadow: 0 0 0 1px rgba(232,236,244,.16), 0 24px 64px rgba(0,0,0,.65);
}

/* Smooth theme switch: a View Transition cross-fade; the class fallback (no View Transitions) skips .reveal so its own transitions survive */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .25s;
}
html.theme-anim *:not(.reveal),
html.theme-anim *::before,
html.theme-anim *::after {
  transition: background-color .25s, color .25s, border-color .25s !important;
}
