:root {
  color-scheme: light dark;
  --ink: #171912;
  --muted: #484c3d;
  --paper: #e8e4d6;
  --panel: #f4f5f0;
  --line: rgba(23, 25, 18, 0.14);
  --teal: #0f8f83;
  --blue: #2563eb;
  --coral: #f05d3e;
  --gold: #e2b714;
  font-family: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

button,
a {
  color: inherit;
  font: inherit;
}

a {
  text-decoration: none;
}

/* ─────────────────────────────────────────────
   APP SHELL
───────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  isolation: isolate;
  min-height: 100vh;
}

.portfolio-stage {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ─────────────────────────────────────────────
   CANVAS / SCENE
───────────────────────────────────────────── */
.scene-region {
  background: #d4e8d0;
  height: 62vh;
  overflow: hidden;
  position: relative;
}

.dark .scene-region {
  background: none;
}

.scene-wrap {
  inset: 0;
  position: absolute;
  z-index: 1;
}

#blockCanvas {
  display: block;
  height: 100%;
  touch-action: none;
  width: 100%;
}

/* ─────────────────────────────────────────────
   BRAND & NAV (overlaid on canvas)
───────────────────────────────────────────── */
.canvas-brand {
  left: 2rem;
  pointer-events: none;
  position: absolute;
  top: 2rem;
  z-index: 5;
}

.canvas-name {
  display: flex;
  flex-direction: column;
}

.name-line {
  color: var(--ink);
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 4rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 0.88;
}

.name-sub {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  margin-top: 0.7rem;
  text-transform: uppercase;
}

.canvas-nav {
  align-items: center;
  bottom: 1.75rem;
  display: flex;
  gap: 0.3rem;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 5;
}

.canvas-nav a {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.4rem 0.55rem;
  text-transform: uppercase;
  transition: color 180ms ease;
}

.canvas-nav a:hover,
.canvas-nav a.is-active {
  color: var(--ink);
}

.canvas-nav span {
  color: var(--muted);
  font-size: 0.65rem;
  opacity: 0.35;
  user-select: none;
}

.canvas-nav a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

/* ─────────────────────────────────────────────
   THEME TOGGLE
───────────────────────────────────────────── */
.theme-toggle {
  align-items: center;
  aspect-ratio: 1;
  background: transparent;
  border: 1px solid var(--line);
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 1.05rem;
  justify-content: center;
  position: absolute;
  right: 2rem;
  top: 2rem;
  transition: background 180ms ease, border-color 180ms ease;
  width: 2.5rem;
  z-index: 5;
}

.theme-toggle:hover {
  background: rgba(23, 25, 18, 0.07);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

/* ─────────────────────────────────────────────
   CONTENT PANEL
───────────────────────────────────────────── */
.content-panel {
  background: var(--panel);
  border-top: 1px solid var(--line);
  flex: 1;
  padding: 2rem 2.5rem 3rem;
  width: 100%;
}

/* ─────────────────────────────────────────────
   PAGE SKELETON
───────────────────────────────────────────── */
.portfolio-page {
  display: none;
  margin: 0 auto;
  max-width: 76rem;
}

.portfolio-page.is-active {
  animation: pageIn 360ms ease both;
  display: block;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(0.75rem); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-kicker {
  color: var(--teal);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  margin: 0 0 0.4rem;
  text-transform: uppercase;
}

.portfolio-page h2 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 3.2rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0 0 0.5rem;
}

.portfolio-page h3 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.2;
  margin: 0;
}

.portfolio-page p {
  color: var(--muted);
  line-height: 1.65;
}

.lead {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
  margin: 0.35rem 0 0;
  max-width: 52rem;
}

/* ═══════════════════════════════════════════════
   CRAFT
════════════════════════════════════════════════ */
.craft-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1.75rem 0 0;
}

.craft-filter {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  font-family: 'Montserrat', ui-sans-serif, sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  padding: 0.4rem 0.9rem;
  text-transform: uppercase;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.craft-filter:hover {
  border-color: var(--muted);
  color: var(--ink);
}

.craft-filter.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--panel);
}

.craft-filter:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.project-rows {
  border-bottom: 1px solid var(--line);
  margin-top: 1.5rem;
}

.project-row {
  border-top: 1px solid var(--line);
  cursor: default;
}

.row-head {
  align-items: baseline;
  display: flex;
  gap: 1.25rem;
  padding: 1.1rem 0;
}

.row-num {
  color: var(--muted);
  flex-shrink: 0;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 400;
  min-width: 2.5rem;
  opacity: 0.4;
  transition: opacity 200ms ease;
}

.row-title {
  color: var(--ink);
  flex: 1;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1.1;
  margin: 0;
  transition: color 200ms ease;
}

.row-title em {
  color: var(--muted);
  font-size: 1.4rem;
}

.project-type {
  color: var(--muted);
  flex-shrink: 0;
  font-size: 0.75rem;
  margin-left: auto;
  padding-left: 1.5rem;
}

.row-body-inner {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 0 1.4rem 3.75rem;
}

.row-body-inner p {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.65;
  margin: 0;
  max-width: 52rem;
}

.row-tech {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0;
  opacity: 0.7;
}

.project-row:hover .row-title { color: var(--teal); }
.project-row:hover .row-num   { opacity: 0.7; }

/* ═══════════════════════════════════════════════
   ABOUT
════════════════════════════════════════════════ */
.about-intro {
  color: var(--ink);
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.55rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.5;
  margin: 0.5rem 0 2.5rem;
  max-width: 44rem;
}

.about-body {
  display: grid;
  gap: 3rem;
  grid-template-columns: 1fr 15rem;
}

.about-main {
  display: flex;
  flex-direction: column;
}

.about-section {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0;
}

.about-section:last-child {
  border-bottom: 1px solid var(--line);
}

.about-section-label {
  color: var(--muted);
  font-family: 'Montserrat', ui-sans-serif, sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  margin: 0 0 0.75rem;
  text-transform: uppercase;
}

.about-section p {
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.75;
  margin: 0;
}

.about-meta {
  margin: 0;
  padding: 0;
}

.about-meta-row {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.15rem;
  padding: 0.85rem 0;
}

.about-meta-row:last-child {
  border-bottom: 1px solid var(--line);
}

.about-meta dt {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
}

.about-meta dd {
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.5;
  margin: 0;
}

.about-meta dd a {
  color: var(--teal);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 160ms ease;
}

.about-meta dd a:hover {
  color: var(--ink);
}

/* ═══════════════════════════════════════════════
   CV
════════════════════════════════════════════════ */
.cv-header {
  align-items: baseline;
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  margin-bottom: 2.25rem;
}

.cv-header h2 {
  margin: 0;
}

.cv-download {
  align-items: center;
  background: transparent;
  border: 1px solid var(--ink);
  color: var(--ink);
  display: inline-flex;
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  min-height: 2.25rem;
  padding: 0 1rem;
  text-transform: uppercase;
  transition: background 180ms ease, color 180ms ease;
}

.cv-download:hover {
  background: var(--ink);
  color: var(--panel);
}

.timeline {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.75rem;
}

.timeline-entry {
  display: grid;
  gap: 0.5rem 2rem;
  grid-template-columns: 11rem 1fr;
  padding: 0 0 2.25rem;
  position: relative;
}

.timeline-entry:last-child {
  padding-bottom: 0;
}

.timeline-entry::before {
  background: var(--teal);
  border: 2px solid var(--panel);
  border-radius: 50%;
  content: '';
  height: 10px;
  left: calc(-1.75rem - 5px);
  position: absolute;
  top: 5px;
  width: 10px;
}

.timeline-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-top: 0.15rem;
}

.date-range {
  color: var(--teal);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.company-name {
  color: var(--ink);
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0.1rem 0 0;
}

.company-location {
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: 0.1rem;
}

.timeline-body h3 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.28rem;
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 0.2rem;
}

.timeline-division {
  color: var(--teal);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
}

.timeline-body > p:not(.timeline-division) {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.65;
  margin: 0;
}

.cv-education {
  margin-top: 2.5rem;
}

.edu-entry {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.5rem 2rem;
  grid-template-columns: 11rem 1fr;
  margin-top: 0.5rem;
  padding: 1rem 0 0;
}

/* ═══════════════════════════════════════════════
   SKILLS
════════════════════════════════════════════════ */
.skill-rows {
  margin: 1.5rem 0 0;
  padding: 0;
}

.skill-row {
  align-items: baseline;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.75rem 2rem;
  grid-template-columns: 11rem 1fr;
  padding: 1.1rem 0;
}

.skill-row:last-child {
  border-bottom: 1px solid var(--line);
}

.skill-row dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  padding-top: 0.1rem;
}

.skill-row dd {
  color: var(--ink);
  font-size: 0.875rem;
  line-height: 1.6;
  margin: 0;
}

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (max-width: 820px) {
  .name-line      { font-size: 2.8rem; }
  .scene-region   { height: 55vh; }
  .content-panel  { padding: 1.5rem 1.5rem 2rem; }

  .portfolio-page h2 { font-size: 2.4rem; }
  .row-title         { font-size: 1.5rem; }

  .about-body    { gap: 0; grid-template-columns: 1fr; }
  .about-sidebar { margin-top: 2rem; }

  .timeline-entry { gap: 0.4rem; grid-template-columns: 1fr; }
  .edu-entry      { gap: 0.4rem; grid-template-columns: 1fr; }

  .skill-row    { gap: 0.5rem; grid-template-columns: 1fr; }
  .skill-row dt { padding-top: 0; }
}

@media (max-width: 520px) {
  .canvas-brand  { left: 1.25rem; top: 1.25rem; }
  .name-line     { font-size: 2.3rem; }
  .name-sub      { display: none; }
  .scene-region  { height: 50vh; }
  .content-panel { padding: 1.25rem 1rem 1.75rem; }

  .portfolio-page h2 { font-size: 2rem; }
  .row-title         { font-size: 1.25rem; }
  .row-body-inner    { padding-left: 0; }
  .row-head          { gap: 0.75rem; }
  .about-intro       { font-size: 1.25rem; }

  .cv-header { align-items: flex-start; flex-direction: column; gap: 0.75rem; }
  .timeline  { padding-left: 1.25rem; }
  .timeline-entry::before { left: calc(-1.25rem - 5px); }
}

/* ─────────────────────────────────────────────
   DARK MODE
───────────────────────────────────────────── */
.dark {
  color-scheme: dark;
  --ink: #e4e2de;
  --muted: #888885;
  --paper: #111111;
  --panel: #1a1a1a;
  --line: rgba(228, 226, 222, 0.10);
}

.dark .theme-toggle:hover {
  background: rgba(221, 228, 214, 0.08);
}

/* ─────────────────────────────────────────────
   REDUCED MOTION
───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
