/* DressAgent project page */
:root {
  --ink: #16191d;
  --ink-2: #3a4049;
  --muted: #6b7380;
  --line: #e7e9ee;
  --line-2: #d9dde4;
  --soft: #f6f7f9;
  --paper: #ffffff;
  --accent: #1f4fb8;
  --accent-soft: #eaf0fc;
  --ours: #fa9d57;
  --ours-soft: #fff4ea;
  --c-input: #d8514b;
  --c-dresscode: #70ad47;
  --c-chatgarment: #f7c56e;
  --c-isp: #69addc;
  --c-gr: #4c74b1;
  --radius: 18px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-2: 0 10px 30px -12px rgba(16, 24, 40, .18), 0 2px 6px rgba(16, 24, 40, .05);
  --shadow-3: 0 30px 60px -24px rgba(16, 24, 40, .28);
  --ease: cubic-bezier(.22, .8, .24, 1);
  --head: 'Google Sans', 'Noto Sans', system-ui, -apple-system, sans-serif;
  --body: 'Noto Sans', system-ui, -apple-system, sans-serif;
}

html { scroll-behavior: smooth; scroll-padding-top: 16px; }

/* ---------- problem setting ---------- */
.setting { background: #f4f4f4; }
.setting__eyebrow {
  font-family: var(--head); font-weight: 700; font-size: .95rem; letter-spacing: .22em; text-transform: uppercase;
  color: #4b5563; text-align: center; margin-bottom: 10px;
}
/* width chosen so the three lines end almost flush (last line ~92% full at desktop) */
.setting .subtitle { max-width: 648px; margin-left: auto; margin-right: auto; text-wrap: pretty; }
.setting__title {
  font-family: var(--head); font-weight: 700; font-size: clamp(1.6rem, 2.6vw, 2.2rem); line-height: 1.2;
  letter-spacing: -.01em; color: #111418; text-align: center; margin-bottom: 22px;
}

/* ---------- blocks ---------- */
.block { padding: 88px 20px; }
.block.is-soft { background: linear-gradient(180deg, #f7f8fa 0%, #fbfbfc 100%); border-top: 1px solid var(--line); }
.block__inner { max-width: 1240px; margin: 0 auto; }
.block__inner.is-narrow { max-width: 820px; }
.block__inner.is-wide { max-width: 1320px; }
.block__head { max-width: 860px; margin: 0 auto 38px; text-align: center; }
.block__title {
  font-family: var(--head); font-weight: 700; font-size: clamp(2rem, 3.6vw, 2.8rem); letter-spacing: -.025em;
  color: var(--ink); margin-bottom: 14px; text-align: center;
}
.block__lead { color: var(--ink-2); font-size: 1.08rem; line-height: 1.7; }
.abstract { font-size: 1.06rem; line-height: 1.8; color: var(--ink-2); text-align: left; hyphens: manual; }
.abstract strong { color: var(--ink); }

.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }

/* ---------- interactive viewer ---------- */
#viewer > .stage-wrap, #gallery > .stage-wrap { max-width: 1040px; }
#viewer .comparison-scene-prompt { font-size: 1.05rem; margin-bottom: .6rem; }
/* the result's own description: two lines reserved and filled from the bottom,
   so a long one never moves the viewer */
.stage-prompt {
  font-family: var(--head); font-size: .95rem; line-height: 1.5; color: #7a7a7a; text-align: center;
  min-height: 3em; max-width: 820px; margin: 0 auto .9rem;
  display: flex; align-items: flex-end; justify-content: center; text-wrap: balance;
}
/* photo over pattern on the left, the gray 3D view on the right, layer buttons under the figure */
.stage {
  --gray: #f0f0f0;
  display: grid; grid-template-columns: 230px minmax(0, 1fr); grid-template-rows: clamp(460px, 62vh, 580px) auto;
  column-gap: 16px;
}
.stage__side { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.stage__tile { position: relative; margin: 0; border-radius: 14px; overflow: hidden; background: var(--gray); }
.stage__tile figcaption {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 6px;
  font-family: var(--head); font-size: .72rem; color: #4a4a4a; background: rgba(255, 255, 255, .86);
}
.stage__photo { flex: none; aspect-ratio: 4 / 5; }
/* the photo is scaled up to fill its tile, anchored at the top so the face always shows */
.stage__photo img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }
.stage__photo img.is-cutout { object-fit: contain; background: #fff; }
.stage__photo img:not([src]) { visibility: hidden; }   /* no broken-image icon before the first result */
/* a hairline keeps a white cut-out photo reading as a tile on the white page */
.stage__photo::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .07); pointer-events: none; }
.stage__pattern { flex: 1 1 auto; min-height: 0; padding: 12px 12px 34px; }
.pattern { display: grid; grid-template-rows: minmax(0, 1fr); height: 100%; }
.pattern img { grid-area: 1 / 1; width: 100%; height: 100%; min-height: 0; object-fit: contain; display: block; }
.pattern img:not(.is-on) { visibility: hidden; }

.stage__view {
  grid-column: 2; grid-row: 1; position: relative; outline: none; overflow: hidden;
  background: var(--gray); border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, .12);
}
.stage__view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.stage__view canvas:active { cursor: grabbing; }
/* WebGL fallback: the white turntable multiplied onto the gray */
.stage__fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.stage__view.is-fallback .stage__tools .tool:not(#tool-full) { display: none; }

.stage__tools {
  position: absolute; top: 14px; right: 14px; z-index: 2; display: flex; gap: 2px; padding: 4px; border-radius: 12px;
  background: rgba(255, 255, 255, .9); box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px -6px rgba(0, 0, 0, .16);
}
.tool {
  width: 34px; height: 34px; border: 0; border-radius: 9px; padding: 0; display: grid; place-items: center;
  background: transparent; color: #4a4a4a; cursor: pointer; transition: background .15s, color .15s;
}
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: #eeeeee; color: #1a1a1a; }
.tool[aria-pressed="true"] { background: #e4e4e4; color: #1a1a1a; }
.tool:focus-visible { outline: 2px solid #3273dc; outline-offset: 1px; }
.stage__nav {
  position: absolute; top: 50%; z-index: 2; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255, 255, 255, .9); box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px -6px rgba(0, 0, 0, .16);
}
.stage__nav:hover { background: #fff; }
.stage__nav.is-prev { left: 14px; }
.stage__nav.is-next { right: 14px; }

/* the layer buttons are the comparison scene buttons; a later layer adds to the ones before it */
/* buttons and tips centre on the whole block (the page), not on the viewer column */
.stage__layers { grid-column: 1 / -1; grid-row: 2; margin: 1.25rem 0 0; }
.stage__layers .comparison-scene-button.is-static { cursor: default; }

.stage__loading {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(240, 240, 240, .72); opacity: 0; visibility: hidden; transition: opacity .35s var(--ease), visibility 0s .35s;
}
.stage__loading.is-on { visibility: visible; transition: opacity .2s; }
.stage__loading-text { margin: 0; font: 500 .9rem/1 var(--head); color: #555; letter-spacing: .01em; }
.stage__loading-text span + span { margin-left: .45em; color: #8a8a8a; font-variant-numeric: tabular-nums; }
.stage__loading.is-on { opacity: 1; }
.ring { width: 40px; height: 40px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke: #dcdcdc; stroke-width: 3; }
.ring .ring__bar { stroke: #2b2b2b; stroke-linecap: round; stroke-dasharray: 106.8; stroke-dashoffset: 106.8; transition: stroke-dashoffset .25s; }
/* before any progress is known the ring spins with a short arc */
.ring.is-spin svg { animation: ring-spin .9s linear infinite; }
.ring.is-spin .ring__bar { stroke-dashoffset: 80 !important; transition: none; }
@keyframes ring-spin { to { transform: rotate(270deg); } }
.stage__view:fullscreen { border-radius: 0; }
.stage > .viewer-illustration { grid-column: 1 / -1; grid-row: 3; margin-top: 1rem; }
#gallery { padding-top: 1.5rem; }
#gallery .comparison-scene-prompt { font-size: 1.05rem; }

/* ---------- gallery cards (marquee on the page, grid on gallery.html) ---------- */
.card {
  position: relative; border-radius: var(--radius); overflow: hidden; background: #fff; cursor: pointer;
  border: 1px solid var(--line); transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .2s;
  outline: none; animation: cardIn .6s var(--ease) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.card:hover, .card:focus-visible { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: var(--line-2); }
.card.is-current { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink), var(--shadow-2); }
.card__media { position: relative; aspect-ratio: 4 / 5; background: #fff; }
.card__media video, .card__media img.poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card__photo {
  position: absolute; left: 10px; top: 10px; width: 25%; aspect-ratio: 3 / 4; border-radius: 9px; overflow: hidden;
  border: 2px solid #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .16); background: var(--soft); transition: width .35s var(--ease);
}
.card__photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 25%; display: block; }
.card:hover .card__photo { width: 34%; }
.card__cta {
  position: absolute; right: 10px; bottom: 10px; font-family: var(--head); font-size: .74rem; color: #fff; background: rgba(20, 22, 26, .78);
  padding: 5px 11px; border-radius: 999px; opacity: 0; transform: translateY(6px); transition: all .3s var(--ease);
}
.card:hover .card__cta, .card.is-current .card__cta { opacity: 1; transform: none; }

/* ---------- gallery marquee ---------- */
#gallery { overflow-x: clip; }
.more-link { color: var(--accent); white-space: nowrap; font-weight: 500; border-bottom: 1px solid transparent; transition: border-color .2s; }
.more-link:hover { color: var(--accent); border-bottom-color: currentColor; }
.more-link svg { width: 1em; height: 1em; margin-left: .25em; vertical-align: -.12em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s var(--ease); }
.more-link:hover svg { transform: translateX(3px); }
/* full bleed, faded at both edges; each track holds its cards twice and slides by one copy */
.marquee {
  --card-w: 212px; --gap: 16px;
  width: 100vw; margin: 1.5rem 0 0 calc(50% - 50vw); padding: 6px 0 12px; display: grid; grid-template-columns: 100%; row-gap: 14px; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.marquee__row { min-width: 0; }
.marquee__track { display: flex; width: max-content; animation: drift-left var(--dur, 120s) linear infinite; will-change: transform; }
.marquee__row[data-dir="right"] .marquee__track { animation-name: drift-right; }
.marquee__row:hover .marquee__track, .marquee__row:focus-within .marquee__track, .marquee.is-off .marquee__track { animation-play-state: paused; }
@keyframes drift-left { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-50%, 0, 0); } }
@keyframes drift-right { from { transform: translate3d(-50%, 0, 0); } to { transform: translate3d(0, 0, 0); } }
.marquee .card { flex: none; width: var(--card-w); margin-right: var(--gap); animation: none; }
.marquee .card:hover { transform: translateY(-3px); }

/* ---------- full gallery page (gallery.html) ---------- */
body.fg { margin: 0; min-height: 100vh; background: #f7f7f8; color: var(--ink); font-family: var(--body); -webkit-font-smoothing: antialiased; }
.fg *, .fg *::before, .fg *::after { box-sizing: border-box; }
.fg-bar {
  position: sticky; top: 0; z-index: 5; height: 60px; padding: 0 clamp(12px, 2.4vw, 32px);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: rgba(247, 247, 248, .86); -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.fg-back {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 10px; border-radius: 999px;
  color: var(--ink-2); text-decoration: none; font: 500 .9rem/1 var(--head); transition: background .15s, color .15s;
}
.fg-back:hover { background: rgba(0, 0, 0, .05); color: var(--ink); }
.fg-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s var(--ease); }
.fg-back:hover svg { transform: translateX(-2px); }
.fg-title { text-align: center; line-height: 1.2; }
.fg-title b { display: block; font: 600 1.05rem/1.2 var(--head); letter-spacing: -.01em; }
.fg-title span { display: block; font: .74rem/1.3 var(--head); color: var(--muted); margin-top: 2px; }
.fg-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px;
  padding: 18px clamp(12px, 2.4vw, 32px) 48px;
}
.fg-grid .card { border-radius: 14px; }
.fg-grid .card__photo { border-radius: 7px; }

/* ---------- comparisons (CHORD template classes, see index.css) ---------- */
/* our turntables are rendered on white; the input photo spans the view rows without
   setting their height, so both rows stay equal and each label centres on its row */
.comparison-section .comparison-video { max-width: 190px; aspect-ratio: 4 / 5; object-fit: cover; background: #fff; }
.comparison-video-wrapper.is-input { position: relative; width: 190px; align-self: stretch; }
.comparison-video.is-input {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto;
  object-fit: contain; padding: 10px;
}
.comparison-section .comparison-view-label { justify-content: center; padding-right: 0; }
.comparison-section .comparison-scene-prompt { font-size: 1.05rem; }
/* scene switch: one grid at a time, swapped only once the next scene is buffered */
.comparison-stack { display: grid; }
.comparison-stack > .comparison-grid { grid-area: 1 / 1; }

/* ---------- BibTeX copy ---------- */
.bib { position: relative; }
.bib pre { padding-right: 4.5rem; }
.bib__copy {
  position: absolute; top: 10px; right: 10px; z-index: 1; height: 32px; min-width: 32px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid #e3e3e3; border-radius: 8px; background: #fff; color: #555; cursor: pointer;
  font: 500 .8rem/1 var(--head); box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
  opacity: 0; transform: translateY(-2px); transition: opacity .18s, transform .18s, background .15s, color .15s, border-color .15s;
}
.bib:hover .bib__copy, .bib__copy:focus-visible, .bib__copy.is-done { opacity: 1; transform: none; }
.bib__copy:hover { background: #f7f7f7; color: #222; border-color: #d6d6d6; }
.bib__copy:focus-visible { outline: 2px solid #3273dc; outline-offset: 2px; }
.bib__copy svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bib__check, .bib__label { display: none; }
.bib__copy.is-done { color: #1a7f4b; border-color: #bfe3cf; background: #f1faf5; }
.bib__copy.is-done .bib__icon { display: none; }
.bib__copy.is-done .bib__check, .bib__copy.is-done .bib__label { display: inline; }

/* ---------- garments in motion ---------- */
/* wide enough that the two sentences set in two full lines, no lone words on a third */
.motion-lead { max-width: 820px; margin: 0 auto; }

/* ---------- hero backdrop film ---------- */
/* fills the hero like a cover image, centred left-right, its bottom edge on the hero's bottom,
   so the dancers and the sand stay in view on any screen shape */
.hero.video .hero-video { display: block; position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }   /* Bulma hides it on phones */
.hero.video .hero-video video {
  position: absolute; inset: 0; width: 100%; height: 100%; min-width: 0; min-height: 0;
  transform: none; object-fit: cover; object-position: 50% 100%;
}

/* ---------- responsive ---------- */
@media (max-width: 767px) {
  /* the view on top, its layer buttons, then photo | pattern */
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: 60vh auto auto auto; }
  .stage > .viewer-illustration { grid-column: 1; }
  .stage__view { grid-column: 1; min-height: 360px; border-radius: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .1); }
  .stage__layers { grid-column: 1; margin-top: 1rem; }
  .stage__side { grid-column: 1; grid-row: 4; flex-direction: row; margin-top: 1rem; }
  .stage__side > * { flex: 1 1 0; min-width: 0; aspect-ratio: 4 / 5; }
  .stage__pattern { padding: 10px 10px 32px; }
  .stage__nav { width: 34px; height: 34px; }
  .stage__layers { gap: .5rem; }
  .stage__layers .comparison-scene-button.button { padding: .45rem 1rem; font-size: .88rem; }
  .marquee { --card-w: 148px; --gap: 10px; row-gap: 10px; }
  .fg-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
  .fg-grid .card__cta { display: none; }
  .fg-title span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  /* no drift: each row scrolls by hand and shows its cards once */
  .marquee__track { animation: none; }
  .marquee__row { overflow-x: auto; }
  .marquee .card[aria-hidden="true"] { display: none; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .card { animation: none; }
  html { scroll-behavior: auto; }
}

/* keep each author name on one line in the title */
.hero-body h1 a { white-space: nowrap; }

/* affiliations in two rows: 1, 2 then 3, 4 */
.affiliation-break { flex-basis: 100%; height: 0; }
.affiliation-line { row-gap: .35rem; }
