/* V3 — surgical refinements. Original palette, type, and motion remain unchanged. */
:root { --safe-top:env(safe-area-inset-top,0px); --safe-right:env(safe-area-inset-right,0px); --safe-bottom:env(safe-area-inset-bottom,0px); --safe-left:env(safe-area-inset-left,0px); }
html { scroll-padding-top:calc(var(--nav-height) + var(--safe-top)); max-width:100%; }
body { overflow-x:clip; max-width:100%; }
.container { padding-inline: max(var(--gutter),var(--safe-left)) max(var(--gutter),var(--safe-right)); }
button,a,input,select,textarea { -webkit-tap-highlight-color:transparent; }
button { touch-action:manipulation; }

/* 01 — Scroll isolation: body is locked in place without locking the fixed detail's scroller. */
body.dialog-open { position:fixed; top:var(--locked-scroll,0px); left:0; right:0; width:100%; height:100%; overflow:hidden; }
.detail-overlay { inset:0; width:100%; height:100svh; height:100dvh; overflow:hidden; overscroll-behavior:none; contain:layout style; }
.detail-shell { height:100%; height:100dvh; min-height:0; overflow:hidden; display:flex; flex-direction:column; }
.detail-navbar { min-height:calc(70px + var(--safe-top)); height:auto; padding-top:var(--safe-top); padding-left:max(20px,var(--safe-left)); padding-right:max(20px,var(--safe-right)); }
.detail-scroll { display:block; flex:1 1 0%; min-height:0; height:0; overflow-x:hidden; overflow-y:auto; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; touch-action:pan-y; scroll-behavior:auto; scrollbar-gutter:stable; outline-offset:-4px; padding-bottom:var(--safe-bottom); }
.detail-scroll:focus:not(:focus-visible) { outline:0; }
.detail-container { width:min(calc(100% - clamp(32px,7vw,96px)),var(--detail-max)); }
.detail-back { min-height:44px; min-width:44px; }
.detail-footer button { min-height:44px; }
.detail-step { will-change:auto; }

/* 02 — Comparison uses an accessible invisible range: no visual bar below the photos. */
.before-after input[type=range] { position:absolute; left:50%; top:50%; width:1px; height:1px; padding:0; margin:0; opacity:0; border:0; clip-path:inset(50%); overflow:hidden; appearance:none; }
.before-after:focus-within { outline:2px solid #F8F5F1; outline-offset:5px; }
.before-after { cursor:ew-resize; user-select:none; -webkit-user-select:none; touch-action:pan-y; }
.before-after__line { background:#F8F5F1; }

/* 04 — Reversible scroll-linked node filling. The outer ring is unchanged. */
.timeline__item::before { left:-42px; top:8px; width:15px; height:15px; border:2px solid var(--wine); background:var(--bg); transition:box-shadow .22s ease, transform .22s ease; }
.timeline__item::after { content:""; position:absolute; z-index:3; left:-39px; top:11px; width:9px; height:9px; border-radius:50%; background:var(--wine); transform:scale(var(--node-progress,0)); transform-origin:center; pointer-events:none; }
.timeline__item.is-node-active::before { box-shadow:0 0 0 6px rgba(var(--wine-rgb),.08); transform:scale(1.08); }

/* 05 — A full-width, measured marquee; JS repeats the source group as necessary. */
.discipline-strip__track { display:flex; width:max-content; gap:0; animation:none; transform:translateZ(0); will-change:transform; }
.discipline-strip__track.marquee-running { animation:marquee-seamless var(--marquee-duration,35s) linear infinite; }
.discipline-strip__group { display:flex; flex:0 0 auto; align-items:center; gap:44px; padding-right:44px; white-space:nowrap; }
.discipline-strip__group span { color:var(--text-soft); font:700 11px var(--display); letter-spacing:.14em; }
.discipline-strip__group b { font-size:8px; color:var(--wine); }
@keyframes marquee-seamless { to { transform:translate3d(calc(-1 * var(--marquee-distance,850px)),0,0); } }
@media (hover:hover) and (pointer:fine) { .discipline-strip:hover .discipline-strip__track { animation-play-state:paused; } }

/* 06 — Editorial skill cards: quiet chips with three tiny proficiency dots. */
.skills__grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.skill { min-width:0; min-height:0; padding:clamp(19px,1.55vw,26px); justify-content:initial; gap:0; transition:background .35s,transform .45s var(--ease),box-shadow .4s; }
.skill__header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.skill__glyph { flex:none; width:28px; height:28px; color:var(--wine); opacity:1; }
.skill__number { font:700 10px var(--display); color:var(--wine); letter-spacing:.08em; }
.skill h3 { margin:23px 0 9px; font-size:clamp(1.22rem,1.55vw,1.65rem); line-height:1.16; }
.skill p { margin:0 0 18px; font-size:12px; line-height:1.6; max-width:none; }
.skill__chips { display:flex; flex-wrap:wrap; gap:7px; margin-top:auto; }
.skill-chip { border:1px solid var(--line); background:var(--bg); min-width:0; max-width:100%; padding:7px 9px; display:inline-flex; flex-wrap:wrap; align-items:center; gap:7px; font-size:10px; line-height:1.35; font-weight:600; border-radius:4px; }
.skill-chip > span:first-child { overflow-wrap:anywhere; }
.skill-chip__dots { display:inline-flex; flex:none; gap:3px; }
.skill-chip__dots i { display:block; width:4px; height:4px; border-radius:50%; background:var(--line); }
.skill-chip__dots i.is-filled { background:var(--wine); }
.skill-chip small { font-size:9px; color:var(--text-soft); font-weight:500; }
@media (hover:hover) and (pointer:fine) { .skill:hover { transform:translateY(-4px); } }
@media (hover:none), (pointer:coarse) { .skill:hover { transform:none; box-shadow:none; } }

/* 07 — Responsive; keep the site's fixed max reading width on ultra-wide screens. */
:root { --gutter:clamp(17px,4.8vw,100px); }
.hero, .story__sticky { min-height:100svh; }
.hero { min-height:100dvh; }
.hero h1 { font-size:clamp(3.6rem,8.2vw,9.9rem); }
.project-card, .project-card__info, .project-card__visual, .detail-art, .about__grid > * { min-width:0; }
.project-card h3,.detail-title,.contact__email { overflow-wrap:anywhere; }
.project-card__open, .filter, .theme-toggle, .menu-toggle, .submit-button, .cv__download, .segmented button, .demo-button, .glb-viewer__controls button, .detail-navbar button, .detail-footer button { min-height:44px; }
.filter { padding:10px 15px; }
.nav { padding-left:max(var(--gutter),var(--safe-left)); padding-right:max(var(--gutter),var(--safe-right)); }
.nav-links a { min-height:44px; display:flex; align-items:center; }
.browser-demo { max-width:100%; min-width:0; }
.browser-demo iframe { height:min(72dvh,690px); }
.device-stage { min-height:0; padding:clamp(20px,5vw,42px) 0; }
.device-frame { width:min(340px,100%); height:min(680px,78dvh); aspect-ratio:340/680; max-height:none; }
.device-frame[data-os=Android] { width:min(355px,100%); }
.glb-viewer { max-width:100%; }
.segmented { flex-wrap:wrap; }
.hotspot { min-width:44px; min-height:44px; }

@media (max-width:1279px) {
  .skills__grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .skill h3 { font-size:clamp(1.3rem,2vw,1.75rem); }
}
@media (max-width:1024px) {
  .skills__grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .hero h1 { font-size:clamp(3.7rem,8.7vw,7.6rem); }
  .detail-hero { padding-top:clamp(48px,8vw,100px); }
}
@media (max-width:900px) {
  .nav-links { top:calc(var(--nav-height) + var(--safe-top)); padding:22px max(var(--gutter),var(--safe-left)) calc(25px + var(--safe-bottom)); max-height:calc(100dvh - var(--nav-height) - var(--safe-top)); overflow-y:auto; overscroll-behavior:contain; }
  body.menu-open { overflow:hidden; }
  .site-header { height:calc(var(--nav-height) + var(--safe-top)); padding-top:var(--safe-top); }
  .nav-links a { min-height:50px; }
  .menu-toggle { min-width:44px; min-height:44px; }
  .hero { padding-top:calc(var(--nav-height) + var(--safe-top) + 38px); }
  .story { height:220svh; }
  .story__sticky { height:100svh; min-height:100svh; }
}
@media (max-width:680px) {
  .section { padding-block:clamp(66px,13vw,92px); }
  .skills__grid { grid-template-columns:1fr; gap:9px; }
  .skill { padding:19px; }
  .skill h3 { font-size:1.45rem; margin:16px 0 8px; }
  .skill p { margin-bottom:13px; }
  .skill__glyph { width:26px; height:26px; }
  .skill-chip { padding:7px 9px; }
  .hero { min-height:max(710px,100svh); min-height:max(710px,100dvh); }
  .hero h1 { font-size:clamp(2.92rem,12.15vw,5.2rem); white-space:normal; }
  .hero__art { width:min(72%,320px); margin-top:8px; }
  .hero__bottom { flex-wrap:wrap; }
  .hero__availability { max-width:245px; line-height:1.5; }
  .story { height:200svh; }
  .story__copy { min-height:270px; }
  .story__sculpture { width:min(58vw,265px); }
  .story__grid { padding-top:72px; }
  .section-title { font-size:clamp(2.75rem,10.2vw,4.5rem); }
  .about__intro h2 { font-size:clamp(2.65rem,10.6vw,5rem); }
  .detail-scroll { scrollbar-gutter:auto; }
  .detail-container { width:calc(100% - max(30px,8vw)); }
  .detail-navbar { min-height:calc(62px + var(--safe-top)); }
  .detail-title { font-size:clamp(2.7rem,13vw,5.4rem); }
  .detail-art { height:clamp(210px,62vw,380px); }
  .detail-method-board { grid-template-columns:1fr 1fr !important; }
  .detail-method-board > :first-child { grid-column:span 2; }
  .detail-step { gap:5px; }
  .detail-demostage { padding:clamp(48px,9vw,80px) 0; }
  .detail-demostage h2 { font-size:clamp(2.35rem,10vw,4rem); }
  .before-after__label { top:8px; font-size:9px; padding:5px 7px; }
  .before-after__label--before { left:7px; }
  .before-after__label--after { right:7px; }
  .before-after__handle { width:44px; height:44px; }
  .device-frame { width:min(340px,95%); height:auto; aspect-ratio:340/680; padding:9px; border-radius:38px; }
  .device-frame iframe { border-radius:28px; }
  .browser-demo iframe { height:min(64dvh,520px); }
  .contact__email { font-size:clamp(1.15rem,5.5vw,2.8rem); }
  .contact-form__row { grid-template-columns:1fr; }
  .detail-footer button { max-width:48%; }
}
@media (max-width:359px) {
  .hero h1 { font-size:clamp(2.65rem,11.7vw,3rem); }
  .hero__coordinate { font-size:8px; }
  .hero__art { width:min(69%,245px); }
  .hero__availability { font-size:8px; }
  .about__facts { gap:14px; }
  .about__stats { gap:0; }
  .stat__number { font-size:2rem; }
  .stat__label { letter-spacing:0; }
  .filter { padding:9px 11px; }
  .detail-navbar__position { font-size:9px; }
}
@media (orientation:landscape) and (max-height:540px) and (max-width:1024px) {
  .hero { min-height:0; padding-top:calc(var(--nav-height) + var(--safe-top) + 36px); }
  .hero__inner { display:grid; grid-template-columns:1.15fr .85fr; align-items:center; }
  .hero__art { width:100%; height:auto; max-height:300px; min-height:0; margin:0; aspect-ratio:1; }
  .hero h1 { font-size:clamp(2.5rem,6vw,4rem); }
  .story { height:210svh; }
  .story__grid { display:grid; grid-template-columns:1fr 1fr; flex-direction:initial; align-items:center; padding-top:40px; }
  .story__copy { min-height:220px; }
  .story__sculpture { width:min(35vw,205px); }
  .story__chapter h2 { font-size:clamp(2rem,4vw,3rem); }
  .story__chapter p { font-size:11px; }
  .story__bottom { display:none; }
  .detail-demostage { padding:45px 0; }
}
@media (min-width:1920px) {
  :root { --gutter:clamp(70px,5vw,120px); }
  .hero__art { max-height:660px; }
  .detail-container { --detail-max:1340px; }
}
@media (hover:none), (pointer:coarse) {
  .project-card:hover,.project-card--featured:hover,.skill:hover { transform:none; }
  .hero__art { will-change:auto; }
  .discipline-strip__track { will-change:transform; }
}
@media (prefers-reduced-motion:reduce) {
  .discipline-strip__track { animation:none !important; transform:none !important; }
  .timeline__item::before { box-shadow:none !important; transition:none !important; }
  .detail-scroll { scroll-behavior:auto; }
  .before-after { --split:50%; }
}

/* Optional video source in a mobile or desktop demo. */
.video-device video { display:block; width:100%; height:100%; object-fit:contain; background:#0e0c10; border-radius:32px; }
.video-demo video { display:block; width:100%; max-height:70dvh; aspect-ratio:16/9; object-fit:contain; background:#0e0c10; }

/* Keep a brief exit animation, but make the fading dialog non-interactive. */
.detail-overlay.is-closing { pointer-events:none; }
