:root {
  --text: #482010;
  --gold: #a69164;
  --gold-bar-top: 204, 189, 160;
  --gold-bar-bottom: 128, 104, 58;
  --gold-bar-height: clamp(110px, 14vh, 168px);
  --key-overlap: 8%;
  --cta-offset: calc(var(--gold-bar-height) / 2);
  --gold-bar-gradient: linear-gradient(
    180deg,
    rgba(var(--gold-bar-top), 0.92) 0%,
    rgb(var(--gold-bar-bottom)) 100%
  );
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  max-height: 100vh;
  font-family: "Noto Sans TC", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  background: #1a3050;
  color: var(--text);
  overflow: hidden;
}

body {
  min-height: 100vh;
  max-height: 100vh;
}

.page {
  position: relative;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background: #1a3050;
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  pointer-events: none;
}

/* Desktop KV background: fixed 2135px wide, centered */
.bg-image {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 2135px;
  max-width: none;
  height: auto;
  pointer-events: none;
  z-index: 0;
}

/* Building + logo object: centered, max 1080px tall */
.key-object {
  position: absolute;
  left: var(--key-object-left, 48%);
  top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  height: 100%;
  max-height: 1080px;
  aspect-ratio: 1091 / 1078;
  pointer-events: none;
  z-index: 3;
}

.key-object__frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.key-object__building {
  position: absolute;
  inset: 0;
}

.key-object__building-layer {
  opacity: 0;
  z-index: 0;
  will-change: opacity;
}

.key-object__building-layer.is-active {
  opacity: 1;
  z-index: 1;
}

.key-object__logo {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.key-object__logo-layer {
  opacity: 0;
  z-index: 0;
  will-change: opacity;
}

.key-object__logo-layer.is-active {
  opacity: 1;
  z-index: 1;
}

.key-object__label {
  z-index: 3;
}

.gold-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  height: calc(var(--gold-bar-height) + var(--gold-bar-lift, 0px));
  background: var(--gold-bar-gradient);
  pointer-events: none;
}

.kv-section-title {
  display: none;
}

.kv-note-wrap {
  display: none;
}

.kv-note {
  display: none;
}

@media (min-width: 1025px) {
  .kv-note {
    display: block;
    position: absolute;
    z-index: 4;
    margin: 0;
    color: #fff;
    font-size: 9px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0.03em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    white-space: nowrap;
    opacity: 0.7;
  }

  /* Desktop: both notes on the key-object, just above the gold bar */
  .kv-note--building {
    left: 13.5%;
    bottom: calc(var(--gold-bar-height) + 9px);
    z-index: 4;
  }

  .kv-note--stock {
    right: 13%;
    bottom: calc(var(--gold-bar-height) + 9px);
    z-index: 4;
  }

  .kv-note--left,
  .kv-note--right {
    display: none;
  }

  .kv-note sup {
    font-size: 0.72em;
    line-height: 0;
    margin-left: 1px;
  }
}

.cta-btn {
  position: absolute;
  z-index: 3;
  left: 48px;
  bottom: var(--cta-offset);
  transform: translateY(50%);
  display: block;
  width: min(130px, 18vw);
  max-width: 130px;
  line-height: 0;
  pointer-events: auto;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  transition: transform 180ms ease, opacity 180ms ease;
}

.cta-btn:hover,
.cta-btn:focus-visible {
  transform: translateY(50%) scale(1.04);
  outline: none;
}

.cta-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
  border-radius: 999px;
}

.cta-btn img {
  display: block;
  width: 100%;
  height: auto;
}

.header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 18px;
  padding: 28px 32px 0;
  overflow: visible;
  box-sizing: border-box;
}

.header > * {
  position: relative;
  z-index: 1;
}

.site-nav {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  min-height: 36px;
}

.site-nav__list {
  display: flex;
  align-items: center;
  gap: 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__item {
  position: relative;
  text-align: center;
}

.site-nav__link {
  display: inline-block;
  border: 0;
  background: transparent;
  padding: 0 0 6px;
  margin: 0;
  color: #fff;
  font-family: "Noto Sans TC", "Noto Sans SC", sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  border-bottom: 1px solid transparent;
}

.site-nav__item:hover > .site-nav__link,
.site-nav__item.is-open > .site-nav__link,
.site-nav__link:focus-visible {
  border-bottom-color: rgba(255, 255, 255, 0.85);
  outline: none;
}

.site-nav__dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 12px 16px 4px;
  list-style: none;
  min-width: max-content;
  z-index: 6;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease 80ms, visibility 160ms ease 80ms;
}

/* Invisible hover bridge so cursor can reach the dropdown */
.site-nav__dropdown::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 20px;
}

/* Touch browsers keep :hover sticky after tap — only open via .is-open there. */
.site-nav__item.has-dropdown.is-open > .site-nav__dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

@media (hover: hover) and (pointer: fine) {
  .site-nav__item.has-dropdown:hover > .site-nav__dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }
}

.site-nav__dropdown a,
.site-nav__dropdown button {
  color: #fff;
  font-family: "Noto Sans TC", "Noto Sans SC", sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  appearance: none;
}

.site-nav__dropdown a:hover,
.site-nav__dropdown a:focus-visible,
.site-nav__dropdown button:hover,
.site-nav__dropdown button:focus-visible {
  opacity: 0.88;
  outline: none;
}

.lang {
  position: relative;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  z-index: 5;
  padding-top: 0;
}

.lang-toggle {
  display: block;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  appearance: none;
  width: 36px;
  height: 36px;
}

.lang-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  border-radius: 50%;
}

.lang-toggle img {
  display: block;
  width: 100%;
  height: 100%;
  filter: brightness(0) invert(1);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  z-index: 3;
}

.lang.is-open .lang-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-menu a {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: transform 160ms ease, opacity 160ms ease;
}

.lang-menu a:hover,
.lang-menu a:focus-visible {
  transform: scale(1.06);
  outline: none;
}

.lang-menu a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.lang-menu img {
  display: block;
  width: 100%;
  height: 100%;
  filter: brightness(0) invert(1);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1024px) {
  /*
    Mobile layout (from WordPress full version):
    - desktop KV background + animated key-object
    - gold bar with kv-t-* title
    - building / stock notes stay visible
  */
  :root {
    --cwb-header-h: 48px;
    --cwb-vvh: 100svh;
    --gold-bar-height: calc(var(--cwb-vvh) * 0.4);
    --gold-bar-lift: 0px;
    --cta-offset: calc(var(--gold-bar-height) / 2);
    --cta-btn-height: 44px;
    --kv-key-overlap: 0.2;
    --kv-title-gap: 8px;
    --kv-btn-reserve: calc(18px + env(safe-area-inset-bottom, 0px) + 56px);
  }

  html,
  body,
  .page {
    height: 100%;
    height: var(--cwb-vvh);
    max-height: var(--cwb-vvh);
  }

  .bg-image {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 2135px;
    max-width: none;
    height: auto;
    object-fit: unset;
    object-position: unset;
  }

  /*
    Mobile home compose:
    - key-object scales down to stay fully visible (no crop)
    - bottom 20% of building overlaps the gold bar
    - title sits under the building, on top of the gold bar
  */
  .key-object {
    left: 50%;
    top: auto;
    bottom: var(--gold-bar-height);
    transform: translate(-50%, calc(var(--kv-key-overlap) * 100%));
    width: auto;
    height: min(
      calc(
        (var(--cwb-vvh) - var(--cwb-header-h) - var(--gold-bar-height)) /
          (1 - var(--kv-key-overlap))
      ),
      calc(min(calc(100% + 130px), 112vw) * 1078 / 1091)
    );
    max-width: min(calc(100% + 130px), 112vw);
    max-height: calc(
      (var(--cwb-vvh) - var(--cwb-header-h) - var(--gold-bar-height)) /
        (1 - var(--kv-key-overlap))
    );
    aspect-ratio: 1091 / 1078;
    opacity: 1;
    z-index: 4;
  }

  .gold-bar {
    display: block;
    z-index: 2;
  }

  .kv-note-wrap {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 5;
    max-width: 500px;
    width: 100%;
    height: 100%;
    margin-left: auto;
    margin-right: auto;
    pointer-events: none;
  }

  .kv-note {
    display: block;
    position: absolute;
    z-index: 5;
    margin: 0;
    color: #fff;
    font-size: 9px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0.03em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    white-space: nowrap;
    opacity: 0.7;
    bottom: calc(var(--gold-bar-height) + 6px);
  }

  /* Mobile: hide in-building notes; use wrapped left/right pair */
  .kv-note--building,
  .kv-note--stock {
    display: none;
  }

  .kv-note--left {
    left: 14px;
  }

  .kv-note--right {
    right: 14px;
  }

  .kv-note sup {
    font-size: 0.72em;
    line-height: 0;
    margin-left: 1px;
  }

  .kv-section-title {
    display: block;
    position: absolute;
    left: 50%;
    bottom: calc(var(--kv-btn-reserve) + 28px);
    transform: translateX(-50%);
    z-index: 3;
    width: min(78vw, 250px);
    max-width: 250px;
    margin-top: 10px;
    max-height: calc(
      var(--gold-bar-height) * (1 - var(--kv-key-overlap)) - var(--kv-btn-reserve) -
        var(--kv-title-gap) - 28px
    );
    height: auto;
    object-fit: contain;
    pointer-events: none;
  }

  .header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    min-height: 48px;
    background: #e5d4b5;
    background: linear-gradient(
      0deg,
      rgba(229, 212, 181, 1) 0%,
      rgba(150, 120, 87, 1) 100%
    );
  }

  /* Mobile only: gold menu veil behind open dropdown */
  .header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 0;
    z-index: 0;
    pointer-events: none;
    background: #e5d4b5;
    background: linear-gradient(
      0deg,
      rgba(229, 212, 181, 1) 0%,
      rgba(200, 175, 140, 1) 100%
    );
    opacity: 0;
    transition: height 200ms ease, opacity 160ms ease;
  }

  .header.is-expanded-residential::after,
  .header.is-expanded-sales::after,
  .header.is-expanded-lang::after,
  .header:has(li.has-dropdown.is-open)::after,
  .header:has(.lang.is-open)::after {
    height: var(--header-menu-pad, 0px);
    opacity: 1;
  }

  .site-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .site-nav__item[hidden] {
    display: none !important;
  }

  .site-nav {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
  }

  .site-nav__list {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    max-width: 100%;
  }

  html[lang="zh-Hant"] .site-nav__list,
  html[lang="zh-Hans"] .site-nav__list,
  html[lang="tc"] .site-nav__list,
  html[lang="sc"] .site-nav__list {
    gap: 14px;
  }

  .site-nav__link {
    font-size: 11px;
    letter-spacing: 0.02em;
    padding-top: 0;
    padding-bottom: 1px;
    line-height: 1.2;
  }

  .site-nav__dropdown a,
  .site-nav__dropdown button {
    font-size: 11px;
  }

  .header-actions {
    gap: 6px;
    min-height: 0;
    align-items: flex-start;
  }

  .page {
    background: #7c6336;
  }

  .cta-btn {
    left: 24px;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    transform: none;
    width: auto;
    max-width: none;
    height: var(--cta-btn-height);
  }

  .cta-btn img {
    width: auto;
    height: 100%;
  }

  .cta-btn:hover,
  .cta-btn:focus-visible {
    transform: scale(1.04);
  }

  .lang-toggle,
  .lang-menu a {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 767px) {
  :root {
    --cwb-header-h: 44px;
    --cta-btn-height: 42px;
  }

  .header {
    gap: 6px;
    padding: 8px 10px;
    min-height: 44px;
    align-items: center;
  }

  .site-nav__list {
    gap: 5px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
  }

  html[lang="tc"] .site-nav__list,
  html[lang="sc"] .site-nav__list,
  html[lang="zh-Hant"] .site-nav__list,
  html[lang="zh-Hans"] .site-nav__list {
    gap: 12px;
  }

  .site-nav__link {
    font-size: 10px;
    letter-spacing: 0;
  }

  .site-nav__dropdown a {
    font-size: 10px;
  }

  .cta-btn {
    left: 16px;
    height: var(--cta-btn-height);
  }

  .lang-toggle,
  .lang-menu a {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 576px) {
  .key-object {
    max-width: calc(100% + 130px);
  }
}

/* Disclaimer popup */
.popup {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background: rgba(20, 16, 12, 0.55);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms ease, visibility 200ms ease;
  overflow: visible;
}

.popup.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.popup--warning {
  z-index: 110;
}

.popup--warning .popup__dialog {
  width: min(640px, 100%);
  min-width: min(640px, 100%);
  max-height: min(80vh, 640px);
}

.popup__dialog {
  position: relative;
  width: min(800px, 100%);
  min-width: min(800px, 100%);
  max-height: min(86vh, 820px);
  display: flex;
  flex-direction: column;
  background-color: #f8f5f0;
  background-image: url("assets/images/popupbg.svg");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center center;
  border: 0;
  box-shadow: 0 18px 48px rgba(40, 24, 12, 0.35);
  padding: 48px 52px 40px;
  overflow: visible;
}

.popup__corner {
  position: absolute;
  width: min(88px, 10vw);
  height: auto;
  pointer-events: none;
  z-index: 1;
}

.popup__corner--tl {
  top: -22px;
  left: -24px;
}

.popup__corner--br {
  right: -24px;
  bottom: -22px;
  transform: rotate(180deg);
}

.popup__close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #5c4033;
  color: #fff;
  cursor: pointer;
  appearance: none;
  display: grid;
  place-items: center;
  padding: 0;
}

.popup__close:focus-visible {
  outline: 2px solid #5c4033;
  outline-offset: 3px;
}

.popup__close-icon {
  display: block;
  width: 12px;
  height: 12px;
}

.popup__body {
  position: relative;
  z-index: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: #5c4033;
  font-family: "Noto Sans TC", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.75;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: #5c4033 #efe8df;
}

.popup__body::-webkit-scrollbar {
  width: 8px;
}

.popup__body::-webkit-scrollbar-track {
  background: #efe8df;
  border-radius: 999px;
}

.popup__body::-webkit-scrollbar-thumb {
  background: #5c4033;
  border-radius: 999px;
}

.popup__body h2 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
}

.popup__body p {
  margin: 0 0 14px;
}

.popup__body a {
  color: inherit;
  text-underline-offset: 2px;
}

.popup__body p:last-child {
  margin-bottom: 0;
}

.popup__meta {
  margin-top: 18px;
  font-size: 13px;
}

.popup--files .popup__dialog {
  width: min(720px, 100%);
  min-width: min(720px, 100%);
  max-height: min(80vh, 640px);
  padding: 40px 44px 32px;
}

.popup--files .popup__body {
  overflow-y: auto;
}

.popup--files .popup__body h2 {
  margin: 0;
  padding: 0 36px 16px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid #5c4033;
}

.file-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 4px;
  border-bottom: 1px solid #5c4033;
}

.file-list__title {
  flex: 1;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.55;
  text-transform: uppercase;
}

.popup--files .file-list__download {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  padding: 10px 18px;
  background: #5c4033;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
}

.popup--files .file-list__download:hover,
.popup--files .file-list__download:focus-visible {
  background: #473227;
  color: #fff;
  outline: none;
}

.file-list__empty {
  margin: 24px 0 8px;
  text-align: center;
}

@media (max-width: 767px) {
  .popup {
    padding: 16px;
  }

  .popup__dialog {
    padding: 40px 28px 28px;
    max-height: 88vh;
  }

  .popup__body {
    font-size: 13px;
  }

  .popup__corner {
    width: min(64px, 18vw);
  }

  .popup--files .popup__dialog {
    padding: 36px 20px 24px;
  }

  .popup--files .popup__body h2 {
    font-size: 15px;
    padding-right: 28px;
    padding-left: 8px;
    letter-spacing: 0.04em;
  }

  .file-list__item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 0;
  }

  .file-list__title {
    font-size: 13px;
    text-transform: none;
  }

  .file-list__download {
    min-width: 112px;
    width: 100%;
  }
}
