:root {
  --bg: #3a3835;
  --bg-deep: #2a2826;
  --ink: #ecebe8;
  --ink-dim: rgba(236, 235, 232, 0.55);
  --card-dark: #111110;
  --card-light: #ecebe7;
  --accent: #ff7a1a;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 45%, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- chrome ---------- */
.top, .bottom {
  position: fixed;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px;
  font-size: 13px;
  letter-spacing: -0.01em;
  z-index: 10;
  pointer-events: none;
}
.top { top: 0; }
.bottom { bottom: 0; color: var(--ink-dim); }
.top > *, .bottom > * { pointer-events: auto; }
.name { font-weight: 500; }
.name::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
nav { display: flex; gap: 22px; }
nav a { color: var(--ink-dim); transition: color .2s; }
nav a:hover, nav a.is-active { color: var(--ink); }

/* ---------- 3d stage ---------- */
.stage {
  position: fixed;
  inset: 0;
  perspective: 1600px;
  perspective-origin: 50% 50%;
  cursor: grab;
  touch-action: none;
}
.stage.is-dragging { cursor: grabbing; }

.world {
  position: absolute;
  left: 50%; top: 50%;
  width: 0; height: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.card {
  position: absolute;
  width: var(--w, 170px);
  height: var(--h, 220px);
  margin-left: calc(var(--w, 170px) / -2);
  margin-top: calc(var(--h, 220px) / -2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-dark);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.03) inset;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  cursor: pointer;
  opacity: 0;
  transition: opacity .6s ease, filter .4s ease;
  will-change: transform;
}
.card.is-in { opacity: 1; }
.card.is-dim { opacity: .18; filter: grayscale(1); pointer-events: none; }
.world.has-hover .card.is-in:not(.is-hover):not(.is-dim) { filter: brightness(.6); }

.card img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* card variants */
.card--photo .cap {
  position: absolute;
  left: 14px; right: 14px; bottom: 14px;
  font-size: 9px;
  line-height: 1.35;
  color: rgba(255,255,255,.85);
  text-shadow: 0 1px 8px rgba(0,0,0,.4);
}

.card--text, .card--title, .card--diagram, .card--list {
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.card--light { background: var(--card-light); color: #1a1a19; }

.card--text p {
  font-size: 10.5px;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.card--title h3 {
  margin-top: auto;
  font-size: 19px;
  line-height: 1.02;
  font-weight: 400;
  letter-spacing: -0.03em;
}
.card--title.has-bg { color: #fff; }
.card--title.has-bg img {
  position: absolute; inset: 0;
  z-index: 0;
}
.card--title.has-bg > *:not(img) { position: relative; z-index: 1; }

.card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 10px;
  font-size: 7px;
  opacity: .55;
  text-transform: lowercase;
}
.card .kicker {
  font-size: 7px;
  opacity: .55;
  margin-bottom: 8px;
  text-align: center;
}
.dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.card--diagram svg { width: 100%; flex: 1; }
.card--diagram .label { font-size: 9px; text-align: center; opacity: .7; }

.card--list ol { list-style: none; display: grid; gap: 7px; margin-top: 2px; }
.card--list li { font-size: 7.5px; line-height: 1.35; text-align: center; opacity: .75; }
.card--list li::before {
  content: "";
  display: block;
  width: 5px; height: 5px;
  margin: 0 auto 5px;
  border-radius: 50%;
  background: currentColor;
}
.card--list li:first-child::before { background: var(--accent); }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20,19,18,.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
}
.lightbox.is-open { opacity: 1; pointer-events: auto; }
.lightbox__card {
  transform: scale(.92);
  transition: transform .45s cubic-bezier(.2,.8,.2,1);
}
.lightbox.is-open .lightbox__card { transform: scale(1); }
.lightbox__card .card {
  position: relative;
  margin: 0;
  opacity: 1;
  cursor: default;
  width: min(calc(var(--w) * 2.4), 86vw);
  height: auto;
  aspect-ratio: var(--ar);
  max-height: 82vh;
  --radius: 22px;
  font-size: 2.4em;
}
.lightbox__card .card * { font-size: inherit; }
.lightbox__card .card--text p { font-size: 28px; }
.lightbox__card .card--title h3 { font-size: 58px; }
.lightbox__card .card .meta,
.lightbox__card .card .kicker,
.lightbox__card .card .cap { font-size: 13px; }
.lightbox__card .card--list li { font-size: 17px; }
.lightbox__card .card--diagram .label { font-size: 18px; }
.lightbox__card .card { padding: 32px; }
.lightbox__card .card--photo { padding: 0; }
.lightbox__close {
  position: absolute;
  top: 22px; right: 28px;
  background: none;
  border: 0;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

@media (max-width: 640px) {
  .top, .bottom { padding: 16px; }
  nav { gap: 14px; }
  .hint { display: none; }
  .bottom { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .lightbox, .lightbox__card { transition: none; }
}
