:root {
  --bg: #06131a;
  --bg-soft: rgba(6, 19, 26, 0.56);
  --panel: rgba(12, 25, 33, 0.62);
  --panel-border: rgba(194, 229, 255, 0.16);
  --text: #f4efe7;
  --muted: #b7c6ce;
  --accent: #ff7a18;
  --accent-soft: #ffd45c;
  --hero-emphasis: #ffe2bc;
  --nav-surface: rgba(8, 18, 24, 0.65);
  --footer-surface: rgba(3, 10, 14, 0.88);
  --card-soft: rgba(255, 255, 255, 0.03);
  --field-bg: rgba(255, 255, 255, 0.03);
  --soft-border: rgba(255, 255, 255, 0.12);
  --bg-gradient:
    radial-gradient(circle at top left, rgba(255, 122, 24, 0.2), transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(65, 154, 255, 0.24), transparent 25%),
    linear-gradient(180deg, #071116 0%, #0b2029 100%);
  --max-width: 1120px;
}

body[data-theme="light"] {
  --bg: #eef3f6;
  --bg-soft: rgba(238, 243, 246, 0.76);
  --panel: rgba(255, 255, 255, 0.76);
  --panel-border: rgba(10, 23, 31, 0.12);
  --text: #0d1b24;
  --muted: #50626d;
  --accent: #d96516;
  --accent-soft: #8e5700;
  --hero-emphasis: #8e5700;
  --nav-surface: rgba(255, 255, 255, 0.88);
  --footer-surface: rgba(220, 229, 235, 0.96);
  --card-soft: rgba(10, 23, 31, 0.035);
  --field-bg: rgba(10, 23, 31, 0.035);
  --soft-border: rgba(10, 23, 31, 0.12);
  --bg-gradient:
    radial-gradient(circle at top left, rgba(255, 122, 24, 0.1), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(65, 154, 255, 0.14), transparent 22%),
    linear-gradient(180deg, #f4f7f9 0%, #e7eef2 100%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: var(--bg-gradient);
  overflow-x: hidden;
}

.webgl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 1.25rem), var(--max-width));
  margin: 0 auto;
  padding: 1.25rem 0 4rem;
}

.nav-shell {
  position: sticky;
  top: 1rem;
  z-index: 3;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--hero-emphasis);
  text-decoration: none;
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-weight: 400;
  font-size: 1.65rem;
  line-height: 1;
  letter-spacing: -0.03em;
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  width: 3.25rem;
  height: 3.25rem;
  cursor: pointer;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 0;
  background: var(--nav-surface);
  color: var(--text);
  font: inherit;
  backdrop-filter: blur(18px);
}

.nav-toggle-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  width: 3.25rem;
  height: 3.25rem;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 0;
  background: var(--nav-surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  backdrop-filter: blur(18px);
}

.theme-toggle-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  padding: 0;
}

.theme-toggle-thumb {
  display: none;
}

.theme-toggle-icon {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--muted);
  opacity: 0;
  transition: opacity 180ms ease;
}

body[data-theme="light"] .theme-toggle-sun,
body[data-theme="dark"] .theme-toggle-moon {
  opacity: 1;
  color: #111;
}

body[data-theme="dark"] .theme-toggle-moon {
  color: #fff;
}

.nav-toggle-icon {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.24rem;
  width: 1rem;
  height: 0.9rem;
}

.nav-toggle-icon span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

.top-nav {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  gap: 0.35rem;
  width: min(16rem, calc(100vw - 1.25rem));
  margin: 0;
  padding: 0.6rem;
  border: 1px solid var(--panel-border);
  border-radius: 1.25rem;
  background: var(--nav-surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
  flex-direction: column;
  display: flex;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-0.6rem) scale(0.98);
  transform-origin: top right;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms ease;
}

.top-nav a {
  display: block;
  width: 100%;
  padding: 0.8rem 0.85rem;
  border-radius: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}

.top-nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-shell.is-open .top-nav {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.nav-shell.is-open .nav-toggle-icon {
  gap: 0;
}

.nav-shell.is-open .nav-toggle-icon span:first-child {
  transform: translateY(2px) rotate(45deg);
}

.nav-shell.is-open .nav-toggle-icon span:nth-child(2) {
  opacity: 0;
}

.nav-shell.is-open .nav-toggle-icon span:last-child {
  transform: translateY(-2px) rotate(-45deg);
}

.scene-section {
  position: relative;
}

.hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 780px;
  min-height: auto;
  padding-top: 5rem;
  padding-bottom: 3rem;
}

.eyebrow,
.panel-label,
.project-index {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: var(--accent-soft);
}

.eyebrow-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.eyebrow-row p {
  margin: 0;
}

.eyebrow-links {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.eyebrow-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  color: var(--accent-soft);
  opacity: 0.82;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.eyebrow-links a:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.eyebrow-links svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 1rem;
  font-size: clamp(2.8rem, 14vw, 4.6rem);
  line-height: 1;
  letter-spacing: -0.04em;
  max-width: 11ch;
}

h1 span {
  display: block;
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-weight: 400;
  color: var(--hero-emphasis);
}

.intro {
  max-width: 620px;
  margin-top: 1.5rem;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.button {
  width: 100%;
  padding: 0.9rem 1.3rem;
  border: 1px solid var(--soft-border);
  border-radius: 999px;
  color: var(--text);
  text-align: center;
  text-decoration: none;
  backdrop-filter: blur(18px);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #ff9a3c 100%);
  color: #111;
  border-color: transparent;
}

body[data-theme="light"] .button-primary {
  color: #fff7ef;
}

body[data-theme="light"] .closing-panel h2 {
  color: #f7fbfd;
}

body[data-theme="light"] .closing-panel p:last-of-type {
  color: #edf4f7;
}

.button-secondary {
  background: var(--card-soft);
}

.button-contact {
  background: rgba(10, 23, 31, 0.82);
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="light"] .button-contact {
  background: rgba(10, 23, 31, 0.9);
  color: #f4efe7;
}

main {
  display: grid;
  gap: 4rem;
  padding-bottom: 5rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(24px);
}

.stats-panel,
.experience-panel,
.projects,
.closing-panel {
  min-height: auto;
}

.stats-panel {
  display: grid;
  gap: 1.5rem;
  align-content: start;
  padding: 1.5rem;
  border-radius: 1rem;
}

.stats-panel h2,
.section-heading h2 {
  margin-top: 0.4rem;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.stats-grid,
.project-grid,
.experience-list {
  display: grid;
  gap: 1rem;
}

.stats-grid,
.project-grid {
  grid-template-columns: 1fr;
}

.stats-grid article,
.project-card {
  padding: 1.2rem;
  border-radius: 1.5rem;
  background: var(--card-soft);
}

.stats-grid span {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 2rem;
  font-weight: 700;
}

.stats-grid p,
.project-card p,
.experience-item p:last-child,
.closing-panel p:last-of-type {
  line-height: 1.7;
  color: var(--muted);
}

.section-heading {
  margin-bottom: 1.5rem;
}

.experience-panel {
  display: grid;
  align-content: start;
  padding: 1.5rem;
  border-radius: 1rem;
}

.experience-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 1.25rem 0;
  border-top: 1px solid rgba(194, 229, 255, 0.12);
}

.experience-item:first-child {
  border-top: 0;
}

.experience-item h3 {
  margin-top: 0.45rem;
  font-size: 1.35rem;
}

.projects {
  display: grid;
  align-content: center;
}

.project-card h3 {
  margin: 0.6rem 0 0.8rem;
  font-size: 1.5rem;
}

.project-card h3 a {
  color: var(--text);
  text-decoration: none;
}

.project-card h3 a:hover {
  color: var(--hero-emphasis);
}

.closing-panel {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1rem;
  max-width: 680px;
  min-height: 100svh;
  padding: 1rem 2rem;
  margin: 0 auto;
  text-align: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.closing-panel p:last-of-type {
  max-width: 34rem;
}

.closing-panel .button {
  width: 100%;
  margin-top: 0.5rem;
}

.contact-page {
  display: grid;
  gap: 3rem;
  padding-top: 3rem;
}

.contact-hero {
  max-width: 700px;
  padding-top: 2rem;
}

.contact-panel {
  display: grid;
  gap: 2rem;
  padding: 1.5rem;
  border-radius: 1rem;
}

.contact-panel-copy {
  display: grid;
  gap: 0.75rem;
}

.contact-panel-copy h2 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.contact-panel-copy p:last-child {
  max-width: 34rem;
  line-height: 1.7;
  color: var(--muted);
}

.contact-form {
  display: grid;
  gap: 1rem;
}

.contact-form.is-submitting .button {
  opacity: 0.72;
  cursor: wait;
}

.form-field {
  display: grid;
  gap: 0.55rem;
}

.form-field span {
  font-size: 0.9rem;
  color: var(--muted);
}

.field-error {
  min-height: 1rem;
  font-size: 0.82rem;
  color: #ff9f8f;
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 1rem 1rem 0.95rem;
  border: 1px solid var(--soft-border);
  border-radius: 0.85rem;
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: rgba(183, 198, 206, 0.72);
}

.form-field textarea {
  min-height: 8rem;
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: 1px solid rgba(255, 212, 92, 0.5);
  border-color: rgba(255, 212, 92, 0.5);
}

.form-field input.is-invalid {
  border-color: rgba(255, 120, 120, 0.75);
  outline: 1px solid rgba(255, 120, 120, 0.32);
}

.form-status {
  min-height: 1.25rem;
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.form-status.is-pending {
  color: #ffd45c;
}

.form-status.is-success {
  color: #89e39d;
}

.form-status.is-error {
  color: #ff9f8f;
}

.site-footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1.5rem;
  border: 1px solid var(--soft-border);
  border-radius: 1.5rem;
  background: var(--footer-surface);
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}

.footer-links {
  display: flex;
  flex-direction: row;
  gap: 0.9rem;
  margin-left: auto;
  justify-content: flex-end;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
}

.footer-links svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

@media (min-width: 641px) {
  .page-shell {
    width: min(calc(100% - 2rem), var(--max-width));
    padding-top: 2rem;
  }

  .nav-shell {
    grid-template-columns: auto 1fr auto;
    justify-content: stretch;
    margin-bottom: 2rem;
  }

  .nav-toggle {
    display: none;
  }

  .top-nav {
    position: static;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    width: fit-content;
    margin-top: 0;
    margin-left: auto;
    padding: 0.8rem 1rem;
    border-radius: 999px;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: none;
  }

  .top-nav a {
    width: auto;
    padding: 0;
    border-radius: 0;
  }

  .top-nav a:hover {
    background: transparent;
  }

  h1 {
    font-size: clamp(2.6rem, 7vw, 5rem);
  }

  .intro {
    font-size: 1.05rem;
  }

  .button,
  .closing-panel .button {
    width: fit-content;
  }

  .button {
    text-align: left;
  }

  .experience-item {
    grid-template-columns: minmax(0, 280px) 1fr;
    gap: 1.5rem;
  }

  .contact-panel {
    grid-template-columns: minmax(0, 280px) 1fr;
    align-items: start;
  }

  .footer-links {
    flex-wrap: wrap;
  }
}

@media (min-width: 901px) {
  .hero {
    min-height: 100vh;
    padding-top: 0;
    padding-bottom: 5rem;
  }

  .projects {
    min-height: 90vh;
  }

  .stats-grid,
  .project-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .hero {
    min-height: 80svh;
    justify-content: flex-start;
    padding-top: 10svh;
    padding-bottom: 0;
  }

  .nav-toggle,
  .theme-toggle {
    transform: translateX(0.44rem);
  }

  .stats-panel {
    margin-top: 0;
  }

  .closing-panel {
    padding: 1rem;
  }
}
