/* ==========================================================================
   VIEWER.CSS — the viewer area: whatever is plugged into Personal.
   Views: work (intro + project grid), project, cv, contact, empty.
   Uses container queries, so layouts follow the viewer's width,
   not the window's.
   ========================================================================== */

/* ---------- The book ----------
   .area--viewer is a 3D stage. .cover (the 2D page) turns on a hinge along
   its RIGHT edge; .space (the 3D viewport) waits behind it. Opening swings
   the page's left edge toward you and over to the right, away from the
   node editor.                                                            */
.area--viewer {
  overflow: visible;                 /* the opening cover swings past the edge */
  z-index: 4;
  background: transparent;
  container-type: inline-size;
  perspective-origin: 0% 50%;        /* vanishing point on the left edge: the page grows only to the right */
}
/* 3D only while it's needed (turning, open, peeking). A permanent
   perspective here stops the mouse wheel from scrolling the page. */
.area--viewer.is-3d { perspective: 2400px; }
.area--viewer.is-3d .cover { transform-style: preserve-3d; }
.space, .cover { position: absolute; inset: 0; }
.space, .cover__front {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: var(--area-radius);
  overflow: hidden;
}
.space { z-index: 1; background: radial-gradient(ellipse at 50% 42%, var(--vp-1), var(--vp-2) 75%); }   /* own layer: its shade stays under the cover */
.space__shade {                      /* the cover's shadow, receding toward the hinge as it opens */
  position: absolute; inset: 0; z-index: 5;
  pointer-events: none;
  background: linear-gradient(270deg, rgba(0,0,0,.95), rgba(0,0,0,.8) 60%, rgba(0,0,0,.6));
  transform-origin: 100% 50%;
  transition: opacity 1100ms ease 150ms, transform 1000ms cubic-bezier(.62,.04,.26,1);
}
.is-book-open .space__shade { opacity: 0; transform: scaleX(.15); }
.space__body.is-swapping { animation: view-in 420ms var(--ease-out); }

.cover {
  z-index: 2;
  transform-origin: 100% 50%;        /* the hinge: the right edge */
  transition: transform 900ms cubic-bezier(.3, 1.22, .5, 1), visibility 0s;   /* closing lands with a small bounce */
}
.cover.is-open {
  transform: rotateY(106deg);
  visibility: hidden;
  transition: transform 1000ms cubic-bezier(.62, .04, .26, 1), visibility 0s linear 1000ms;
}
/* Peek: a barely-there lift. The slight inward scale keeps every part of the
   page inside its frame (nothing gets cut), and a hairline of light shows. */
.cover.is-peek { transform: rotateY(1.2deg) scale(.986); transition: transform 700ms var(--ease-out); }
.cover.is-instant, .cover.is-instant .cover__front::after { transition: none !important; }
.cover__front, .cover__back {
  position: absolute; inset: 0;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.cover__front { background: var(--viewer); box-shadow: 0 0 0 1px var(--rule); }
.cover__front::after {               /* shading as the page turns away from the light */
  content: ""; position: absolute; inset: 0; z-index: 6; pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(270deg, rgba(0,0,0,.05), rgba(0,0,0,.6));
  opacity: 0;
  transition: opacity 900ms ease;
}
.cover.is-open .cover__front::after { opacity: 1; transition-duration: 1000ms; }
.cover.is-peek .cover__front::after { opacity: .08; }
.cover__back {                       /* inside of the cover: a dark board with your logo */
  transform: rotateY(180deg);
  border-radius: var(--area-radius);
  display: grid; place-items: center;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.025) 0 2px, transparent 2px 6px),
    linear-gradient(270deg, #1b1b1e, #26262a);
  box-shadow: inset 18px 0 30px rgba(0,0,0,.5);
}
.cover__back img { width: min(30%, 220px); opacity: .25; }
:root[data-theme="light"] .cover__back img:not(.no-invert) { filter: none; }

/* Peek light: a soft line along the free (left) edge */
.space::after {
  content: ""; position: absolute; z-index: 6; top: 0; bottom: 0; left: 0; width: 14px;
  pointer-events: none;
  background: linear-gradient(90deg, color-mix(in srgb, var(--cable-model) 45%, transparent), transparent);
  opacity: 0; transition: opacity 600ms;
}
.is-peeking .space::after { opacity: 1; }
.is-peeking .space__shade { opacity: .9; }

/* ---------- Head: big section title + top-right flap ---------- */
.viewer__head { position: relative; min-width: 0; }
.viewer__titlewrap {
  display: flex; align-items: center; gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px clamp(16px, 4cqi, 44px) 18px;
  padding-right: max(clamp(16px, 4cqi, 44px), calc(var(--flap-w, 0px) - (100cqi - min(100cqi, 1180px)) / 2 + 12px));
  min-height: 78px;
}
.viewer__title {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
  margin: 0;
  font-family: var(--font-display);
  font-variation-settings: "wdth" 125;
  font-weight: 700;
  font-size: clamp(24px, 2.4vw, 36px);
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--text);
}
.viewer__title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kind-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--c, var(--cable-idle)); border: 1px solid var(--sock-edge); }
.viewer__back {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--field); color: var(--text);
  text-decoration: none;
}
.viewer__back:hover { background: var(--field-hover); }
.viewer__back .icon { width: 18px; height: 18px; }

/* Top-right flap: hangs from the frame, holds the view's info */
.flap--tr { z-index: 2; top: 0; right: 0; height: 42px; }
.flap--tr .flap__body { padding: 0 14px 6px 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.flap-btn {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  color: var(--frame-text);
  text-decoration: none;
}
.flap-btn:hover { background: color-mix(in srgb, var(--frame-text) 16%, transparent); color: var(--text); }
.flap-btn--wide { width: auto; padding: 0 10px; border-radius: 999px; gap: 6px; display: inline-flex; align-items: center; }
.flap-btn .icon { width: 15px; height: 15px; }
@media (pointer: coarse) { .flap--tr { height: 48px; } .flap-btn { width: 36px; height: 36px; } }

.is-tall .viewer__titlewrap { min-height: 60px; padding-top: 14px; padding-bottom: 10px; }
.is-tall .viewer__title { font-size: 22px; gap: 10px; }
.is-tall .kind-dot { width: 10px; height: 10px; }
.is-tall .viewer__back { width: 32px; height: 32px; }
.is-short .viewer__titlewrap { min-height: 52px; padding-top: 12px; padding-bottom: 8px; }
.is-short .viewer__title { font-size: 20px; }

/* Reaction when something new is plugged in */
.area--viewer::after {
  content: "";
  position: absolute; inset: 0; z-index: 4;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--react, var(--accent));
  opacity: 0;
}
.area--viewer.is-reacting::after { animation: ring 800ms var(--ease-out); }
.area--viewer.is-reacting .flap--tr { animation: flap-drop 600ms cubic-bezier(.3, 1.5, .5, 1); }
@keyframes ring { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes flap-drop { 0% { transform: translateY(-16px); } 100% { transform: none; } }

/* ---------- Body ---------- */
.viewer__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  container-type: inline-size;
  outline: none;
}
.view { padding: 6px clamp(16px, 4cqi, 44px) 56px; max-width: 1180px; margin: 0 auto; }
.view.is-entering { animation: view-in 360ms cubic-bezier(.3, 1.3, .5, 1) backwards; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px) scale(.992); } }

/* Display type: Archivo, widened to echo the logo */
.display {
  margin: 0;
  font-family: var(--font-display);
  font-variation-settings: "wdth" 112;
  font-weight: 640;
  letter-spacing: -0.015em;
  line-height: 1.04;
  text-wrap: balance;
}

/* ---------- Work ---------- */
.intro { max-width: 780px; margin: 4px 0 clamp(24px, 4cqi, 40px); }
.intro .display { font-size: clamp(20px, 3cqi, 30px); max-width: 28ch; font-variation-settings: "wdth" 100; font-weight: 600; }
.intro__text { margin: 14px 0 0; max-width: 58ch; color: var(--text-dim); font-size: 15px; line-height: 1.6; }

.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px 18px;
}
@container (min-width: 520px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@container (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card { display: block; text-decoration: none; color: inherit; border-radius: 8px; }
.card__img {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--rule);
}
.card__img img { width: 100%; height: 100%; object-fit: cover; transition: transform 500ms var(--ease-out); }
.card:hover .card__img img { transform: scale(1.04); }
.card:focus-visible { outline-offset: 4px; }
.card__title { display: flex; justify-content: space-between; gap: 12px; margin: 12px 0 2px; font-size: 15px; font-weight: 600; }
.card__title span:last-child { color: var(--text-dim); font-weight: 400; font-variant-numeric: tabular-nums; }
.card__short { margin: 0; color: var(--text-dim); font-size: 13.5px; line-height: 1.5; }

/* ---------- Project ---------- */
.project__hero { margin: 0; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--surface); }
.project__hero img { width: 100%; height: 100%; object-fit: cover; }
.project__title { margin-top: clamp(22px, 4cqi, 40px); font-size: clamp(30px, 6cqi, 64px); }
.project__title:focus { outline: none; }
.project__short { margin: 10px 0 clamp(22px, 4cqi, 36px); max-width: 46ch; color: var(--text-dim); font-size: clamp(16px, 2cqi, 19px); line-height: 1.45; }
.project__grid { display: grid; gap: 20px; padding-top: 22px; border-top: 1px solid var(--rule); }
@container (min-width: 640px) { .project__grid { grid-template-columns: 200px minmax(0, 1fr); gap: 20px 48px; } }
.meta { margin: 0; display: grid; gap: 14px; align-content: start; }
.meta dt { color: var(--text-dim); font-size: 12.5px; margin-bottom: 4px; }
.meta dd { margin: 0; font-size: 14.5px; }
.project__desc p { margin: 0 0 1.1em; max-width: 64ch; font-size: 16px; line-height: 1.65; }
.ext-link {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; margin-top: 6px; padding: 0 18px;
  border-radius: 999px;
  background: var(--text); color: var(--viewer);
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.ext-link:hover { opacity: .88; }
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--rule); }
.pager a { display: grid; gap: 2px; max-width: 48%; padding: 8px 0; text-decoration: none; font-size: 15px; font-weight: 500; }
.pager a span { color: var(--text-dim); font-size: 12.5px; font-weight: 400; }
.pager a:last-child { text-align: right; margin-left: auto; }
.pager a:hover strong { text-decoration: underline; text-underline-offset: 3px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; list-style: none; }
.chips li { padding: 3px 8px; border-radius: 4px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule); font-size: 12.5px; }

/* ---------- CV ---------- */
.cv__banner {
  position: relative;
  height: clamp(70px, 12cqi, 120px);
  margin: 0;
  border-radius: 10px;
  background-color: color-mix(in srgb, var(--hdr-cv) 22%, var(--viewer));
  overflow: hidden;
}
.cv__banner::before {            /* the line texture (white lines) */
  content: "";
  position: absolute; inset: 0;
  background-image: var(--banner);
  background-position: center; background-size: cover;
}
:root[data-theme="light"] .cv__banner::before { filter: invert(1); opacity: .45; }
.cv__head { position: relative; z-index: 1; display: flex; align-items: flex-end; gap: 20px; margin-top: -44px; padding-left: clamp(12px, 3cqi, 28px); }
.cv__photo {
  flex: none;
  width: clamp(92px, 14cqi, 128px);
  aspect-ratio: 4 / 5;
  margin: 0;
  border-radius: 999px 999px 10px 10px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--viewer);
}
.cv__photo img { width: 100%; height: 100%; object-fit: cover; }
.cv .cv__name { font-size: clamp(24px, 4cqi, 36px); }
.cv__role { margin: 6px 0 0; color: var(--text-dim); font-size: 14px; }
.cv__summary { margin: 22px 0 28px; max-width: 64ch; font-size: 15.5px; line-height: 1.6; }
.cv__cols { display: grid; gap: 28px; }
@container (min-width: 720px) { .cv__cols { grid-template-columns: minmax(0, 1fr) 240px; gap: 48px; } }
.cv h3 { margin: 0 0 10px; font-family: var(--font-display); font-variation-settings: "wdth" 112; font-size: 16px; font-weight: 640; }
.cv__side h3:not(:first-child) { margin-top: 22px; }
.timeline { list-style: none; margin: 0 0 28px; padding: 0; }
.timeline li { display: grid; gap: 2px 18px; padding: 14px 0; border-top: 1px solid var(--rule); }
@container (min-width: 560px) { .timeline li { grid-template-columns: 110px 1fr; } }
.timeline__period { color: var(--text-dim); font-size: 13px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.timeline__title { margin: 0; font-size: 15px; font-weight: 600; }
.timeline__where { margin: 2px 0 6px; color: var(--text-dim); font-size: 13px; }
.timeline__desc { margin: 0; font-size: 14px; line-height: 1.6; max-width: 62ch; }

/* ---------- Contact ---------- */
.contact { max-width: 640px; }
.contact__email { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 14px; margin: 8px 0 28px; }
.contact__email a { font-size: clamp(24px, 5.4cqi, 44px); text-decoration: none; overflow-wrap: anywhere; }
.contact__email a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 0; border-radius: 999px;
  background: var(--field); color: var(--text);
  font-size: 12.5px;
}
.copy-btn:hover { background: var(--field-hover); }
.copy-btn .icon { width: 14px; height: 14px; }
.rows { list-style: none; margin: 0 0 18px; padding: 0; border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--rule); }
.rows li {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 48px; padding: 6px 16px;
  background: var(--surface);
  font-size: 14.5px;
}
.rows li + li { border-top: 1px solid var(--rule); }
.rows li > span:first-child { color: var(--text-dim); }
.rows a { font-weight: 500; text-decoration: none; text-align: right; overflow-wrap: anywhere; }
.rows a:hover { text-decoration: underline; }
.contact__note { margin: 0; color: var(--text-dim); font-size: 13.5px; }

/* Phone behind the password */
.unlock { display: flex; gap: 6px; align-items: center; }
.unlock input {
  width: 130px; height: 32px; padding: 0 10px;
  border: 1px solid var(--rule); border-radius: 6px;
  background: var(--viewer); color: var(--text);
  font-size: 14px;
}
.unlock input:focus { outline: 2px solid var(--cable-contact); outline-offset: 0; }
.unlock button, .reveal-btn {
  height: 32px; padding: 0 12px;
  border: 0; border-radius: 6px;
  background: var(--field); color: var(--text);
  font-size: 13px; font-weight: 500;
}
.unlock button:hover, .reveal-btn:hover { background: var(--field-hover); }
.unlock.is-wrong { animation: shake 420ms cubic-bezier(.36,.07,.19,.97); }
.unlock__msg { color: #e0533f; font-size: 12.5px; }
@keyframes shake { 20%, 80% { transform: translateX(-2px); } 40%, 60% { transform: translateX(5px); } 50% { transform: translateX(-6px); } }
@media (pointer: coarse) { .unlock input { font-size: 16px; height: 40px; } .unlock button, .reveal-btn { height: 40px; } }

/* ---------- Empty (nothing plugged in) ---------- */
.empty {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px clamp(20px, 6cqi, 64px);
}
.cover__front:has(.empty) { background: #000; }
.cover__front:has(.empty) .viewer__title { color: #f1f1f1; }
.empty__inner { max-width: 760px; display: grid; gap: 32px; justify-items: start; }
.empty .display { color: #f1f1f1; font-size: clamp(26px, 6cqi, 58px); }
.empty .display::before { content: "\201C"; display: block; height: .5em; color: #666; font-size: 1.8em; line-height: 1; }
.plug-btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 0 20px 0 16px;
  border: 1px solid #3a3a3a; border-radius: 999px;
  background: #1c1c1c; color: #fff;
  font-size: 15px; font-weight: 500;
}
.plug-btn:hover { background: #262626; border-color: #4a4a4a; }
.plug-btn .icon { color: var(--cable-work); width: 18px; height: 18px; }

/* ---------- 3D: cards ---------- */
.card-wrap { position: relative; }
.card[data-model] .card__img { cursor: grab; }
.card[data-model] img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.card.is-source { opacity: .4; }
.card.is-holding .card__img { transform: scale(.97); transition: transform 380ms var(--ease-out); }
.card__3d {
  position: absolute; z-index: 1; top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 9px 0 7px;
  border: 0; border-radius: 999px;
  background: rgba(12, 12, 12, .74); color: #fff;
  font-size: 11.5px; font-weight: 600;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.card__3d .icon { width: 13px; height: 13px; color: var(--cable-model); }
.card__3d:hover { background: var(--hdr-model); }
.card__3d:hover .icon { color: #fff; }
@media (pointer: coarse) { .card__3d { height: 34px; padding: 0 12px 0 10px; } }
.intro__tip { display: flex; align-items: flex-start; gap: 8px; margin: 16px 0 0; max-width: 62ch; font-size: 13px; line-height: 1.5; color: var(--text-dim); }
.intro__tip .icon { color: var(--cable-model); margin-top: 1px; }
.intro__tip b { color: var(--text); font-weight: 600; }

.project__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.project__actions .ext-link { margin-top: 0; }
.ext-link--3d { border: 0; background: var(--hdr-model); color: #fff; }
.ext-link--3d .icon { color: var(--cable-model); }

button.flap-btn { border: 0; background: transparent; font: inherit; font-size: 12.5px; }
.flap-btn[aria-pressed="true"] { color: var(--text); background: color-mix(in srgb, var(--cable-model) 24%, transparent); }

/* ---------- 3D: the viewport ---------- */
:root, :root[data-theme="dark"] { --vp-1: #3b3b3b; --vp-2: #1e1e1e; }
:root[data-theme="light"] { --vp-1: #ffffff; --vp-2: #d9dbdf; }
.viewer__body:has(.model-view) { overflow: hidden; }
.model-view { position: relative; height: 100%; min-height: 240px; }
.model-view__stage {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 42%, var(--vp-1), var(--vp-2) 72%);
  background-size: cover; background-position: center;
}
.model-view__stage model-viewer { width: 100%; height: 100%; background: transparent; --poster-color: transparent; }
.model-view__status {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--text-dim); font-size: 13.5px;
  pointer-events: none;
}
.model-view.is-loaded .model-view__status { display: none; }
.model-view.is-error .model-view__status { color: var(--text); }
.model-view.is-poster .model-view__status { background: rgba(0, 0, 0, .62); color: #fff; font-size: 14.5px; line-height: 1.5; }
.model-view__bar { position: absolute; left: 0; right: 0; top: 0; height: 2px; }
.model-view__bar i { display: block; width: 0; height: 100%; background: var(--cable-model); transition: width 200ms; }
.model-view.is-loaded .model-view__bar, .model-view.is-error .model-view__bar { display: none; }
.model-view__hint {
  position: absolute; right: 16px; bottom: 16px;
  margin: 0; padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .5); color: #fff;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 400ms;
}
.model-view.is-loaded:not(.is-touched) .model-view__hint { opacity: 1; }
.model-view__link {
  position: absolute; left: 16px; bottom: 16px;
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 999px;
  background: var(--field); color: var(--text);
  font-size: 12.5px; font-weight: 500; text-decoration: none;
}
.model-view__link:hover { background: var(--field-hover); }
@media (pointer: coarse) { .model-view__link { height: 38px; } }

/* ---------- 3D: the node-shaped ghost while dragging ---------- */
.ghost { position: fixed; left: 0; top: 0; z-index: 300; width: 184px; pointer-events: none; will-change: transform; }
.ghost__node {
  overflow: hidden;
  border-radius: 6px;
  background: var(--node);
  border: 1px solid var(--node-edge);
  box-shadow: 0 20px 40px rgba(0, 0, 0, .45);
  opacity: .9;
  transform: scale(.94);
  transition: transform 180ms var(--ease-out), opacity 180ms, box-shadow 180ms;
}
.ghost__hdr {
  display: flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 8px;
  background: color-mix(in srgb, var(--hdr-model) var(--hdr-mix), var(--hdr-mix-base));
  color: var(--hdr-text);
  font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden;
}
.ghost__hdr .icon { width: 13px; height: 13px; }
.ghost img { width: calc(100% - 16px); margin: 6px 8px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; }
.ghost__label { margin: -2px 8px 8px; font-size: 11px; line-height: 1.35; color: var(--text-dim); }
.ghost__label:empty { display: none; }
.ghost.is-over .ghost__node { opacity: 1; transform: scale(1); box-shadow: 0 0 0 2px var(--cable-model), 0 24px 48px rgba(0, 0, 0, .5); }
.ghost.is-dropped .ghost__node { opacity: 0; transform: scale(1.08); transition-duration: 200ms; }
.ghost.is-returning { opacity: 0; transition: transform 300ms var(--ease-out), opacity 300ms; }
body.is-dragging-3d, body.is-dragging-3d * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }

/* Phones: icon-only turntable button so the title has room */
.is-tall .flap-btn--wide span { display: none; }
.is-tall .flap-btn--wide { width: 36px; padding: 0; justify-content: center; }

/* ---------- Material balls (CSS only) ---------- */
.ball {
  position: relative;
  display: inline-block;
  width: 40px; height: 40px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}
.ball::after {                          /* shared shading: highlight + core shadow */
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, rgba(255,255,255,.55) 0 6%, rgba(255,255,255,0) 30%),
              radial-gradient(circle at 60% 66%, rgba(0,0,0,0) 40%, rgba(0,0,0,.5) 100%);
}
.ball--color { background: conic-gradient(from 200deg, #8a4f1e, #e3c446, #2fb3bf, #7a2a3a, #8a4f1e); }
.ball--wireframe {
  background:
    repeating-linear-gradient(0deg, transparent 0 6px, #3fd0b6 6px 7px),
    repeating-linear-gradient(90deg, transparent 0 6px, #3fd0b6 6px 7px),
    #2c2c2e;
}
.ball--matcap { background: radial-gradient(circle at 36% 30%, #fff6ee 0 3%, #e6cbb3 18%, #a57f68 55%, #4a342b 86%); }
.ball--matcap::after { background: none; }
.ball--uv { background: repeating-conic-gradient(#e8506a 0 25%, #f6c445 0 50%) 0 0 / 12px 12px; }
.ball--tiny { box-shadow: none; }

/* ---------- 3D viewport layout ---------- */
.model-view__stage { cursor: grab; }
.model-view__stage:active { cursor: grabbing; }
.vp-canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.model-view__top { position: absolute; left: 16px; top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.model-view__top .model-view__link { position: static; }
.model-view__info {
  display: inline-flex; align-items: center; height: 28px; padding: 0 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--viewer) 70%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 1px var(--rule);
  color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums;
}
.model-view__info[hidden] { display: none; }
.model-view__hint { right: auto; left: 50%; bottom: auto; top: 14px; transform: translateX(-50%); }
.mats {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; gap: 4px;
  padding: 6px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--viewer) 72%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px var(--rule), 0 8px 24px rgba(0, 0, 0, .25);
}
.mat {
  display: grid; justify-items: center; gap: 5px;
  min-width: 70px; padding: 7px 6px 6px;
  border: 0; border-radius: 11px;
  background: transparent; color: var(--text-dim);
  font-size: 11px; font-weight: 500;
  cursor: grab; touch-action: none;
}
.mat:hover { background: var(--field); color: var(--text); }
.mat:hover .ball { transform: translateY(-3px) rotate(-8deg); }
.mat .ball { transition: transform 260ms cubic-bezier(.3, 1.6, .5, 1); }
.mat.is-active { color: var(--text); background: color-mix(in srgb, var(--cable-material) 20%, transparent); }
.mat.is-active .ball { box-shadow: 0 0 0 2px var(--viewer), 0 0 0 4px var(--cable-material); }
@media (max-width: 480px) { .mat { min-width: 56px; } .mat .ball { width: 32px; height: 32px; } .mat__label { font-size: 10px; } }

/* Dragging a ball onto the model */
.ball--ghost { position: fixed; left: 0; top: 0; z-index: 300; width: 44px; height: 44px; pointer-events: none; transition: scale 160ms var(--ease-out), box-shadow 160ms; }
.ball--ghost.is-over { scale: 1.25; box-shadow: 0 0 0 3px var(--cable-material), 0 12px 30px rgba(0, 0, 0, .5); }
.ball--ghost.is-dropped { scale: 1.8; opacity: 0; transition: scale 240ms var(--ease-out), opacity 240ms; }
.ball--ghost.is-returning { opacity: 0; transition: transform 300ms var(--ease-out), opacity 300ms; }
body.is-dragging-mat, body.is-dragging-mat * { cursor: grabbing !important; user-select: none; }
.model-view.is-mat-target::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--cable-material);
}

/* Ripple where a material lands */
.ripple {
  --rc: var(--cable-material);
  position: absolute; z-index: 3;
  width: 24px; height: 24px; margin: -12px 0 0 -12px;
  border-radius: 50%;
  border: 2px solid var(--rc);
  pointer-events: none;
  animation: ripple 850ms var(--ease-out) forwards;
}
.ripple--wireframe { --rc: var(--cable-model); }
.ripple--matcap { --rc: #e6cbb3; }
.ripple--uv { --rc: #f6c445; }
.ripple--color { --rc: var(--cable-work); }
@keyframes ripple { from { transform: scale(.4); opacity: 1; } to { transform: scale(16); opacity: 0; border-width: .5px; } }

.is-tall .model-view__hint { display: none; }
.is-tall .model-view__top { top: 10px; left: 10px; }

/* ---------- Cards: stagger in, lean toward the pointer ---------- */
.view.is-entering .card-wrap { animation: card-in 520ms cubic-bezier(.3, 1.2, .5, 1) backwards; animation-delay: calc(var(--i, 0) * 55ms + 80ms); }
@keyframes card-in { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.card { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 380ms var(--ease-out); }
.card:hover { transition-duration: 120ms; }
.card:hover .card__img { box-shadow: 0 0 0 1px var(--rule), 0 14px 30px rgba(0, 0, 0, .28); }
.card__img { transition: box-shadow 300ms var(--ease-out); }

/* ---------- Project showcase ---------- */
.showcase { margin-top: clamp(36px, 6cqi, 64px); }
.showcase__title {
  margin: 0 0 16px;
  font-family: var(--font-display); font-variation-settings: "wdth" 112;
  font-size: clamp(18px, 2.4cqi, 24px); font-weight: 640;
}
.pgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(10px, 1.6cqi, 18px); }
.pg { margin: 0; grid-column: span 6; }
.pg--half { grid-column: span 3; }
.pg--third { grid-column: span 2; }
@container (max-width: 560px) { .pg--half, .pg--third { grid-column: span 6; } }
.pbreak { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(8px, 1.4cqi, 14px); }
@container (max-width: 640px) { .pbreak { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pb { margin: 0; }
.pb .shot { aspect-ratio: 1; }
.shot {
  display: block; width: 100%; padding: 0;
  border: 0; border-radius: 8px; overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--rule);
  cursor: zoom-in;
}
.shot img { width: 100%; height: 100%; object-fit: cover; transition: transform 600ms var(--ease-out); }
.shot:hover img { transform: scale(1.03); }
.pg figcaption, .pb figcaption, .pvideo figcaption { margin-top: 8px; font-size: 13px; color: var(--text-dim); }

.pvideo { margin: clamp(32px, 5cqi, 52px) 0 0; }
.pvideo__facade, .pvideo__frame, .pvideo__slot {
  display: block; width: 100%; aspect-ratio: 16 / 9;
  border: 0; border-radius: 10px; overflow: hidden;
}
.pvideo__facade {
  position: relative; padding: 0;
  background-color: var(--surface); background-size: cover; background-position: center;
  box-shadow: 0 0 0 1px var(--rule);
}
.pvideo__facade::before { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 40%, rgba(0,0,0,.45)); }
.pvideo__play {
  position: absolute; left: 50%; top: 50%;
  display: grid; place-items: center;
  width: 76px; height: 76px; margin: -38px 0 0 -38px;
  border-radius: 50%;
  background: rgba(15, 15, 15, .72); color: #fff;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .25);
  transition: transform 260ms cubic-bezier(.3, 1.6, .5, 1), background-color 200ms;
}
.pvideo__play .icon { width: 30px; height: 30px; margin-left: 4px; }
.pvideo__facade:hover .pvideo__play { transform: scale(1.1); background: var(--hdr-work); }
.pvideo__slot {
  display: grid; place-items: center; align-content: center; gap: 10px; padding: 20px;
  border: 2px dashed color-mix(in srgb, var(--text-faint) 60%, transparent);
  color: var(--text-dim); font-size: 13.5px; text-align: center;
}
.pvideo__slot .icon { width: 30px; height: 30px; color: var(--text-faint); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 320;
  display: grid; place-items: center;
  padding: clamp(16px, 5vw, 64px);
  background: rgba(10, 10, 10, .92);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: lb-in 240ms var(--ease-out);
}
.lightbox.is-closing { animation: lb-out 200ms ease-in forwards; }
@keyframes lb-in { from { opacity: 0; } }
@keyframes lb-out { to { opacity: 0; } }
.lightbox__fig { margin: 0; display: grid; justify-items: center; gap: 12px; max-width: 100%; max-height: 100%; }
.lightbox__fig img {
  max-width: 100%; max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px);
  border-radius: 8px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.lightbox__fig img.is-in { animation: lb-zoom 380ms cubic-bezier(.3, 1.2, .5, 1); transform-origin: var(--ox, 50%) var(--oy, 50%); }
@keyframes lb-zoom { from { opacity: 0; transform: scale(.88); } }
.lightbox figcaption { color: #cfcfcf; font-size: 14px; }
.lightbox__count { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); margin: 0; color: #9a9a9a; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.lightbox__btn {
  position: absolute; display: grid; place-items: center;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .1); color: #fff;
}
.lightbox__btn:hover { background: rgba(255, 255, 255, .2); }
.lightbox__btn .icon { width: 20px; height: 20px; }
.lightbox__close { top: 16px; right: 16px; }
.lightbox__prev { left: 16px; top: 50%; margin-top: -22px; }
.lightbox__next { right: 16px; top: 50%; margin-top: -22px; }


/* Phones: the nodes are below the viewer. Put the vanishing point on the
   bottom edge so the swinging page only grows upward, never over the nodes. */
.is-tall .area--viewer { perspective-origin: 0% 100%; }
