/* Andrew Cao: portfolio landing page.
   The room is a stack of artwork layers on a fixed-ratio stage. Interactive
   slots are placed in percentages of the stage: --x/--y/--w/--h on desktop,
   --px/--py/--pw/--ph on phones. */

:root {
  --page: #f2ece2;
  --text: #1f1b17;
  --muted: #5c5148;
  --rule: #d8cdbd;
  --accent: #762e37;
  --brass: #b08d57;
  --dim: 0;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: Inter, system-ui, sans-serif;
  --enoch: "Libre Caslon Display", Georgia, serif;
}
[data-time="evening"] {
  --page: #1f1a17;
  --text: #f1e5d3;
  --muted: #c3b29f;
  --rule: #4a3f37;
  --accent: #d79a8f;
  --dim: 0.55;
}

* { box-sizing: border-box; }
html { background: var(--page); color: var(--text); }
body { margin: 0; font-family: var(--sans); line-height: 1.5; transition: background-color .8s ease, color .8s ease; background: var(--page); }
a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--brass); outline-offset: 4px; }

.skip { position: absolute; left: -9999px; top: 8px; }
.skip:focus { left: 16px; z-index: 10; background: var(--page); padding: 8px 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Masthead */
.masthead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px 32px; padding: 28px clamp(20px, 4vw, 56px) 20px; max-width: 1600px; margin: 0 auto; }
.who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; }
.who h1, .who .who-name { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(36px, 4vw, 56px); line-height: 1; }
.who p { margin: 0; color: var(--muted); }
.masthead nav { display: flex; gap: 24px; }
.masthead nav a { text-decoration: none; padding: 10px 0; }
.masthead nav a:hover { text-decoration: underline; text-underline-offset: 5px; }

/* The room */
.room { max-width: 1600px; margin: 0 auto; padding: 0 clamp(0px, 2vw, 32px); }
.stage { position: relative; aspect-ratio: 2880 / 1800; overflow: hidden; border-radius: 2px; isolation: isolate; }
.layer, .layer img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.layer img { object-fit: cover; }
.layer, .avatar { will-change: transform; transition: transform .25s ease-out; }

/* Evening: dim the art, then light a warm pool around the lamp. */
.stage::after { content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; background: #141022; mix-blend-mode: multiply; opacity: var(--dim); transition: opacity .8s ease; }
.lamp-glow { position: absolute; z-index: 4; left: 8%; top: 0; width: 46%; height: 100%; pointer-events: none; background: radial-gradient(closest-side, rgba(255, 207, 140, .55), rgba(255, 207, 140, 0)); mix-blend-mode: screen; opacity: 0; transition: opacity .8s ease; }
[data-time="evening"] .lamp-glow { opacity: 1; }

.slot { position: absolute; left: var(--x); top: var(--y); width: var(--w); height: var(--h); z-index: 5; }

/* A work: the canvas inside the frame plus its plaque, all one link. */
.work { display: block; text-decoration: none; color: #f1e5d3; transition: transform .6s ease; }
.work:hover, .work:focus-visible { transform: translateY(-6px); }
.work .canvas { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4%; background: #2b2420; outline: 1.5px dashed rgba(176, 141, 87, .7); outline-offset: 6px; }
.work .canvas img { width: 40%; height: auto; }
.work .mark-word { font-family: var(--enoch); font-size: clamp(16px, 2.4vw, 36px); }
.work .plaque { position: absolute; left: 50%; top: calc(100% + 12px); transform: translateX(-50%); white-space: nowrap; padding: 4px 14px 5px; background: linear-gradient(180deg, #d6b98a, #a9875a); color: #2b2420; font-size: clamp(10px, .85vw, 13px); text-align: center; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.work .plaque strong { display: block; font-family: var(--enoch); font-weight: 400; font-size: 1.2em; }

.empty { display: flex; align-items: center; justify-content: center; outline: 1.5px dashed var(--brass); outline-offset: -1px; }
.empty .note { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: clamp(12px, 1.2vw, 20px); }

.avatar { object-fit: contain; z-index: 6; }

.lamp { background: none; border: 0; padding: 0; cursor: pointer; border-radius: 40%; z-index: 7; }
.lamp:hover { background: radial-gradient(closest-side, rgba(255, 220, 160, .35), transparent); }

/* Fire placeholder: two flickering glows. Andrew's own fire art can replace it. */
.fire { z-index: 2; background:
  radial-gradient(50% 60% at 50% 100%, rgba(255, 170, 70, .95), rgba(160, 60, 20, .6) 55%, transparent 75%),
  radial-gradient(35% 45% at 45% 100%, rgba(255, 230, 150, .9), transparent 70%);
  animation: flicker 2.6s ease-in-out infinite alternate; transform-origin: 50% 100%; }
@keyframes flicker {
  0% { opacity: .85; transform: scaleY(.96); }
  35% { opacity: 1; transform: scaleY(1.04); }
  70% { opacity: .9; transform: scaleY(.98); }
  100% { opacity: 1; transform: scaleY(1.02); }
}

/* Works list: the same content as text. */
.works { max-width: 760px; margin: 0 auto; padding: 56px 24px 32px; }
.works h2 { margin: 0 0 12px; font-family: var(--serif); font-weight: 400; font-size: 34px; }
.works ul { list-style: none; margin: 0; padding: 0; }
.works li a { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; padding: 16px 0; border-top: 1px solid var(--rule); text-decoration: none; }
.works .title { font-family: var(--enoch); font-size: 26px; }
.works .desc { grid-column: 1; color: var(--muted); }
.works .year { grid-column: 2; grid-row: 1; color: var(--muted); font-size: 14px; }
.works li a:hover .title { color: var(--accent); }
.works .ai-note { margin-top: 48px; padding-top: 14px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.works .more { margin: 0; padding-top: 16px; border-top: 1px solid var(--rule); color: var(--muted); }

.foot { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: center; padding: 24px 24px 40px; color: var(--muted); font-size: 14px; }

/* Phones: a portrait room, slots move to their phone positions. */
@media (max-width: 700px) {
  .room { padding: 0; }
  .stage { aspect-ratio: 1170 / 2532; max-height: 82vh; margin: 0 auto; }
  .slot { left: var(--px); top: var(--py); width: var(--pw); height: var(--ph); }
  .lamp-glow { left: -10%; width: 70%; height: 60%; }
  .work .canvas img { width: 34%; }
  .work .mark-word { font-size: 24px; }
  .work .plaque { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Provisional gallery wall: warm, restrained, museum-informed ---------- */
:root { --serif: "Instrument Serif", "Times New Roman", Times, serif; --sans: "Libre Franklin", "Franklin Gothic", "Helvetica Neue", Arial, sans-serif; --mono: var(--sans); }
[data-time="day"] { --wall: #f6f2ec; --page: #f6f2ec; --text: #2a2521; --muted: #74695f; --rule: #e3dbd0; --panel: #ece4d8; --panel2: #e4d9ca; }
[data-time="evening"] { --wall: #1f1a16; --page: #1f1a16; --text: #efe7dc; --muted: #ab9e90; --rule: #3a322b; --panel: #2c2520; --panel2: #332a24; }
body { background: var(--wall); font-family: var(--sans); color: var(--text); }
.masthead { align-items: flex-end; padding-top: 44px; }
.who { flex-direction: column; gap: 10px; }
.who h1, .who .who-name { font-family: var(--serif); font-weight: 400; color: var(--text); letter-spacing: -0.015em; font-size: clamp(48px, 6.5vw, 104px); line-height: .9; }
.who p { font-size: 14px; color: var(--muted); }
.who .who-name a { color: inherit; text-decoration: none; }
.masthead nav { align-items: center; gap: 26px; font-size: 14px; }
.masthead nav a { color: var(--text); }
.lamp { width: 44px; height: 44px; border: 0; background: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.lamp .bulb { width: 11px; height: 11px; border-radius: 50%; border: 1.25px solid var(--muted); transition: background-color .8s ease, box-shadow .8s ease, border-color .8s ease; }
[data-time="evening"] .lamp .bulb { background: #f3cf95; border-color: #f3cf95; box-shadow: 0 0 16px 5px rgba(243, 207, 149, .35); }

/* Wall text, as a gallery opens a room. */
.wall-text { max-width: 46ch; margin: clamp(20px, 3vw, 40px) auto 0; padding: 0 24px; font-size: 16px; line-height: 1.7; color: var(--text); text-align: left; }

.gallery { padding: clamp(40px, 6vw, 96px) 0 clamp(32px, 4vw, 64px); max-width: none; }
.wall { overflow-x: auto; scrollbar-width: none; }
.wall::-webkit-scrollbar { display: none; }
.track { display: flex; align-items: flex-start; gap: clamp(64px, 8vw, 144px); width: max-content; padding: 24px clamp(24px, 6vw, 96px); }
.piece { position: relative; margin: 0; display: grid; grid-template-rows: var(--band) auto; align-items: center; gap: 22px; text-decoration: none; color: var(--text); width: var(--pw); }
.track { --band: clamp(240px, 24vw, 400px); }
.piece.size-l { --pw: clamp(360px, 36vw, 610px); }
.piece.size-m { --pw: clamp(260px, 25vw, 420px); }
.piece.size-s { --pw: clamp(150px, 14vw, 230px); }
.piece .art { position: relative; display: block; align-self: center; box-shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 14px 30px rgba(60, 40, 20, .08); }
.piece .art img { display: block; width: 100%; height: auto; }
.piece .art.sketch { background: #fbf8f3; transition: filter .8s ease; }
[data-time="evening"] .piece .art.sketch { filter: brightness(.78) sepia(.15); }
.piece .art.square { aspect-ratio: 1; background: var(--panel); box-shadow: none; }
.piece .art.square.alt { background: var(--panel2); }
.label { align-self: start; display: flex; flex-direction: column; gap: 3px; font-size: 13px; line-height: 1.5; color: var(--muted); max-width: 36ch; }
.label .t { font-family: var(--serif); font-style: italic; font-size: 21px; line-height: 1.15; color: var(--text); }
.label .ty { color: var(--muted); }
.label .m { color: var(--text); opacity: .85; }
.label .c { font-size: 12px; }
a.piece:hover .art, a.piece:focus-visible .art { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(60,40,20,.08), 0 20px 40px rgba(60,40,20,.12); }
a.piece:focus-visible { outline: none; }
a.piece:focus-visible .art { outline: 1.5px solid var(--text); outline-offset: 8px; }

/* The edge glide (Pottermore style): still while the mouse is in the middle,
   a slow glide toward whichever edge it nears, a soft coast to a stop. The
   work nearest the centre comes forward. Touch screens, reduced motion and
   no JavaScript get a still, swipeable row. */
.wall.glide { overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); }
.wall.glide .track { will-change: transform; }
/* The glide moves the strip itself; native snapping underneath it would pull the
   hidden scroll position back to the nearest work and break the loop. */
.wall.glide { scroll-snap-type: none; }
.wall.glide .piece { scroll-snap-align: none; }
.wall .piece .art { transition: transform .9s cubic-bezier(.2, .7, .2, 1), box-shadow .6s ease, opacity .9s ease; }
.wall.glide .piece:not(.is-active) .art { transform: scale(.94); opacity: .82; }
.wall.glide .piece .label { opacity: .4; transition: opacity .8s ease; }
.wall.glide .piece.is-active .label { opacity: 1; }
.wall { scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.wall .piece { scroll-snap-align: center; }
.glide-nav { display: inline-flex; gap: 22px; }
.step { font: inherit; font-size: 14px; color: var(--text); background: none; border: 0; padding: 12px 0; min-height: 44px; cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 6px; transition: text-decoration-color .4s ease; }
.step:hover { text-decoration-color: var(--text); }

.wall-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: clamp(32px, 4vw, 56px) clamp(20px, 5vw, 80px) 0; }
.note-next { margin: 0; font-size: 14px; font-style: italic; color: var(--muted); }

/* Evening: the room goes dark and each work gets its own spotlight. */
.piece::before { content: ""; position: absolute; left: -30%; right: -30%; top: -30%; height: 120%; background: radial-gradient(50% 50% at 50% 45%, rgba(255, 226, 180, .14), transparent 70%); opacity: 0; transition: opacity .8s ease; pointer-events: none; }
[data-time="evening"] .piece::before { opacity: 1; }
[data-time="evening"] .piece .art { box-shadow: 0 20px 50px rgba(0,0,0,.5); }

.foot { font-size: 13px; }
.works h1, .works h2 { font-family: var(--serif) !important; font-weight: 400 !important; }

@media (max-width: 700px) {
  .track { --band: 52vw; gap: 40px; }
  .piece.size-l { --pw: 78vw; }
  .piece.size-m { --pw: 64vw; }
  .piece.size-s { --pw: 40vw; }
}

/* ---------- Editorial flourishes ---------- */
.orn { display: block; color: var(--muted); opacity: .7; }
.orn-wrap { display: flex; justify-content: center; margin-top: clamp(8px, 2vw, 24px); }
.wall-text { text-align: center; max-width: 44ch; font-size: 17px; }
.wall-text .lead { font-variant-caps: all-small-caps; letter-spacing: .06em; font-size: 1.08em; }
.wall-foot { justify-content: center; position: relative; }
.wall-foot .glide-nav { position: absolute; right: clamp(20px, 5vw, 80px); }
.note-next { display: flex; align-items: center; gap: 16px; font-family: var(--serif); font-style: italic; font-size: 18px; }
.note-next .rule { width: 56px; height: 1px; background: linear-gradient(90deg, transparent, var(--muted)); }
.note-next .rule.r { background: linear-gradient(90deg, var(--muted), transparent); }
.foot { flex-direction: column; align-items: center; gap: 14px; padding-top: 40px; }
.colophon { margin: 0; font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--muted); text-align: center; }
.colophon a { margin-left: 10px; font-style: normal; font-family: var(--sans); font-size: 13px; }
@media (max-width: 700px) {
  .wall-foot { flex-direction: column; gap: 8px; }
  .wall-foot .glide-nav { position: static; }
  .note-next .rule { width: 32px; }
}

/* ---------- A work's windows fan out on hover or focus ---------- */
.piece .art.fan { aspect-ratio: 1440 / 900; box-shadow: none; background: none; }
.fan .w { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 3px;
  box-shadow: 0 1px 2px rgba(60,40,20,.08), 0 14px 30px rgba(60,40,20,.12);
  transition: transform .8s cubic-bezier(.2, .8, .2, 1), opacity .6s ease; }
.fan .back-l { transform: translate(-2%, -3%) rotate(-1.2deg) scale(.96); opacity: .9; }
.fan .back-r { transform: translate(2%, -3%) rotate(1.2deg) scale(.96); opacity: .9; }
a.piece:hover .fan, a.piece:focus-visible .fan { transform: none; box-shadow: none; }
a.piece:hover .fan .back-l, a.piece:focus-visible .fan .back-l { transform: translate(-30%, -7%) rotate(-5deg) scale(.86); opacity: 1; }
a.piece:hover .fan .back-r, a.piece:focus-visible .fan .back-r { transform: translate(30%, -7%) rotate(5deg) scale(.86); opacity: 1; }
a.piece:hover .fan .front, a.piece:focus-visible .fan .front { transform: translateY(-4px); box-shadow: 0 2px 4px rgba(60,40,20,.1), 0 24px 48px rgba(60,40,20,.18); }
.wall.glide .piece:not(.is-active) .fan .w { transition-duration: .5s; }

/* ---------- Case study pages ---------- */
.case { max-width: 1080px; margin: 0 auto; padding: 8px 24px 40px; }
.case .back { font-size: 14px; color: var(--muted); }
.case h1 { margin: 28px 0 6px; font-family: var(--serif); font-weight: 400; font-size: clamp(44px, 6vw, 84px); line-height: .95; letter-spacing: -.015em; }
.case .dek { margin: 0 0 8px; font-size: 17px; max-width: 52ch; }
.case .meta { margin: 0 0 32px; font-size: 13px; color: var(--muted); }
.case figure { margin: 0 0 56px; }
.case figure img { display: block; width: 100%; height: auto; border-radius: 3px; box-shadow: 0 1px 2px rgba(60,40,20,.08), 0 16px 36px rgba(60,40,20,.12); }
.case figcaption { margin-top: 14px; font-size: 14px; color: var(--muted); max-width: 60ch; }
.case figcaption b { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 21px; color: var(--text); margin-right: 6px; }
.case .pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.case .visit { display: inline-block; margin: 8px 0 48px; font-size: 16px; text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 6px; }
.case .visit:hover { text-decoration-color: var(--text); }
@media (max-width: 700px) { .case .pair { grid-template-columns: 1fr; } }

/* ---------- Interludes: public-domain paintings hung between works ---------- */
.piece .art.painting img { width: 100%; height: auto; }
.piece .art.lunette { box-shadow: none; filter: drop-shadow(0 1px 1px rgba(60,40,20,.08)) drop-shadow(0 12px 22px rgba(60,40,20,.10)); }
.piece .art.painting { transition: transform .9s cubic-bezier(.2, .7, .2, 1), box-shadow .6s ease, opacity .9s ease, filter .8s ease; }
[data-time="evening"] .piece .art.painting img { filter: brightness(.86); }
[data-time="evening"] .piece .art.lunette { filter: drop-shadow(0 18px 30px rgba(0,0,0,.5)); }
.interlude .label .c { font-style: italic; }

/* ---------- Engraved Corinthian pilasters framing the glide ----------
   Capital from the Encyclopédie's plate of the five orders; its fluted shaft is
   repeated to full height and fades toward the floor. A wall-coloured body sits
   under the engraving so the works pass behind it. */
.gallery { position: relative; --band: clamp(240px, 24vw, 400px); }
.pilaster { position: absolute; z-index: 3; pointer-events: none;
  top: calc(clamp(40px, 6vw, 96px) - 10px); height: calc(var(--band) + 210px);
  width: clamp(46px, 4.4vw, 76px); }
.pilaster.l { left: clamp(10px, 2.6vw, 44px); }
.pilaster.r { right: clamp(10px, 2.6vw, 44px); }
.pilaster::before, .pilaster::after { content: ""; position: absolute; inset: 0;
  -webkit-mask: var(--m) top center / 100% auto no-repeat; mask: var(--m) top center / 100% auto no-repeat; }
.pilaster::before { --m: url(/art/wall/pilaster-body.webp); background: var(--wall); transition: background-color .8s ease; }
.pilaster::after { --m: url(/art/wall/pilaster-ink.webp); background: var(--muted); opacity: .78; transition: background-color .8s ease; }
[data-time="evening"] .pilaster::after { opacity: .6; }
@media (max-width: 700px) { .pilaster { display: none; } }

/* Instagram and TikTok as quiet text links in the footer. */
.elsewhere { margin: 0; display: flex; gap: 18px; align-items: baseline; font-size: 13px; }
.elsewhere a { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 5px; }
.elsewhere a:hover { text-decoration-color: var(--text); }
.elsewhere span { color: var(--muted); }
@media (max-width: 700px) { .masthead nav { flex-wrap: wrap; gap: 0 20px; } }

/* Credits on How it was made. */
.credits { list-style: none; margin: 0; padding: 0; }
.credits li { padding: 14px 0; border-top: 1px solid var(--rule); }
.credits .t { font-family: var(--serif); font-style: italic; font-size: 20px; }
.credits .s { display: block; color: var(--muted); font-size: 14px; }
/* With pilasters at the edges, the fade ends at them: nothing shows beyond. */
@media (min-width: 701px) {
  .wall.glide { -webkit-mask-image: linear-gradient(90deg, transparent 5.5%, #000 10.5%, #000 89.5%, transparent 94.5%); mask-image: linear-gradient(90deg, transparent 5.5%, #000 10.5%, #000 89.5%, transparent 94.5%); }
}
.works .credits li a { display: inline; padding: 0; border: 0; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 4px; }
