/* ============================================================
   THE COUNTER ON KINGSWAY — Jin Mai Bakery 金麦面包
   v3 · B&W documentary photo-essay · X9 Lab Media
   ============================================================ */

/* ---------- TOKENS ---------- */
:root {
  --paper:    oklch(0.965 0.008 83);   /* warm near-white */
  --paper-2:  oklch(0.928 0.011 80);   /* deeper paper for alt sections */
  --ink:      oklch(0.175 0.012 60);   /* warm near-black */
  --ink-soft: oklch(0.42 0.012 60);    /* muted ink for captions */
  --hair:     oklch(0.175 0.012 60 / 0.16);
  --oxblood:  oklch(0.40 0.118 24);    /* the seal */
  --film:     oklch(0.16 0.006 250);   /* B&W film black */

  --maxw: 720px;
  --bound: 1200px;          /* desktop content container */
  --gutter: clamp(20px, 6vw, 96px);
  /* distance from viewport edge to the centered content column edge */
  --side: max(var(--gutter), calc((100vw - var(--bound)) / 2 + var(--gutter)));

  --f-display: "Bodoni Moda", "Noto Serif SC", Georgia, serif;
  --f-body:    "Newsreader", "Noto Serif SC", Georgia, serif;
  --f-mono:    "Space Mono", ui-monospace, monospace;
  --f-cjk:     "Noto Serif SC", serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- RESET ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 18px;
  line-height: 1.62;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }

/* ---------- DOCUMENTARY PHOTOGRAPHY (warm B&W duotone) ---------- */
.shot {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(1) contrast(1.05) brightness(1.02) sepia(0.14);
}
.bun__ph .shot { position: absolute; }
.ph.is-fallback { display: none; }   /* shown only if the photo 404s */

a { color: inherit; }
::selection { background: var(--oxblood); color: var(--paper); }

/* ---------- LAYOUT ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.wrap--wide { max-width: var(--bound); }
.wrap--wide > p { max-width: 70ch; }
section { position: relative; }

/* ---------- READING PROGRESS ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: transparent; z-index: 80; pointer-events: none;
}
.progress__bar { height: 100%; width: 0%; background: var(--oxblood); transform-origin: left; }

/* ---------- RECURRING MINI-SEAL (corner sigil) ---------- */
.sigil {
  position: fixed; top: 18px; right: 18px; z-index: 70;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-family: var(--f-cjk); font-weight: 900;
  color: var(--paper);
  background: var(--oxblood);
  border-radius: 3px;
  font-size: 13px; line-height: 1; letter-spacing: 1px;
  writing-mode: vertical-rl; text-orientation: upright;
  opacity: 0; transform: scale(0.6) rotate(-8deg);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
  box-shadow: 0 2px 14px oklch(0.40 0.118 24 / 0.35);
}
.sigil.show { opacity: 1; transform: scale(1) rotate(-4deg); }
.sigil::after {
  content: ""; position: absolute; inset: 0; border-radius: 3px;
  background: var(--grain); mix-blend-mode: overlay; opacity: 0.5;
}

/* ---------- KICKERS / LABELS ---------- */
.kicker {
  font-family: var(--f-mono);
  font-size: 11.5px; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--ink-soft);
}
.kicker--ox { color: var(--oxblood); }
.idx {
  font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.2em;
  color: var(--oxblood);
}

/* ============================================================
   MASTHEAD
   ============================================================ */
.mast {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
  overflow: hidden;
}
.mast__bleed { position: absolute; inset: 0; z-index: 0; }
.mast__bleed-img { position: absolute; inset: -14% 0; will-change: transform; }
.mast__bleed .ph__label { display: none; }
.mast__scrim {
  position: absolute; inset: 0; z-index: 1;
  background:
    linear-gradient(180deg, oklch(0.16 0.006 250 / 0.55) 0%, oklch(0.16 0.006 250 / 0.2) 40%, oklch(0.16 0.006 250 / 0.78) 100%);
}
.mast__top, .mast__mid, .mast__btm { position: relative; z-index: 3; color: var(--paper); }
.mast__top {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: clamp(20px, 4vw, 40px) var(--side);
  gap: 12px;
}
.mast__top .kicker { color: oklch(0.965 0.008 83 / 0.82); }

.mast__mid { display: flex; flex-direction: column; justify-content: center; padding: 0 var(--side); }
.mast__title {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(2.7rem, 11.5vw, 5.5rem);
  line-height: 0.94;
  letter-spacing: -0.015em;
  margin: 0.18em 0 0.32em;
}
.mast__title .ln { display: block; overflow: hidden; }
.mast__title .ln > span { display: block; }
.js .mast__title .ln > span { transform: translateY(118%); transition: transform 1.05s var(--ease); }
.mast.ready .mast__title .ln > span { transform: translateY(0); }
.mast.ready .mast__title .ln:nth-child(1) > span { transition-delay: 0.12s; }
.mast.ready .mast__title .ln:nth-child(2) > span { transition-delay: 0.26s; }
.mast__title .it { font-style: italic; font-weight: 500; }
.mast__sub {
  font-family: var(--f-cjk); font-weight: 700;
  font-size: clamp(1.1rem, 4.4vw, 1.7rem);
  letter-spacing: 0.04em;
  color: oklch(0.965 0.008 83 / 0.94);
}
.mast__sub small { font-family: var(--f-body); font-style: italic; font-weight: 400; letter-spacing: 0; opacity: 0.8; }

.mast__btm {
  display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center;
  padding: clamp(18px, 3vw, 34px) var(--gutter) clamp(24px, 4vw, 44px);
  border-top: 1px solid oklch(0.965 0.008 83 / 0.22);
  margin-inline: var(--side);
  padding-inline: 0;
}
.mast__meta {
  font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.06em;
  color: oklch(0.965 0.008 83 / 0.8);
  display: flex; align-items: center; gap: 10px;
}
.mast__meta .star { color: var(--paper); }
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.6; }

/* the seal, set as a top-right document chop so it never overlaps the title */
.seal {
  position: absolute; z-index: 3;
  right: var(--side); top: clamp(78px, 13vh, 140px);
  width: clamp(80px, 19vw, 132px); aspect-ratio: 1;
  display: grid; place-items: center;
  background: var(--oxblood);
  color: var(--paper);
  font-family: var(--f-cjk); font-weight: 900;
  font-size: clamp(2.2rem, 7.5vw, 4rem); line-height: 0.9;
  writing-mode: vertical-rl; text-orientation: upright;
  letter-spacing: 0.04em;
  border-radius: 5px;
  transform: rotate(-3deg);
  box-shadow: 0 8px 40px oklch(0.40 0.118 24 / 0.4);
}
.seal::after {
  content: ""; position: absolute; inset: 0; border-radius: 5px;
  background: var(--grain); mix-blend-mode: overlay; opacity: 0.55;
}
.js .seal--stamp { opacity: 0; transform: scale(1.4) rotate(7deg); transition: opacity 0.55s cubic-bezier(0.16,1,0.3,1), transform 0.55s cubic-bezier(0.16,1,0.3,1); }
.mast.ready .seal--stamp { opacity: 1; transform: scale(1) rotate(-3deg); transition-delay: 0.5s; }

.scrollcue {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 4; color: oklch(0.965 0.008 83 / 0.7);
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.scrollcue .bar { width: 1px; height: 34px; background: oklch(0.965 0.008 83 / 0.5); transform-origin: top; animation: cue 2.2s var(--ease) infinite; }
@keyframes cue { 0% { transform: scaleY(0); } 40% { transform: scaleY(1); transform-origin: top; } 41% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

/* ============================================================
   ESSAY BODY
   ============================================================ */
.essay { padding: clamp(64px, 12vw, 140px) 0; }
.essay--alt { background: var(--paper-2); }

.sec-head { margin-bottom: clamp(28px, 5vw, 52px); }
.sec-head .idx { display: block; margin-bottom: 14px; }
.sec-title {
  font-family: var(--f-display); font-weight: 700;
  font-size: clamp(2rem, 8vw, 4rem); line-height: 1.0;
  letter-spacing: -0.01em;
}
.sec-title .it { font-style: italic; font-weight: 500; }
.sec-zh { font-family: var(--f-cjk); font-weight: 700; color: var(--ink-soft); margin-top: 10px; letter-spacing: 0.08em; font-size: clamp(1rem, 4vw, 1.4rem); }

.lede {
  font-size: clamp(1.18rem, 4.6vw, 1.5rem);
  line-height: 1.5;
}
.lede .dropcap {
  float: left; font-family: var(--f-display); font-weight: 800;
  font-size: 5.2em; line-height: 0.74; padding: 0.04em 0.1em 0 0;
  color: var(--oxblood);
}
.essay p + p { margin-top: 1.1em; }
.essay p { text-wrap: pretty; }

.osup {
  font-family: var(--f-mono); font-size: 0.72em; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--oxblood);
  border: 1px dashed oklch(0.40 0.118 24 / 0.5);
  padding: 1px 6px; border-radius: 3px; white-space: nowrap;
  vertical-align: 0.06em;
}

/* vertical Chinese rail — anchored to the content column's left boundary */
.rail {
  position: absolute; top: 0; bottom: 0;
  left: max(12px, calc((100vw - var(--bound)) / 2 + 6px));
  writing-mode: vertical-rl; text-orientation: upright;
  font-family: var(--f-cjk); font-weight: 700;
  font-size: clamp(13px, 2.4vw, 16px); letter-spacing: 0.3em;
  color: var(--hair); user-select: none; pointer-events: none;
  display: flex; align-items: center;
}
@media (max-width: 720px) { .rail { display: none; } }

/* ============================================================
   FULL-BLEED FIGURE
   ============================================================ */
.bleed { position: relative; width: 100%; height: clamp(64vh, 78vh, 88vh); overflow: hidden; background: var(--film); }
.bleed__img { position: absolute; inset: -16% 0; will-change: transform; }
.bleed__cap {
  position: absolute; left: var(--gutter); bottom: 18px; z-index: 3;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em;
  color: oklch(0.965 0.008 83 / 0.82); max-width: 70%;
}
.bleed__cap .tag { color: oklch(0.965 0.008 83 / 0.95); border-bottom: 1px solid oklch(0.965 0.008 83 / 0.4); }

/* ============================================================
   IMAGE PLACEHOLDER (B&W documentary)
   ============================================================ */
.ph {
  position: relative; width: 100%; height: 100%;
  background-color: var(--film);
  background-image:
    repeating-linear-gradient(135deg,
      oklch(0.24 0.006 250) 0 2px,
      transparent 2px 11px);
  display: grid; place-items: center; overflow: hidden;
}
.ph::before { /* grain */
  content: ""; position: absolute; inset: 0; background: var(--grain);
  opacity: 0.55; mix-blend-mode: screen;
}
.ph::after { /* vignette */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 30%, transparent 40%, oklch(0.10 0.006 250 / 0.65) 100%);
}
.ph__label {
  position: relative; z-index: 2; text-align: center;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.14em;
  color: oklch(0.965 0.008 83 / 0.66); line-height: 1.9;
  text-transform: uppercase; padding: 14px;
}
.ph__label b { color: oklch(0.965 0.008 83 / 0.92); font-weight: 400; border: 1px dashed oklch(0.965 0.008 83 / 0.4); padding: 2px 7px; border-radius: 3px; display: inline-block; margin-bottom: 8px; }
.ph__label span { display: block; opacity: 0.7; font-size: 10px; letter-spacing: 0.18em; }

/* ============================================================
   ATLAS OF BUNS
   ============================================================ */
.atlas { display: grid; grid-template-columns: 1fr; gap: 2px; background: var(--hair); border: 1px solid var(--hair); }
@media (min-width: 560px) { .atlas { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .atlas { grid-template-columns: 1fr 1fr 1fr; } }

.bun { background: var(--paper); position: relative; }
.essay--alt .bun { background: var(--paper-2); }
.bun__ph { aspect-ratio: 4 / 5; position: relative; }
.bun__body { padding: 18px 18px 22px; display: flex; flex-direction: column; gap: 4px; }
.bun__no { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.2em; color: var(--oxblood); }
.bun__zh { font-family: var(--f-cjk); font-weight: 700; font-size: 1.5rem; line-height: 1.1; letter-spacing: 0.04em; }
.bun__en { font-family: var(--f-body); font-style: italic; color: var(--ink-soft); font-size: 1rem; }
.bun__tag { margin-top: 8px; }
.atlas-note { margin-top: 22px; font-family: var(--f-mono); font-size: 11.5px; letter-spacing: 0.04em; color: var(--ink-soft); line-height: 1.7; }

/* ============================================================
   PULL QUOTE / THESIS
   ============================================================ */
.thesis { padding: clamp(80px, 16vw, 180px) 0; background: var(--ink); color: var(--paper); overflow: hidden; }
.thesis .kicker { color: oklch(0.965 0.008 83 / 0.55); }
.pq {
  font-family: var(--f-display); font-weight: 500; font-style: italic;
  font-size: clamp(2rem, 8.5vw, 5rem); line-height: 1.04;
  letter-spacing: -0.015em; margin: 0.3em 0 0.5em;
  text-wrap: balance;
}
.pq b { font-weight: 800; font-style: normal; color: oklch(0.62 0.13 24); }
.thesis__foot { font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.06em; color: oklch(0.965 0.008 83 / 0.6); display: flex; gap: 22px; flex-wrap: wrap; }
.thesis__foot b { color: var(--paper); font-weight: 400; font-size: 1.6em; }

/* ============================================================
   PROPOSAL
   ============================================================ */
.props { display: grid; grid-template-columns: 1fr; gap: 0; border-top: 1px solid var(--hair); margin-top: 36px; }
.prop { display: grid; grid-template-columns: auto 1fr; gap: 16px 20px; padding: 24px 0; border-bottom: 1px solid var(--hair); align-items: start; }
.prop__no { font-family: var(--f-mono); font-size: 12px; color: var(--oxblood); letter-spacing: 0.1em; padding-top: 6px; }
.prop__t { font-family: var(--f-display); font-weight: 700; font-size: clamp(1.3rem, 5vw, 1.9rem); line-height: 1.05; }
.prop__t small { display: block; font-family: var(--f-cjk); font-size: 0.62em; color: var(--ink-soft); font-weight: 700; margin-top: 4px; letter-spacing: 0.06em; }
.prop__d { font-size: 1rem; color: var(--ink-soft); margin-top: 6px; line-height: 1.55; }
.prop__body { grid-column: 1 / -1; }
@media (min-width: 600px) { .prop { grid-template-columns: 56px 1fr; } .prop__body { grid-column: 2; } }

/* ============================================================
   CTA / COLOPHON
   ============================================================ */
.cta { padding: clamp(80px, 16vw, 170px) 0 clamp(40px, 8vw, 80px); text-align: center; position: relative; overflow: hidden; }
.cta__seal {
  width: clamp(84px, 18vw, 120px); aspect-ratio: 1; margin: 0 auto clamp(28px, 5vw, 44px);
  display: grid; place-items: center; background: var(--oxblood); color: var(--paper);
  font-family: var(--f-cjk); font-weight: 900; font-size: clamp(2.2rem, 7vw, 3.4rem);
  writing-mode: vertical-rl; text-orientation: upright; border-radius: 5px; position: relative;
  box-shadow: 0 8px 40px oklch(0.40 0.118 24 / 0.3);
}
.cta__seal::after { content: ""; position: absolute; inset: 0; border-radius: 5px; background: var(--grain); mix-blend-mode: overlay; opacity: 0.5; }
.cta__head { font-family: var(--f-display); font-weight: 700; font-size: clamp(2rem, 8vw, 4.2rem); line-height: 0.98; letter-spacing: -0.01em; }
.cta__head .it { font-style: italic; font-weight: 500; }
.cta__zh { font-family: var(--f-cjk); font-weight: 700; font-size: clamp(1rem, 4vw, 1.4rem); color: var(--ink-soft); margin-top: 12px; letter-spacing: 0.08em; }

.callbtn {
  display: inline-flex; align-items: baseline; gap: 14px;
  margin-top: clamp(32px, 6vw, 52px);
  font-family: var(--f-display); font-weight: 700; text-decoration: none;
  font-size: clamp(1.5rem, 6vw, 2.6rem);
  color: var(--paper); background: var(--ink);
  padding: 0.5em 0.85em; border-radius: 4px;
  transition: transform 0.45s var(--ease), background 0.45s var(--ease);
  position: relative; overflow: hidden;
}
.callbtn:hover { transform: translateY(-3px); background: var(--oxblood); }
.callbtn .num { font-family: var(--f-mono); font-weight: 400; font-size: 0.62em; letter-spacing: 0.04em; }
.cta__sec { margin-top: 26px; }
.cta__sec a { font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.1em; color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--hair); padding-bottom: 3px; transition: color 0.3s, border-color 0.3s; }
.cta__sec a:hover { color: var(--oxblood); border-color: var(--oxblood); }

.colophon {
  margin-top: clamp(64px, 12vw, 120px);
  padding-top: 26px; border-top: 1px solid var(--hair);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.05em;
  color: var(--ink-soft); line-height: 2; text-align: left;
  display: grid; gap: 4px; max-width: 72ch; margin-inline: auto;
}
.colophon .lead { color: var(--ink); }

/* ============================================================
   REVEAL ANIMATIONS
   ============================================================ */
.rise { transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.js .rise { opacity: 0; transform: translateY(28px); }
.rise.in { opacity: 1; transform: none; }
.rise[data-d="1"] { transition-delay: 0.08s; }
.rise[data-d="2"] { transition-delay: 0.16s; }
.rise[data-d="3"] { transition-delay: 0.24s; }
.rise[data-d="4"] { transition-delay: 0.32s; }
.rise[data-d="5"] { transition-delay: 0.4s; }

.clipline { transition: clip-path 1.1s var(--ease); }
.js .clipline { clip-path: inset(0 100% 0 0); }
.clipline.in { clip-path: inset(0 0 0 0); }

/* ============================================================
   DESKTOP OPTIMIZATION (1000px and up)
   ============================================================ */
@media (min-width: 1000px) {
  /* Proposal "services" become a 2 x 2 grid */
  .props {
    grid-template-columns: 1fr 1fr;
    column-gap: clamp(40px, 5vw, 84px);
    border-top: none;
  }
  .prop { border-bottom: none; border-top: 1px solid var(--hair); }

  /* roomier atlas cards inside the wide container */
  .bun__body { padding: 22px 22px 26px; }
  .bun__zh { font-size: 1.7rem; }

  /* sit the proposal intro on a comfortable measure */
  .essay .wrap--wide .sec-head { max-width: 70ch; }
}

/* very wide screens: hold the line, never sprawl */
@media (min-width: 1600px) {
  .lede { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: 0.001s !important; }
  .rise, .clipline { opacity: 1 !important; transform: none !important; clip-path: none !important; }
  .mast__title .ln > span { transform: none !important; }
  html { scroll-behavior: auto; }
}
