* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --font-sans: "Geist Sans", "Geist", system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, monospace;
  --sidebar-width: clamp(280px, 28vw, 360px);
  --page-pad: clamp(16px, 2.5vw, 32px);
  --gap: clamp(8px, 0.8vw, 12px);
  --layout-gap: clamp(20px, 3vw, 40px);
  --content-pad: clamp(12px, 1.5vh, 20px);
  --content-pad-x: clamp(12px, 2vw, 24px);
  --sidebar-top: clamp(20px, 3vh, 36px);
  --intro-pad: clamp(26px, 3.2vh, 34px);
  --nav-name-indent: 6px;
  /* Scales with both width and height so the intro fits short laptop screens
     and still reads comfortably on large monitors. */
  --intro-font: clamp(12.5px, 0.42vw + 0.62vh, 15px);
  --max-width: 1680px;
}

html,
body {
  height: 100%;
  min-height: 100%;
  font-family: var(--font-sans);
}

body {
  overflow: hidden;
}

.wrap {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  width: 100%;
  max-width: 100vw;
  padding: var(--page-pad);
  border-radius: 0;
  font-family: var(--font-sans);
  transition: background 0.2s;
  overflow: hidden;
}

.wrap.dark {
  background: #111110;
  --text: #f0eee8;
  --muted: #888780;
  --subtle: #444441;
  --surface: #1a1a18;
  --surface2: #222220;
  --border: #2e2e2c;
  --orange: #e8601c;
  --orange-light: #f2845a;
  --orange-dim: #3d1f0d;
  --blue: #1a6ebf;
  --blue-light: #5b9fd8;
  --blue-dim: #0a2540;
  --green: #2a7d52;
  --green-light: #5bb88a;
  --green-dim: #0d2e1c;
}

.wrap.light {
  background: #f5f3ee;
  --text: #1a1a18;
  --muted: #888780;
  --subtle: #b4b2a9;
  --surface: #ffffff;
  --surface2: #eeece8;
  --border: #d3d1c7;
  --orange: #e8601c;
  --orange-light: #c04a10;
  --orange-dim: #fde8dc;
  --blue: #1a6ebf;
  --blue-light: #0c447c;
  --blue-dim: #dceaf7;
  --green: #2a7d52;
  --green-light: #1e5c3d;
  --green-dim: #dcefe4;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: var(--gap);
  flex-shrink: 0;
}

.nav-name {
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  line-height: 1.2;
  letter-spacing: -0.01em;
  padding-left: var(--nav-name-indent);
}

.nav-name .nav-accent--blue {
  color: var(--blue-light);
}

.nav-name .nav-accent--orange {
  color: var(--orange);
}

.nav-name .nav-accent--green {
  color: var(--green-light);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
}

.nav-links a {
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-links a[data-nav="home"].active {
  color: var(--text);
}

.nav-links a[data-nav="tech"].active {
  color: var(--blue-light);
}

.nav-links a[data-nav="design"].active {
  color: var(--orange);
}

.nav-links a[data-nav="other"].active {
  color: var(--green-light);
}

.nav-links a[data-nav="cv"].active,
.nav-links a.cv-link.active {
  color: var(--orange);
}

.nav-links a[data-nav="home"]:hover {
  color: var(--text);
}

.nav-links a[data-nav="tech"]:hover {
  color: var(--blue-light);
}

.nav-links a[data-nav="design"]:hover {
  color: var(--orange);
}

.nav-links a[data-nav="other"]:hover {
  color: var(--green-light);
}

.nav-links a[data-nav="cv"]:hover,
.nav-links a.cv-link:hover {
  color: var(--orange);
}

.toggle {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  border: 0.5px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-knob {
  position: absolute;
  top: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  transition: left 0.2s;
}

.wrap.dark .toggle-knob {
  left: 3px;
}

.wrap.light .toggle-knob {
  left: 21px;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  column-gap: var(--layout-gap);
  row-gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
  max-width: var(--sidebar-width);
  max-height: 100%;
  padding-top: var(--sidebar-top);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  align-self: stretch;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex-shrink: 0;
  margin-top: auto;
}


.btn-cell {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s;
  user-select: none;
  text-decoration: none;
  color: inherit;
  display: block;
}

.btn-cell > * {
  position: relative;
  z-index: 1;
}

.btn-shader-host {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.5s ease-out;
  pointer-events: none;
  overflow: hidden;
}

.btn-shader-host canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.action-cell.is-shader-active .btn-shader-host {
  opacity: 1;
}

.intro-cell.is-shader-active .btn-shader-host--intro {
  opacity: 1;
}

.intro-cell.is-shader-active .intro-title,
.intro-cell.is-shader-active .intro-body,
.intro-cell.is-shader-active .intro-name,
.intro-cell.is-shader-active .intro-accent,
.intro-cell.is-shader-active .label,
.intro-cell.is-shader-active .book-title,
.intro-cell.is-shader-active .book-author,
.intro-cell.is-shader-active .tools-note,
.intro-cell.is-shader-active .social-links a {
  text-shadow: 0 1px 10px rgba(17, 17, 16, 0.85), 0 0 18px rgba(17, 17, 16, 0.45);
}

.wrap.light .intro-cell.is-shader-active .intro-title,
.wrap.light .intro-cell.is-shader-active .intro-body,
.wrap.light .intro-cell.is-shader-active .intro-name,
.wrap.light .intro-cell.is-shader-active .intro-accent,
.wrap.light .intro-cell.is-shader-active .label,
.wrap.light .intro-cell.is-shader-active .book-title,
.wrap.light .intro-cell.is-shader-active .book-author,
.wrap.light .intro-cell.is-shader-active .tools-note,
.wrap.light .intro-cell.is-shader-active .social-links a {
  text-shadow: 0 1px 8px rgba(255, 255, 255, 0.9), 0 0 14px rgba(255, 255, 255, 0.6);
}

.btn-cell:active {
  transform: scale(0.96);
  filter: brightness(0.88);
}

.intro-cell {
  background: var(--surface);
  border: none;
  padding: var(--intro-pad);
  /* Grow to fill spare space but never shrink below the text, so nothing is
     clipped; on short screens the sidebar scrolls instead. */
  flex: 1 0 auto;
  min-height: clamp(320px, 46vh, 520px);
}

.intro-copy {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.intro-copy-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: -4px;
}

.label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.action-cell {
  padding: clamp(16px, 1.2vw, 20px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: clamp(92px, 12vh, 116px);
}

.tech-cell {
  background: var(--blue);
}

.design-cell {
  background: var(--orange);
}

.other-cell {
  background: var(--green);
}

.action-cell p {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
}

.action-cell p:last-child {
  text-transform: none;
  letter-spacing: normal;
  color: rgba(255, 255, 255, 0.5);
}

.main-area {
  background: transparent;
  border: none;
  border-radius: 0;
  min-height: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.page-viewport {
  width: 100%;
  min-height: 100%;
  position: relative;
}

.page-panel {
  width: 100%;
  min-height: 100%;
  padding: var(--content-pad) var(--content-pad-x);
  will-change: transform, opacity;
}

.page-content {
  padding: 0;
}

.page-panel.slide-in {
  animation: slideInFromRight 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.page-panel.slide-out {
  animation: slideOutToLeft 0.28s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInFromRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutToLeft {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-18%);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-panel.slide-in,
  .page-panel.slide-out {
    animation: none;
  }
}

.page-content--home {
  display: flex;
  align-items: center;
  min-height: 100%;
  padding: clamp(20px, 6vh, 64px) 0;
}

.home-now {
  max-width: 44ch;
}

.home-now-title {
  font-size: 14px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.05em;
  color: var(--text);
  text-transform: lowercase;
  margin-bottom: 18px;
}

.home-now-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.home-now-list li {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  text-transform: lowercase;
}

.page-content h2 {
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.3;
}

.page-content .page-lead {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 24px;
  max-width: 52ch;
}

.page-content ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-content li a,
.page-content li span {
  font-size: 14px;
  color: var(--blue-light);
  text-decoration: none;
}

.page-content li a:hover {
  text-decoration: underline;
}

.intro-name {
  font-weight: 500;
  color: #ffffff;
}

.intro-body {
  font-size: var(--intro-font);
  color: #ffffff;
  line-height: 1.7;
  margin-bottom: 0;
}

.wrap.light .intro-name {
  color: var(--text);
}

.wrap.light .intro-body {
  color: var(--text);
}

.intro-body:last-child {
  margin-bottom: 0;
}

.intro-accent {
  font-weight: 500;
}

.intro-accent--tech {
  color: var(--blue-light);
}

.intro-accent--design {
  color: var(--orange);
}

.divider {
  height: 0.5px;
  background: var(--border);
  margin-bottom: 12px;
}

.intro-copy .divider-sm {
  width: 50%;
  height: 0.5px;
  margin: 0;
}

.intro-copy .social-links a {
  color: var(--blue-light);
}

.book-title {
  font-size: 12px;
  font-style: italic;
  color: var(--text);
  margin-bottom: 2px;
}

.book-author {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.book-author:last-of-type {
  margin-bottom: 12px;
}

.tools-note {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.social-links {
  display: flex;
  gap: 14px;
}

.social-links a {
  font-size: 12px;
  color: var(--blue-light);
  text-decoration: none;
}

.social-links a:hover {
  text-decoration: underline;
}

/* tech page */
.tech-page > h2,
.cv-page h2 {
  font-size: 26px;
  text-transform: lowercase;
}

/* cv page */
.cv-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 70vh;
}

.cv-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.cv-head h2 {
  margin-bottom: 0;
}

.cv-open {
  font-size: 13px;
  color: var(--blue-light);
  text-decoration: none;
}

.cv-open:hover {
  text-decoration: underline;
}

.cv-frame {
  flex: 1;
  width: 100%;
  min-height: 70vh;
  border: 0.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

/* ---------- responsive ---------- */

.wrap > nav,
.layout {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
}

/* Large monitors: scale the whole UI up a step so type and cards aren't tiny.
   Height is divided by the zoom so the shell still fits the viewport exactly. */
@media (min-width: 1800px) and (min-height: 1000px) {
  .wrap {
    --ui-zoom: 1.15;
  }
}

@media (min-width: 2300px) and (min-height: 1250px) {
  .wrap {
    --ui-zoom: 1.3;
  }
}

@media (min-width: 1800px) and (min-height: 1000px) {
  .wrap {
    zoom: var(--ui-zoom);
    height: calc(100dvh / var(--ui-zoom));
    max-height: calc(100dvh / var(--ui-zoom));
  }
}

/* Short screens (small laptops): tighten vertical spacing so the sidebar fits. */
@media (min-width: 861px) and (max-height: 820px) {
  :root {
    --sidebar-top: 12px;
    --intro-pad: 22px;
  }

  .intro-copy {
    gap: 10px;
  }

  .action-cell {
    min-height: 76px;
  }
}

/* Tablet and phone: one column, and the whole page scrolls instead of the
   sidebar and content scrolling separately. */
@media (max-width: 860px) {
  :root {
    --intro-font: clamp(14px, 1.6vw + 8px, 15px);
    --intro-pad: clamp(20px, 5vw, 28px);
    --page-pad: 16px;
  }

  body {
    overflow-y: auto;
  }

  .wrap {
    height: auto;
    max-height: none;
    min-height: 100dvh;
    overflow: visible;
    overflow-x: clip;
  }

  .layout {
    display: flex;
    flex-direction: column;
    gap: var(--layout-gap);
    overflow: visible;
  }

  .sidebar {
    max-width: none;
    max-height: none;
    padding-top: 8px;
    overflow: visible;
  }

  .intro-cell {
    flex: 0 0 auto;
    min-height: 0;
  }

  /* On small screens the intro only shows on home, so other pages start near the top. */
  .wrap:not([data-page="home"]) .intro-cell {
    display: none;
  }

  .sidebar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 0;
  }

  .main-area {
    overflow: visible;
  }

  .page-panel {
    padding-inline: 0;
  }

  .page-content--home {
    min-height: 0;
    padding: 8px 0 24px;
  }

  .cv-frame {
    min-height: 80vh;
  }
}

@media (max-width: 480px) {
  nav {
    gap: 10px 14px;
  }

  .nav-links {
    gap: 10px 14px;
  }

  .action-cell {
    min-height: 84px;
  }

  .tech-page > h2,
  .cv-page h2 {
    font-size: 22px;
  }
}

/* tech page: intro + links, skills list */
.tech-intro {
  margin-top: -24px;
  margin-bottom: clamp(32px, 4.5vh, 48px);
}

.tech-intro .page-lead {
  margin-bottom: 12px;
  text-transform: lowercase;
}

.tech-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.tech-links a {
  font-size: 13px;
  color: var(--blue-light);
  text-decoration: none;
}

.tech-links a:hover {
  text-decoration: underline;
}

.tech-skills {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 64ch;
}

.tech-skills-row {
  display: grid;
  grid-template-columns: minmax(120px, 11rem) 1fr;
  gap: 4px 16px;
  font-size: 14px;
  line-height: 1.6;
  text-transform: lowercase;
}

.tech-skills-row dt {
  color: var(--muted);
  font-size: 13px;
}

.tech-skills-row dd {
  color: var(--text);
}

@media (max-width: 520px) {
  .tech-skills-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}
