/* Jan Chi Builders — base: reset, type, layout, header, buttons, motion */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: var(--header-h); }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--fg);
  background: var(--paper);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 800; line-height: 0.98; letter-spacing: 0.005em; }
/* the display face is set in capitals, as in the approved direction (Chinese headings are unaffected) */
h1, h2, h3 { text-transform: uppercase; }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
::selection { background: var(--amber); color: var(--ink); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 200; padding: 10px 14px; background: var(--amber); color: var(--ink); font-weight: 600; }
.skip-link:focus { top: 12px; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.section { position: relative; padding-block: var(--section-y); background: var(--bg); color: var(--fg); }
.section--tight { padding-block: clamp(48px, 6vw, 96px); }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(16px, 2.2vw, 32px); }

/* ---------- type helpers ---------- */
.eyebrow { display: inline-flex; align-items: center; gap: 0.75em; font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.eyebrow b { color: var(--accent); font-weight: 700; }
/* the old serif italic accent: now the accent colour in the heading's own face */
.serif-it { font: inherit; color: var(--accent); }
.mono { font-family: var(--font-mono); }
.lede { font-size: var(--fs-lg); line-height: 1.45; color: var(--muted); max-width: 46ch; text-wrap: pretty; } /* no lone "minute." */
.muted { color: var(--muted); }
.h-xl { font-size: var(--fs-2xl); text-wrap: balance; }
.h-lg { font-size: var(--fs-xl); }

/* section heading block: eyebrow, then the headline (two balanced lines) beside or above the lede */
.section-head { display: grid; gap: 22px; margin-bottom: clamp(40px, 5vw, 72px); }
.section-head h2 { font-size: var(--fs-2xl); max-width: 20ch; text-wrap: balance; }
/* the lede in balanced lines: no one-word (EN) or one-character (ZH) last line under the headline; Chrome's `pretty`
   still left "in-house." and "到底。" alone */
.section-head .lede { text-wrap: balance; }
/* Chrome balances six lines at most; below 340 px the English Process lede runs to seven and fell back to a lone
   "later.", so it takes `pretty` there ("traded / off later."). Balance still serves the Chinese one best. */
@media (max-width: 339.98px) { #process .lede:lang(en) { text-wrap: pretty; } }
/* top-aligned, so a tall right column (a lede with links) never pushes the headline away from its eyebrow */
.section-head--split { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; column-gap: clamp(24px, 5vw, 80px); }
.section-head--split .eyebrow { grid-column: 1 / -1; }
/* below 1200 px the split left the headline a 360–490 px column and stranded its last word on a line of its own:
   stack it above the lede instead, so it keeps its full 20ch measure */
@media (max-width: 1199.98px) { .section-head--split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- buttons ---------- */
.btn { --btn-bg: transparent; --btn-fg: var(--fg); --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 12px 22px;
  border: 1px solid var(--btn-bd); border-radius: var(--radius); background: var(--btn-bg); color: var(--btn-fg);
  font-family: var(--font-body); font-weight: 700; font-size: 0.95rem; letter-spacing: 0.01em; text-decoration: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.btn:active { transform: translateY(1px); }
.btn--primary { --btn-bg: var(--accent); --btn-fg: var(--accent-contrast); --btn-bd: var(--accent); }
.btn .arrow { transition: transform var(--t-fast) var(--ease); }
.btn:focus-visible .arrow { transform: translateX(4px); }
.btn--sm { min-height: 40px; padding: 8px 16px; font-size: 0.875rem; }
.link-arrow { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-body); font-weight: 700; text-decoration: none; border-bottom: 1px solid var(--line-strong); padding-bottom: 2px; }
/* hover only where a pointer can hover: on touch a tap would leave it stuck on */
@media (hover: hover) {
  .btn:hover { --btn-bd: var(--fg); }
  .btn--primary:hover { --btn-bg: var(--fg); --btn-fg: var(--bg); --btn-bd: var(--fg); }
  .btn:hover .arrow { transform: translateX(4px); }
  .link-arrow:hover { border-color: var(--accent); }
}
@media (pointer: coarse) { .link-arrow { min-height: 44px; } }

.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--fg); font-size: var(--fs-sm); text-decoration: none; transition: background-color 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease); touch-action: manipulation; }
/* The press is a tint, not a shrink: a chip scaled under the pointer pulled its edge out from under it, so a press
   1–3 px inside the edge ended outside the chip and its click was lost. */
.chip:active { background-color: color-mix(in srgb, currentColor 16%, transparent); border-color: currentColor; transition-duration: var(--t-press); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* ---------- header ---------- */
.site-header { position: fixed; inset: 0 0 auto; z-index: var(--z-header); height: var(--header-h); color: #fff; transition: background var(--t-med) var(--ease), color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), transform var(--t-med) var(--ease); }
/* three states: transparent at the very top, translucent ink over the rest of the hero (so its CTAs never show
   through), paper once past it. Text and the amber focus ring stay as on the hero while it is ink. */
.site-header.is-scrolled { background: rgba(var(--ink-rgb), 0.86); -webkit-backdrop-filter: saturate(1.2) blur(12px); backdrop-filter: saturate(1.2) blur(12px); box-shadow: 0 1px 0 rgba(var(--on-rgb), 0.08); }
.site-header.is-solid { background: rgba(var(--paper-rgb), 0.92); color: var(--ink); box-shadow: 0 1px 0 var(--line); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); }
.site-header.is-hidden { transform: translateY(-100%); }
.site-header .container { height: 100%; display: flex; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; text-decoration: none; margin-right: auto; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-mark .m-shape { fill: currentColor; }
.brand-mark .m-win { fill: var(--amber); }
.site-header.is-solid .brand-mark .m-win { fill: var(--cobalt); } /* the windows follow the accent: deep sea on paper */
.brand-text { display: grid; line-height: 1.05; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; letter-spacing: 0.06em; text-transform: uppercase; }
.brand-sub { font-size: var(--fs-label, 0.75rem); letter-spacing: 0.32em; opacity: 0.75; } /* the 12 px floor */
.brand-sub[lang|="zh"] { font-size: var(--fs-label-zh, 0.8125rem); } /* 展齊建設: hanzi at 13 px */
.nav { display: flex; align-items: center; gap: clamp(14px, 2vw, 30px); }
/* direct children only: the action buttons at the foot of the phone menu are buttons, not menu links */
.nav > a { position: relative; display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; justify-content: center; font-size: 0.9375rem; font-weight: 600; text-decoration: none; padding: 6px 0; }
.nav > a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 7px; height: 2px; background: var(--amber); transform: scaleX(0); transform-origin: right; transition: transform var(--t-med) var(--ease); }
.nav > a:hover::after, .nav > a[aria-current="true"]::after { transform: scaleX(1); transform-origin: left; }
.nav-actions { display: none; }
.header-actions { display: flex; align-items: center; gap: 10px; }
/* the ::after pads the 28 px pill to a 44 px tap target without changing how it looks */
.lang-toggle { position: relative; display: inline-flex; border: 1px solid currentColor; border-radius: 999px; padding: 3px; background: transparent; font-family: var(--font-mono); font-size: 12px; text-decoration: none; }
.lang-toggle::after { content: ""; position: absolute; inset: -8px -4px; }
.lang-toggle span { padding: 4px 9px; border-radius: 999px; line-height: 1; white-space: nowrap; transition: background-color 160ms var(--ease); }
@media (pointer: coarse) { .lang-toggle span { padding: 7px 10px; } }
/* narrow phones: keep the taller touch padding but tighten the sides, so the header row still fits at 320 px */
@media (max-width: 420px) { .lang-toggle span { padding-inline: 7px; } .site-header .container { gap: 12px; } }
.lang-toggle span.is-active { background: currentColor; }
.lang-toggle span.is-active b { color: var(--ink); mix-blend-mode: normal; }
.site-header.is-solid .lang-toggle span.is-active b { color: var(--paper); }
.lang-toggle b { font-weight: 500; }
.lang-toggle [lang|="zh"] b { font-size: var(--fs-label-zh, 0.8125rem); } /* hanzi at the 13 px floor */
.header-cta { --btn-bg: var(--amber); --btn-fg: var(--ink); --btn-bd: var(--amber); }
/* on the paper header the accent is the deep sea, with white text (5.8:1), as on every paper section */
.site-header.is-solid .header-cta { --btn-bg: var(--cobalt); --btn-fg: #fff; --btn-bd: var(--cobalt); }
.site-header.is-solid .nav > a::after { background: var(--cobalt); }
@media (hover: hover) {
  .lang-toggle:hover span:not(.is-active) { background: color-mix(in srgb, currentColor 14%, transparent); }
  /* amber fill on ink: invert to white; on the paper header, to ink with amber text */
  .header-cta:hover { --btn-bg: var(--amber-soft); --btn-fg: var(--ink); --btn-bd: var(--amber-soft); }
  .site-header.is-solid .header-cta:hover { --btn-bg: var(--ink); --btn-fg: var(--amber); --btn-bd: var(--ink); }
}
.menu-toggle { display: none; width: 44px; height: 44px; border: 0; background: transparent; position: relative; }
.menu-toggle span { position: absolute; left: 11px; right: 11px; height: 1.5px; background: currentColor; transition: transform var(--t-med) var(--ease), opacity var(--t-fast); }
.menu-toggle span:nth-child(1) { top: 16px; }
.menu-toggle span:nth-child(2) { top: 22px; }
.menu-toggle span:nth-child(3) { top: 28px; }
.menu-open .menu-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
.menu-open .menu-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 1080px) {
  .menu-toggle { display: block; }
  .header-cta { display: none; }
  /* the open menu fills the screen below the header, so the page never shows half-covered beneath it */
  .nav { position: fixed; inset: var(--header-h) 0 0; flex-direction: column; align-items: stretch; gap: 0; padding: 12px var(--gutter) 28px; background: var(--ink); color: #fff; transform: translateY(-8px); opacity: 0; visibility: hidden; transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease), visibility 0s linear var(--t-med); overflow: auto; overscroll-behavior: contain; }
  .nav > a { justify-content: flex-start; font-family: var(--font-display); font-weight: 800; font-size: 2rem; line-height: 1; text-transform: uppercase; letter-spacing: 0.03em; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.1); }
  .nav > a::after { display: none; }
  /* you are here: amber, led by the mark's window square */
  .nav > a[aria-current="true"] { color: var(--amber); }
  .nav > a[aria-current="true"]::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 12px; vertical-align: .18em; background: var(--amber); }
  /* the menu ends in the actions: start a project, then call or WhatsApp */
  .nav-actions { display: grid; gap: 8px; margin-top: auto; padding-top: 28px; }
  .nav-actions .btn { width: 100%; min-height: 52px; font-size: 1rem; }
  .nav-actions .btn--primary { --btn-bg: var(--amber); --btn-fg: var(--ink); --btn-bd: var(--amber); }
  .nav-actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .nav-actions-row .btn { --btn-fg: #fff; --btn-bd: rgba(255, 255, 255, .32); }
  .menu-open .nav { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
  /* no backdrop-filter while open: it would make the header the containing block of the fixed menu and clip it to 72 px */
  .menu-open .site-header { background: var(--ink); color: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }
  /* the open menu turns the header ink even after it went solid: undo the solid header's paper-on-white colours */
  .menu-open .site-header .lang-toggle span.is-active b { color: var(--ink); }
  .menu-open .site-header .brand-mark .m-shape { fill: currentColor; }
}
/* short landscape (phones on their side, zoomed windows): the links in two columns and the actions in one row,
   so the whole menu, actions included, shows on opening */
@media (max-width: 1080px) and (orientation: landscape) and (max-height: 500px) {
  .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; column-gap: 32px; padding-bottom: 20px; }
  .nav > a { font-size: 1.2rem; line-height: 1.3; padding: 10px 0; }
  .nav-actions { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; padding-top: 16px; }
  .nav-actions .btn { min-height: 48px; }
}
@media (max-width: 520px) { .brand-sub { display: none; } .brand-name { font-size: 0.9rem; } }

/* ---------- scale ruler (desktop scroll indicator) ---------- */
.scale-ruler { position: fixed; right: 14px; top: 50%; z-index: var(--z-ruler); height: min(56vh, 520px); width: 34px; transform: translateY(-50%); pointer-events: none; color: var(--ink); mix-blend-mode: difference; opacity: 0; transition: opacity var(--t-med) var(--ease); }
.scale-ruler.is-visible { opacity: 1; }
.scale-ruler .ruler-track { position: absolute; right: 8px; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,.55); }
.scale-ruler .ruler-tick { position: absolute; right: 8px; height: 1px; width: 6px; background: rgba(255,255,255,.55); }
.scale-ruler .ruler-tick.major { width: 12px; }
/* the marker and the section labels ride on one layer that main.js moves with a single transform per frame */
.scale-ruler .ruler-labels { position: absolute; inset: 0; transition: transform 120ms linear; will-change: transform; }
.scale-ruler .ruler-marker { position: absolute; top: 0; right: 2px; width: 14px; height: 2px; background: #fff; transform: translateY(-1px); }
/* labels run vertically beside the ruler so they never sit over page content; at the 12 px label floor (hanzi 13 px),
   the line box's own leading keeps the glyphs clear of the 12 px major ticks */
.scale-ruler .ruler-label { position: absolute; top: 0; right: 22px; font-family: var(--font-mono); font-size: var(--fs-label, 0.75rem); letter-spacing: .12em; color: #fff; white-space: nowrap; writing-mode: vertical-rl; transform: translateY(-50%) rotate(180deg); opacity: 0; transition: opacity var(--t-med); }
.scale-ruler .ruler-label.is-active { opacity: 1; }
/* hanzi turn with the line instead of standing upside-down, at the 13 px floor and almost untracked */
.lang-zh .scale-ruler .ruler-label { text-orientation: sideways; font-size: var(--fs-label-zh, 0.8125rem); letter-spacing: .04em; }
/* the label needs ~55 px beside the content: windows from 1380 px */
@media (max-width: 1379.98px), (hover: none) { .scale-ruler { display: none; } }

/* headline lines: one block per line, unclipped so the serif italic's overhang shows */
.line-mask { display: block; }

/* ---------- footer ---------- */
.site-footer { background: var(--ink); color: #c5d0cf; padding-block: 72px 32px; font-size: var(--fs-sm); }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: #fff; }
.footer-top { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; padding-bottom: 48px; border-bottom: 1px solid rgba(255,255,255,.1); }
.footer-brand .brand { color: #fff; margin-bottom: 18px; }
.footer-zh { font-family: var(--font-serif); font-size: 1.25rem; color: #fff; letter-spacing: .08em; }
.footer-col h3 { font-family: var(--font-mono); font-size: var(--fs-label); line-height: 1.4; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; color: #93a5a8; margin-bottom: 14px; }
/* links are 44 px tall tap targets set edge to edge; plain lines keep a similar rhythm */
.footer-col li + li { margin-top: 0; }
/* "Class 2" whole, and no line opening on its dash ("— CW02", as balance set it); Chinese breaks at its ：
   (balance split 建筑 / 商) */
.footer-col li { text-wrap: pretty; }
.lang-zh .footer-col li { text-wrap: wrap; word-break: keep-all; overflow-wrap: anywhere; }
.lang-zh .footer-col a[href^="mailto:"] { overflow-wrap: normal; } /* the address whole: its column sizes to it, as in English */
.footer-col a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
.footer-col li:not(:has(a)) { padding-block: 6px; }
.footer-top-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: #c5d0cf; text-decoration: none; }
@media (hover: hover) { .footer-top-link:hover { color: #fff; } }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;padding-top: 24px; font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: .06em; color: #93a5a8; }
@media (max-width: 860px) { .footer-top { grid-template-columns: 1fr 1fr; } .footer-brand { grid-column: 1 / -1; } }
/* the e-mail address and "Registrations" side by side need 270 px: a narrower gap keeps them off the side gutter */
@media (max-width: 339.98px) { .footer-top { column-gap: 16px; } }

/* Chinese: mono labels one step larger and almost untracked, so hanzi do not read as spaced-out letters */
.lang-zh :is(.eyebrow, .footer-col h3, .footer-bottom, .footer-meaning) { font-size: var(--fs-label-zh); letter-spacing: .04em; }
.lang-zh .footer-brand p { text-wrap: balance; } /* the line under the mark: "宅。" never alone (1024 px) */

/* ---------- quick-contact bar (phones and tablets) ---------- */
/* main.js shows it (.is-on) mid-page only: never over the hero CTAs, the contact section, the Studio, the open
   menu or a focused text field. Hidden means visibility:hidden, so it is never focusable while out of sight. */
.action-bar { display: none; }
@media (max-width: 1080px) {
  .action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; /* above content and the ruler (40), below the header (50) */
    display: grid; grid-template-columns: 1fr 1fr 1.5fr; gap: 8px; padding: 8px var(--gutter) calc(8px + env(safe-area-inset-bottom));
    background: rgba(var(--ink-rgb), .94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid rgba(var(--on-rgb), .12); --focus: var(--amber);
    opacity: 0; transform: translateY(12px); visibility: hidden;
    transition: opacity 120ms var(--ease-exit), transform 120ms var(--ease-exit), visibility 0s linear 120ms; }
  .action-bar.is-on { opacity: 1; transform: none; visibility: visible; transition: opacity 180ms var(--ease), transform 180ms var(--ease), visibility 0s; }
  /* one line each, even below 344 px (EN "Start a project" wrapped there and made the bar taller than the scroll padding below) */
  .action-bar .btn { min-height: 48px; padding-inline: 10px; font-size: .9rem; white-space: nowrap; --btn-fg: #fff; --btn-bd: rgba(255, 255, 255, .3); }
  .action-bar .btn--primary { --btn-bg: var(--amber); --btn-fg: var(--ink); --btn-bd: var(--amber); }
  /* room under the legal row, so the bar never covers it (only on pages that have the bar) */
  body:has(.action-bar) .site-footer { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  /* while the bar shows, a control Tab reaches is scrolled clear of it, never left focused beneath it (WCAG 2.4.11) */
  html:has(.action-bar.is-on) { scroll-padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* the open phone menu holds the page still beneath it (main.js also makes the page inert) */
html.menu-locked { overflow: hidden; }

/* Windows High Contrast: forced colours paint backgrounds as Canvas, which hides the pressed chip, the active
   language and the menu's you-are-here mark; redraw them in system colours */
@media (forced-colors: active) {
  .chip[aria-pressed="true"], .chip.is-active { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
  .chip[aria-pressed="true"]:focus-visible, .chip.is-active:focus-visible { outline-color: CanvasText; }
  .lang-toggle span.is-active { forced-color-adjust: none; background: Highlight; }
  .lang-toggle span.is-active b, .site-header.is-solid .lang-toggle span.is-active b,
  .menu-open .site-header .lang-toggle span.is-active b { color: HighlightText; }
  .nav > a[aria-current="true"]::before, .nav > a[aria-current="true"]::after { forced-color-adjust: none; background: Highlight; }
  .menu-toggle span:not(.visually-hidden) { forced-color-adjust: none; background: CanvasText; } /* the three bars */
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; transition-delay: 0ms !important; }
}
