/* ============================================
   DESIGN SYSTEM & CUSTOM PROPERTIES
   ============================================ */
:root {
  /* Colors */
  --color-bg: #1C1D20;
  --color-bg-light: #242527;
  --color-bg-card: #292929;
  --color-text: #E8E4DE;
  --color-text-dim: #999999;
  --color-text-muted: #6a6a6a;
  --color-accent: #C4A35A;
  --color-border: rgba(255, 255, 255, 0.12);
  --color-white: #ffffff;

  /* Typography */
  --font-primary: 'Open Sauce Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Open Sauce Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-hero: 'Peace Sans', var(--font-display);

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 8rem;
  --space-2xl: 12rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-xl: 50px;
  --radius-full: 50%;

  /* Transitions */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 0.3s;
  --duration-med: 0.6s;
  --duration-slow: 1s;
  --duration-slower: 1.5s;

  /* Layout */
  --container-padding: clamp(1.5rem, 4vw, 4rem);
  --header-height: 80px;
}

/* Light theme — toggled via [data-theme="light"] on <html> */
:root[data-theme="light"] {
  --color-bg: #F5F3EF;
  --color-bg-light: #EAE7E0;
  --color-bg-card: #FFFFFF;
  --color-text: #1C1D20;
  --color-text-dim: #6B6B6B;
  --color-text-muted: #9A9A9A;
  --color-accent: #A9812E;
  --color-border: rgba(0, 0, 0, 0.1);
  /* --color-white is deliberately NOT overridden here — it's only used
     by the custom cursor's mix-blend-mode: difference, which needs to
     stay white in both themes for the blend trick to work. The navbar
     used to rely on this too, but that caused real readability bugs
     across the theme switch, so it now uses plain --color-text instead. */
}

/* Smooth crossfade on the base background/text when toggling themes */
body {
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* ============================================
   BASE STYLES
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: auto; /* Lenis handles smooth scroll */
}

html.lenis, html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

body {
  font-family: var(--font-primary);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* The projects list uses display:flex on each row, which would otherwise beat the
   browser's own [hidden] rule and keep the archive rows visible. */
[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

ul, ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 400;
}

p {
  margin: 0;
}

::selection {
  background-color: var(--color-accent);
  color: var(--color-bg);
}

/* ============================================
   CUSTOM CURSOR
   ============================================ */
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background-color: var(--color-white);
  pointer-events: none;
  z-index: 10000;
  mix-blend-mode: difference;
  transform: translate(-50%, -50%);
  transition: width 0.4s var(--ease-out-expo),
              height 0.4s var(--ease-out-expo);
}

.cursor.cursor-grow {
  width: 60px;
  height: 60px;
}

.cursor.cursor-text {
  width: 120px;
  height: 120px;
}

@media (hover: none) and (pointer: coarse) {
  .cursor {
    display: none;
  }
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 0 var(--container-padding);
  height: var(--header-height);
  background-color: color-mix(in srgb, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  transform: translateY(0);
  transition: transform 0.5s var(--ease-out-expo);
}

.navbar.hidden {
  transform: translateY(-100%);
}

.navbar .logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text);
}

.navbar .logo span {
  display: inline-block;
}

.navbar .logo .logo-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  /* Always shows true colors — the navbar's difference-blend is applied
     per-element to the text/icons individually now, not to the whole
     navbar, so the avatar was never part of that blend group to begin
     with. The invert below is a deliberate hover-only effect. */
  filter: invert(0);
  transition: filter 0.35s var(--ease-out-expo);
}

.navbar .logo:hover .logo-avatar {
  filter: invert(1);
}

.navbar .copyright {
  font-size: 0.7rem;
  color: var(--color-text-dim);
  font-weight: 300;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(1.5rem, 3vw, 3rem);
}

.nav-links a {
  font-size: 0.85rem;
  color: var(--color-text);
  position: relative;
  padding: 4px 0;
  letter-spacing: 0.02em;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background-color: var(--color-text);
  transition: width 0.4s var(--ease-out-expo);
}

.nav-links a:hover::after {
  width: 100%;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  z-index: 101;
}

.nav-toggle span {
  width: 28px;
  height: 1.5px;
  background-color: var(--color-text);
  transition: all 0.3s var(--ease-out-expo);
}

/* Theme toggle — always visible, on both desktop and mobile navbar */
.theme-toggle {
  position: relative;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 101;
}

.theme-icon {
  position: absolute;
  width: 18px;
  height: 18px;
  transition: opacity 0.4s var(--ease-out-expo), transform 0.5s var(--ease-out-expo);
}

.theme-icon-sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.theme-icon-moon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

:root[data-theme="light"] .theme-icon-sun {
  opacity: 1;
  transform: rotate(0) scale(1);
}

:root[data-theme="light"] .theme-icon-moon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 var(--container-padding);
  /* Guarantees a minimum gap below the fixed navbar. Since content here is
     bottom-anchored (justify-content: flex-end), this only has a visible
     effect once the title stack is tall enough to reach the top — which is
     exactly the case that was crowding the navbar. */
  padding-top: calc(var(--header-height) + 1rem);
  padding-bottom: clamp(3rem, 8vh, 6rem);
  position: relative;
  overflow: hidden;
}

.hero-content {
  width: 100%;
}

.hero-title {
  font-family: var(--font-hero);
  overflow: hidden;
}

.hero-title .line {
  display: block;
  overflow: hidden;
}

.hero-title .line-inner {
  display: block;
  transform: translateY(100%);
  font-size: clamp(3rem, 9vw, 9rem);
  font-weight: 300;
  line-height: 1.18;
  letter-spacing: -0.03em;
  color: var(--color-text);
  /* Subtle depth: a tight shadow for edge definition + a soft, wider one
     underneath so the type reads as slightly lifted off the page rather
     than flat. Kept light on purpose — this is meant to be felt, not seen. */
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.18),
    0 10px 26px rgba(0, 0, 0, 0.22);
}

.hero-title .line-inner.indent {
  padding-left: clamp(2rem, 12vw, 15rem);
}

.hero-title .line-inner em {
  font-style: italic;
  font-weight: 300;
}

.hero-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: clamp(2rem, 4vh, 4rem);
}

.hero-subtitle {
  font-size: clamp(0.85rem, 1.2vw, 1rem);
  color: var(--color-text-dim);
  max-width: 280px;
  line-height: 1.7;
  font-weight: 300;
}

.hero-subtitle .line {
  display: block;
  overflow: hidden;
}

.hero-subtitle .line span {
  display: block;
  transform: translateY(100%);
}

/* Rotating Badge */
.hero-badge {
  position: relative;
  width: clamp(100px, 12vw, 150px);
  height: clamp(100px, 12vw, 150px);
  flex-shrink: 0;
  cursor: pointer;
}

.hero-badge svg {
  width: 100%;
  height: 100%;
  animation: rotateBadge 12s linear infinite;
}

.hero-badge svg text {
  font-size: 12px;
  fill: var(--color-text);
  letter-spacing: 5px;
  text-transform: uppercase;
  font-family: var(--font-primary);
}

.hero-badge .badge-arrow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(1.5rem, 2.5vw, 2.5rem);
  color: var(--color-text);
}

@keyframes rotateBadge {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Scroll Indicator */
.hero-scroll-indicator {
  position: absolute;
  bottom: clamp(2rem, 4vh, 3rem);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
}

.hero-scroll-indicator .scroll-line {
  width: 1px;
  height: 40px;
  background-color: var(--color-text-dim);
  position: relative;
  overflow: hidden;
}

.hero-scroll-indicator .scroll-line::after {
  content: '';
  position: absolute;
  top: -100%;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-text);
  animation: scrollLine 2s var(--ease-in-out) infinite;
}

@keyframes scrollLine {
  0% { top: -100%; }
  50% { top: 0; }
  100% { top: 100%; }
}

/* ============================================
   MARQUEE
   ============================================ */
.marquee-section {
  padding: clamp(1.5rem, 3vw, 2.5rem) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  overflow: hidden;
  position: relative;
}

.marquee-track {
  display: flex;
  align-items: center;
  gap: 0;
  width: max-content;
  will-change: transform;
  animation: marqueeScroll 30s linear infinite;
}

.marquee-section:hover .marquee-track {
  animation-play-state: paused;
}

.marquee-item {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 3rem);
  padding: 0 clamp(1rem, 3vw, 3rem);
  white-space: nowrap;
  flex-shrink: 0;
}

.marquee-item h3 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 4.5rem);
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.marquee-item .marquee-dot {
  width: clamp(8px, 1vw, 12px);
  height: clamp(8px, 1vw, 12px);
  border-radius: var(--radius-full);
  background-color: var(--color-accent);
  flex-shrink: 0;
}

.marquee-item h3.outline {
  color: transparent;
  -webkit-text-stroke: 1px var(--color-text);
}

/* Tech Stack marquee — smaller + icons, distinct from the tagline marquee above */
.marquee-icon {
  width: clamp(1.4rem, 3vw, 2.2rem);
  height: clamp(1.4rem, 3vw, 2.2rem);
  flex-shrink: 0;
}

.tech-marquee .marquee-item {
  gap: clamp(0.6rem, 1.5vw, 1.2rem);
  padding: 0 clamp(0.8rem, 2vw, 1.8rem);
}

.tech-marquee .marquee-item h3 {
  font-size: clamp(1.2rem, 2.8vw, 2.2rem);
}

.tech-marquee.marquee-section {
  padding: clamp(1rem, 2vw, 1.6rem) 0;
}

@keyframes marqueeScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ============================================
   WORK SECTION
   ============================================ */
.work-section {
  padding: clamp(4rem, 10vw, 10rem) var(--container-padding);
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: clamp(3rem, 6vw, 6rem);
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.section-header p {
  font-size: 0.85rem;
  color: var(--color-text-dim);
  font-weight: 300;
}

/* Project List (hover-preview style) */
.projects-list {
  display: flex;
  flex-direction: column;
}

.project-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(1.2rem, 3vw, 2.2rem) 0;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
  cursor: pointer;
  transition: opacity 0.4s var(--ease-out-expo);
}

.projects-list:hover .project-row {
  opacity: 0.4;
}

.projects-list .project-row:hover {
  opacity: 1;
}

.project-row h3 {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3.5vw, 2.4rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  transition: transform 0.4s var(--ease-out-expo);
}

.project-row:hover h3 {
  transform: translateX(10px);
}

.project-row-meta {
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 2vw, 2rem);
  flex-shrink: 0;
}

.project-row-meta span {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  font-weight: 300;
}

.project-row-meta .tag {
  padding: 4px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  font-size: 0.75rem;
  color: var(--color-text-dim);
  transition: all 0.3s var(--ease-out-expo);
}

.project-row:hover .project-row-meta .tag {
  background-color: var(--color-text);
  color: var(--color-bg);
  border-color: var(--color-text);
}

/* Floating preview — follows the cursor on hover, hidden on touch devices */
.project-preview {
  position: fixed;
  top: 0;
  left: 0;
  width: clamp(320px, 28vw, 440px);
  border-radius: var(--radius-md);
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  z-index: 60;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
}

.project-preview-image {
  width: 100%;
  aspect-ratio: 16 / 11;
}

.project-preview img,
.project-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.project-preview img[hidden],
.project-preview video[hidden] {
  display: none !important;
}

.project-preview-info {
  padding: clamp(0.9rem, 2vw, 1.3rem) clamp(1rem, 2vw, 1.4rem);
}

.project-preview-info h4 {
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.project-preview-info p {
  font-size: clamp(0.8rem, 1.1vw, 0.88rem);
  line-height: 1.5;
  color: var(--color-text-dim);
}

@media (hover: none), (pointer: coarse) {
  .project-preview {
    display: none;
  }

  /* Touch has no hover, so the floating preview (image/video +
     description) never appears. Render each row's own data-desc
     inline instead — pure CSS, zero extra downloads. */
  .project-row {
    flex-wrap: wrap;
  }

  .project-row::after {
    content: attr(data-desc);
    flex: 1 1 100%;
    display: block;
    margin-top: 0.6rem;
    font-size: clamp(0.85rem, 1.2vw, 0.95rem);
    line-height: 1.6;
    font-weight: 300;
    color: var(--color-text-dim);
  }

  /* No hover dimming on touch — avoids stuck dimmed rows after tap. */
  .projects-list:hover .project-row {
    opacity: 1;
  }
}

/* ============================================
   MORE WORK / ARCHIVE MODAL
   ============================================ */
.view-all-projects {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: clamp(2.5rem, 5vw, 4rem);
}

.more-work {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border: 0;
  background: none;
  color: var(--color-text);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.3s var(--ease-out-expo);
}

.more-work::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: var(--color-text-dim);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.5s var(--ease-out-expo);
}

.more-work:hover::after,
.more-work:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left;
}

.more-work .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--color-text-dim);
}

.more-work .arrow {
  display: inline-block;
  transition: transform 0.3s var(--ease-out-expo);
}

.more-work:hover .arrow,
.more-work:focus-visible .arrow {
  transform: translateX(6px);
}

.more-work:focus-visible,
.work-modal-close:focus-visible,
.work-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* Full-viewport layer below the custom cursor (z-index 10000), so the cursor stays visible. */
.work-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-out-expo), visibility 0s linear 0.25s;
}

.work-modal.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.25s var(--ease-out-expo), visibility 0s;
}

.work-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 11, 0.74);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.work-modal-panel {
  position: relative;
  width: min(900px, 100%);
  max-height: min(82svh, 800px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  transition: transform 0.45s var(--ease-out-expo), opacity 0.3s var(--ease-out-expo);
}

.work-modal.is-open .work-modal-panel {
  opacity: 1;
  transform: none;
}

.work-modal-head {
  flex: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  border-bottom: 1px solid var(--color-border);
}

.work-modal-eyebrow {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.work-modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 300;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.work-modal-head-right {
  display: flex;
  align-items: center;
  gap: clamp(0.7rem, 2vw, 1.2rem);
}

.work-modal-close {
  flex: none;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.3s var(--ease-out-expo), color 0.3s var(--ease-out-expo),
    transform 0.3s var(--ease-out-expo);
}

.work-modal-close:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  transform: rotate(90deg);
}

.work-modal-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(1.2rem, 3vw, 2rem);
}

.work-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  row-gap: 0.9rem;
  column-gap: clamp(1.2rem, 3vw, 2rem);
}

.work-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-light);
  color: var(--color-text);
  transition: border-color 0.3s var(--ease-out-expo), transform 0.3s var(--ease-out-expo);
}

.work-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.work-card-media {
  aspect-ratio: 16 / 11;
  overflow: hidden;
  background: var(--color-bg);
}

.work-card-media img,
.work-card-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.work-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.85rem 1rem 1rem;
}

.work-card-tag {
  align-self: flex-start;
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

.work-card-body h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.work-card-body p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  font-weight: 300;
  color: var(--color-text-dim);
}

body.work-modal-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  .work-modal {
    padding: 1rem;
  }

  .work-modal-panel {
    width: 100%;
    max-width: 520px;
    height: auto;
    max-height: 78svh;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }

  .work-modal-head {
    align-items: center;
    padding: 1rem 1.1rem;
  }

  .work-modal-head h2 {
    font-size: 1.5rem;
  }

  .work-modal-scroll {
    padding: 1rem 1.1rem 1.2rem;
  }

  .work-modal-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin-inline: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .work-modal,
  .work-modal-panel,
  .more-work::after,
  .more-work .arrow,
  .work-modal-close,
  .work-card {
    transition: none;
  }
}

/* ============================================
   STACK SECTION
   ============================================ */
.stack-section {
  padding: clamp(3rem, 8vw, 6rem) var(--container-padding);
}

.stack-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

.stack-group h4 {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-dim);
  margin-bottom: 1rem;
}

.stack-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.pill {
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  font-size: 0.85rem;
  color: var(--color-text);
  background-color: var(--color-bg-light);
  transition: all 0.3s var(--ease-out-expo);
}

.pill:hover {
  background-color: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
}

@media (max-width: 768px) {
  .stack-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stack-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   ABOUT SECTION
   ============================================ */
.about-section {
  padding: clamp(4rem, 10vw, 10rem) var(--container-padding);
  border-top: 1px solid var(--color-border);
}

.about-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(3rem, 8vw, 10rem);
  align-items: start;
}

.about-left h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
}

.about-description {
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  line-height: 1.7;
  color: var(--color-text);
  font-weight: 300;
  max-width: 480px;
}

.about-description span.highlight {
  color: var(--color-accent);
}

.about-right {
  padding-top: clamp(0rem, 4vw, 5rem);
}

.services-label {
  font-size: 0.75rem;
  color: var(--color-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
}

.services-list {
  display: flex;
  flex-direction: column;
}

.services-list li {
  padding: clamp(1rem, 1.5vw, 1.5rem) 0;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.3s var(--ease-out-expo);
  cursor: default;
}

.services-list li:last-child {
  border-bottom: 1px solid var(--color-border);
}

.services-list li:hover {
  padding-left: 16px;
}

.services-list li h4 {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  font-weight: 300;
  letter-spacing: -0.01em;
}

.services-list li .service-dot {
  width: clamp(6px, 0.8vw, 9px);
  height: clamp(6px, 0.8vw, 9px);
  border-radius: var(--radius-full);
  background-color: var(--color-accent);
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(-10px);
  transition: all 0.3s var(--ease-out-expo);
}

.services-list li:hover .service-dot {
  opacity: 1;
  transform: translateX(0);
}

/* ============================================
   BLOG SECTION
   ============================================ */
.blog-section {
  padding: clamp(4rem, 10vw, 10rem) var(--container-padding);
  border-top: 1px solid var(--color-border);
}

.blog-teaser {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: clamp(2rem, 4vw, 3rem);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.blog-teaser.has-posts {
  flex-direction: column;
  align-items: stretch;
}

.blog-teaser p {
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  color: var(--color-text-dim);
  max-width: 32ch;
}

.blog-teaser.has-posts p {
  display: none;
}

.blog-teaser-posts {
  display: none;
  flex-direction: column;
}

.blog-teaser.has-posts .blog-teaser-posts {
  display: flex;
}

.blog-teaser-post-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  transition: opacity 0.3s var(--ease-out-expo);
}

.blog-teaser-post-row:first-child { padding-top: 0; }
.blog-teaser-post-row:hover { opacity: 0.6; }

.blog-teaser-post-row h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1rem, 1.8vw, 1.3rem);
}

.blog-teaser-post-row span {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  flex-shrink: 0;
}

.blog-teaser-link {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--color-text);
  padding: 12px 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  transition: all 0.3s var(--ease-out-expo);
  flex-shrink: 0;
}

.blog-teaser-link:hover {
  background-color: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
}

.blog-teaser-link .arrow {
  transition: transform 0.3s var(--ease-out-expo);
}

.blog-teaser-link:hover .arrow {
  transform: translateX(4px);
}

/* ============================================
   CONTACT / FOOTER SECTION
   ============================================ */
.contact-section {
  padding: clamp(2rem, 4.5vw, 4rem) var(--container-padding);
  padding-bottom: clamp(2rem, 4vw, 3rem);
  position: relative;
  overflow: hidden;
}

.contact-top {
  text-align: center;
  margin-bottom: clamp(2rem, 4vw, 3.5rem);
}

.contact-top .eyebrow {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: clamp(1rem, 2vw, 2rem);
}

.contact-title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8vw, 8.5rem);
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1.15;
  position: relative;
  display: inline-block;
}

.contact-title a {
  position: relative;
  display: inline-block;
  transition: color 0.4s var(--ease-out-expo);
}

.contact-title a::after {
  content: '';
  position: absolute;
  bottom: 5%;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-text);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.6s var(--ease-out-expo);
}

.contact-title a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.contact-email {
  display: block;
  margin-top: clamp(1rem, 2vw, 1.8rem);
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  color: var(--color-text-dim);
  transition: color 0.3s var(--ease-out-expo);
}

.contact-email:hover {
  color: var(--color-text);
}

/* Footer */
.footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: clamp(1.5rem, 3vw, 2.5rem);
  border-top: 1px solid var(--color-border);
}

.footer-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-left .footer-version {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.footer-left .footer-label {
  font-size: 0.8rem;
  color: var(--color-text-dim);
}

.footer-socials {
  display: flex;
  gap: clamp(1rem, 2.5vw, 2rem);
}

.footer-socials a {
  font-size: 0.85rem;
  color: var(--color-text-dim);
  position: relative;
  padding: 4px 0;
  transition: color 0.3s var(--ease-out-expo);
}

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

.footer-socials a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background-color: var(--color-text);
  transition: width 0.4s var(--ease-out-expo);
}

.footer-socials a:hover::after {
  width: 100%;
}

.footer-right {
  text-align: right;
}

.footer-right .footer-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.footer-right .back-to-top {
  font-size: 0.85rem;
  color: var(--color-text-dim);
  padding: 4px 0;
  position: relative;
  transition: color 0.3s var(--ease-out-expo);
}

.footer-right .back-to-top:hover {
  color: var(--color-text);
}

.footer-right .back-to-top::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background-color: var(--color-text);
  transition: width 0.4s var(--ease-out-expo);
}

.footer-right .back-to-top:hover::after {
  width: 100%;
}

/* ============================================
   MAGNETIC BUTTON
   ============================================ */
.magnetic-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 1.5vw, 18px) clamp(24px, 3vw, 40px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  font-size: 0.85rem;
  color: var(--color-text);
  overflow: hidden;
  transition: border-color 0.4s var(--ease-out-expo),
              color 0.4s var(--ease-out-expo);
}

.magnetic-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background-color: var(--color-text);
  border-radius: var(--radius-xl);
  transform: translateY(101%);
  transition: transform 0.5s var(--ease-out-expo);
}

.magnetic-btn:hover::before {
  transform: translateY(0);
}

.magnetic-btn:hover {
  color: var(--color-bg);
  border-color: var(--color-text);
}

.magnetic-btn span {
  position: relative;
  z-index: 1;
}

/* ============================================
   TEXT REVEAL ANIMATIONS
   ============================================ */
.reveal-text {
  overflow: hidden;
}

.reveal-text .reveal-inner {
  transform: translateY(100%);
  display: block;
}

.reveal-text.revealed .reveal-inner {
  transform: translateY(0);
}

.fade-in-up {
  opacity: 0;
  transform: translateY(40px);
}

.fade-in-up.revealed {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.8s var(--ease-out-expo),
              transform 0.8s var(--ease-out-expo);
}

/* ============================================
   MOBILE MENU
   ============================================ */
.mobile-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 450px;
  height: 100vh;
  background-color: var(--color-bg-light);
  z-index: 99;
  padding: calc(var(--header-height) + 2rem) var(--container-padding) 2rem;
  transform: translateX(100%);
  transition: transform 0.6s var(--ease-out-expo);
}

.mobile-menu.open {
  transform: translateX(0);
}

.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 98;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-out-expo);
}

.mobile-menu-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.mobile-menu-links {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mobile-menu-links a {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 300;
  padding: clamp(0.8rem, 2vw, 1.2rem) 0;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: padding-left 0.3s var(--ease-out-expo);
}

.mobile-menu-links a:first-child {
  border-top: 1px solid var(--color-border);
}

.mobile-menu-links a:hover {
  padding-left: 16px;
}

.mobile-menu-links a .menu-arrow {
  font-size: 1.2rem;
  color: var(--color-text-dim);
}

.mobile-menu-socials {
  display: flex;
  gap: 1.5rem;
  margin-top: auto;
  padding-top: 3rem;
}

.mobile-menu-socials a {
  font-size: 0.85rem;
  color: var(--color-text-dim);
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */
@media (max-width: 1024px) {
  .projects-list {
    gap: clamp(0.5rem, 1vw, 1rem);
  }

  .about-content {
    grid-template-columns: 1fr;
    gap: clamp(3rem, 6vw, 5rem);
  }

  .about-right {
    padding-top: 0;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 64px;
  }

  .nav-links {
    display: none;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-toggle.open span:first-child {
    transform: rotate(45deg) translate(4px, 4px);
  }

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

  .nav-toggle.open span:last-child {
    transform: rotate(-45deg) translate(4px, -4px);
  }

  .hero-title .line-inner {
    font-size: clamp(2.5rem, 12vw, 5rem);
  }

  .hero-title .line-inner.indent {
    padding-left: clamp(1rem, 5vw, 3rem);
  }

  .hero-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 2rem;
  }

  .hero-badge {
    align-self: flex-end;
  }

  .contact-title {
    font-size: clamp(2.5rem, 12vw, 5rem);
  }

  .footer {
    flex-direction: column;
    gap: 2rem;
    align-items: flex-start;
  }

  .footer-right {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .project-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.container {
  width: 100%;
  padding: 0 var(--container-padding);
}

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

/* ============================================
   BACKGROUND NOISE TEXTURE
   ============================================ */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9998;
  opacity: 0.4;
}

/* ============================================
   FLOATING CONTACT BAR
   Appears on scroll-pause, hides while scrolling
   or while the real Contact section is in view.
   ============================================ */
.floating-contact {
  position: fixed;
  bottom: clamp(1.2rem, 3vh, 2rem);
  left: 50%;
  transform: translateX(-50%) translateY(24px);
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 2vw, 1.5rem);
  padding: 10px 12px 10px 20px;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  z-index: 90;
  transition: opacity 0.5s var(--ease-out-expo), transform 0.5s var(--ease-out-expo);
  max-width: 90vw;
}

.floating-contact.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.floating-contact-text {
  font-size: 0.85rem;
  color: var(--color-text-dim);
  white-space: nowrap;
}

.floating-contact-cta {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-bg);
  background-color: var(--color-accent);
  padding: 8px 16px;
  border-radius: var(--radius-xl);
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

.floating-contact-cta:hover {
  opacity: 0.85;
}

@media (max-width: 560px) {
  .floating-contact-text {
    display: none;
  }
  .floating-contact {
    /* Equal left/right padding — the 16px/8px split above exists to
       balance the text + button pair, but with the text hidden on
       mobile only the button remains, so uneven padding pushed it
       off-center inside the pill. */
    padding: 8px;
  }
}

/* ============================================
   ASCII BACKGROUND (ascii.rest scenes, self-hosted)
   Fixed full-site layer behind everything. Sharpness rules:
   width-only sizing (never height), no transforms/filters on
   the layer — mount.js already handles DPR + ResizeObserver.
   ============================================ */
#ascii-bg {
  position: fixed;
  inset: 0;
  z-index: -1; /* paints above body bg, below all static content */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  background-color: var(--color-bg); /* fallback while scene loads */
  opacity: 0;
  transition: opacity 0.8s ease;
}

#ascii-bg.is-ready {
  opacity: 1;
}

#ascii-canvas {
  /* Cover the viewport without stretching cells: scenes are 200x100
     (2:1), so width must be at least 200vh to fill viewport height.
     Crops sides on narrow/tall screens instead of squashing.
     !important beats the inline width mount.js assigns. */
  width: max(100vw, 200vh) !important;
  max-width: none !important;
  height: auto !important;
  display: block;
  flex-shrink: 0;
  image-rendering: auto;
}

.ascii-scrim {
  position: absolute;
  inset: 0;
  /* Solid translucent gradient (no backdrop-blur: blur would soften
     the art and cost GPU on scroll). Uses theme vars so both
     dark and light themes keep text contrast. */
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--color-bg) 88%, transparent),
    color-mix(in srgb, var(--color-bg) 80%, transparent) 35%,
    color-mix(in srgb, var(--color-bg) 84%, transparent) 70%,
    color-mix(in srgb, var(--color-bg) 90%, transparent)
  );
}
