/* ============================================================
   BEAUTECH — Clinical / Scientific design system
   ============================================================ */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300;0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,300;1,6..72,400&family=Hanken+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Noto+Serif+TC:wght@300;400;500;600&family=Noto+Sans+TC:wght@300;400;500;600&display=swap');

/* ---- Tokens ---- */
:root {
  /* palette (tweakable) */
  --paper:    #FFFFFF;
  --surface:  #FAF7FB;
  --surface-2:#FFFFFF;
  --ink:      #1B1320;
  --ink-soft: #4A4253;
  --muted:    #8B8395;
  --line:     rgba(27,19,32,0.12);
  --line-soft:rgba(27,19,32,0.06);
  --accent:   #862D92;        /* Beautech purple */
  --accent-d: #6A2275;
  --accent-tint:#F4E7F6;
  --brand-blue:#1880C0;       /* BT monogram blue */
  --accent-on-dark:#CE86D8;    /* light purple for labels on dark sections */
  --heading:  #862D92;        /* headings in brand purple */
  --signal:   #C24E3A;        /* warm signal, used sparingly */

  /* type */
  --f-display: 'Newsreader', 'Noto Serif TC', Georgia, serif;
  --f-sans:    'Hanken Grotesk', 'Noto Sans TC', system-ui, sans-serif;
  --f-mono:    'JetBrains Mono', 'Noto Sans TC', monospace;

  /* metrics */
  --maxw: 1280px;
  --gutter: clamp(20px, 5vw, 76px);
  --radius: 3px;
}

:root[data-theme="dark"] {
  --paper:    #14101A;
  --surface:  #1A1522;
  --surface-2:#201A29;
  --ink:      #EFEAF2;
  --ink-soft: #B6AEBE;
  --muted:    #756B7E;
  --line:     rgba(239,234,242,0.14);
  --line-soft:rgba(239,234,242,0.07);
  --accent:   #C77BD2;
  --accent-d: #DCA6E4;
  --accent-tint:#2A1730;
  --heading:  #D49ADC;
  --accent-on-dark:#D49ADC;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--f-sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.62;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
::selection { background: var(--accent); color: #fff; }

/* ---- Language visibility ---- */
:root[data-lang="en"] .zh { display: none !important; }
:root[data-lang="zh"] .en { display: none !important; }
:root[data-lang="zh"] body { letter-spacing: 0; }

/* ---- Menu legibility: ZH glyphs read a touch larger than mono EN ---- */
.nav-links a .zh, .mobile-menu a .zh { font-size: 1.06em; }
:root[data-lang="zh"] .nav-links a { letter-spacing: 0.02em; }

/* ---- Tablet → laptop: nudge reading + UI sizes up (headers untouched) ---- */
@media (min-width: 760px) and (max-width: 1366px) {
  body { font-size: 18.5px; }
  .lead { font-size: clamp(19px, 1.9vw, 23px); }
  .nav-links a { font-size: 15.5px; }
  .lang-toggle button { font-size: 13px; }
  .btn { font-size: 14px; }
  .eyebrow { font-size: 13px; }
}

/* ---- Layout primitives ---- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: var(--gutter); }
.wrap-wide { max-width: 1480px; margin: 0 auto; padding-inline: var(--gutter); }
section { position: relative; }

/* ---- Type ---- */
.eyebrow {
  font-family: var(--f-mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow .idx { color: var(--muted); }
.eyebrow.on-dark { color: var(--accent-d); }

/* keep small accent labels readable on the dark sections */
.proc .eyebrow, .actives .eyebrow, .flow .eyebrow, .qc .eyebrow,
.proc-step .ps-n, .act .an, .flow-item .fn, .qc-steps .qs .qn {
  color: var(--accent-on-dark) !important;
}

h1,h2,h3 { font-family: var(--f-display); font-weight: 400; line-height: 1.04; letter-spacing: -0.015em; text-wrap: balance; color: var(--heading); }
.display {
  font-size: clamp(40px, 6.4vw, 92px);
  font-weight: 300;
  line-height: 0.98;
  letter-spacing: -0.025em;
}
.h-xl { font-size: clamp(32px, 4.4vw, 60px); font-weight: 300; }
.h-lg { font-size: clamp(26px, 3vw, 40px); }
.h-md { font-size: clamp(21px, 2.2vw, 28px); }
:root[data-lang="zh"] .display,
:root[data-lang="zh"] .h-xl { font-weight: 400; letter-spacing: 0; }

.lead {
  font-size: clamp(18px, 1.5vw, 22px);
  line-height: 1.56;
  color: var(--ink-soft);
  text-wrap: pretty;
  font-weight: 400;
}
.muted { color: var(--muted); }
.serif-i { font-family: var(--f-display); font-style: italic; font-weight: 400; }
.accent-text { color: var(--accent); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--f-mono);
  font-size: 13.5px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 14px 23px;
  border-radius: var(--radius);
  transition: all .25s cubic-bezier(.2,.7,.3,1);
  white-space: nowrap;
}
.btn .arrow { transition: transform .25s ease; }
.btn:hover .arrow { transform: translateX(4px); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-d); }
.btn-ghost { border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); background: var(--ink); color: var(--paper); }

/* ---- Hairline / divider ---- */
.rule { height: 1px; background: var(--line); border: 0; }
.rule-soft { height: 1px; background: var(--line-soft); border: 0; }

/* ---- Reveal animation ---- */
@media (prefers-reduced-motion: no-preference) {
  html.reveal-armed .reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s ease, transform .8s cubic-bezier(.2,.7,.3,1); }
  html.reveal-armed .reveal.in { opacity: 1; transform: none; }
  .reveal[data-d="1"] { transition-delay: .08s; }
  .reveal[data-d="2"] { transition-delay: .16s; }
  .reveal[data-d="3"] { transition-delay: .24s; }
  .reveal[data-d="4"] { transition-delay: .32s; }
}

/* ============================================================
   HEADER / NAV
   ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid var(--line-soft);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  height: 76px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark {
  width: 38px; height: 38px; position: relative; flex: none;
}
.brand .mark svg, .brand .mark img { width: 100%; height: 100%; display: block; }
.brand .name {
  font-family: var(--f-sans); font-size: 21px; font-weight: 800;
  letter-spacing: 0.01em; line-height: 1; color: var(--accent); text-transform: uppercase;
}
.brand .name b { font-weight: 800; }
.brand .sub {
  font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--muted); display: block; margin-top: 4px;
  font-weight: 500;
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  font-family: var(--f-mono); font-size: 14.5px; font-weight: 500;
  letter-spacing: 0.03em; text-transform: uppercase;
  padding: 9px 14px; border-radius: var(--radius);
  color: var(--ink-soft); transition: color .2s, background .2s;
  position: relative;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 8px; }
.lang-toggle {
  display: flex; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.lang-toggle button {
  font-family: var(--f-mono); font-size: 12.5px; font-weight: 500;
  padding: 8px 12px; letter-spacing: 0.03em; color: var(--muted);
  transition: all .2s;
}
.lang-toggle button.on { background: var(--ink); color: var(--paper); }
.nav-cta { display: inline-flex; }
.burger { display: none; width: 40px; height: 40px; align-items: center; justify-content: center; }
.burger span { display:block; width: 20px; height: 1.5px; background: var(--ink); position: relative; }
.burger span::before, .burger span::after { content:''; position:absolute; left:0; width:20px; height:1.5px; background: var(--ink); transition: .25s; }
.burger span::before { top: -6px; } .burger span::after { top: 6px; }

.mobile-menu {
  position: fixed; inset: 76px 0 0; z-index: 99;
  background: var(--paper); padding: var(--gutter);
  transform: translateY(-8px); opacity: 0; pointer-events: none; transition: .3s;
  display: flex; flex-direction: column; gap: 4px;
}
.mobile-menu.open { transform: none; opacity: 1; pointer-events: auto; }
.mobile-menu a {
  font-family: var(--f-display); font-size: 30px; font-weight: 300;
  padding: 14px 0; border-bottom: 1px solid var(--line-soft);
}

@media (max-width: 940px) {
  .nav-links, .nav-cta { display: none; }
  .burger { display: flex; }
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer { background: var(--ink); color: var(--paper); padding: 88px 0 36px; margin-top: 0; }
:root[data-theme="dark"] .site-footer { background: #090B0C; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 48px; }
.site-footer .brand .name { color: var(--paper); }
.site-footer .ftitle {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 18px;
}
.site-footer a.fl { display: block; color: rgba(255,255,255,0.7); padding: 6px 0; font-size: 15px; transition: color .2s; }
.site-footer a.fl:hover { color: #fff; }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-top: 64px; padding-top: 28px; border-top: 1px solid rgba(255,255,255,0.12); }
.footer-bottom, .footer-bottom a { font-family: var(--f-mono); font-size: 11.5px; letter-spacing: 0.03em; color: var(--muted); text-transform: uppercase; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr 1fr; gap: 36px; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }

/* ---- utility ---- */
.col { display: flex; flex-direction: column; }
.center { text-align: center; }
.tag {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 100px; padding: 6px 13px;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }

/* reveal safety net — guarantees visibility even if paint/transition stalls */
html.reveal-done .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }

/* ============================================================
   TWEAKS PANEL
   ============================================================ */
#btc-tweaks {
  position: fixed; right: 20px; bottom: 20px; z-index: 1000;
  width: 264px; background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 24px 60px -18px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.08);
  font-family: var(--f-sans);
  transform: translateY(12px) scale(.98); opacity: 0; pointer-events: none;
  transition: .26s cubic-bezier(.2,.7,.3,1);
}
#btc-tweaks.open { transform: none; opacity: 1; pointer-events: auto; }
.tw-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); }
.tw-title { font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.tw-close { font-size: 22px; line-height: 1; color: var(--muted); width: 26px; height: 26px; }
.tw-close:hover { color: var(--ink); }
.tw-body { padding: 8px 16px 18px; }
.tw-sec { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 16px 0 9px; }
.tw-swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tw-swatches button { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; transition: .18s; }
.tw-swatches button i { width: 15px; height: 15px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
.tw-swatches button span { font-size: 12px; text-transform: capitalize; color: var(--ink-soft); }
.tw-swatches button.sel { border-color: var(--ink); }
.tw-swatches button.sel span { color: var(--ink); }
.tw-seg { display: flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.tw-seg button { flex: 1; padding: 9px; font-family: var(--f-mono); font-size: 11.5px; letter-spacing: 0.04em; color: var(--muted); transition: .18s; }
.tw-seg button + button { border-left: 1px solid var(--line); }
.tw-seg button.sel { background: var(--ink); color: var(--paper); }
@media (max-width: 560px) { #btc-tweaks { right: 12px; left: 12px; width: auto; bottom: 12px; } }

/* ============================================================
   MOTION — dynamic layer
   stagger · image-settle · nav-underline · hover-lift · marquee
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  /* staggered cascade for grid / list children */
  html.reveal-armed .rise {
    opacity: 0; transform: translateY(24px);
    transition: opacity .7s ease, transform .75s cubic-bezier(.2,.7,.3,1);
    transition-delay: calc(var(--si, 0) * 65ms);
  }
  html.reveal-armed .rise.in { opacity: 1; transform: none; }

  /* prominent images settle (scale) as their container reveals */
  html.reveal-armed .reveal image-slot {
    transform: scale(1.055); transform-origin: center;
    transition: transform 1.05s cubic-bezier(.2,.7,.3,1);
  }
  html.reveal-armed .reveal.in image-slot { transform: none; }

  /* hero spec card gently floats */
  .hero-spec { animation: hs-float 5.5s ease-in-out infinite; }
  @keyframes hs-float {
    0%, 100% { transform: translate(-14px, 14px); }
    50%      { transform: translate(-14px, 6px); }
  }
}
/* safety net — never leave motion elements stuck or scaled */
html.reveal-done .rise { opacity: 1 !important; transform: none !important; transition: none !important; }
html.reveal-done .reveal image-slot { transform: none !important; }

/* ---- Animated nav underline (hover + active) ---- */
.nav-links a::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: 3px; height: 2px;
  background: var(--accent); border-radius: 2px;
  transform: scaleX(0); transform-origin: left;
  transition: transform .32s cubic-bezier(.2,.7,.3,1);
}
.nav-links a:hover::after { transform: scaleX(1); }
.nav-links a.active::after { transform: scaleX(1); }

/* ---- Hover lift on standalone cards ---- */
.pcard, .val, .qb, .cert-item {
  transition: transform .35s cubic-bezier(.2,.7,.3,1), box-shadow .35s ease, background .3s ease;
}
.pcard:hover { transform: translateY(-6px); box-shadow: 0 28px 52px -30px rgba(27,19,32,.5); }
.val:hover, .qb:hover, .cert-item:hover { transform: translateY(-4px); }

/* ---- Button press feedback ---- */
.btn:active { transform: translateY(1px) scale(.99); }

/* ---- Certifications marquee ---- */
.certbar .wrap-wide, .certbar .wrap { overflow: hidden; }
.cb-inner { display: flex; width: max-content; }
.cb-track {
  display: flex; align-items: center; flex: none;
  gap: clamp(24px, 5vw, 64px); padding-right: clamp(24px, 5vw, 64px);
}
@media (prefers-reduced-motion: no-preference) {
  .cb-inner.run { animation: cb-scroll 42s linear infinite; }
  .certbar:hover .cb-inner.run { animation-play-state: paused; }
}
@keyframes cb-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
