:root {
  --color-bg: #f4f3ef;
  --color-primary: #c21f1f;
  --color-text: #111111;
  --color-white: #ffffff;
  /* Menu overlay: half viewport height */
  --menu-bar-height: 50vh;
  --ease-eco: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --font-inter: "Inter", system-ui, sans-serif;
  --font-ibm: "IBM Plex Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-inter);
  background: var(--color-bg);
  color: var(--color-text);
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ——— Home01 header ——— */
.site-header {
  --header-nav-fs: clamp(0.88rem, 1.65vw, 1.55rem);
  position: relative;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  gap: clamp(1rem, 4vw, 3rem);
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(0.5rem, 1.2vw, 12px) clamp(1rem, 4vw, 48px) 0;
  transition: opacity 0.45s var(--ease-eco), visibility 0.45s;
}

body.menu-open .site-header {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Vertical KMC × LUCAS mark (native portrait asset, top-left) */
.site-header__logo--vertical {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-shrink: 0;
  width: auto;
  margin-left: clamp(-6px, -0.4vw, 0px);
  padding-top: 0.15rem;
  overflow: visible;
}

/* Vertical mark: slightly larger than WORK (tuned under previous “big” pass) */
.site-header__logo-img {
  display: block;
  width: auto;
  height: clamp(150px, 26vh, 276px);
  max-width: max(
    clamp(46px, 6.5vw, 74px),
    calc(var(--header-nav-fs) * 2)
  );
  object-fit: contain;
  object-position: left top;
}

.site-header__nav {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  justify-items: center;
  align-items: center;
  column-gap: clamp(0.12rem, 1vw, 0.75rem);
  padding-top: 0.35rem;
}

.site-header__nav > a {
  justify-self: center;
  text-align: center;
}

.site-header__nav > .site-header__menu {
  justify-self: end;
  text-align: center;
}

.site-header__nav a {
  font-weight: 600;
  font-size: var(--header-nav-fs);
  line-height: 1.2;
  letter-spacing: 0.02em;
  position: relative;
  white-space: nowrap;
}

.site-header__nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease-eco);
}

.site-header__nav a:hover::after,
.site-header__nav a:focus-visible::after {
  transform: scaleX(1);
}

.site-header__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0;
  white-space: nowrap;
}

.site-header__menu-icon img {
  width: clamp(32px, 3.2vw, 44px);
  height: auto;
}

/* ——— Hero / brands ——— */
.main {
  position: relative;
  min-height: calc(100vh - 80px);
  min-height: calc(100dvh - 80px);
}

/* Home: header uses a tall vertical logo — 80px reserve was too small; main was taller than first screen and KMC+/LUCAS sat below the fold */
.main:has(#hero-brand) {
  min-height: calc(100svh - clamp(168px, 28vh, 320px));
  min-height: calc(100dvh - clamp(168px, 28vh, 320px));
}

.hero-brand {
  position: absolute;
  left: auto;
  top: auto;
  right: var(--hero-inline-pad);
  bottom: max(
    var(--hero-inline-pad),
    calc(var(--hero-inline-pad) + env(safe-area-inset-bottom, 0px))
  );
  width: fit-content;
  max-width: min(92vw, 1440px);
  margin: 0;
  /* Compensates for tagline removed from flow (was ~36px at desktop) */
  padding: 0 0 clamp(22px, 3.5vw, 42px) 0;
  text-align: right;
  --hero-inline-pad: clamp(12px, 3vw, 48px);
  /* Bleed for headline lines + tagline (right-aligned block) */
  --hero-bleed-x: clamp(24px, 4.5vw, 72px);
  transform: scale(1);
  transform-origin: bottom right;
  transition: transform 0.9s var(--ease-out-expo), top 0.9s var(--ease-out-expo), left 0.9s var(--ease-out-expo),
    right 0.9s var(--ease-out-expo), bottom 0.9s var(--ease-out-expo), width 0.9s var(--ease-out-expo),
    max-width 0.9s var(--ease-out-expo), transform-origin 0.9s var(--ease-out-expo);
  z-index: 2;
}

body.menu-open .hero-brand {
  --hero-inline-pad: clamp(12px, 3vw, 40px);
  right: var(--hero-inline-pad);
  bottom: var(--hero-inline-pad);
  max-width: min(92vw, 820px);
  --hero-bleed-x: clamp(14px, 2.4vw, 38px);
  transform: scale(0.57);
  transform-origin: bottom right;
}

@media (max-width: 900px) {
  .hero-brand {
    --hero-bleed-x: clamp(18px, 3.8vw, 52px);
  }

  body.menu-open .hero-brand {
    --hero-inline-pad: clamp(8px, 2vw, 24px);
    --hero-bleed-x: clamp(10px, 2vw, 22px);
    right: var(--hero-inline-pad);
    bottom: var(--hero-inline-pad);
    transform: scale(0.42);
  }
}

.hero-brand__scan {
  position: absolute;
  inset: -8% -5%;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(194, 31, 31, 0.06) 45%,
    transparent 50%,
    rgba(194, 31, 31, 0.05) 100%
  );
  opacity: 0;
  animation: scanSweep 1.8s ease-out 0.15s both;
}

.hero-brand__line {
  margin: 0;
  font-weight: 500;
  font-size: clamp(3.5rem, 16vw, 18rem);
  line-height: 0.72;
  letter-spacing: -0.02em;
  color: var(--color-primary);
  transform: translateX(var(--hero-bleed-x));
  transition: transform 0.9s var(--ease-out-expo);
}

.hero-brand__line--kmc,
.hero-brand__line--lucas {
  margin-bottom: -0.02em;
  font-weight: 900;
  font-size: clamp(5.5rem, 23vw, 26rem);
}

.hero-brand__word {
  display: inline-block;
  will-change: transform, filter, clip-path, text-shadow;
}

.hero-brand__tagline {
  /* Vertical side label — left of KMC+/LUCAS block */
  position: absolute;
  left: 0;
  top: 50%;
  margin: 0;
  max-width: none;
  text-align: left;
  /* Pull outside the left edge of hero-brand, center vertically */
  transform: translateX(calc(-100% - 28px)) translateY(-50%);
  opacity: 0;
  transition: opacity 0.9s var(--ease-out-expo) 0.2s;
}

html.hero-scroll-soft .hero-brand__tagline {
  opacity: 1;
  transform: translateX(calc(-100% - 28px)) translateY(-50%);
  transition: opacity 0.7s var(--ease-out-expo);
}

/* Vertical text — reads bottom → top */
.hero-brand__tagline-text {
  display: block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-inter, "Inter", sans-serif);
  font-weight: 500;
  font-size: clamp(0.6rem, 0.8vw, 0.85rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.38);
  opacity: 1;
  transition: none;
}

html.hero-scroll-soft .hero-brand__tagline-text {
  opacity: 1;
}

/* Merged Lottie → page rise + brand signal: type stays “off-air” until intro-active (no second fade flash) */
html.has-opening.opening-finished:not(.intro-active):not(.intro-done) .hero-brand__word {
  opacity: 0;
  filter: none;
  transform: none;
  clip-path: inset(0 0 100% 0);
  animation: none;
}

html.has-opening.opening-finished:not(.intro-active):not(.intro-done) .hero-brand__scan {
  opacity: 0;
  animation: none;
}

/* Intro: creative “broadcast signal” reveal (also used on rare pages without has-opening) */
html.intro-pending .hero-brand__word {
  animation: none;
  opacity: 0;
}

html.intro-active .hero-brand__line--kmc .hero-brand__word {
  animation: glitchReveal 1.15s var(--ease-out-expo) 0.05s both;
}

html.intro-active .hero-brand__line--lucas .hero-brand__word {
  animation: glitchReveal 1.15s var(--ease-out-expo) 0.22s both;
}

/* tagline now revealed on scroll (hero-scroll-soft), not during intro */

html.intro-active .hero-brand__scan {
  animation: scanSweep 1.8s ease-out 0.15s both;
}

@keyframes glitchReveal {
  0% {
    opacity: 0;
    clip-path: inset(0 0 100% 0);
    filter: blur(14px) drop-shadow(3px 0 0 rgba(255, 0, 0, 0.45)) drop-shadow(-3px 0 0 rgba(0, 255, 255, 0.35));
    transform: translateY(12%) scale(0.96);
  }
  35% {
    opacity: 1;
    clip-path: inset(0 0 0 0);
    filter: blur(4px) drop-shadow(2px 0 0 rgba(255, 0, 0, 0.25)) drop-shadow(-2px 0 0 rgba(0, 200, 255, 0.2));
    transform: translateY(2%) scale(0.995);
  }
  60% {
    filter: blur(1px) drop-shadow(1px 0 0 rgba(255, 255, 255, 0.12));
    transform: translateY(0) scale(1.01);
  }
  100% {
    opacity: 1;
    clip-path: inset(0 0 0 0);
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

@keyframes taglineReveal {
  0% {
    opacity: 0;
    letter-spacing: 0.35em;
    transform: translateY(24px);
  }
  100% {
    opacity: 1;
    letter-spacing: -0.02em;
    transform: translateY(0);
  }
}

@keyframes scanSweep {
  0% {
    opacity: 0;
    transform: translateY(-30%);
  }
  20% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
    transform: translateY(30%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-brand,
  .hero-brand__line,
  .site-header,
  .menu-drawer {
    transition-duration: 0.01ms !important;
  }

  .hero-brand__scan {
    animation: none !important;
  }

  html.intro-active .hero-brand__word {
    animation: fadeInSoft 0.4s ease both !important;
  }

  .hero-brand__tagline {
    opacity: 1 !important;
    transform: translateX(calc(-100% - 28px)) translateY(-50%) !important;
  }

  .hero-brand__tagline-text {
    opacity: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }

  @keyframes fadeInSoft {
    from {
      opacity: 0;
      transform: none;
    }
    to {
      opacity: 1;
    }
  }
}

/* ——— Menu overlay (home02) ——— */
.menu-drawer {
  position: fixed;
  inset: 0 0 auto;
  left: 0;
  right: 0;
  height: var(--menu-bar-height);
  z-index: 200; /* above all stack panels (max z-index: 40) and cursor (80) */
  pointer-events: none;
  transform: translateY(-100%);
  transition: transform 0.85s var(--ease-out-expo);
}

.menu-drawer.is-active {
  pointer-events: auto;
  transform: translateY(0);
}

.menu-drawer__panel {
  height: 100%;
  min-height: 50vh;
  background: var(--color-primary);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: clamp(0.75rem, 2vh, 1.25rem) clamp(1rem, 4vw, 72px) clamp(1rem, 2.5vh, 1.75rem);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12);
}

.menu-drawer__bar {
  --menu-drawer-bar-icon-h: clamp(30px, 3.8vw, 44px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0;
  flex: 1;
  min-height: 0;
}

/* Logo + nav share one column so links align under the wordmark (K). */
.menu-drawer__brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
  min-height: 0;
  gap: clamp(0.525rem, 2.1vh, 1.125rem);
}

/* Horizontal wordmark in drawer (white asset on brand red) */
.menu-drawer__logo--horizontal {
  display: block;
  flex-shrink: 1;
  min-width: 0;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.22));
  line-height: 0;
  height: var(--menu-drawer-bar-icon-h);
}

.menu-drawer__logo-img {
  display: block;
  height: var(--menu-drawer-bar-icon-h);
  width: auto;
  max-width: min(100%, 85vw);
  object-fit: contain;
  object-position: left center;
}

.menu-drawer__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-bg);
  flex-shrink: 0;
  padding: 0.2rem;
  height: var(--menu-drawer-bar-icon-h);
  align-self: flex-start;
}

.menu-drawer__toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--menu-drawer-bar-icon-h);
}

.menu-drawer__toggle-icon img {
  width: var(--menu-drawer-bar-icon-h);
  height: var(--menu-drawer-bar-icon-h);
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.menu-drawer__nav {
  display: flex;
  flex-direction: column;
  gap: clamp(0.12rem, 1.425vh, 0.57rem);
  margin: 0;
  padding: 0;
  flex: 1;
  align-self: stretch;
  max-width: 100%;
}

/* 半屏菜单：六项 + 较长文案，略收字号与行距 */
.menu-drawer__link {
  font-weight: 400;
  font-size: clamp(22.5px, 2.025vh + 0.825rem, 33px);
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--color-bg);
  width: fit-content;
  max-width: 100%;
  position: relative;
  text-decoration: none;
  transition: opacity 0.25s var(--ease-eco);
}

/* Home 与其余项同字重、同字号（保留 class 供当前页标记） */
.menu-drawer__link--accent {
  font-weight: 400;
  font-size: clamp(22.5px, 2.025vh + 0.825rem, 33px);
  letter-spacing: 0.02em;
}

.menu-drawer__link:hover,
.menu-drawer__link:focus-visible {
  opacity: 0.88;
}

.menu-drawer__link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 1px;
  width: 100%;
  height: 1px;
  background: var(--color-bg);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease-eco);
}

.menu-drawer__link:hover::after,
.menu-drawer__link:focus-visible::after {
  transform: scaleX(1);
}

/* ——— Lottie opening (home only; assets/v2.json) + hero slide-in after ——— */
html.opening-active {
  overflow: hidden;
}

.opening-lottie-root {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  transition:
    opacity 0.75s var(--ease-out-expo),
    transform 0.75s var(--ease-out-expo),
    visibility 0.75s;
  touch-action: none;
}

.opening-lottie-view {
  width: min(96vw, calc(96vh * 1920 / 1080));
  max-height: 96vh;
}

.opening-lottie-view svg {
  display: block;
  width: 100% !important;
  height: auto !important;
}

/* Hero + header wait under Lottie: soft lift + blur */
html.has-opening:not(.opening-finished) .site-header,
html.has-opening:not(.opening-finished) .main {
  opacity: 0;
  transform: translate3d(0, clamp(1.25rem, 4vh, 2.75rem), 0);
  filter: blur(10px);
  pointer-events: none;
  transition: none;
}

/* After opening: show chrome immediately — creative beat is the hero “signal” intro (JS intro-active), not a second page fade */
html.has-opening.opening-finished .site-header,
html.has-opening.opening-finished .main {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  filter: none;
  pointer-events: auto;
  transition: none;
}

html.opening-finished .opening-lottie-root {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, -2.5vh, 0);
}

@media (prefers-reduced-motion: reduce) {
  .opening-lottie-root {
    display: none !important;
  }

  html.has-opening:not(.opening-finished) .site-header,
  html.has-opening:not(.opening-finished) .main {
    opacity: 1;
    transform: none;
    filter: none;
    pointer-events: auto;
  }

  html.has-opening.opening-finished .site-header,
  html.has-opening.opening-finished .main {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
