/* ============================================================
   Hopeet Safety Valve — exhibition page
   Palette aligned with hopeet-search (warm off-white + Hopeet red)
   ============================================================ */
:root {
  --bg: #f5f1ee;
  --surface: #ffffff;
  --surface-2: #faf8f6;
  --red-600: #d11f2a;
  --red-700: #b3151f;
  --red-800: #8f1019;
  --red-tint: #fbeeef;
  --ink-900: #15110f;
  --ink-700: #453d38;
  --ink-500: #6b625d;
  --ink-400: #a39a93;
  --line: #ece7e4;
  --line-2: #e3dcd6;
  --green-600: #1b9e63;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(21, 17, 15, 0.05), 0 6px 16px -12px rgba(21, 17, 15, 0.3);
  --shadow-md: 0 4px 10px -6px rgba(21, 17, 15, 0.12), 0 24px 48px -28px rgba(21, 17, 15, 0.32);
  --maxtext: 760px;
  --sidebar-w: 280px;
  --topbar-h: 72px;
  --font: "Helvetica Neue", Helvetica, Arial, "PingFang TC", "Hiragino Sans",
    "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 24px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-900);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- language visibility (toggled on <html data-lang>) ---- */
[data-lang="en"] .zh { display: none; }
[data-lang="zh"] .en { display: none; }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 4vw, 40px);
  background: rgba(245, 241, 238, 0.82);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; }
.brand__logo { height: 34px; width: auto; display: block; }

.topbar__right { display: flex; align-items: center; gap: 14px; }

/* Language segmented toggle */
.langtoggle {
  display: inline-flex;
  padding: 4px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.langtoggle__opt {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-500);
  padding: 7px 16px;
  border-radius: 999px;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.langtoggle__opt:hover { color: var(--ink-900); }
[data-lang="en"] .langtoggle__opt[data-set-lang="en"],
[data-lang="zh"] .langtoggle__opt[data-set-lang="zh"] {
  color: var(--red-700);
  background: var(--red-tint);
  box-shadow: inset 0 0 0 1px rgba(209, 31, 42, 0.12);
}

/* Mobile menu button */
.navbtn {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.navbtn span {
  width: 20px; height: 2px; background: var(--ink-700); border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ============================================================
   Shell layout
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  max-width: 1320px;
  margin: 0 auto;
}

/* ============================================================
   Sidebar nav tree
   ============================================================ */
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 30px 18px 40px 28px;
}
.tree { display: flex; flex-direction: column; gap: 6px; }

.tree__group { padding-bottom: 4px; }
.tree__head {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--ink-900);
  text-align: left;
  transition: background 0.16s ease;
}
.tree__head:hover { background: var(--surface); }
.tree__title { font-size: 0.95rem; font-weight: 800; letter-spacing: 0.01em; }
.tree__chevron {
  width: 8px; height: 8px;
  border-right: 2px solid var(--red-600);
  border-bottom: 2px solid var(--red-600);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  flex: 0 0 auto;
}
.tree__group.is-open .tree__chevron { transform: rotate(45deg); }

.tree__list {
  list-style: none;
  margin: 2px 0 0;
  padding: 0 0 0 8px;
  overflow: hidden;
  max-height: 600px;
  transition: max-height 0.3s ease, opacity 0.24s ease, margin-top 0.3s ease;
}
.tree__group:not(.is-open) .tree__list {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}
.tree__list a,
.tree__solo {
  display: block;
  padding: 7px 12px;
  margin: 1px 0;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-500);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.tree__list a:hover { color: var(--ink-900); background: var(--surface); }
.tree__list a.is-active {
  color: var(--red-700);
  background: var(--surface);
  border-left-color: var(--red-600);
  font-weight: 700;
}
.tree__group--solo { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.tree__solo { font-size: 0.95rem; font-weight: 800; color: var(--ink-900); padding: 9px 10px; }
.tree__solo:hover { background: var(--surface); }
.tree__solo.is-active { color: var(--red-700); }

.scrim { position: fixed; inset: 0; background: rgba(21, 17, 15, 0.4); z-index: 25; }

/* ============================================================
   Main content
   ============================================================ */
.main { padding: 12px clamp(20px, 5vw, 72px) 80px; min-width: 0; }

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--red-600);
}

.prose { max-width: var(--maxtext); }
.prose p { margin: 0 0 16px; color: var(--ink-700); font-size: 1.05rem; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--ink-900); font-weight: 800; }

/* Hero */
.hero {
  padding: clamp(40px, 7vw, 80px) 0 56px;
  border-bottom: 1px solid var(--line);
}
.hero__title {
  margin: 0 0 26px;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: var(--ink-900);
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 34px;
  max-width: var(--maxtext);
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 24px 26px;
  box-shadow: var(--shadow-sm);
}
.card p { margin: 0; color: var(--ink-500); font-size: 0.98rem; line-height: 1.6; }
.card__tag {
  display: inline-block;
  margin-bottom: 12px;
  padding: 5px 13px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--red-700);
  background: var(--red-tint);
  border-radius: 999px;
}

/* Standard section */
.section { padding: clamp(44px, 6vw, 72px) 0; border-bottom: 1px solid var(--line); }
.section__title {
  margin: 0 0 22px;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  line-height: 1.18;
  letter-spacing: -0.01em;
  font-weight: 800;
}

/* Stat callout */
.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 16px;
  margin-top: 30px;
  padding: 20px 28px;
  background: var(--ink-900);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.stat__num { font-size: 2.4rem; font-weight: 800; color: #fff; letter-spacing: -0.02em; }
.stat__label { font-size: 0.95rem; color: rgba(255, 255, 255, 0.7); max-width: 240px; line-height: 1.4; }

/* Manufacturing divider */
.divider {
  padding: clamp(56px, 8vw, 96px) 0 clamp(40px, 5vw, 60px);
  border-bottom: 1px solid var(--line);
}
.divider__title {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 800;
}

/* ============================================================
   Video
   ============================================================ */
.video { margin: 30px 0 0; max-width: 920px; }
.video__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0d0b0a;
  box-shadow: var(--shadow-md);
}
.video__frame iframe,
.video__frame video {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block;
  object-fit: cover; background: #0d0b0a;
}
.video__ph {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 1rem; font-weight: 600; letter-spacing: 0.02em;
  background:
    repeating-linear-gradient(45deg, #17120f 0 14px, #1d1714 14px 28px);
}
.video__cap { margin: 12px 2px 0; font-size: 0.88rem; color: var(--ink-400); }

/* Chapter clip: poster + play overlay + timecode badge */
.video--chapter .video__el { cursor: pointer; }
.video__play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 78px; height: 78px;
  display: flex; align-items: center; justify-content: center;
  padding-left: 5px;
  font-size: 1.7rem; color: #fff;
  background: rgba(209, 31, 42, 0.92);
  border: 0; border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 10px 30px -8px rgba(209, 31, 42, 0.6);
  transition: transform 0.16s ease, background 0.16s ease, opacity 0.2s ease;
}
.video__play:hover { background: var(--red-600); transform: translate(-50%, -50%) scale(1.06); }
.video--chapter.is-playing .video__play { opacity: 0; pointer-events: none; }

.chapter-badge {
  position: absolute;
  top: 14px; left: 14px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em;
  color: #fff;
  background: rgba(13, 11, 10, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 999px;
}
.chapter-badge__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red-600);
  box-shadow: 0 0 0 4px rgba(209, 31, 42, 0.28);
}
.chapter-badge__time { color: #fff; font-variant-numeric: tabular-nums; opacity: 0.92; }

/* Photo placeholder (e.g. 調壓 / Pressure Setting) */
.photo { margin: 30px 0 0; max-width: 920px; }
.photo__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px dashed var(--line-2);
  background: var(--surface-2);
}
.photo__phinner {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--ink-400); font-weight: 600;
}
.photo__img { display: block; width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow-md); }

/* ============================================================
   Certifications
   ============================================================ */
.section--certs { border-bottom: 0; }
.certs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 20px;
  margin-top: 36px;
}
.cert {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  font: inherit;
}
.cert:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.cert__img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.cert__img--ph {
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-400);
  font-weight: 800; font-size: 1.3rem; line-height: 1.2;
  border: 1px dashed var(--line-2);
}
.cert__name { font-size: 0.92rem; font-weight: 700; color: var(--ink-700); }

/* ============================================================
   Footer
   ============================================================ */
.foot {
  margin-top: 60px;
  padding: 40px 0 8px;
  text-align: center;
  border-top: 1px solid var(--line);
}
.foot__logo { height: 40px; width: auto; opacity: 0.85; margin-bottom: 14px; }
.foot__name { font-size: 0.95rem; font-weight: 700; color: var(--ink-700); }
.foot__sub { margin-top: 6px; font-size: 0.85rem; color: var(--ink-400); }

/* ============================================================
   Lightbox
   ============================================================ */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 4vmin;
  background: rgba(13, 11, 10, 0.92);
  backdrop-filter: blur(4px);
  animation: lbfade 0.2s ease;
}
@keyframes lbfade { from { opacity: 0; } to { opacity: 1; } }
.lightbox__fig { margin: 0; max-width: 92vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.lightbox__fig img {
  max-width: 100%; max-height: 80vh; object-fit: contain;
  border-radius: 10px; background: #fff; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
}
.lightbox__fig figcaption { color: rgba(255, 255, 255, 0.82); font-size: 0.95rem; text-align: center; }
.lightbox__close {
  position: absolute; top: 18px; right: 22px;
  width: 46px; height: 46px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 2rem; line-height: 1; cursor: pointer;
  transition: background 0.16s ease;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 54px; height: 54px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 2rem; line-height: 1; cursor: pointer;
  transition: background 0.16s ease;
}
.lightbox__nav:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox__nav--prev { left: 18px; }
.lightbox__nav--next { right: 18px; }

/* ============================================================
   Manufacturing module (single player + chapter tabs)
   ============================================================ */
.mfg__rail { display: flex; gap: 10px; flex-wrap: wrap; margin: 28px 0 24px; }
.mfg__tab {
  display: inline-flex; flex-direction: column; gap: 3px;
  padding: 11px 18px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer; font: inherit; text-align: left;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.mfg__tab:hover { border-color: var(--line-2); }
.mfg__tab.is-active {
  border-color: var(--red-600);
  background: var(--red-tint);
  box-shadow: inset 0 0 0 1px rgba(209, 31, 42, 0.25);
}
.mfg__tabname { font-size: 0.92rem; font-weight: 700; color: var(--ink-900); }
.mfg__tab.is-active .mfg__tabname { color: var(--red-700); }
.mfg__tabtime {
  font-size: 0.74rem; font-weight: 600; color: var(--ink-400);
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.mfg__tab.is-active .mfg__tabtime { color: var(--red-600); }

.mfg__stage { max-width: 920px; }
.mfg__video, .mfg__photo { margin: 0; }

.mfg__panels { max-width: var(--maxtext); margin-top: 28px; }
.mfg__panel { display: none; }
.mfg__panel.is-active { display: block; animation: mfgfade 0.25s ease; }
@keyframes mfgfade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mfg__ptitle { margin: 0 0 14px; font-size: 1.35rem; font-weight: 800; color: var(--ink-900); }

[hidden] { display: none !important; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 920px) {
  .navbtn { display: flex; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: 300px;
    max-width: 86vw;
    height: calc(100vh - var(--topbar-h));
    background: var(--bg);
    border-right: 1px solid var(--line);
    z-index: 30;
    transform: translateX(-104%);
    transition: transform 0.26s ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.is-open { transform: translateX(0); }
  .navbtn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .navbtn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .navbtn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .lightbox__nav { width: 44px; height: 44px; font-size: 1.6rem; }
  .lightbox__nav--prev { left: 6px; }
  .lightbox__nav--next { right: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
