:root {
  --bg: #000;
  --fg: #fff;
  --side: 30px;
  --radius: 48px;
  --card-shadow: inset 0 2.012px 4.024px rgba(255, 255, 255, 0.25);
  --max: 800px;
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); color-scheme: dark; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video { display: block; max-width: 100%; }
p { margin: 0; }

/* ---------- Header (morphs on scroll, driven by main.js) ---------- */

/* No pinned full-width bar and no fill: Safari 26 turns a fixed/sticky element spanning the
   top of the viewport into an opaque status-bar zone. Instead two small pinned clusters:
   the social icons (left) and a 0×0 anchor in the top-right corner for avatar + name.
   Nothing pinned touches the very top edge (the anchor sits 12px down and clips above 4px). */
.header { pointer-events: none; }

.header__social {
  position: fixed;
  top: 32px;
  left: 24px;
  z-index: 10;
  display: flex;
  gap: 16px;
  pointer-events: auto;
  transform: translateZ(0); /* own compositing layer: iOS Safari can drop un-composited fixed elements */
  will-change: transform;
}

/* Compact-header backdrop from the Figma frame "Gradient + Blur": a 210px black gradient
   (38% → 0) plus a progressive background blur (Figma 20 ≈ CSS 10px at the top, fading out
   by 121px). It starts 80px above the viewport so it also covers the zone under the status bar.
   Not fixed/sticky on purpose: Safari 26 turns a pinned full-width element into an opaque
   status bar. main.js pins it with a scroll-driven translateY instead (fixed is only the
   fallback for browsers without ScrollTimeline). */
.header__bg {
  position: absolute;
  top: -80px;
  left: 0;
  right: 0;
  height: 290px;
  z-index: 9;
  pointer-events: none;
  will-change: transform; /* no opacity/filter here: that would isolate the children's backdrop-filter */
}
.no-scroll-timeline .header__bg { position: fixed; }

.header__bg > * { position: absolute; inset: 0; opacity: 0; will-change: opacity; }

.header__fade { background: linear-gradient(180deg, rgba(0,0,0,.384) 0px, rgba(0,0,0,0.384) 80.0px, rgba(0,0,0,0.376) 101.0px, rgba(0,0,0,0.376) 113.6px, rgba(0,0,0,0.368) 126.2px, rgba(0,0,0,0.352) 138.8px, rgba(0,0,0,0.328) 151.4px, rgba(0,0,0,0.296) 164.0px, rgba(0,0,0,0.256) 176.6px, rgba(0,0,0,0.216) 189.2px, rgba(0,0,0,0.168) 201.8px, rgba(0,0,0,0.128) 214.4px, rgba(0,0,0,0.088) 227.0px, rgba(0,0,0,0.056) 239.6px, rgba(0,0,0,0.032) 252.2px, rgba(0,0,0,0.018) 264.8px, rgba(0,0,0,0.009) 277.4px, rgba(0,0,0,0) 290.0px); }

.header__blur {
  -webkit-backdrop-filter: blur(var(--b));
          backdrop-filter: blur(var(--b));
  -webkit-mask-image: linear-gradient(180deg, #000 var(--solid), transparent var(--end));
          mask-image: linear-gradient(180deg, #000 var(--solid), transparent var(--end));
}
/* stacked bands approximate the progressive blur: strongest at the top, gone at ~121px */
.header__blur--1 { --b: 8px; --solid: 100px; --end: 140px; }
.header__blur--2 { --b: 5px; --solid: 140px; --end: 175px; }
.header__blur--3 { --b: 2px; --solid: 175px; --end: 201px; }

.header__id {
  position: fixed;
  top: 12px;
  right: 0;
  width: 0;
  height: 0;
  z-index: 10;
  pointer-events: none;
  clip-path: polygon(-4000px -8px, 1000px -8px, 1000px 4000px, -4000px 4000px);
}

.social { display: block; width: 44px; height: 44px; border-radius: 12px; }
.social:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Avatar, glow and name are anchored to the top-right corner;
   main.js moves them with transform only. */
.avatar, .avatar-glow, .name__word, .role {
  position: absolute;
  top: 0;
  right: 0;
  transform-origin: 100% 0;
  will-change: transform;
}

.avatar {
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  transform: translate(-31px, 20px);
}
/* The visible circle (photo + rim light). It is what scales on press/hover, around its own
   centre; the outer .avatar only carries the scroll-driven morph transform. */
.avatar__inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar__inner::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 2.012px 4.024px rgba(255,255,255,.25),
    inset 0 -0.402px 3.906px rgba(255,255,255,.65),
    inset 0 1.006px 0 -6.036px rgba(255,255,255,.3);
  pointer-events: none;
}

/* Pre-blurred bitmap exported from Figma at 2x (586 px → 293 css px, 40% opacity baked in).
   The 135px avatar box sits in its centre with a 79px margin; the transform origin is
   that box's top-right corner. A live CSS blur scaled every frame is expensive on iOS. */
.avatar-glow {
  width: 293px;
  height: 293px;
  max-width: none;
  transform-origin: 214px 79px;
  transform: translate(63px, -51px);
}

.name {
  margin: 0;
  font-weight: 700;
  font-size: 24px;
  line-height: normal;
  letter-spacing: -0.08em;
  white-space: nowrap;
}
.name__word { display: block; }

.role {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: normal;
  white-space: nowrap;
  transform: translate(-31px, 162.5px);
}

/* ---------- Content ---------- */

.main {
  padding: 276px 0 max(40px, calc(50vh - 135px)); /* scrolled to the end, the link cards (270px) sit mid-screen */
}

.hero {
  margin: 0 auto;
  padding: 0 20px;
  max-width: calc(var(--max) + 40px);
  font-size: min(30px, 7.7vw); /* fixed line breaks must fit narrow phones */
  font-weight: 700;
  line-height: normal;
  letter-spacing: -0.08em;
}
.hero__line { display: block; }
.nw { white-space: nowrap; }
.hero__line + .hero__line { margin-top: 32px; }

.projects {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 56px;
  column-gap: var(--side);
  margin: 81px auto 0;
  padding: 0 var(--side);
  max-width: calc(var(--max) + var(--side) * 2);
}

.project__media {
  position: relative;
  aspect-ratio: 332 / 581;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0d0d0d;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  --persp: 1500px; /* tall card: deeper perspective so the tilt reads like the small cards */
  -webkit-mask-image: -webkit-radial-gradient(white, black); /* forces Safari to clip composited children to the radius */
          mask-image: radial-gradient(white, black);
}
.project__media--static { cursor: default; }
.project__media::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--card-shadow);
  pointer-events: none;
}
.project__media video,
.project__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Safari draws <video> on its own compositing layer and ignores the parent's rounded
     overflow clip once the parent has a 3D transform (the tilt). Round and clip the video
     itself, and mask the card (below) so the layer is clipped too. */
  border-radius: inherit;
  clip-path: inset(0 round var(--radius));
}
.project__media:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

.project__title {
  margin: 24px 0 0;
  font-size: 24px;
  line-height: 24px;
  font-weight: 700;
}

.project__text {
  margin-top: 8px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
}
.project__text b { font-weight: 700; }
.hl { color: #0e0; }

.project__year {
  margin-top: 8px;
  font-size: 12px;
  line-height: normal;
  letter-spacing: -0.03em;
  color: rgba(255, 255, 255, .5);
}

@media (min-width: 600px) {
  .projects { grid-template-columns: 1fr 1fr; gap: 50px; }
  /* odd last project sits centred on its own row */
  .project:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc((100% - 50px) / 2);
  }
}

/* ---------- Slot machine ---------- */

.slot {
  --cell: 70px;
  display: flex;
  justify-content: center;
  gap: 13px;
  margin: 204px auto 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: 700 50px/var(--cell) var(--font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.slot:focus-visible { outline: 2px solid #fff; outline-offset: 8px; border-radius: 12px; }
.slot__reel {
  display: block;
  width: 1.2em;
  height: var(--cell);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
          mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}
.slot__strip { display: flex; flex-direction: column; will-change: transform; }
.slot__strip > span { display: block; height: var(--cell); text-align: center; }
.slot.is-win .slot__reel { animation: win .5s cubic-bezier(.3,1.6,.5,1) both; }
.slot.is-win .slot__reel:nth-child(2) { animation-delay: .05s; }
.slot.is-win .slot__reel:nth-child(3) { animation-delay: .1s; }
.slot.is-win .slot__reel:nth-child(4) { animation-delay: .15s; }
@keyframes win { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* Jackpot (every 5th spin): the whole machine shakes and pulses for a second */
.slot.is-jackpot { animation: jackpot 1.1s cubic-bezier(.36, .07, .19, .97) both; }
.slot.is-jackpot .slot__reel { animation: win .5s cubic-bezier(.3,1.6,.5,1) 3 alternate both; }
@keyframes jackpot {
  0%, 100% { transform: none; }
  8%  { transform: translateX(-6px) rotate(-3deg) scale(1.06); }
  16% { transform: translateX(6px)  rotate(3deg)  scale(1.1); }
  24% { transform: translateX(-6px) rotate(-3deg) scale(1.1); }
  32% { transform: translateX(6px)  rotate(3deg)  scale(1.1); }
  40% { transform: translateX(-5px) rotate(-2deg) scale(1.08); }
  48% { transform: translateX(5px)  rotate(2deg)  scale(1.08); }
  56% { transform: translateX(-4px) rotate(-1.5deg) scale(1.05); }
  64% { transform: translateX(4px)  rotate(1.5deg)  scale(1.05); }
  72% { transform: translateX(-2px) rotate(-.5deg) scale(1.02); }
  80% { transform: translateX(2px)  rotate(.5deg)  scale(1.02); }
}

/* ---------- Social link cards (tilt on scroll, driven by main.js) ---------- */

.links {
  display: grid;
  grid-template-columns: repeat(2, 160px);
  max-width: calc(337px * 2 + 30px + var(--side) * 2);
  justify-content: center;
  gap: 12px;
  margin: 135px auto 0;
  padding: 0 var(--side);
}

.link-card {
  position: relative;
  display: block;
  height: 270px;
  border-radius: 36px;
  overflow: hidden;
  isolation: isolate;
  background: rgba(255, 255, 255, .05);
  color: #fff;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.link-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, .25);
  pointer-events: none;
}
.link-card:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

.link-card__img {
  position: absolute;
  left: 50%;
  margin-left: calc(var(--w) / -2);
  width: var(--w);
  height: 146px;
  object-fit: cover;
  mix-blend-mode: lighten; /* the renders sit on pure black: let the card background show through */
}
.link-card__img--insta { --w: 122px; top: 33px; }
.link-card__img--linkedin { --w: 134px; top: 30px; }

.link-card__text {
  position: absolute;
  top: 193px;
  left: 50%;
  width: 156px;
  margin-left: -78px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 700;
  text-align: center;
}
.link-card__text s {
  text-decoration-color: #0e0;
  text-decoration-thickness: 3px;
}

/* Below 600px the 160×270 Figma card scales as a whole when two of them don't fit (≈ <365px):
   everything inside is expressed in container units of the card's own width (100cqi = 160px
   at full size), so image, text, strike-through and corners shrink together. */
@media (max-width: 599px) {
  .links {
    grid-template-columns: repeat(2, minmax(0, 160px));
    padding: 0 16px;
  }
  .link-card {
    container-type: inline-size;
    height: auto;
    aspect-ratio: 160 / 270;
    border-radius: 22.5% / 13.333%; /* 36px at 160×270 */
  }
  .link-card__img { height: 91.25cqi; }                            /* 146 */
  .link-card__img--insta { --w: 76.25cqi; top: 20.625cqi; }        /* 122, 33 */
  .link-card__img--linkedin { --w: 83.75cqi; top: 18.75cqi; }      /* 134, 30 */
  .link-card__text {
    top: 120.625cqi;                                               /* 193 */
    width: 97.5cqi;                                                /* 156 */
    margin-left: -48.75cqi;
    font-size: 10cqi;                                              /* 16 */
    line-height: 15cqi;                                            /* 24 */
  }
  .link-card__text s { text-decoration-thickness: 1.875cqi; }      /* 3 */
}

/* From 600px: wider cards (Figma "Frame 2": 337px each, 30px apart), content stays centred */
@media (min-width: 600px) {
  .links { grid-template-columns: repeat(2, minmax(0, 337px)); gap: 30px; }
}

/* soft specular highlight that slides with the tilt */
.link-card__shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120% 70% at calc(50% + var(--ry) * 4%) calc(30% - var(--rx) * 4%),
    rgba(255, 255, 255, .10), rgba(255, 255, 255, 0) 60%);
  mix-blend-mode: screen;
}


/* ---------- Tilt + press (shared) ---------- */

/* Registered so it can be transitioned: drives the press scale with a bounce. */
@property --press { syntax: '<number>'; inherits: false; initial-value: 1; }

/* Cards that tilt on scroll (main.js sets --rx/--ry in degrees). The transform also keeps
   rounded clipping on Safari during video playback. */
.tilt {
  --rx: 0;
  --ry: 0;
  --persp: 700px;
  transform: perspective(var(--persp)) rotateX(calc(var(--rx) * 1deg)) rotateY(calc(var(--ry) * 1deg)) scale(var(--press));
  will-change: transform;
}

/* Every tappable element: shrinks to .95 on press, springs back with an overshoot. */
.press {
  -webkit-tap-highlight-color: transparent;
  transition: --press .6s cubic-bezier(.3, 2.2, .45, 1), opacity .2s;
}
.press:not(.tilt) { scale: var(--press); } /* `scale` composes with `transform` (owned by the header morph on .avatar) */

/* Hover (mouse only): grow 5% with the same bounce */
@media (hover: hover) and (pointer: fine) {
  .press:hover { --press: 1.05; }
}
.press.is-pressed {
  --press: .95;
  transition: --press .14s cubic-bezier(.3, 0, .5, 1), opacity .2s;
}

/* Specular highlight that slides with the tilt (video cards; link cards have their own span). */
.project__media.tilt::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120% 60% at calc(50% + var(--ry) * 4%) calc(25% - var(--rx) * 4%),
    rgba(255, 255, 255, .08), rgba(255, 255, 255, 0) 60%);
  mix-blend-mode: screen;
}

@media (prefers-reduced-motion: reduce) {
  .press, .press.is-pressed { transition-timing-function: ease-out; transition-duration: .12s; }
}

/* ---------- Fullscreen viewer ---------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
}
.viewer[hidden] { display: none; }

.viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .9);
  -webkit-backdrop-filter: blur(20px);
          backdrop-filter: blur(20px);
}

.viewer__frame {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  border-radius: var(--radius);
  transform-origin: 0 0;
  background: #000;
}
.viewer__video { width: 100%; height: 100%; object-fit: cover; cursor: pointer; border-radius: inherit; }

.viewer__close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  box-shadow: inset 0 1px 2px rgba(255,255,255,.25);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  cursor: pointer;
}
.viewer__close:hover { background: rgba(255, 255, 255, .22); }
.viewer__close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

body.is-locked { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .slot.is-win .slot__reel, .slot.is-jackpot, .slot.is-jackpot .slot__reel { animation: none; }
}
