:root {
  --bg: #17130f;
  --surface: #241e16;
  --ink: #f5ecd9;
  --ink-dark: #2b2116;
  --dim: #a89a7d;
  --coral: #ff7a5c;
  --teal: #2fb8a6;
  --yellow: #ffcf56;
  --hand: 'Caveat', cursive;
  --sans: 'Nunito', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(rgba(245,236,217,0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--sans);
  position: relative;
  overflow-x: hidden;
  animation: bg-drift 50s linear infinite;
}
@keyframes bg-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 220px 220px, 0 0; }
}

/* Scroll-reveal (JS toggles .in-view) */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in-view { opacity: 1; transform: translateY(0); }

.doodle {
  position: fixed;
  font-family: var(--hand);
  color: rgba(245,236,217,0.07);
  font-size: 5rem;
  pointer-events: none;
  z-index: 0;
}
.d1 { top: 10%; left: 4%; animation: sway1 9s ease-in-out infinite; }
.d2 { top: 60%; right: 6%; font-size: 4rem; animation: sway2 11s ease-in-out infinite; }
.d3 { bottom: 8%; left: 10%; animation: sway3 10s ease-in-out infinite; }
@keyframes sway1 { 0%,100% { transform: rotate(-12deg) translateY(0); } 50% { transform: rotate(-7deg) translateY(-16px); } }
@keyframes sway2 { 0%,100% { transform: rotate(10deg) translateY(0); } 50% { transform: rotate(15deg) translateY(14px); } }
@keyframes sway3 { 0%,100% { transform: rotate(6deg) translateY(0); } 50% { transform: rotate(1deg) translateY(-12px); } }

main, .nav { position: relative; z-index: 1; }

.ambient-bg {
  position: fixed; inset: 0; z-index: 0;
  background-color: transparent;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  /* background-image is injected by JS (interactions.js) once the browser
     is idle / after load, instead of being fetched eagerly on first paint.
     This keeps the initial request queue free for fonts/CSS/hero sprite. */
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
}
.ambient-bg.visible { opacity: 1; }

/* NAV */
.nav { padding: 20px 32px; position: relative; z-index: 20; }
.nav-inner {
  max-width: 1140px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.logo {
  font-family: 'Courier New', monospace; font-size: 0.95rem; font-weight: 700;
  letter-spacing: 0.06em; color: var(--teal); text-decoration: none;
}
.logo-blink { animation: cursor-blink 1s step-end infinite; }
@keyframes cursor-blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
.nav-links { display: flex; gap: 26px; }
.nav-links a { color: var(--dim); text-decoration: none; font-size: 0.92rem; font-weight: 600; }
.nav-links a:hover { color: var(--coral); }
.nav-right { display: flex; align-items: center; gap: 14px; }
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 40px; height: 40px; border: 2px solid var(--ink); border-radius: 10px;
  background: var(--surface); cursor: pointer; padding: 0;
}
.nav-toggle span { width: 18px; height: 2px; background: var(--ink); margin: 0 auto; transition: transform .2s, opacity .2s; }
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.lang-switch { display: flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.lang-btn {
  border: none; background: var(--surface); color: var(--ink);
  font-family: var(--sans); font-weight: 800; font-size: 0.8rem;
  padding: 7px 14px; cursor: pointer; transition: background .15s, color .15s;
}
.lang-btn + .lang-btn { border-left: 2px solid var(--ink); }
.lang-btn.active { background: var(--ink); color: var(--bg); }
.lang-btn:not(.active):hover { background: rgba(245,236,217,0.1); }

main { max-width: 1140px; margin: 0 auto; padding: 0 32px; }

/* HERO */
.handwritten-tag { font-family: var(--hand); font-size: 1.6rem; color: var(--coral); margin-bottom: 6px; }
.hero-video-text h1 {
  font-family: var(--hand);
  font-size: clamp(3rem, 7vw, 4.8rem);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}
.role { font-weight: 800; font-size: 1.1rem; margin-bottom: 18px; }
.subtitle { color: var(--dim); font-size: 1.05rem; margin-bottom: 30px; max-width: 460px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.btn {
  padding: 13px 26px; border-radius: 14px; text-decoration: none; font-weight: 800; font-size: 0.95rem;
  transition: transform .2s, box-shadow .2s;
  display: inline-block;
}
.btn-coral { background: var(--coral); color: var(--ink-dark); box-shadow: 4px 4px 0 var(--ink); animation: glow-pulse 2.6s ease-in-out infinite; }
.btn-coral:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 var(--ink); animation-play-state: paused; }
@keyframes glow-pulse {
  0%,100% { box-shadow: 4px 4px 0 var(--ink), 0 0 0 rgba(255,122,92,0); }
  50% { box-shadow: 4px 4px 0 var(--ink), 0 0 22px rgba(255,122,92,0.55); }
}
.btn-outline { background: var(--bg); color: var(--ink); border: 2px solid var(--ink); }
.btn-outline:hover { transform: translate(-2px,-2px); box-shadow: 4px 4px 0 var(--ink); }
.btn.big { font-size: 1.05rem; padding: 16px 30px; }

/* SCROLL-SCRUBBED VIDEO HERO */
.hero-video {
  position: relative; height: 325vh;
  width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
}
.hero-video-pin {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.hero-video-el {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.hero-video-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(43,33,22,0.35) 0%, rgba(43,33,22,0.15) 40%, rgba(43,33,22,0.55) 100%);
}
.hero-video-overlay {
  position: relative; z-index: 2; width: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  transition: opacity .25s ease-out;
}
.hero-video-inner {
  width: 100%; padding: 0 5vw;
}
.hero-video-text { color: white; max-width: 420px; text-align: left; }
.hero-video-text .handwritten-tag { color: var(--yellow); }
.hero-video-text .role { font-weight: 800; font-size: 1.1rem; margin-bottom: 18px; }
.hero-video-text .subtitle { color: rgba(255,255,255,0.85); font-size: 1.05rem; margin-bottom: 30px; }
.hero-video-text .hero-actions { justify-content: flex-start; }
.hero-video-text .btn-outline { background: transparent; color: white; border-color: white; }
.hero-scroll-hint {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%);
  color: white; font-family: var(--hand); font-size: 1.3rem;
  animation: float-hint 2s ease-in-out infinite;
}
@keyframes float-hint { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -8px); } }

.hero-video.reduced-motion { height: auto; }
.hero-video.reduced-motion .hero-video-pin { position: relative; height: 100vh; }
.hero-video.reduced-motion .hero-scroll-hint { display: none; }

@media (max-width: 720px) {
  .hero-video { height: 250vh; }
}

/* SECTIONS */
section:not(.hero) { padding: 30px 0; }
.section-title {
  font-family: var(--hand);
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin-bottom: 20px;
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-color: rgba(255,122,92,0.55);
  text-decoration-thickness: 3px;
  text-underline-offset: 8px;
}
.scribble { display: none; }

/* ABOUT */
.about-grid { display: grid; grid-template-columns: 1.4fr 1fr; grid-template-rows: auto auto; gap: 18px; }
.about-text { grid-row: span 2; color: var(--dim); font-size: 1.05rem; align-self: start; }
.sticky-mini {
  padding: 20px; border-radius: 4px; font-weight: 700; font-size: 0.95rem;
  border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
}
.sticky-mini.yellow { background: var(--yellow); color: var(--ink-dark); transform: rotate(-2deg); }
.sticky-mini.teal { background: var(--teal); color: var(--ink-dark); transform: rotate(1.5deg); }
.sticky-mini.coral { background: var(--coral); color: var(--ink-dark); transform: rotate(-1deg); }

/* PROJECTS */
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 28px; }
.sticky {
  position: relative;
  padding: 26px 22px 22px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform .2s, box-shadow .2s;
}
.sticky:hover { transform: translate(-3px,-3px) rotate(0deg) !important; box-shadow: 8px 8px 0 var(--ink); animation-play-state: paused; }
.sticky.r1 { animation: wiggle-1 7s ease-in-out infinite; }
.sticky.r2 { animation: wiggle-2 7s ease-in-out infinite 1s; }
@keyframes wiggle-1 { 0%,100% { transform: rotate(-1.5deg); } 50% { transform: rotate(-0.5deg); } }
@keyframes wiggle-2 { 0%,100% { transform: rotate(1.5deg); } 50% { transform: rotate(0.5deg); } }
.sticky.yellow { background: var(--yellow); color: var(--ink-dark); }
.sticky.coral { background: var(--coral); color: var(--ink-dark); }
.sticky.teal { background: var(--teal); color: var(--ink-dark); }
.pin { position: absolute; top: -14px; left: 16px; font-size: 1.4rem; }

.sticky.confidential {
  background: repeating-linear-gradient(135deg, #332a1c, #332a1c 10px, #2c2416 10px, #2c2416 20px);
  color: #f2ede0;
  border-color: var(--ink);
}
.sticky.confidential .desc,
.sticky.confidential .tagline { color: #d8cfba; }
.sticky.confidential .tags { color: #b8ad94; }
.stamp {
  position: absolute; top: 14px; right: -8px;
  font-family: var(--sans); font-weight: 800; font-size: 0.68rem; letter-spacing: 0.06em;
  color: #ff7a5c; border: 2px solid #ff7a5c; border-radius: 4px;
  padding: 3px 8px; transform: rotate(8deg);
  background: rgba(255,122,92,0.08);
}
.sticky .icon { font-size: 1.7rem; display: block; margin-bottom: 8px; }
.sticky h3 { font-family: var(--hand); font-size: 1.6rem; margin-bottom: 4px; }
.sticky .tagline { font-weight: 700; font-size: 0.85rem; margin-bottom: 8px; opacity: 0.9; }
.sticky .desc { font-size: 0.86rem; margin-bottom: 10px; opacity: 0.95; }
.sticky .tags { font-size: 0.75rem; font-weight: 700; opacity: 0.85; }
.sticky .tags a { color: inherit; text-decoration: underline; }

/* STACK */
.stack-intro { color: var(--dim); font-size: 1.02rem; max-width: 640px; margin-bottom: 36px; }
.stack-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 30px; }
.stack-group h3 {
  font-family: var(--hand); font-size: 1.35rem; color: var(--coral);
  margin-bottom: 14px; transform: rotate(-1deg);
}
.stack-row { display: flex; flex-wrap: wrap; gap: 12px; }
.badge {
  background: var(--surface); border: 2px solid var(--ink); border-radius: 999px;
  padding: 10px 18px; font-weight: 700; font-size: 0.86rem;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .15s, box-shadow .15s;
}
.badge:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--ink); }

/* CONTACT */
.postcard {
  background: var(--surface); border: 2px solid var(--ink); border-radius: 8px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 50px; text-align: center; max-width: 560px; margin: 0 auto;
}
.postcard h2 { font-family: var(--hand); font-size: 2.2rem; margin-bottom: 14px; }
.postcard p { color: var(--dim); margin-bottom: 24px; }
.contact-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px; }
.btn-github {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--ink); color: var(--bg);
}
.btn-github:hover { transform: translate(-2px,-2px); box-shadow: 4px 4px 0 var(--ink); }

.footer { text-align: center; padding: 34px; color: var(--dim); font-size: 0.85rem; font-weight: 600; }

@media (max-width: 780px) {
  .about-grid { grid-template-columns: 1fr; }
  .about-text { grid-row: auto; }
  .nav-toggle { display: flex; }
  .nav-links {
    display: none; flex-direction: column; gap: 0;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--surface); border-bottom: 2px solid var(--ink);
    padding: 8px 32px 16px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 0; border-top: 1px solid rgba(245,236,217,0.1); }
  .doodle { display: none; }
}

/* Visually-hidden but screen-reader-accessible content */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Respect the OS/browser-level reduced-motion preference everywhere,
   not just the scroll-scrubbed hero: kills the infinite decorative
   loops (bg-drift, doodle sway, logo blink, button glow, sticky
   wiggle, scroll hint float) and the .reveal scroll-in transition. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
