/* Round 4: palette roles, layout fixes, project photos on the sa bàn, and motion. Loaded last. */

/* ---------- Language swap: no flash of Vietnamese before the English or Korean text is in ---------- */
html:not([lang="vi"]):not(.i18n-ready) body { visibility: hidden; }

/* ---------- Palette: off-white ground, forest green, sage; deep red only for actions and project markers ---------- */
.band__title, .pj-title, .policy h1, .pj-unit__name { color: var(--lake); }
#projects { background: var(--sage); }
[data-theme="dark"] #projects { background: var(--sand); }
#projects .band__title { color: var(--night); }
[data-theme="dark"] #projects .band__title { color: var(--lake); }
.about__list li > span { color: var(--lake); }
.about__faq details { background: var(--sand); box-shadow: none; }
.kk-lang button[aria-pressed="true"] { color: var(--night); }
[data-theme="dark"] .kk-lang button[aria-pressed="true"] { color: var(--ink); }
.pj-amenities li { padding-left: 18px; position: relative; }
.pj-amenities li::before { content: ""; position: absolute; left: 0; top: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--sage); }

/* ---------- Layout fixes ---------- */
/* A centred .wrap inside the flex column was shrinking to its content: the other-projects cards stacked and blocks sat off-centre. */
.page-project main > .wrap, .page-project main > section { width: 100%; }
/* The big number sits on the optical centre of the spec column next to it. */
.pj-key { align-items: center; }
.pj-key__lead { align-items: baseline; }
.pj-key .kk-spec { align-items: start; }
#more .project-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) {
  /* One row that scrolls sideways, so three projects never cost three screens of scrolling. */
  #more .project-grid { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: min(72vw, 300px); overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px var(--space-6) var(--space-4); margin-inline: calc(var(--space-6) * -1); scrollbar-width: none; overscroll-behavior-x: contain; }
  #more .project-grid > * { scroll-snap-align: start; }
}
.pj-sales .pj-sub:first-child { margin-top: 0; }
.pj-sales .pj-sub { color: var(--lake); }

/* Select: own chevron with room on the right, instead of the native arrow pressed against the edge. */
.kk-field select { -webkit-appearance: none; appearance: none; padding-right: 48px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236B6E86' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 6l4.5 4.5L12.5 6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 18px center; background-size: 16px; }

/* Bigger targets (Fitts): close button, language and filter pills, legal links. */
.consult .kk-panel__close { position: relative; width: 40px; height: 40px; }
.consult .kk-panel__close::before, .kk-lang button::before { content: ""; position: absolute; inset: -6px; }
/* Text links are 25px tall; the tap area reaches 45px. */
.kk-link { position: relative; }
.kk-link::before { content: ""; position: absolute; inset: -10px -6px; }
.kk-lang { position: relative; }
.kk-lang button { position: relative; z-index: 1; padding: 11px 14px; line-height: 18px; }
.legal a { display: inline-block; padding: 12px 0; margin: -12px 0; }

/* ---------- Project photo on the sa bàn, in place of the red volume ---------- */
/* Card radius 18 with 6px padding, so the photo radius is 12. */
.kk-pin--project .kk-pin__label, .kk-pin--project .kk-pin__label:has(.kk-pin__thumb:not([hidden])) { display: block; width: 156px; padding: 6px 6px 8px; border-radius: 18px; white-space: normal; box-sizing: border-box; transition: transform 500ms var(--kk-ease-fluid), box-shadow 500ms var(--kk-ease-fluid); transform-origin: 50% 100%; }
.kk-pin--project .kk-pin__thumb { width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: 12px; margin-bottom: 6px; }
.kk-pin--project .kk-pin__name, .kk-pin--project .kk-pin__meta { display: block; padding: 0 6px; }
.kk-pin--project { gap: 0; }
.kk-pin--project .kk-pin__label::after { content: ""; position: absolute; left: 50%; width: 2px; height: 10px; margin-left: -1px; background: var(--surface); top: 100%; }
.kk-pin--project .kk-pin__label { position: relative; margin-bottom: 10px; }
.kk-pin--below { flex-direction: column; }
.kk-pin--below .kk-pin__label { order: 1; margin: 10px 0 0; transform-origin: 50% 0; }
.kk-pin--below .kk-pin__label::after { top: auto; bottom: 100%; }
@media (hover: hover) and (pointer: fine) { a.kk-pin--project:hover .kk-pin__label { transform: scale(1.04); box-shadow: var(--shadow-highlight), var(--shadow-3); } a.kk-pin--project:hover { z-index: 3; } }
a.kk-pin--project:active .kk-pin__label { transform: scale(0.97); transition-duration: 120ms; }
.maplibregl-marker.kk-pin--project { z-index: 2; }
.maplibregl-marker.kk-pin--project.is-compact { z-index: 1; }
@media (max-width: 760px) { .kk-pin--project .kk-pin__label, .kk-pin--project .kk-pin__label:has(.kk-pin__thumb:not([hidden])) { width: 118px; } .kk-pin--project .kk-pin__meta { display: none; } }

/* ---------- Motion ---------- */
/* Arrival: ease-out, short travel, siblings staggered by 60ms. */
.kk-settle { opacity: 0; transform: translateY(18px); }
.kk-settle.is-in { opacity: 1; transform: none; transition: opacity 520ms var(--kk-ease-out), transform 620ms var(--kk-ease-out); transition-delay: calc(var(--kk-i, 0) * 60ms); }

/* Segmented control thumb. */
.kk-lang__thumb { position: absolute; left: 0; top: 0; border-radius: var(--radius-pin); background: var(--surface); box-shadow: var(--shadow-1); opacity: 0; pointer-events: none; transform-origin: 50% 50%; will-change: transform; }
.kk-lang[data-thumb] { background: var(--bezel); padding: 3px; border-radius: var(--radius-pin); }
.kk-lang[data-thumb] button[aria-pressed="true"] { background: none; }
.kk-lang button:active { transform: scale(0.97); }

/* Dialogs: start at 0.95, grow from the trigger, leave 20% faster than they came. */
.kk-navmodal { transition: opacity 240ms var(--kk-ease-out), visibility 0s 240ms; visibility: hidden; }
.kk-navmodal.is-open { transition: opacity 300ms var(--kk-ease-out), visibility 0s; visibility: visible; }
.kk-navmodal__shell { transform: scale(0.95); transition: transform 240ms var(--kk-ease-out); }
.kk-navmodal.is-open .kk-navmodal__shell { transition-duration: 300ms; }
.kk-navmodal__links a { transform: translateY(12px); transition: opacity 120ms linear, transform 120ms linear, color 200ms var(--kk-ease-out); }
.kk-navmodal.is-open .kk-navmodal__links a { transition: opacity 320ms var(--kk-ease-out), transform 420ms var(--kk-ease-out), color 200ms var(--kk-ease-out); transition-delay: calc(var(--kk-i, 0) * 40ms + 60ms), calc(var(--kk-i, 0) * 40ms + 60ms), 0ms; }
.kk-burger, .kk-burger__x::before, .kk-burger__x::after { transition-duration: 300ms; }

/* Tooltip: enters from its control at 0.95. */
[data-tip]::after { transition-duration: 180ms; }
.kk-burger[data-tip]::after { right: auto; left: calc(100% + 12px); transform: translateY(-50%) translateX(-4px); }

/* FAQ: the answer opens in 220ms and closes in 180ms. */
.about__faq details { interpolate-size: allow-keywords; }
.about__faq details::details-content { block-size: 0; overflow: clip; opacity: 0; transition: block-size 180ms var(--kk-ease-out), opacity 180ms linear, content-visibility 180ms allow-discrete; }
.about__faq details[open]::details-content { block-size: auto; opacity: 1; transition-duration: 220ms; }
.about__faq summary::after { transition-duration: 220ms; }

/* Confirmation: one pulse when a request is received. */
.kk-alert--success { animation: kk-confirm 700ms var(--kk-ease-out) 1; }
@keyframes kk-confirm { 0% { box-shadow: 0 0 0 0 rgba(96, 172, 112, 0.45); transform: scale(0.98); } 40% { transform: scale(1); } 100% { box-shadow: 0 0 0 14px rgba(96, 172, 112, 0); } }

/* Cookie card leaves 20% faster than it arrived. */
.cookie.is-leaving { animation: cookie-out 480ms var(--kk-ease-out) both; pointer-events: none; }
@keyframes cookie-out { to { opacity: 0; transform: translate(-50%, 16px); } }

/* Pins land with a small squash; the opening dot falls along an arc. */
@keyframes pin-drop { 0% { opacity: 0; transform: translateY(-36px) scale(0.96, 1.04); } 70% { opacity: 1; transform: translateY(0) scale(1.03, 0.96); } 100% { opacity: 1; transform: none; } }
.maplibregl-marker.kk-pin > * { transform-origin: 50% 100%; }
@keyframes dot-drop { 0% { opacity: 0; transform: translate(-56px, -72px) scale(0.6); } 55% { opacity: 1; transform: translate(-14px, -26px) scale(0.9); } 100% { opacity: 1; transform: none; } }

/* While the camera flies, the locator dot stretches along its track. */
.stage.is-flying .kk-locator__stop[aria-current="true"] .kk-locator__dot::before { transform: scaleX(1.12); }
.kk-locator__stop::before { transition: background-color 600ms var(--kk-ease-in-out); }

/* Lightbox: neighbours cross-fade, edges answer a key press past the last image. */
.lightbox img { transition: opacity 160ms linear; }
.lightbox.is-swapping img { opacity: 0; }
.lightbox.is-edge img { animation: edge 320ms var(--kk-ease-out); }
@keyframes edge { 40% { transform: translateX(var(--edge, 14px)); } }
.lightbox__nav { position: absolute; top: 50%; width: 48px; height: 48px; margin: -24px 0 0; background: rgba(255, 255, 255, 0.14); color: #fff; }
.lightbox__nav--prev { left: var(--space-6); } .lightbox__nav--prev svg { transform: rotate(180deg); }
.lightbox__nav--next { right: var(--space-6); }

/* Shared element: the project image you clicked becomes the cover of its page. */
@view-transition { navigation: auto; }
.pj-cover .kk-bezel__core { view-transition-name: pj-cover; }
::view-transition-group(pj-cover), ::view-transition-group(zoom) { animation-duration: 420ms; animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
::view-transition-old(pj-cover), ::view-transition-new(pj-cover), ::view-transition-old(zoom), ::view-transition-new(zoom) { height: 100%; object-fit: cover; overflow: clip; }
::view-transition-old(root) { animation-duration: 200ms; }
::view-transition-new(root) { animation-duration: 250ms; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .kk-settle { opacity: 1; transform: none; }
  .kk-alert--success, .cookie.is-leaving, .lightbox.is-edge img { animation: none; }
  .about__faq details::details-content, .kk-navmodal, .kk-navmodal__shell, .kk-navmodal__links a { transition-duration: 1ms; transition-delay: 0ms; }
}

/* ---------- Project pages: a single-hue landscape as the page ground ---------- */
/* Five tints of the forest green over the off-white ground; it stays fixed while the page scrolls over it. */
:root { --scape-ink: var(--night); }
[data-theme="dark"] { --scape-ink: var(--lake); }
body.page-project { background: none; }
.scape { position: fixed; left: 0; right: 0; bottom: 0; width: 100%; height: 100lvh; z-index: -1; pointer-events: none; background: linear-gradient(to bottom, color-mix(in oklab, var(--scape-ink) 9%, var(--ground)), var(--ground) 58%); }
/* Text blocks keep their contrast over the hills: facts and questions sit on the surface colour. */
.page-project .pj-sales > div, .page-project .pj-unit__info { background: color-mix(in oklab, var(--surface) 82%, transparent); border-radius: var(--radius-inner); padding: var(--space-6); box-shadow: var(--shadow-1); box-sizing: border-box; }
.maplibregl-marker.kk-pin--project.is-compact .kk-pin__label { display: none !important; }

/* ---------- Golden sand: a quiet second accent. Small marks only; the deep red stays the one loud colour. ---------- */
::selection { background: var(--green-tint); color: var(--ink); }
.about__list li > span, .about__faq summary::after { color: var(--green-text); }
.pj-amenities li::before { background: var(--green); }
.talk__contact dt, .talk__qr figcaption span { color: var(--green); }
.legal { border-top: 1px solid color-mix(in oklab, var(--green) 45%, transparent); padding-top: var(--space-6); }
.pj-sales .pj-sub { display: flex; align-items: center; gap: var(--space-3); }
.pj-sales .pj-sub::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: var(--green); flex: none; }
.kk-locator__stop.is-passed::before { background: var(--green); }
.post__meta b { color: var(--green-text); }
@media (max-width: 860px) { .pj-head { margin-bottom: calc(var(--space-6) * -1); } }

/* ---------- Round 10 ---------- */
/* Key figures: every number stands on one baseline, the labels hang below it. */
.pj-key { align-items: baseline; }
.pj-key .kk-spec { align-items: baseline; }
.pj-key .kk-spec > div { flex-direction: column; justify-content: flex-start; }
.pj-key .kk-spec dd { order: -1; }
.pj-key__lead { position: relative; }
@media (min-width: 861px) { .pj-key__lead span { position: absolute; left: 4px; top: 100%; margin-top: var(--space-1); font-size: 13px; line-height: 18px; white-space: nowrap; } .pj-key__lead b { line-height: 0.8; } }

/* Language block: three flags in one pill, fixed in the top corner. Each flag is 28px inside a 44px target. */
.kk-flags { position: fixed; z-index: 30; top: calc(var(--space-6) + env(safe-area-inset-top, 0px)); right: max(var(--space-6), env(safe-area-inset-right, 0px)); display: inline-flex; height: 52px; padding: 4px; box-sizing: border-box; border-radius: var(--radius-pin); background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%); box-shadow: inset 0 0 0 1px var(--bezel-ring), var(--shadow-highlight), var(--shadow-2); }
.kk-flags button { all: unset; cursor: pointer; position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-pin); transition: transform 300ms var(--kk-ease-out); }
.kk-flags #lang-next svg { width: 28px; height: 28px; border-radius: 50%; display: block; box-shadow: 0 0 0 1px var(--bezel-ring); transition: transform 300ms var(--kk-ease-out); }
.kk-flags__theme { color: var(--ink); }
.kk-flags__theme svg { width: 22px; height: 22px; }
.kk-flags button:focus-visible { box-shadow: var(--shadow-focus); }
.kk-flags button:active { transform: scale(0.94); transition-duration: 120ms; }
@media (hover: hover) and (pointer: fine) { .kk-flags button:hover { background: var(--bezel); } .kk-flags #lang-next:hover svg { transform: scale(1.06); } }
.kk-flags [data-tip]::after { z-index: 61; }
.kk-navmodal__foot { justify-content: flex-end; }
:fullscreen ~ .kk-flags { display: none; }
@media (max-width: 760px) { .kk-flags { top: calc(var(--space-4) + env(safe-area-inset-top, 0px)); right: var(--space-4); } .tools { top: 160px; } }

/* Palette roles for navy, warm off-white and green. */
:root, [data-theme="dark"] { --scape-ink: #60AC70; }
#projects .band__title, [data-theme="dark"] #projects .band__title { color: var(--night); }
[data-theme="dark"] #projects { background: var(--sage); }
[data-theme="dark"] #projects .band__title { color: var(--on-night); }
.kk-lang button[aria-pressed="true"], [data-theme="dark"] .kk-lang button[aria-pressed="true"] { color: var(--ink); }

/* ---------- Chosen palette roles: the red is the only loud colour; green stays in small marks ---------- */
/* The projects band is the page ground, and the landscape is drawn in faint navy tints. */
#projects, [data-theme="dark"] #projects { background: transparent; }
#projects .band__title, [data-theme="dark"] #projects .band__title { color: var(--lake); }
:root, [data-theme="dark"] { --scape-ink: var(--ink); }
.scape { background: linear-gradient(to bottom, color-mix(in oklab, var(--scape-ink) 5%, var(--ground)), var(--ground) 58%); }
.scape__1 { fill: color-mix(in oklab, var(--scape-ink) 9%, var(--ground)); }
.scape__2 { fill: color-mix(in oklab, var(--scape-ink) 14%, var(--ground)); }
.scape__3 { fill: color-mix(in oklab, var(--scape-ink) 18%, var(--ground)); }
.scape__4 { fill: color-mix(in oklab, var(--scape-ink) 23%, var(--ground)); }
.scape__5 { fill: color-mix(in oklab, var(--scape-ink) 29%, var(--ground)); }
.scape circle { fill: color-mix(in oklab, var(--surface) 70%, var(--ground)); }

/* ================= Round 11: living landscapes, hover, scrollytelling ================= */
/* ---------- Landscape ground behind each content band ---------- */
main > .band { position: relative; overflow: clip; view-timeline: --band block; }
main > .band > .wrap { position: relative; z-index: 1; }
.scape--band { position: absolute; left: 0; right: 0; bottom: 0; top: auto; width: 100%; height: min(72%, 600px); z-index: 0; pointer-events: none; background: none; }
.scape--band.is-flip { transform: scaleX(-1); }
/* Each layer is a little wider than the frame so it can drift without showing an edge. */
.scape path, .scape circle { transform-box: fill-box; transform-origin: 50% 100%; }
.scape__1, .scape__2, .scape__4, .scape__5 { scale: 1.08 1; }
@keyframes scape-drift { from { translate: -2.2% 0; } to { translate: 2.2% 0; } }
@keyframes scape-sun { from { translate: 0 16px; } to { translate: 0 -16px; } }
.scape.is-live .scape__1 { animation: scape-drift 46s ease-in-out infinite alternate; }
.scape.is-live .scape__2 { animation: scape-drift 34s ease-in-out infinite alternate-reverse; }
.scape.is-live .scape__4 { animation: scape-drift 26s ease-in-out infinite alternate; }
.scape.is-live .scape__5 { animation: scape-drift 19s ease-in-out infinite alternate-reverse; }
.scape.is-live circle { animation: scape-sun 28s ease-in-out infinite alternate; }
/* Scroll-linked depth: far ridges rise more slowly than near hills as the band comes up the screen. */
@supports (animation-timeline: view()) {
  @keyframes rise-1 { from { transform: translateY(70px); } to { transform: none; } }
  @keyframes rise-2 { from { transform: translateY(52px); } to { transform: none; } }
  @keyframes rise-3 { from { transform: translateY(40px); } to { transform: none; } }
  @keyframes rise-4 { from { transform: translateY(26px); } to { transform: none; } }
  @keyframes rise-5 { from { transform: translateY(12px); } to { transform: none; } }
  .scape--band.is-live .scape__1 { animation: scape-drift 46s ease-in-out infinite alternate, rise-1 linear both; animation-timeline: auto, --band; animation-range: normal, entry 0% cover 55%; }
  .scape--band.is-live .scape__2 { animation: scape-drift 34s ease-in-out infinite alternate-reverse, rise-2 linear both; animation-timeline: auto, --band; animation-range: normal, entry 0% cover 55%; }
  .scape--band .scape__3 { animation: rise-3 linear both; animation-timeline: --band; animation-range: entry 0% cover 55%; }
  .scape--band.is-live .scape__4 { animation: scape-drift 26s ease-in-out infinite alternate, rise-4 linear both; animation-timeline: auto, --band; animation-range: normal, entry 0% cover 55%; }
  .scape--band.is-live .scape__5 { animation: scape-drift 19s ease-in-out infinite alternate-reverse, rise-5 linear both; animation-timeline: auto, --band; animation-range: normal, entry 0% cover 55%; }
}

/* ---------- Scroll on the sa bàn zooms it; this control takes you past it ---------- */
.stage__down { all: unset; cursor: pointer; position: absolute; z-index: 2; right: max(var(--space-6), env(safe-area-inset-right, 0px)); bottom: calc(var(--space-16) + env(safe-area-inset-bottom, 0px)); width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--radius-pin); color: var(--ink); background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%); box-shadow: inset 0 0 0 1px var(--bezel-ring), var(--shadow-highlight), var(--shadow-2); transition: transform 400ms var(--kk-ease-fluid); }
.stage__down svg { transform: rotate(90deg); animation: down-nudge 1600ms var(--kk-ease-in-out) 2600ms 3; }
@keyframes down-nudge { 50% { transform: rotate(90deg) translateX(5px); } }
.stage__down:focus-visible { box-shadow: var(--shadow-focus); }
.stage__down:active { transform: scale(0.94); transition-duration: 120ms; }
@media (hover: hover) and (pointer: fine) { .stage__down:hover { transform: translateY(3px); } }

/* ---------- Hover ---------- */
/* Cards lean toward the pointer; a soft light follows it across the picture. */
.kk-card, .post { perspective: 900px; }
.kk-card.is-tilting .kk-card__core { transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition-duration: 120ms; }
.post.is-tilting .post__cover { transform: translateY(-4px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition-duration: 120ms; }
.kk-card__plan::after, .post__cover > span::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.22), transparent 55%); opacity: 0; transition: opacity 300ms linear; }
.post__cover > span { position: relative; }
.is-tilting .kk-card__plan::after, .is-tilting .post__cover > span::after { opacity: 1; }
/* Gallery: the caption slides up from the bottom edge of the picture. */
.pj-shot { position: relative; }
.pj-shot__cap { position: absolute; left: 0; right: 0; bottom: 0; padding: var(--space-10) var(--space-4) var(--space-3); font-family: var(--font-sans); font-size: 13px; line-height: 18px; font-weight: 500; color: #fff; text-align: left; background: linear-gradient(to top, rgba(0, 13, 33, 0.72), transparent); opacity: 0; transform: translateY(8px); transition: opacity 200ms linear, transform 300ms var(--kk-ease-out); pointer-events: none; }
.pj-shot:focus-visible .pj-shot__cap { opacity: 1; transform: none; }
.pj-unit__media .pj-shot__cap, .pj-floor .pj-shot__cap, .pj-cover .pj-shot__cap { display: none; }
@media (hover: hover) and (pointer: fine) {
  .pj-shot:hover .pj-shot__cap { opacity: 1; transform: none; }
  .about__list li { transition: transform 400ms var(--kk-ease-out), opacity 300ms linear; }
  .about__list li > span { transition: transform 400ms var(--kk-ease-out), color 200ms linear; }
  .about__list li:hover { transform: translateX(8px); opacity: 1 !important; }
  .about__list li:hover > span { transform: scale(1.12) rotate(-4deg); color: var(--red-text); }
  .about__faq summary { transition: background-color 200ms linear; }
  .about__faq summary:hover { background: color-mix(in oklab, var(--ink) 5%, transparent); }
  .talk__qr img { transition: transform 400ms var(--kk-ease-out); }
  .talk__qr figure:hover img { transform: scale(1.05) rotate(-1.5deg); }
  .kk-navmodal.is-open .kk-navmodal__links a:hover { transform: translateX(10px); transition-delay: 0ms; transition-duration: 300ms; }
  .pj-facts > div { transition: transform 300ms var(--kk-ease-out); }
  .pj-facts > div:hover { transform: translateX(4px); }
  .pj-facts > div:hover dt { color: var(--red-text); }
  .pj-amenities li { transition: transform 300ms var(--kk-ease-out); }
  .pj-amenities li:hover { transform: translateX(4px); }
  .pj-amenities li:hover::before { background: var(--kk-red); }
}

/* ---------- Scrollytelling ---------- */
/* Services: the line at reading height is lit, the rest wait; a rail fills as you go. */
.about__list.is-spy { position: relative; padding-left: var(--space-6); }
.about__list.is-spy::before, .about__list.is-spy::after { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 2px; border-radius: 2px; background: var(--hairline); }
.about__list.is-spy::after { background: var(--kk-red); transform-origin: 50% 0; transform: scaleY(var(--spy, 0)); transition: transform 200ms linear; }
.about__list.is-spy li { opacity: 0.4; transition: opacity 300ms linear, transform 400ms var(--kk-ease-out); }
.about__list.is-spy li.is-current { opacity: 1; }
.about__list.is-spy li.is-current > span { color: var(--red-text); }
/* Chapters rail on project pages. */
.kk-chapters { position: fixed; z-index: 25; right: max(var(--space-4), env(safe-area-inset-right, 0px)); top: 50%; transform: translateY(-50%) translateX(12px); display: flex; flex-direction: column; padding: 6px 0; border-radius: var(--radius-pin); background: var(--glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: inset 0 0 0 1px var(--bezel-ring), var(--shadow-2); opacity: 0; pointer-events: none; transition: opacity 240ms linear, transform 300ms var(--kk-ease-out); }
.kk-chapters.is-on { opacity: 1; pointer-events: auto; transform: translateY(-50%); }
.kk-chapters a { width: 32px; height: 28px; display: grid; place-items: center; border-radius: var(--radius-pin); }
.kk-chapters a::before { content: ""; width: 6px; height: 6px; border-radius: 6px; background: var(--muted); opacity: 0.5; transition: height 320ms var(--kk-ease-in-out), background-color 200ms linear, opacity 200ms linear; }
.kk-chapters a.is-passed::before { background: var(--ink); opacity: 0.8; }
.kk-chapters a.is-current::before { height: 18px; background: var(--kk-red); opacity: 1; }
.kk-chapters a:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
@media (hover: hover) and (pointer: fine) { .kk-chapters a:hover::before { opacity: 1; background: var(--kk-red); } }
@media (max-width: 1100px) { .kk-chapters { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .scape path, .scape circle, .stage__down svg { animation: none !important; }
  .about__list.is-spy li { opacity: 1; }
  .pj-shot__cap, .kk-chapters, .kk-chapters a::before { transition-duration: 1ms; }
}
/* On the dark navy ground the tints need a wider spread to read as hills. */
[data-theme="dark"] .scape__1 { fill: color-mix(in oklab, var(--scape-ink) 6%, var(--ground)); }
[data-theme="dark"] .scape__2 { fill: color-mix(in oklab, var(--scape-ink) 10%, var(--ground)); }
[data-theme="dark"] .scape__3 { fill: color-mix(in oklab, var(--scape-ink) 14%, var(--ground)); }
[data-theme="dark"] .scape__4 { fill: color-mix(in oklab, var(--scape-ink) 18%, var(--ground)); }
[data-theme="dark"] .scape__5 { fill: color-mix(in oklab, var(--scape-ink) 24%, var(--ground)); }
[data-theme="dark"] .scape circle { fill: color-mix(in oklab, var(--scape-ink) 12%, var(--ground)); }

/* ================= Round 12 ================= */
/* ---------- Hover: the locate target ---------- */
.kk-locate { position: fixed; left: 0; top: 0; z-index: 90; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none; will-change: transform; }
.kk-locate::before { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 9px #F3EFE8, 0 0 0 1px rgba(0, 13, 33, 0.35), 0 8px 24px rgba(0, 13, 33, 0.35); opacity: 0; scale: 1.7; transition: opacity 160ms linear, scale 240ms var(--kk-ease-out); }
.kk-locate::after { content: ""; position: absolute; inset: -12px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--kk-red); opacity: 0; }
.kk-locate i { position: absolute; inset: 22px; border-radius: 50%; background: var(--kk-red); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5); opacity: 0; translate: -22px -40px; scale: 0.6; transition: opacity 120ms linear, translate 160ms var(--kk-ease-out), scale 160ms var(--kk-ease-out); }
.kk-locate.is-on::before { opacity: 1; scale: 1; transition: opacity 200ms linear, scale 420ms var(--kk-ease-fluid); }
.kk-locate.is-on i { opacity: 1; translate: 0 0; scale: 1; transition: opacity 160ms linear 140ms, translate 420ms var(--kk-ease-fluid) 140ms, scale 420ms var(--kk-ease-fluid) 140ms; }
.kk-locate.is-on::after { animation: kk-ping 1800ms var(--kk-ease-out) 520ms infinite; }
.kk-locate.is-down::before { scale: 0.86; transition-duration: 120ms; }
.has-locate .kk-card, .has-locate .post, .has-locate .pj-shot { cursor: none; }
.has-locate .lightbox, .has-locate .lightbox .pj-shot { cursor: zoom-out; }
/* The earlier tilt and sheen are replaced by the locate target. */
.kk-card__plan::after, .post__cover > span::after { display: none; }
@media (prefers-reduced-motion: reduce) { .kk-locate::before, .kk-locate i { transition-duration: 1ms; transition-delay: 0ms; } .kk-locate.is-on::after { animation: none; } }

/* ---------- Opening: long enough to watch the locate happen ---------- */
/* 0.0s ring closes in · 0.7s the red dot falls into it · 1.6s two pings · 3.6s logo · 4.8s slogan · 7.0s the sa bàn */
.opening__target { animation-duration: 1100ms; }
.opening__target::before { animation: dot-drop 900ms var(--kk-ease-fluid) 700ms both; }
.opening__target::after { animation: kk-ping 1000ms var(--kk-ease-out) 1200ms 2 both; }

/* ---------- Back to top ---------- */
.to-top { all: unset; cursor: pointer; position: fixed; z-index: 28; right: max(var(--space-6), env(safe-area-inset-right, 0px)); bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--radius-pin); color: var(--ink); background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%); box-shadow: inset 0 0 0 1px var(--bezel-ring), var(--shadow-highlight), var(--shadow-2); opacity: 0; transform: translateY(12px) scale(0.95); pointer-events: none; transition: opacity 240ms linear, transform 240ms var(--kk-ease-out); }
.to-top.is-on { opacity: 1; transform: none; pointer-events: auto; transition-duration: 300ms; }
.to-top svg { transform: rotate(-90deg); transition: transform 400ms var(--kk-ease-fluid); }
.to-top:focus-visible { box-shadow: var(--shadow-focus); }
.to-top.is-on:active { transform: scale(0.94); transition-duration: 120ms; }
@media (hover: hover) and (pointer: fine) { .to-top:hover svg { transform: rotate(-90deg) translateX(3px); } }
@media (max-width: 760px) { .to-top { right: var(--space-4); bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); } }
@media (prefers-reduced-motion: reduce) { .to-top, .to-top svg { transition-duration: 1ms; } }

/* ================= Round 14 ================= */
/* ---------- Opening: the ring becomes the O of KKUMHOUSE ---------- */
/* Ring stroke and dot follow the proportions of the O in the artwork (stroke 19.8% and dot 29% of the diameter). */
.opening__brand { width: min(460px, 80vw); position: relative; z-index: 1; }
/* Landscape behind the opening: it fades in under the ring and drifts like the bands below. */
.scape--opening { animation: scape-fade 900ms linear both; }
@keyframes scape-fade { from { opacity: 0; } }
.opening__target { box-shadow: inset 0 0 0 19px var(--ink); }
.opening__target::before { inset: 34px; }
.opening__wordmark { transform: none; transition: opacity 420ms linear 520ms; }
.opening__mark { transition: opacity 500ms linear 900ms, transform 900ms var(--kk-ease-fluid) 900ms; }
.opening__slogan { width: 100%; margin-top: 5.5%; transition: opacity 400ms linear, clip-path 1100ms var(--kk-ease-fluid); }
@keyframes target-to-o { to { transform: translate(var(--ox, 0px), var(--oy, 0px)) scale(var(--os, 0.4)); } }
/* Only the ring stroke dissolves into the lettering; the red dot stays, so the O keeps the exact KK red on any theme. */
@keyframes target-fade { to { box-shadow: inset 0 0 0 19px transparent; } }
.opening.is-leaving .opening__target { opacity: 0; }
.opening.is-logo .opening__target { animation: target-to-o 950ms cubic-bezier(0.45, 0, 0.55, 1) forwards, target-fade 200ms linear 900ms forwards; }
.opening.is-logo .opening__target::before { animation: none; opacity: 1; transform: none; }
.opening.is-logo .opening__target::after { animation: none; opacity: 0; }
@media (prefers-reduced-motion: reduce) { .opening.is-logo .opening__target { animation: target-fade 1ms forwards; } }

/* ---------- Locate hover, smaller: 36px ring, 5px stroke, 10px dot ---------- */
.kk-locate { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
.kk-locate::before { box-shadow: inset 0 0 0 5px #F3EFE8, 0 0 0 1px rgba(0, 13, 33, 0.35), 0 4px 14px rgba(0, 13, 33, 0.35); }
.kk-locate::after { inset: -8px; }
.kk-locate i { inset: 13px; translate: -12px -24px; }

/* ================= Round 17: the dot's fall ================= */
.opening__target::before, .opening.is-logo .opening__target::before { content: none; }
.opening__dot { position: absolute; inset: 34px; display: block; will-change: transform; animation: dot-x 480ms cubic-bezier(0.2, 0.6, 0.35, 1) 600ms both; }
.opening__dot b { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--kk-red); will-change: transform, opacity; animation: dot-y 480ms cubic-bezier(0.5, 0, 0.75, 0.5) 600ms both, dot-land 220ms var(--kk-ease-out) 1080ms forwards; }
@keyframes dot-x { from { transform: translateX(-58px); } to { transform: none; } }
@keyframes dot-y { 0% { transform: translateY(-78px) scale(0.6); opacity: 0; } 18% { opacity: 1; } 100% { transform: none; opacity: 1; } }
/* A small squash on landing, then rest. */
@keyframes dot-land { 0% { transform: scale(1.12, 0.86); } 100% { transform: none; } }
.opening__target { will-change: transform; }
.opening__target::after { will-change: transform, opacity; }
@media (prefers-reduced-motion: reduce) { .opening__dot, .opening__dot b { animation: none; } }

/* ================= Round 19: the dot no longer falls; it arrives with the ring ================= */
/* 0.0s ring and dot appear · 0.9s two pings · 2.9s ring shrinks into the O as the logo appears · 4.1s slogan · 6.3s the sa bàn */
.opening__dot, .opening__dot b { animation: none; }
.opening__target::after { animation: kk-ping 1000ms var(--kk-ease-out) 900ms 2 both; }
.opening__target { position: relative; z-index: 2; }
.opening__dot { inset: 32.5px; }

/* ================= Round 20 ================= */
/* ---------- Logo on dark grounds: lettering turns light, the slogan and the dot of the O stay KK red ---------- */
/* The artwork is inverted for the lettering; the two red parts are redrawn on top in the brand red. */
.kk-logo__dot, .kk-logo__slogan { display: none; }
[data-theme="dark"] .kk-slogan, .kk-on-dark .kk-slogan { filter: none; background: var(--kk-red); -webkit-mask: var(--kk-logo) no-repeat 0 100% / 100% auto; mask: var(--kk-logo) no-repeat 0 100% / 100% auto; }
[data-theme="dark"] .kk-wordmark, .kk-on-dark .kk-wordmark { position: relative; }
[data-theme="dark"] .kk-wordmark::after, .kk-on-dark .kk-wordmark::after { content: ""; position: absolute; left: 63.25%; top: 49.8%; height: 32%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; background: var(--kk-red); filter: invert(1) hue-rotate(180deg); }
/* The wordmark element itself carries the invert filter, so its dot is pre-inverted to come out red. */
[data-theme="dark"] .kk-logo::after, .kk-on-dark .kk-logo::after { clip-path: inset(0 0 26% 0); }
[data-theme="dark"] .kk-logo__dot, .kk-on-dark .kk-logo__dot { display: block; position: absolute; z-index: 1; left: 63.25%; top: 81.75%; height: 5%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; background: var(--kk-red); }
[data-theme="dark"] .kk-logo__slogan, .kk-on-dark .kk-logo__slogan { display: block; position: absolute; left: 0; right: 0; bottom: 0; aspect-ratio: 1773 / 86; background: var(--kk-red); -webkit-mask: var(--kk-logo) no-repeat 0 100% / 100% auto; mask: var(--kk-logo) no-repeat 0 100% / 100% auto; }
.opening__wordmark::after { display: none; }

/* ---------- Opening, quicker: ring in, one blink, one red ring out, then into the O ---------- */
/* 0.0s ring and dot appear · 0.45s the dot blinks and one red ring spreads · 1.4s ring shrinks into the O with the logo · 2.6s slogan · 4.8s the sa bàn */
.opening__target { animation-duration: 450ms; }
.opening__dot b { animation: dot-blink 320ms var(--kk-ease-out) 450ms 1 both; }
@keyframes dot-blink { 0% { transform: none; opacity: 1; } 40% { transform: scale(1.35); opacity: 0.55; } 100% { transform: none; opacity: 1; } }
.opening__target::after { animation: kk-ping 800ms var(--kk-ease-out) 520ms 1 both; }
@media (prefers-reduced-motion: reduce) { .opening__dot b { animation: none; } }
/* The big figure is always the KK red itself, on light and dark grounds. */
.pj-key__lead b, .kk-keyfigures__lead b { color: var(--kk-red); }
/* Service names stand alone, so each line is centred on its icon. */
.about__list li { align-items: center; }
.about__list li > span { margin-top: 0; }
.about__list strong { font-size: 20px; line-height: 28px; }

/* ================= Round 23: services as a cluster of tiles ================= */
/* Five tiles side by side. Each waits at rest and lights up under the pointer; on touch screens all are lit. */
.about__lead { max-width: none; }
.about .about__list { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-3); width: 100%; padding: 0; }
.about .about__list li { flex-direction: column; align-items: flex-start; gap: var(--space-6); padding: var(--space-6); min-height: 132px; box-sizing: border-box; justify-content: space-between; border-radius: var(--radius-inner); background: color-mix(in oklab, var(--surface) 50%, transparent); box-shadow: inset 0 0 0 1px var(--bezel-ring); opacity: 1; transform: none; transition: transform 400ms var(--kk-ease-out), opacity 200ms linear, background-color 200ms linear, box-shadow 400ms var(--kk-ease-out); }
.about .about__list li > span { color: var(--ink); }
[data-theme="light"] .about .about__list li { background: color-mix(in oklab, var(--surface) 72%, transparent); }
.about .about__list strong { font-size: 18px; line-height: 24px; text-wrap: balance; }
@media (hover: hover) and (pointer: fine) {
  [data-theme="dark"] .about .about__list li { opacity: 0.55; }
  [data-theme="dark"] .about .about__list li:hover { opacity: 1; }
  .about .about__list li:hover { opacity: 1; transform: translateY(-4px); background: var(--surface); box-shadow: inset 0 0 0 1px var(--bezel-ring), var(--shadow-2); }
  .about .about__list li:hover > span { transform: none; color: var(--kk-red); }
}
@media (hover: none) { .about .about__list li > span { color: var(--kk-red); } }
/* The mark and the lettering appear together. */
.opening__mark { transition: opacity 420ms linear 520ms, transform 700ms var(--kk-ease-fluid) 520ms; }

/* ================= Round 24: service tiles ================= */
.has-locate .about__list li { cursor: none; }
/* Under the pointer a tile becomes a light pane of glass, clearly apart from the dark ground. */
@media (hover: hover) and (pointer: fine) {
  .about .about__list li:hover { background: color-mix(in oklab, #FFFFFF 78%, transparent); box-shadow: inset 0 0 0 1px var(--bezel-ring), var(--shadow-2); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
  [data-theme="dark"] .about .about__list li:hover { background: color-mix(in oklab, #FFFFFF 13%, transparent); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), var(--shadow-2); }
}

/* ================= Round 25 ================= */
/* ---------- Landscape fills the whole band ---------- */
.scape--band { top: 0; height: 100%; }
.scape__0b { fill: color-mix(in oklab, var(--scape-ink) 6%, var(--ground)); scale: 1.08 1; }
.scape__0a { fill: color-mix(in oklab, var(--scape-ink) 8%, var(--ground)); scale: 1.08 1; }
[data-theme="dark"] .scape__0b { fill: color-mix(in oklab, var(--scape-ink) 2.5%, var(--ground)); }
[data-theme="dark"] .scape__0a { fill: color-mix(in oklab, var(--scape-ink) 4.5%, var(--ground)); }
.scape.is-live .scape__0b { animation: scape-drift 64s ease-in-out infinite alternate; }
.scape.is-live .scape__0a { animation: scape-drift 54s ease-in-out infinite alternate-reverse; }
/* A faint glow of sky at the top of each band, so the upper part is never one flat colour. */
main > .band::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 46%; z-index: 0; pointer-events: none; background: radial-gradient(120% 100% at 78% 0%, color-mix(in oklab, var(--scape-ink) 7%, transparent), transparent 70%); }
@media (prefers-reduced-motion: reduce) { .scape__0a, .scape__0b { animation: none !important; } }

/* ---------- Project cards light up like the service tiles ---------- */
@media (hover: hover) and (pointer: fine) {
  .project-grid .kk-card__core { transition: transform 500ms var(--kk-ease-fluid), background-color 200ms linear, box-shadow 400ms var(--kk-ease-out); }
  .project-grid .kk-card:hover .kk-card__core { background: color-mix(in oklab, #FFFFFF 78%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
  [data-theme="dark"] .project-grid .kk-card:hover .kk-card__core { background: color-mix(in oklab, #FFFFFF 13%, transparent); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), var(--shadow-2); }
}

/* ================= Round 27: phone layout ================= */
:lang(ko) .hero__title, :lang(ko) .band__title, :lang(ko) .pj-title, :lang(ko) .about__lead, :lang(ko) .kk-card__title { word-break: keep-all; }
@media (max-width: 760px) {
  /* The corner nav and the language flags share one row without touching. */
  .kk-nav { top: calc(var(--space-4) + env(safe-area-inset-top, 0px)); left: var(--space-4); height: 44px; padding: 0 3px 0 14px; gap: 10px; }
  .kk-nav__brand .kk-wordmark { height: 12px; }
  .kk-burger { width: 38px; height: 38px; }
  .kk-burger__x::before, .kk-burger__x::after { left: 12px; right: 12px; }
  .kk-flags { height: 44px; padding: 3px; }
  .kk-flags button { width: 38px; height: 38px; }
  .kk-flags #lang-next svg { width: 24px; height: 24px; }
  .tools { top: 76px; }
  .hero__title { font-size: clamp(30px, 9vw, 40px); }
  /* Services: two columns of shorter tiles instead of five full-width ones. */
  .about .about__list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .about .about__list li { min-height: 112px; padding: var(--space-4); gap: var(--space-4); }
  .about .about__list strong { font-size: 15px; line-height: 20px; }
  .about .about__list li:last-child { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; justify-content: flex-start; }
  /* Projects: one row that scrolls sideways, as on the project pages. */
  #project-grid { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: min(76vw, 300px); overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px var(--space-6) var(--space-4); margin-inline: calc(var(--space-6) * -1); scrollbar-width: none; overscroll-behavior-x: contain; }
  #project-grid > * { scroll-snap-align: start; }
  .blog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6) var(--space-3); }
  .post__title { font-size: 14px; line-height: 20px; }
  .post__meta { flex-direction: column; gap: 0; }
  .stage__down { right: var(--space-4); bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); width: 44px; height: 44px; }
  .dock { justify-content: flex-start; padding-left: var(--space-4); }
  .maplibregl-ctrl-bottom-right { bottom: 84px; }
}
@media (max-width: 760px) {
  /* Option rows stay on one line and scroll sideways instead of breaking a label in two. */
  .band__head .kk-lang { display: flex; flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  .band__head .kk-lang button { white-space: nowrap; flex: none; }
}

/* ================= Round 29: phone fixes ================= */
.rail-nav { display: none; }
.rail-nav button:last-child svg { transform: none; } .rail-nav button:first-child svg { transform: rotate(180deg); }
.rail-nav button[disabled] { opacity: 0.35; cursor: default; }
@media (max-width: 860px) {
  /* A sideways row of cards keeps the page margin at both ends, also when a card snaps into place. */
  #project-grid, #more .project-grid { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: min(76vw, 300px); overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--space-6); padding: 4px var(--space-6) var(--space-4); margin-inline: calc(var(--space-6) * -1); scrollbar-width: none; overscroll-behavior-x: contain; }
  #project-grid > *, #more .project-grid > * { scroll-snap-align: start; }
  .rail-nav { display: inline-flex; margin-top: var(--space-2); }
  /* Option rows wrap whole labels onto a second line; nothing is cut off or hidden past the edge. */
  .band__head .kk-lang { display: flex; flex-wrap: wrap; overflow: visible; max-width: 100%; border-radius: var(--radius-inner); }
  .band__head .kk-lang button { white-space: nowrap; flex: none; padding: 10px 14px; }
  /* Underlined fields: text and caret start a little in from the edge. */
  .talk__form .kk-field input { padding: 0 2px; caret-color: var(--on-night); -webkit-appearance: none; appearance: none; background-clip: padding-box; }
}

/* ================= Round 30: dialogs on phones ================= */
html.is-modal { overflow: hidden; }
/* A dialog taller than the screen scrolls inside its own layer, starting from its top edge. */
.kk-navmodal { overflow-y: auto; overscroll-behavior: contain; align-items: safe center; -webkit-overflow-scrolling: touch; }
.kk-navmodal__shell { margin-block: auto; }
@media (max-width: 760px) {
  .kk-navmodal { padding: 76px var(--space-4) var(--space-6); place-items: start center; }
  .consult { padding: var(--space-6); gap: var(--space-4); }
  .consult__head .kk-panel__title { font-size: 28px; }
  .kk-navmodal__links a { font-size: 26px; padding: 10px 0; }
  .kk-navmodal__foot .kk-btn { width: 100%; justify-content: space-between; }
  /* 16px text in fields: iOS zooms the page on focus below that. */
  .kk-field input, .kk-field select, .kk-field textarea { font-size: 16px; }
  .kk-field textarea { height: 88px; }
  #consult-form .kk-btn { align-self: stretch; justify-content: space-between; }
}
