/* ------------------------------------------------------------------
   Dark theme. Follows the OS setting unless the visitor picks a theme
   with the header toggle (stored as <html data-theme="light|dark">).
   Palette comes from the logo: slate navy ground, logo blue accent.
   Light mode is untouched; everything here is dark-only.
   ------------------------------------------------------------------ */
:root {
  color-scheme: light;
  --line: #bcb8ae;
}

/* Tokens — written twice: once for "system says dark and the visitor
   hasn't forced light", once for "visitor forced dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0f172a;
    --ink: #e8e6e1;
    --muted: #94a3b8;
    --red: #3b82f6;
    --line: #334155;
    --surface: #1e293b;
    --danger: #f87171;
    --ok: #4ade80;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0f172a;
  --ink: #e8e6e1;
  --muted: #94a3b8;
  --red: #3b82f6;
  --line: #334155;
  --surface: #1e293b;
  --danger: #f87171;
  --ok: #4ade80;
}

/* Everything below only applies while dark is active. `:root.dark` is
   kept in sync by the inline script in <head>, so the overrides are
   written once. */
:root.dark body {
  background: var(--paper);
}

/* Primary buttons keep the deeper blue so white text stays legible. */
:root.dark .button {
  background: #2563eb;
  color: #fff;
}
@media (hover: hover) and (pointer: fine) {
  :root.dark .button:hover {
    background: #1d4ed8;
  }
}

/* Hairlines */
:root.dark .person,
:root.dark .project-links > a,
:root.dark .capability,
:root.dark .capability:nth-child(n),
:root.dark .mobile-nav:not([hidden]),
:root.dark .hero-foot {
  border-color: var(--line);
}
:root.dark .process-stops::before {
  border-color: #475569;
}

/* Project frames */
:root.dark .project-screen {
  background: var(--surface);
  border-color: #ffffff1f;
  box-shadow: 0 0.8vw 2.4vw -0.9vw #000000b3;
}

/* Studio notebook (process panel) */
:root.dark .delivery-print {
  background: linear-gradient(115deg, #1e293bf0, #172033e6);
  border-color: #64748b;
  box-shadow: 3px 4px 0 #00000059;
}
:root.dark .print-label {
  border-color: #475569;
}
:root.dark .diagram {
  stroke: #cbd5e1;
}
:root.dark .diagram text {
  fill: #94a3b8;
}
:root.dark .diagram circle {
  fill: #1e293b;
}
:root.dark .diagram .stamp {
  fill: #3b82f6;
  stroke: #3b82f6;
}
:root.dark .diagram .signal {
  stroke: #60a5fa;
}

/* Glass layers illustration: soften the bright panes on a dark ground. */
:root.dark .glass-figure svg {
  opacity: 0.82;
}
:root.dark .plate .etch {
  stroke: #cbd5e1;
}
:root.dark .plate.is-lit .etch {
  stroke: #60a5fa;
}

/* Contact form */
:root.dark .contact-form {
  background: none;
}
:root.dark .field-error {
  color: var(--danger);
}
:root.dark [aria-invalid="true"] {
  border-color: var(--danger) !important;
}
:root.dark .form-status.error {
  color: var(--danger);
}
:root.dark .form-status.success {
  color: var(--ok);
}
:root.dark .project-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='14' viewBox='0 0 20 14'%3E%3Cpath d='m2 3 8 8 8-8' stroke='%23e8e6e1' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
}
:root.dark .form-field input,
:root.dark .form-field textarea,
:root.dark .form-field select {
  color: var(--ink);
  border-color: #64748b;
}
:root.dark .form-field select option {
  background: var(--paper);
  color: var(--ink);
}

/* Logo: lift the slate tile off the slate page. */
:root.dark .logo-icon {
  border-radius: 25%;
  box-shadow: 0 0 0 1px #ffffff26;
}
:root.dark #logo-grad stop:first-child {
  stop-color: #334155;
}
:root.dark #logo-grad stop:last-child {
  stop-color: #475569;
}

/* Credit badge on light-on-dark screenshots */
:root.dark .project-badge {
  background: #0f172acc;
}

/* ------------------------------------------------------------------
   Theme toggle button (header)
   ------------------------------------------------------------------ */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  margin-left: 14px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent);
  border-radius: 50%;
  cursor: pointer;
  transition:
    background 0.18s,
    border-color 0.18s;
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}
.theme-toggle .icon-sun {
  display: none;
}
:root.dark .theme-toggle .icon-sun {
  display: block;
}
:root.dark .theme-toggle .icon-moon {
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  .theme-toggle:hover {
    background: color-mix(in srgb, var(--ink) 8%, transparent);
  }
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}
@media (max-width: 1024px) {
  .theme-toggle {
    width: 40px;
    height: 40px;
    margin-left: 0;
  }
}
/* Smooth the switch itself, but not on first paint. */
:root.theme-anim,
:root.theme-anim * {
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease !important;
}

/* ------------------------------------------------------------------
   Glass panels: project index + team directory (open by default).
   The fixed ribbon canvas sits behind <main>, so the blur picks it up.
   ------------------------------------------------------------------ */
:root {
  --glass-bg: rgba(255, 255, 255, 0.42);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-edge: rgba(16, 19, 16, 0.08);
  --glass-shadow: 0 24px 60px -28px rgba(30, 41, 59, 0.35);
  --glass-row: rgba(16, 19, 16, 0.1);
}
:root.dark {
  --glass-bg: rgba(30, 41, 59, 0.42);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-edge: rgba(255, 255, 255, 0.04);
  --glass-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.7);
  --glass-row: rgba(255, 255, 255, 0.08);
}
.extended-projects,
.directory-content {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 0 0 1px var(--glass-edge),
    var(--glass-shadow);
}
:root.dark .extended-projects,
:root.dark .directory-content {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px var(--glass-edge),
    var(--glass-shadow);
}
.project-links > a,
.person {
  border-color: var(--glass-row) !important;
}
@media (hover: hover) and (pointer: fine) {
  .project-links > a,
  .person > summary {
    border-radius: 10px;
    transition: background 0.18s;
  }
  .project-links > a:hover,
  .person > summary:hover {
    background: rgba(255, 255, 255, 0.28);
  }
  :root.dark .project-links > a:hover,
  :root.dark .person > summary:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

/* Desktop spacing: the index no longer tucks up under the second
   preview's caption (it was covering "View project"). */
@media (min-width: 1025px) {
  .work-more {
    margin-top: 0;
    padding-top: 1.6vw;
  }
  .extended-projects {
    margin-top: 1.6vw;
    padding: 1.2vw 2.4vw 2.2vw;
  }
  .extended-projects > p {
    margin-top: 1.6vw;
  }
  .directory-content {
    margin-top: 2vw;
    padding: 2.4vw 2.4vw 1.2vw;
  }
  .project-links > a {
    padding-inline: 10px;
  }
  .person > summary {
    padding-inline: 10px;
  }
}
@media (max-width: 1024px) {
  .extended-projects {
    margin-top: 20px;
    padding: 8px 18px 20px;
    border-radius: 18px;
  }
  .directory-content {
    margin-top: 20px;
    padding: 20px 18px 6px;
    border-radius: 18px;
  }
}
.disclosure-trigger {
  background: transparent;
}
