:root {
  --bg: #fbfaf7;
  --ink: #121212;
  --green: #97978F;
  --pad: clamp(1.25rem, 3vw, 2.5rem);
  --nav-size: clamp(0.85rem, 1.1vw, 1rem);
}

/* home page only: inverted palette (off-white <-> near-black), green kept */
body[data-page="home"] {
  --bg: #121212;
  --ink: #fbfaf7;
}

/* retro film grain over the dark home background; inline SVG turbulence,
   sits above the bg but below the hero (z-index:2) and never traps clicks */
body[data-page="home"]::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.13;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Archivo", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- page transition overlay ---------- */

.page-transition {
  position: fixed;
  inset: 0;
  background: var(--green);
  z-index: 10;
  transform: scaleY(0);
  transform-origin: top;
  pointer-events: none;
}

/* When arriving via a transition, the incoming page is painted fully
   covered in green from the very first frame (class set by an inline
   <head> script) so the destination never flashes before GSAP runs. */
html.is-entering .page-transition {
  transform: scaleY(1);
  transform-origin: bottom;
  /* CSS-only fallback: if GSAP/main.js never executes (CDN failure, JS
     error), the overlay still retracts on its own. The delay is long
     enough that GSAP normally takes over and removes the class first. */
  animation: ll-overlay-retract 0.7s cubic-bezier(0.76, 0, 0.24, 1) 1.4s forwards;
}

@keyframes ll-overlay-retract {
  from { transform: scaleY(1); }
  to { transform: scaleY(0); }
}

/* ---------- corner navigation ---------- */

.corner {
  position: fixed;
  z-index: 5;
}

.corner--tr { top: calc(var(--pad) + env(safe-area-inset-top)); right: calc(var(--pad) + env(safe-area-inset-right)); }
.corner--tl { top: calc(var(--pad) + env(safe-area-inset-top)); left: calc(var(--pad) + env(safe-area-inset-left)); }
.corner--bl { bottom: calc(var(--pad) + env(safe-area-inset-bottom)); left: calc(var(--pad) + env(safe-area-inset-left)); }
.corner--br { bottom: calc(var(--pad) + env(safe-area-inset-bottom)); right: calc(var(--pad) + env(safe-area-inset-right)); }

.nav-link {
  position: relative;
  display: inline-block;
  padding: 0.5rem 0.25rem; /* generous touch target */
  font-size: var(--nav-size);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.35s ease;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0.25rem;
  right: 0.25rem;
  bottom: 0.2rem;
  height: 1px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--green);
}

.nav-link:hover::after,
.nav-link:focus-visible::after {
  transform: scaleX(1);
}

.nav-link:focus-visible {
  outline: 1px solid var(--green);
  outline-offset: 4px;
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 var(--pad);
}

.hero__stack {
  position: relative;
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.hero__title {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  font-size: clamp(3.4rem, 12vw, 8.5rem);
  font-weight: 300;
  letter-spacing: 0.02em;
  line-height: 1.05;
  user-select: none;
}

/* thin green copy stacked on the title; hover crossfades between the two
   so weight and colour appear to morph without any per-frame reflow */
.hero__title--ghost {
  position: absolute;
  inset: 0;
  color: var(--green);
  font-weight: 230;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.hero__word {
  display: inline-flex;
  white-space: nowrap;
}

.char {
  display: inline-block;
  will-change: transform;
}

.hero__rule {
  width: clamp(3.5rem, 8vw, 5.5rem);
  height: 1px;
  margin-top: clamp(1.5rem, 4vh, 2.75rem);
  background: var(--green);
  transform: scaleX(0);
}

/* ---------- inner (blank) pages ---------- */

.inner {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 var(--pad);
  text-align: center;
}

.inner__title {
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  font-weight: 300;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.inner__rule {
  width: clamp(2.5rem, 6vw, 4rem);
  height: 1px;
  margin-top: clamp(1.25rem, 3vh, 2rem);
  background: var(--green);
  transform: scaleX(0);
}

.inner__hint {
  margin-top: clamp(1.25rem, 3vh, 2rem);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: rgba(18, 18, 18, 0.45);
}

/* ---------- globe gallery (projects) ---------- */

.globe-viewport {
  position: fixed;
  inset: 0;
  z-index: 1;
  perspective: 1100px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.globe-viewport.is-dragging {
  cursor: grabbing;
}

.globe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  transform-style: preserve-3d;
  will-change: transform;
}

.globe-card {
  --card-w: clamp(169px, 19.4vw, 278px);
  --card-h: calc(var(--card-w) * 0.75 + 5.5rem);
  position: absolute;
  left: 0;
  top: 0;
  width: var(--card-w);
  height: var(--card-h);
  margin-left: calc(var(--card-w) * -0.5);
  margin-top: calc(var(--card-h) * -0.5);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  cursor: pointer;
}

.globe-card__media {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #e7e9e0;
}

.globe-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.globe-card:hover .globe-card__media img {
  transform: scale(1.05);
}

.globe-card__caption {
  padding-top: 0.6rem;
}

.globe-card__caption h3 {
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  transition: color 0.35s ease;
}

.globe-card:hover .globe-card__caption h3 {
  color: var(--green);
}

.globe-card__caption p {
  margin-top: 0.2rem;
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: rgba(18, 18, 18, 0.55);
}

/* ---------- category selector ---------- */

/* full-width strip so the toggle centers without a transform (a transformed
   ancestor would trap the fixed overlay); empty areas let globe drags pass */
.cat-select {
  position: fixed;
  top: var(--pad);
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.cat-select__toggle {
  font-family: inherit;
  font-size: var(--nav-size);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0.5rem 0.25rem;
  cursor: pointer;
  position: relative;
  z-index: 5;
  pointer-events: auto;
  transition: color 0.35s ease;
}

.cat-select__toggle::after {
  content: "";
  position: absolute;
  left: 0.25rem;
  right: 0.25rem;
  bottom: 0.2rem;
  height: 1px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.cat-select__toggle:hover,
.cat-select__toggle:focus-visible,
.cat-select[data-open="true"] .cat-select__toggle {
  color: var(--green);
}

.cat-select__toggle:hover::after,
.cat-select__toggle:focus-visible::after,
.cat-select[data-open="true"] .cat-select__toggle::after {
  transform: scaleX(1);
}

.cat-select__toggle:focus-visible {
  outline: 1px solid var(--green);
  outline-offset: 4px;
}

/* open: full-screen overlay; globe stays visible behind */
.cat-select__menu {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.75rem, 2.5vh, 1.75rem);
  background: rgba(251, 250, 247, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: auto;
}

.cat-select__menu[hidden] {
  display: none;
}

.cat-select__option {
  font-family: inherit;
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  font-weight: 300;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0.1em 0.25em;
  cursor: pointer;
  position: relative;
  transition: color 0.35s ease;
}

.cat-select__option:hover,
.cat-select__option:focus-visible {
  color: var(--green);
}

.cat-select__option:focus-visible {
  outline: 1px solid var(--green);
  outline-offset: 4px;
}

/* ---------- projects category intro ---------- */

.projcat {
  margin: auto auto auto clamp(1.5rem, 6vw, 7rem);
}

.projcat__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: clamp(0.3rem, 1vh, 0.9rem);
}

.projcat__item {
  font-family: inherit;
  font-size: clamp(3.4rem, 12vw, 8.5rem);
  font-weight: 300;
  letter-spacing: 0.01em;
  text-transform: lowercase;
  line-height: 1.05;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: inline-block;
  transition: color 0.4s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.projcat__item:hover,
.projcat__item:focus-visible {
  color: var(--green);
  transform: translateX(clamp(1.5rem, 4vw, 3.5rem));
}

.projcat__item:focus-visible {
  outline: none;
}

/* "projects" corner button reuses the nav-link look but resets the
   native <button> chrome */
.nav-link--btn {
  font-family: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

/* WebGL image stack revealed on category hover (three.js canvas host) */
.projstack {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.projstack canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* view switching: category intro vs. the filtered list */
body[data-view="categories"] .projlist__items,
body[data-view="categories"] .projlist__stage,
body[data-view="categories"] [data-cat-back] {
  display: none;
}

body[data-view="list"] .projcat,
body[data-view="list"] .projstack {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .projcat__item {
    transition: color 0.4s ease;
  }
  .projcat__item:hover,
  .projcat__item:focus-visible {
    transform: none;
  }
}

/* ---------- projects list view ---------- */

.projlist {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding-block: max(var(--pad), 4.5rem);
  scrollbar-width: none;
}

.projlist::-webkit-scrollbar {
  display: none;
}

/* centered image revealed on hover, sitting behind the list */
.projlist__stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

.projlist__stage.is-visible {
  opacity: 1;
}

.projlist__img {
  width: min(39vw, 570px);
  height: auto;
}

.projlist__items {
  position: relative;
  z-index: 2;
  list-style: none;
  /* margin-block:auto centers the list when it fits and, unlike flex
     centering, keeps the overflowing ends reachable by scroll */
  margin: auto auto auto clamp(1.5rem, 6vw, 7rem);
}

.projlist__item {
  line-height: 1.08;
}

.projlist__link {
  display: inline-flex;
  align-items: flex-start;
  gap: clamp(0.6rem, 1.4vw, 1.1rem);
  text-decoration: none;
  color: var(--ink);
  transition: color 0.35s ease;
}

.projlist__num {
  font-size: clamp(0.6rem, 0.85vw, 0.8rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--green);
  padding-top: 0.55em;
}

.projlist__title {
  font-size: clamp(2.2rem, 8vw, 5rem);
  font-weight: 300;
  letter-spacing: 0.01em;
  text-transform: lowercase;
}

.projlist__item.is-active .projlist__link,
.projlist__link:hover,
.projlist__link:focus-visible {
  color: var(--green);
}

.projlist__link:focus-visible {
  outline: 1px solid var(--green);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .projlist__stage {
    transition: none;
  }
}

/* ---------- project detail template ---------- */

body.page--scroll {
  overflow-y: auto;
  overflow-x: hidden;
}

.project {
  position: relative;
  z-index: 2;
  max-width: 1080px;
  margin: 0 auto;
  padding: max(calc(var(--pad) * 3.2), 6.5rem) var(--pad) calc(var(--pad) * 2 + env(safe-area-inset-bottom) + 3rem);
}

/* hero: first image on the left, vertically centered with the text */
.project__intro {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* match the gallery gap so the hero image renders at the same width
     as the gallery images (equal columns => identical image box) */
  gap: clamp(1rem, 2.5vw, 2rem);
  align-items: center;
}

.project__text {
  align-self: center;
}

.project__title {
  margin: 0 0 1.5rem;
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  font-weight: 300;
  letter-spacing: 0.02em;
  line-height: 1.05;
}

/* all project images share one fixed box so they line up uniformly */
.project__media {
  width: 100%;
  display: flex;
  justify-content: flex-start;
}

.project__media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.project__body {
  max-width: 62ch;
  margin-top: 2.5rem;
  font-size: 0.95rem;
  line-height: 1.7;
  color: rgba(18, 18, 18, 0.75);
}

.project__body p + p {
  margin-top: 1.2em;
}

.project__gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(1rem, 2.5vw, 2rem);
  margin-top: 2.5rem;
  /* don't stretch cells to the tallest in a row, or shorter images would
     be distorted to match */
  align-items: start;
}

/* gallery images use the same fixed box as the hero */
.project__media--gallery img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  align-self: start;
}

@media (max-width: 860px) {
  .project__intro {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

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

/* ---------- about page ---------- */

.about {
  position: relative;
  z-index: 2;
  max-width: 1080px;
  margin: 0 auto;
  padding: max(calc(var(--pad) * 3.2), 6.5rem) var(--pad) calc(var(--pad) * 3 + env(safe-area-inset-bottom) + 3rem);
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

@media (min-width: 900px) {
  .about {
    grid-template-columns: 5fr 6fr;
    gap: clamp(3rem, 6vw, 5.5rem);
    align-items: start;
  }
}

.about__media {
  overflow: hidden;
  background: #e7e9e0;
}

.about__media img {
  display: block;
  width: 100%;
  height: auto;
}

.about__meta {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
}

.about__lead {
  margin: 0.75rem 0 2rem;
  font-size: clamp(1.45rem, 2.6vw, 2.1rem);
  font-weight: 300;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.about__body {
  max-width: 58ch;
  font-size: 0.95rem;
  line-height: 1.7;
  color: rgba(18, 18, 18, 0.75);
}

.about__body p + p {
  margin-top: 1.2em;
}

.about__clients {
  margin-top: 2.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(18, 18, 18, 0.12);
}

.about__clients h2 {
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
}

.about__clients p {
  margin-top: 0.7rem;
  max-width: 58ch;
  font-size: 0.95rem;
  line-height: 1.7;
  color: rgba(18, 18, 18, 0.75);
}

/* ---------- contact page ---------- */

.contact {
  position: relative;
  z-index: 2;
  max-width: 1080px;
  margin: 0 auto;
  padding: max(calc(var(--pad) * 3.2), 6.5rem) var(--pad) calc(var(--pad) * 3 + env(safe-area-inset-bottom) + 3rem);
  min-height: 70vh;
}

.contact__meta {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
}

.contact__lead {
  margin: 0.75rem 0 2.75rem;
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 300;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.contact__details {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.contact__block {
  font-style: normal;
  font-size: 0.95rem;
  line-height: 1.9;
  color: rgba(18, 18, 18, 0.75);
}

.contact__link {
  position: relative;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.35s ease;
}

.contact__link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.contact__link--green {
  color: var(--green);
}

.contact__link:hover,
.contact__link:focus-visible {
  color: var(--green);
}

.contact__link:hover::after,
.contact__link:focus-visible::after {
  transform: scaleX(1);
}

.contact__cvr {
  flex-basis: 100%;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: rgba(18, 18, 18, 0.45);
}

.contact__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 3.25rem;
}

.btn {
  position: relative;
  z-index: 0;
  display: inline-block;
  padding: 0.9rem 1.8rem;
  overflow: hidden;
  border: 1px solid var(--ink);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  transition: color 0.35s ease, border-color 0.35s ease;
}

/* green fill sweeps up from the bottom on hover */
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--green);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn:hover,
.btn:focus-visible {
  color: var(--bg);
  border-color: var(--green);
}

.btn:hover::before,
.btn:focus-visible::before {
  transform: scaleY(1);
}

.btn:focus-visible {
  outline: 1px solid var(--green);
  outline-offset: 4px;
}

.btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.95rem;
}

.btn--icon svg {
  display: block;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn--icon:hover svg,
.btn--icon:focus-visible svg {
  transform: translateY(-1px) scale(1.05);
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .hero__rule,
  .inner__rule {
    transform: none;
  }
  .nav-link,
  .nav-link::after {
    transition: none;
  }
}

/* ---------- small screens ---------- */

@media (max-width: 480px) {
  .hero__title {
    letter-spacing: 0.01em;
  }
}