/* ─── Fonts ─────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Ronzino';
  src: url('brand_assets/fonts/Ronzino-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Ronzino';
  src: url('brand_assets/fonts/Ronzino-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ─── Tokens ────────────────────────────────────────────────────────────── */
:root {
  --bg: #fffbf2;
  --ink: #070707;
  --ink-muted: rgba(25, 25, 25, 0.7);
  --paper: #ffffff;
  --placeholder: #d9d9d9;
  --fade-rgb: 255, 253, 249;
  --card-shadow: drop-shadow(-10px 6px 16px rgba(20, 14, 4, 0.22));
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}
[data-theme='dark'] {
  --bg: #191919;
  --ink: #e2e0d9;
  --ink-muted: rgba(226, 224, 217, 0.65);
  --paper: #f5f2ea;
  --placeholder: #d9d9d9;
  --fade-rgb: 25, 25, 25;
  --card-shadow: drop-shadow(-10px 6px 18px rgba(0, 0, 0, 0.55));
}

/* ─── Base ──────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Ronzino', 'Neue Haas Grotesk Display Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 20px;
  min-height: 100%;
  transition: background-color 0.4s ease;
  -webkit-font-smoothing: antialiased;
}
body[data-view='home'] { overflow: hidden; height: 100%; }
img { display: block; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
a { color: inherit; text-decoration: none; }
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
  border-radius: 2px;
}
.inline-svg svg { display: block; width: 100%; height: 100%; }
.inline-svg { color: var(--ink); }

/* ─── Header chrome ─────────────────────────────────────────────────────── */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: 96px;
  z-index: 60;
  pointer-events: none;
}
.site-header > * { pointer-events: auto; }
.logo {
  position: absolute;
  left: 37px;
  top: 37px;
  width: 54px;
  height: 32px;
}
.logo .inline-svg { width: 100%; height: 100%; }

.nav {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(calc(-50% - 13px));
  width: 314px;
  height: 90px;
}
.nav-link { position: absolute; }
.nav-link .inline-svg { width: 100%; height: 100%; }
.nav-pd { left: 0; top: 35px; width: 151px; height: 41px; }
.nav-dr { left: 213px; top: 36px; width: 101px; height: 47px; }
.nav-link { transition: opacity 0.25s ease, transform 0.25s var(--ease-spring); }
.nav-link:hover { opacity: 0.65; }
.nav-link:active { transform: scale(0.96); }
.nav-circle {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.nav-circle.is-active { opacity: 1; }
.nav-circle-pd { left: -18px; top: 28px; width: 192px; height: 47px; }
.nav-circle-dr { left: 206px; top: 26px; width: 117px; height: 47px; }

.clock-box {
  position: absolute;
  right: 28px;
  top: 22px;
  display: flex;
  align-items: flex-start;
  gap: 15px;
}
.clock-doodle { width: 39px; height: 37px; }
.clock-text { padding-top: 10px; font-size: 20px; white-space: nowrap; }

.theme-toggle {
  position: absolute;
  right: 28px;
  top: 64px;
  font-size: 13px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  transition: color 0.2s ease, transform 0.2s var(--ease-spring);
}
.theme-toggle:hover { color: var(--ink); }
.theme-toggle:active { transform: scale(0.94); }

/* ─── Footer chrome ─────────────────────────────────────────────────────── */
.site-footer {
  position: fixed;
  inset: auto 0 0 0;
  height: 48px;
  z-index: 60;
  pointer-events: none;
}
.site-footer > * { pointer-events: auto; }
body[data-view='project'] .site-footer { display: none; }
.foot-left {
  position: absolute;
  left: 37px;
  bottom: 11px;
  font-size: 20px;
  white-space: nowrap;
}
body[data-view='grid'] .foot-left { left: 26px; }
.view-toggle {
  position: absolute;
  right: 31px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 20px;
  transition: opacity 0.25s ease, transform 0.25s var(--ease-spring);
}
.view-toggle:hover { opacity: 0.65; }
.view-toggle:active { transform: scale(0.97); }
.view-toggle .inline-svg { width: 30px; height: 24px; }

/* ─── Home: 3D deck ─────────────────────────────────────────────────────── */
#view-home {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1440px;
  height: 900px;
  translate: -50% -50%;
  transform: scale(var(--stage-scale, 1));
}
.deck-card {
  position: absolute;
  width: 278px;
  height: 425px;
  transform-origin: center;
  filter: var(--card-shadow);
  will-change: transform;
  cursor: none;
}
.deck-card .skew {
  width: 100%;
  height: 100%;
  transform: rotate(-0.42deg) skewY(11.43deg);
  overflow: hidden;
  background: var(--placeholder);
}
#deck { transition: opacity 0.22s ease; }
#deck.is-swapping { opacity: 0; }
.deck-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}
.deck-card.is-drawing .skew { background: #ffffff; }

/* edge fades along the deck diagonal (cream → transparent), per Figma */
.stage-fade { position: absolute; inset: 0; pointer-events: none; }
.stage-fade-a {
  background: linear-gradient(64deg, rgb(var(--fade-rgb)) 1%, rgba(var(--fade-rgb), 0) 26%);
}
.stage-fade-b {
  background: linear-gradient(244deg, rgb(var(--fade-rgb)) 4%, rgba(var(--fade-rgb), 0) 30%);
}

/* ─── Grid view ─────────────────────────────────────────────────────────── */
#view-grid {
  max-width: 1440px;
  margin: 0 auto;
  padding: 194px 24px 140px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 16px;
  row-gap: 55px;
}
.grid-cell { display: block; text-align: left; }
.grid-cell .thumb {
  width: 100%;
  aspect-ratio: 336 / 424;
  overflow: hidden;
  background: var(--placeholder);
}
.grid-cell.is-drawing .thumb { background: #ffffff; }
.grid-cell.is-drawing img { object-fit: cover; }
.grid-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s var(--ease-spring);
}
.grid-cell .caption {
  margin-top: 9px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.grid-cell { transition: opacity 0.35s ease; cursor: none; }
.grid.has-hover .grid-cell:not(:hover) { opacity: 0.15; }
.grid-cell:hover img { transform: scale(1.03); }
.bottom-fade {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 130px;
  pointer-events: none;
  background: linear-gradient(to top, rgb(var(--fade-rgb)) 20%, rgba(var(--fade-rgb), 0));
  z-index: 40;
}

/* ─── Drawing lightbox ──────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: flex-start;
  justify-content: center;
}
.lightbox.is-open { display: flex; }
.lightbox.is-open .lightbox-backdrop { animation: lbFade 0.3s ease both; }
.lightbox.is-open .lightbox-paper { animation: lbPop 0.45s var(--ease-spring) both; }
.lightbox.is-open .lightbox-close { animation: lbFade 0.45s ease both; }
@keyframes lbFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes lbPop {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to { opacity: 1; transform: none; }
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(var(--fade-rgb), 0.92);
}
.lightbox-paper {
  position: relative;
  margin-top: 127px;
  width: 553px;
  height: 668px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center;
}
.lightbox-paper img {
  max-width: 86%;
  max-height: 88%;
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 127px;
  left: calc(50% + 308px);
  width: 21px;
  height: 23px;
  color: var(--ink);
}
.lightbox-close:hover { opacity: 0.6; }
.lightbox-close:active { transform: scale(0.9); }

/* ─── Project detail ────────────────────────────────────────────────────── */
#view-project {
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
}
.project-title {
  margin: 224px 24px 0;
  max-width: 923px;
  font-size: 72px;
  font-weight: 400;
  letter-spacing: -1.44px;
  text-transform: capitalize;
  line-height: 1.28;
}
.project-tags {
  display: flex;
  gap: 29px;
  margin: 14px 27px 0;
  color: var(--ink-muted);
  font-size: 20px;
}
.project-text {
  margin: 77px 27px 0;
  font-size: 32px;
  line-height: 1.2;
  max-width: 1389px;
}
.project-hero {
  margin: 45px 23px 0;
  height: 804px;
  background: var(--placeholder);
  overflow: hidden;
}
.project-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 25px;
  margin: 24px 23px 0;
}
.project-pair .pair-img {
  height: 855px;
  background: var(--placeholder);
  overflow: hidden;
}
.project-hero img,
.project-pair img { width: 100%; height: 100%; object-fit: cover; }
.project-text + .project-hero { margin-top: 45px; }
.project-pair + .project-text { margin-top: 131px; }
.view-all {
  display: block;
  margin: 179px auto 0;
  font-size: 20px;
  text-align: center;
  transition: opacity 0.25s ease;
}
.view-all:hover { opacity: 0.6; }
.project-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 218px 21px 0 21px;
  padding-bottom: 15px;
  font-size: 20px;
}

/* scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s var(--ease-spring);
}
.reveal.is-in { opacity: 1; transform: none; }

/* ─── Hand cursor ───────────────────────────────────────────────────────── */
.hand-cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 32px;
  height: 50px;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: var(--ink);
}
.hand-cursor.is-on { opacity: 1; }

/* ─── FLIP morph layer ──────────────────────────────────────────────────── */
.flip-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}
.flip-ghost {
  position: absolute;
  overflow: hidden;
  transform-origin: top left;
}
.flip-ghost img { width: 100%; height: 100%; object-fit: cover; }

/* ─── View switching ────────────────────────────────────────────────────── */
.view { display: none; }
.view.is-active { display: block; }
#view-home.view.is-active { display: block; }
.view-fade { animation: viewFade 0.45s ease both; }
@keyframes viewFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  body { font-size: 16px; }
  .logo { left: 20px; top: 24px; width: 44px; height: 26px; }
  .nav {
    top: 48px;
    transform: translateX(-50%) scale(0.78);
    transform-origin: top center;
  }
  .site-header { height: 140px; }
  .clock-box { right: 16px; top: 18px; gap: 8px; }
  .clock-doodle { width: 30px; height: 28px; }
  .clock-text { font-size: 15px; padding-top: 7px; }
  .theme-toggle { right: 16px; top: 52px; }
  .foot-left { left: 20px; bottom: 12px; font-size: 15px; }
  .view-toggle { right: 16px; bottom: 10px; font-size: 15px; gap: 8px; }
  .view-toggle .inline-svg { width: 24px; height: 19px; }

  #view-grid { padding: 120px 16px 110px; }
  .grid { grid-template-columns: repeat(2, 1fr); column-gap: 12px; row-gap: 24px; }
  .grid-cell .caption { font-size: 12px; }
  .grid.has-hover .grid-cell:not(:hover) { opacity: 1; }

  .lightbox-paper {
    margin-top: 14vh;
    width: min(86vw, 553px);
    height: min(64vh, 668px);
  }
  .lightbox-close { left: auto; right: 5vw; top: 14vh; }

  .project-title { margin: 140px 20px 0; font-size: 40px; letter-spacing: -0.8px; }
  .project-tags { margin: 12px 20px 0; font-size: 15px; gap: 18px; }
  .project-text { margin: 44px 20px 0; font-size: 20px; line-height: 1.35; }
  .project-hero { margin: 28px 16px 0; height: 56vw; }
  .project-pair { grid-template-columns: 1fr; gap: 16px; margin: 16px 16px 0; }
  .project-pair .pair-img { height: 110vw; }
  .project-pair + .project-text { margin-top: 64px; }
  .view-all { margin-top: 90px; }
  .project-footer { margin: 110px 16px 0; padding-bottom: 14px; font-size: 15px; }
  .deck-card { cursor: pointer; }
  .grid-cell { cursor: pointer; }
  .hand-cursor { display: none; }
}

/* ─── Reduced motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
