:root {
  --bg: #0c0c0c;
  --fg: #f2efe9;
  --muted: #8a867f;
  --accent: #e8b64c;
  --pad: clamp(16px, 2.4vw, 32px);
  --font: "Inter Tight", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }

/* ---------- top / bottom bars ---------- */
.topbar, .bottombar {
  position: fixed; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: var(--pad); font-size: 13px; letter-spacing: .02em;
  pointer-events: none;
}
.topbar > *, .bottombar > * { pointer-events: auto; }
.topbar { top: 0; }
.bottombar { bottom: 0; color: var(--muted); }
.brand { font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

.filters { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.filters button, .shapes button, .about-btn { color: var(--muted); transition: color .2s; }
.filters button:hover, .filters button.on,
.shapes button:hover, .shapes button.on, .about-btn:hover { color: var(--fg); }
.filters button.on::before { content: "● "; color: var(--accent); font-size: 9px; vertical-align: 2px; }

.shapes { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- the cloud ---------- */
.home { overflow: hidden; height: 100vh; height: 100dvh; }
.stage { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
.stage.dragging, .stage.dragging .tile { cursor: grabbing; }

.tile {
  position: absolute; left: 0; top: 0;
  display: block; will-change: transform;
  opacity: 0;
  transition: opacity .6s ease, filter .4s ease;
  cursor: pointer;
}
.tile img {
  display: block; width: 100%; height: auto;
  max-height: none; user-select: none; -webkit-user-drag: none;
  transition: filter .3s;
}
.tile.in { opacity: var(--a, 1); }
.stage .tile.is-hover { opacity: 1; }
.tile.out { opacity: .07 !important; pointer-events: none; filter: grayscale(1); }

.stage.has-hover .tile.in:not(.is-hover):not(.is-related) { opacity: .28; filter: grayscale(1); }
.stage.has-hover .tile.is-related { opacity: .9; }
.tile.is-hover img { filter: drop-shadow(0 18px 30px rgba(0,0,0,.25)); }

/* cursor label */
.label {
  position: fixed; left: 0; top: 0; z-index: 1001; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 12px; background: var(--fg); color: var(--bg);
  font-size: 13px; line-height: 1.25; white-space: nowrap;
  opacity: 0; transform: translate(-999px, -999px); transition: opacity .2s;
}
.label.show { opacity: 1; }
.label-title { font-weight: 600; }
.label-meta { opacity: .6; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }

/* page-leave transition */
body.leaving .tile { opacity: 0 !important; transition: opacity .4s ease; }
.ants-bg { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; transition: opacity .4s; }
body.leaving .ants-bg { opacity: 0 !important; }
.page main { position: relative; z-index: 1; } /* page content above the ant background */
.ants-video { inset: auto; left: 50%; top: 50%; width: auto; transform: translate(-50%, -50%); mix-blend-mode: multiply; object-fit: contain; }
.ants-toggle { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1100; font-size: 12px;
  display: flex; gap: 6px; align-items: center; background: var(--fg); color: var(--bg); padding: 6px 10px; }
.ants-toggle a { color: var(--bg); opacity: .55; padding: 2px 6px; text-decoration: none; }
.ants-toggle a.on { opacity: 1; outline: 1px solid var(--bg); }
body.leaving .tile.clicked { transition: opacity .4s ease .05s; }
body.leaving .topbar, body.leaving .bottombar { opacity: 0; transition: opacity .3s; }


/* ---------- project page ---------- */
.project-page { opacity: 0; transition: opacity .5s; }
.project-page.ready { opacity: 1; }
.project-page .topbar { position: sticky; background: linear-gradient(var(--bg), transparent); }
.project-page .topbar, .project-page .bottombar { pointer-events: auto; }
.back { color: var(--muted); transition: color .2s; }
.back:hover { color: var(--fg); }

.proj { padding: 0 var(--pad) 120px; max-width: 1400px; margin: 0 auto; }
.proj-hero { width: 100%; max-height: 82vh; object-fit: cover; display: block; margin-top: 8px; }
.proj-head { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin: 48px 0 64px; }
.proj-title { font-size: clamp(36px, 6vw, 88px); line-height: .98; font-weight: 500; margin: 0; letter-spacing: -.02em; }
.proj-meta { color: var(--muted); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; margin-top: 18px; }
.proj-desc { font-size: clamp(16px, 1.5vw, 20px); line-height: 1.6; }
.proj-desc p:first-child { margin-top: 0; }
.proj-credits { display: grid; grid-template-columns: auto 1fr; gap: 6px 24px; font-size: 14px; margin-top: 28px; }
.proj-credits dt { color: var(--muted); }
.proj-credits dd { margin: 0; }

.proj-video { position: relative; aspect-ratio: 16 / 9; margin-bottom: 24px; background: #000; }
.proj-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.proj-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.proj-gallery img { width: 100%; height: auto; display: block; }
.proj-gallery img.wide { grid-column: 1 / -1; }

/* content blocks (project pages written with "blocks" in config.js) */
.proj-body { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 40px; }
.b-text { font-size: clamp(18px, 1.7vw, 23px); line-height: 1.65; }
.b-text strong, .b-quote strong { font-weight: 600; }
html:has(.project-page) { scroll-behavior: smooth; }
.b-insta { display: flex; justify-content: center; }
.b-insta .instagram-media { margin: 0 auto !important; width: 100%; max-width: 540px; min-width: 280px !important; }
.b-text[id] { scroll-margin-top: 90px; } /* in-page links land below the sticky top bar */
.b-row { display: flex; gap: 14px; align-items: flex-start; }
.b-cell { flex: 1 1 0%; min-width: 0; }
.b-cell img, .b-cell video, .b-image img, .b-image video { display: block; width: 100%; height: auto; }
.b-row.square .b-cell img, .b-row.square .b-cell video { aspect-ratio: 1; object-fit: cover; }
.b-row + .b-row { margin-top: -26px; }
.b-grid { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); gap: 24px; align-items: start; }
.b-grid .b-cell { margin: 0; }
.b-grid.square .b-cell img, .b-grid.square .b-cell video { aspect-ratio: 1; object-fit: cover; }
.b-grid .b-cell.big { grid-column: span 2; grid-row: span 2; align-self: stretch; display: flex; flex-direction: column; }
.b-grid .b-cell.big img, .b-grid .b-cell.big video { flex: 1; min-height: 0; height: 100%; object-fit: cover; }
.b-grid figcaption { margin-top: 8px; font-size: 13px; color: var(--muted); text-align: center; }
@media (max-width: 600px) { .b-grid { grid-template-columns: repeat(min(var(--cols, 3), 3), 1fr); gap: 10px; } }
.b-image { margin: 0 auto; width: 100%; }
.b-image figcaption { margin-top: 10px; font-size: 13px; color: var(--muted); text-align: center; }
.b-quote { margin: 0; padding: 4px 0 4px 24px; border-left: 2px solid var(--fg); font-size: clamp(16px, 1.4vw, 19px); line-height: 1.7; }
.b-pullquote { margin: 40px auto 0; max-width: 560px; padding: 36px 0; border-top: 1px solid var(--fg); border-bottom: 1px solid var(--fg); text-align: center; font-size: clamp(18px, 1.8vw, 22px); line-height: 1.6; }

.b-text.center { text-align: center; }
.b-text.small { font-size: 14px; color: var(--muted); }
.b-text ul, .b-text ol { margin: 0; padding-left: 1.2em; }
.b-text a, .b-quote a, .b-link a { border-bottom: 1px solid currentColor; }
.b-heading { font-size: clamp(24px, 2.6vw, 34px); font-weight: 500; margin: 20px 0 -10px; letter-spacing: -.01em; }
.b-pullquote cite { display: block; margin-top: 14px; font-style: normal; font-size: 13px; color: var(--muted); }
.b-divider { border: 0; border-top: 1px solid color-mix(in srgb, var(--fg) 20%, transparent); width: 100%; margin: 10px 0; }
.b-link { margin: 0; text-align: center; font-size: 15px; }

.b-columns { display: flex; gap: 28px; align-items: flex-start; }
.b-col { min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.b-col .b-text { font-size: clamp(16px, 1.3vw, 19px); }

.b-video { position: relative; aspect-ratio: 16 / 9; background: #000; }
.b-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.b-slides { position: relative; overflow: hidden; outline: none; touch-action: pan-y; user-select: none; }
.b-slides-track { display: flex; transition: transform .5s cubic-bezier(.6,0,.2,1); }
.b-slide { flex: 0 0 100%; display: flex; align-items: center; justify-content: center; }
.b-slide img, .b-slide video { display: block; width: 100%; height: auto; max-height: 80vh; object-fit: contain; pointer-events: none; }
.b-prev, .b-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 85%, transparent); color: var(--fg);
  font-size: 18px; opacity: 0; transition: opacity .2s;
}
.b-prev { left: 12px; } .b-next { right: 12px; }
.b-slides:hover .b-prev, .b-slides:hover .b-next, .b-slides:focus-visible .b-prev, .b-slides:focus-visible .b-next { opacity: 1; }
.b-count { position: absolute; right: 12px; bottom: 10px; font-size: 12px; padding: 3px 8px; background: color-mix(in srgb, var(--bg) 85%, transparent); }

.b-compare { position: relative; overflow: hidden; user-select: none; }
.b-compare > img, .b-compare > video { display: block; width: 100%; height: auto; }
.b-compare-before { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.b-compare-before img, .b-compare-before video { width: 100%; height: 100%; object-fit: cover; display: block; }
.b-compare input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.b-compare-handle { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.4); pointer-events: none; }
.b-compare-handle::after { content: "↔"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 36px; height: 36px; border-radius: 50%; background: #fff; color: #111; display: grid; place-items: center; font-size: 15px; }

@media (max-width: 720px) {
  .b-columns { flex-direction: column; }
  .b-col { width: 100%; }
  .b-prev, .b-next { opacity: 1; }
}

.proj-next { display: block; margin-top: 120px; border-top: 1px solid color-mix(in srgb, var(--fg) 15%, transparent); padding-top: 24px; }
.proj-next small { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.proj-next span { display: block; font-size: clamp(28px, 4vw, 56px); margin-top: 8px; transition: color .2s; }
.proj-next:hover span { color: var(--accent); }

.notfound { padding: 30vh var(--pad); text-align: center; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .filters { order: 3; width: 100%; justify-content: flex-start; gap: 14px; }
  .shapes { display: none; }
  .proj-head { grid-template-columns: 1fr; gap: 24px; margin: 28px 0 40px; }
  .proj-gallery { grid-template-columns: 1fr; gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile, .about, .project-page { transition: none; }
}

/* ---------- Works + About pages ---------- */
.page { opacity: 0; transition: opacity .5s; }
.page.ready { opacity: 1; }
.page .topbar, .project-page .topbar { position: sticky; background: linear-gradient(var(--bg) 60%, transparent); }
.pagenav { display: flex; gap: 22px; }
.pagenav a { color: var(--muted); transition: color .2s; }
.pagenav a:hover, .pagenav a.on { color: var(--fg); }

.works { padding: 20px var(--pad) 120px; max-width: 1300px; margin: 0 auto; }
.works-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 48px 28px; }
.work { display: block; }
.work-img { display: block; aspect-ratio: 3 / 4; overflow: hidden; background: color-mix(in srgb, var(--fg) 5%, transparent); }
.work-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s cubic-bezier(.2,.7,.2,1), filter .4s; }
.work:hover .work-img img { transform: scale(1.04); }
.work-cap { display: block; margin-top: 12px; font-size: 13px; line-height: 1.45; letter-spacing: .04em; text-transform: uppercase; font-style: italic; color: var(--muted); }
.work-cap strong { color: var(--fg); font-weight: 600; }
.work:hover .work-cap strong { text-decoration: underline; }

.aboutpage { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(28px, 5vw, 80px); align-items: start;
  padding: 20px var(--pad) 120px; max-width: 1300px; margin: 0 auto; }
.aboutpage-photo { margin: 0; position: sticky; top: 90px; }
.aboutpage-photo img { width: 100%; height: auto; display: block; }
.aboutpage-text { font-size: clamp(17px, 1.5vw, 21px); line-height: 1.65; }
.aboutpage-text p:first-child { margin-top: 0; }
.aboutpage-text .b-divider { margin: 40px 0 24px; }
.aboutpage-links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; font-size: 15px; }
.aboutpage-links a { border-bottom: 1px solid currentColor; }

.proj-subtitle { margin-top: 10px; font-size: 14px; letter-spacing: .05em; text-transform: uppercase; font-style: italic; }

@media (max-width: 720px) {
  .aboutpage { grid-template-columns: 1fr; }
  .aboutpage-photo { position: static; }
  .works-grid { grid-template-columns: 1fr 1fr; gap: 28px 12px; }
}
.b-videofig { margin: 0; }
.b-videofig figcaption, .b-col .b-image figcaption { margin-top: 10px; font-size: 13px; color: var(--muted); text-align: center; }
.b-link small { color: var(--muted); font-size: 13px; }

/* edit mode (index.html?edit) */
.editbar { position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%); z-index: 1200;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: var(--fg); color: var(--bg); padding: 10px 16px; font-size: 13px; max-width: calc(100vw - 32px); }
.editbar button, .editbar a { color: var(--bg); border: 1px solid color-mix(in srgb, var(--bg) 40%, transparent); padding: 4px 10px; }
.editbar button:hover, .editbar a:hover { background: color-mix(in srgb, var(--bg) 15%, transparent); }
.editing .tile[data-weight]:not([data-weight=""])::after {
  content: "×" attr(data-weight); position: absolute; top: 2px; left: 2px;
  background: var(--fg); color: var(--bg); font-size: 10px; line-height: 1; padding: 3px 4px; }
.editing .tile { outline: 1px dashed color-mix(in srgb, var(--fg) 25%, transparent); }

/* project page entered from the cloud: the page continues the zoom while fading in */
.project-page.zoom-in .proj { transform: scale(.9); transform-origin: 50% 30vh; transition: transform .75s cubic-bezier(.2,.7,.2,1); }
.project-page.zoom-in.ready .proj { transform: none; }
.project-page.zoom-in { transition: opacity .6s ease; }
.editbar .editbar-tools { display: inline-flex; }
.editbar .editbar-tools button + button { border-left: 0; }
.editbar button.on { background: var(--bg); color: var(--fg); }
.editbar-hint, #hiddenCount { opacity: .75; }
.editing .tile.is-hidden { opacity: .12 !important; filter: grayscale(1); }
.editing .tile.is-hidden::before { content: "×"; position: absolute; inset: 0; display: grid; place-items: center;
  color: #d33; font-size: 22px; font-weight: 600; z-index: 1; }
.editing.tool-delete .tile { cursor: not-allowed; }
.editing.tool-delete .tile.is-hidden { cursor: copy; opacity: .3 !important; }
.editbar button.primary { background: var(--bg); color: var(--fg); font-weight: 600; }
.unsaved #saveState { color: #ffb44c; }
