/* BD1AHN Product Showcase */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080808;
  --bg-elevated: rgba(8, 8, 8, 0.96);
  --header-fade: rgba(8, 8, 8, 0.94);
  --border: rgba(255, 255, 255, 0.06);
  --text: #f0ece4;
  --text-secondary: rgba(240, 236, 228, 0.72);
  --text-muted: rgba(240, 236, 228, 0.45);
  --text-prose: rgba(240, 236, 228, 0.72);
  --accent: #c9a962;
  --accent-soft: rgba(201, 169, 98, 0.68);
  --accent-border: rgba(201, 169, 98, 0.35);
  --tag-bg: rgba(255, 255, 255, 0.03);
  --scrollbar-track: rgba(255, 255, 255, 0.02);
  --scrollbar-thumb: rgba(201, 169, 98, 0.28);
  --showcase-glow: rgba(201, 169, 98, 0.04);
  --grain-opacity: 0.035;
  --modal-bg: #141414;
  --modal-backdrop: rgba(0, 0, 0, 0.75);
  --donation-row-hover: rgba(201, 169, 98, 0.05);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --header-h: 60px;
  --wheel-w: 200px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f4ef;
  --bg-elevated: rgba(247, 244, 239, 0.98);
  --header-fade: rgba(247, 244, 239, 0.94);
  --border: rgba(26, 24, 20, 0.1);
  --text: #1a1814;
  --text-secondary: rgba(26, 24, 20, 0.72);
  --text-muted: rgba(26, 24, 20, 0.5);
  --text-prose: rgba(26, 24, 20, 0.72);
  --accent: #8a6d2f;
  --accent-soft: rgba(138, 109, 47, 0.75);
  --accent-border: rgba(138, 109, 47, 0.35);
  --tag-bg: rgba(26, 24, 20, 0.04);
  --scrollbar-track: rgba(26, 24, 20, 0.04);
  --scrollbar-thumb: rgba(138, 109, 47, 0.28);
  --showcase-glow: rgba(138, 109, 47, 0.06);
  --grain-opacity: 0.018;
  --modal-bg: #faf8f4;
  --modal-backdrop: rgba(26, 24, 20, 0.45);
  --donation-row-hover: rgba(138, 109, 47, 0.06);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color 0.45s var(--ease), color 0.45s var(--ease);
}

body.page-home,
body.page-product {
  height: 100vh;
  overflow: hidden;
}

body.page-home {
  padding-left: var(--wheel-w);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--grain-opacity);
  transition: opacity 0.45s var(--ease);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 clamp(1.5rem, 4vw, 3rem);
  padding-left: calc(var(--wheel-w) + 1.5rem);
  z-index: 200;
  background: linear-gradient(to bottom, var(--header-fade) 65%, transparent);
  backdrop-filter: blur(10px);
  transition: background 0.45s var(--ease);
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.theme-toggle {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  transition:
    color 0.3s var(--ease),
    border-color 0.3s var(--ease),
    background 0.3s var(--ease);
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--tag-bg);
}

.theme-toggle:focus-visible {
  outline: 1px solid var(--accent-border);
  outline-offset: 2px;
}

.theme-toggle__icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.35s var(--ease), transform 0.45s var(--ease);
}

.theme-toggle__icon--sun {
  opacity: 0;
  transform: rotate(-30deg) scale(0.72);
}

.theme-toggle__icon--moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-toggle__icon--sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-toggle__icon--moon {
  opacity: 0;
  transform: rotate(30deg) scale(0.72);
}

body.page-product .site-header {
  padding-left: clamp(1.5rem, 4vw, 3rem);
}

.logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55em;
  text-decoration: none;
  transition: color 0.3s var(--ease);
  white-space: nowrap;
}

.logo__brand {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  font-variant-numeric: lining-nums;
  color: var(--text);
}

.logo__tagline {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.logo:hover .logo__brand,
.logo:hover .logo__tagline {
  color: var(--accent);
}

.site-header__brand {
  display: flex;
  align-items: baseline;
  gap: clamp(0.65rem, 1.8vw, 1.35rem);
  min-width: 0;
}

.visitor-stat {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--accent-soft);
  white-space: nowrap;
}

.visitor-stat #busuanzi_site_uv {
  color: var(--accent);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.visitor-stat__loading {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(201, 169, 98, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: visitor-stat-spin 0.8s linear infinite;
  vertical-align: -0.05em;
}

@keyframes visitor-stat-spin {
  to { transform: rotate(360deg); }
}

/* Left product wheel */
.product-wheel {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--wheel-w);
  height: 100vh;
  z-index: 180;
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  transition: background 0.45s var(--ease), border-color 0.45s var(--ease);
}

.product-wheel__viewport {
  position: relative;
  height: 100%;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 22%,
    #000 78%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 22%,
    #000 78%,
    transparent 100%
  );
}

.product-wheel__track {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  will-change: transform;
}

.product-wheel__item {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 1.25rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  line-height: 1.35;
  opacity: 0.3;
  transform: scale(0.94);
  transition: color 0.35s var(--ease);
  cursor: pointer;
}

.product-wheel__item span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-wheel__item.active {
  color: var(--text);
  font-weight: 500;
  opacity: 1;
  transform: scale(1);
}

/* Full-page scroll */
.showcase-scroll {
  height: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

.showcase-scroll--single {
  scroll-snap-type: none;
}

.product-page {
  height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
}

.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  height: 100%;
  padding-top: var(--header-h);
  box-sizing: border-box;
  overflow: hidden;
}

.product-showcase {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 2vh, 1.5rem);
  min-height: 0;
  height: 100%;
  background:
    radial-gradient(ellipse 70% 60% at 50% 48%, var(--showcase-glow), transparent),
    var(--bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.product-info {
  padding: clamp(1.25rem, 2.5vh, 2rem) clamp(1.5rem, 4vw, 3.5rem);
  padding-right: clamp(1.25rem, 3vw, 2.5rem);
  overflow: hidden;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.product-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.device-badge {
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 100px;
}

.device-badge--walkie {
  border-color: var(--accent-border);
  color: var(--accent);
}

.device-badge--phone { color: var(--text-muted); }

.device-badge--pc {
  border-color: rgba(120, 160, 220, 0.35);
  color: rgba(160, 190, 240, 0.85);
}

.product-meta time {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.product-title {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
  flex-shrink: 0;
  max-width: 100%;
}

.product-info h1,
.product-title h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 400;
  line-height: 1.15;
  margin-bottom: 0;
}

.firmware-version-badge {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1;
  padding: 0.28rem 0.55rem;
  border-radius: 3px;
  background: linear-gradient(145deg, #e8cc7a 0%, #c9a962 42%, #9a7835 100%);
  color: #1a1408;
  box-shadow:
    0 1px 0 rgba(255, 236, 180, 0.45) inset,
    0 2px 10px rgba(201, 169, 98, 0.28);
  white-space: nowrap;
}

.product-lead {
  font-size: 0.92rem;
  font-weight: 300;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.65;
  flex-shrink: 0;
}

.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}

.tag {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding: 0.28rem 0.65rem;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

.product-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.25rem;
}

.prose {
  font-size: 0.88rem;
  font-weight: 300;
  line-height: 1.75;
  color: var(--text-prose);
}

.prose h2, .prose h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--text);
  margin: 1.25rem 0 0.5rem;
}

.prose h2 { font-size: 1.35rem; }
.prose h3 { font-size: 1.1rem; }
.prose p { margin-bottom: 0.7rem; }
.prose ul, .prose ol { margin: 0 0 0.7rem 1.2rem; }
.prose li { margin-bottom: 0.3rem; }
.prose strong { font-weight: 500; color: var(--text); }

.prose a {
  color: rgba(201, 169, 98, 0.9);
  text-decoration: none;
  border-bottom: 1px solid rgba(201, 169, 98, 0.32);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
  word-break: break-word;
}

.prose a:hover {
  color: var(--accent);
  border-bottom-color: rgba(201, 169, 98, 0.7);
}

.prose a:focus-visible {
  outline: 1px solid rgba(201, 169, 98, 0.45);
  outline-offset: 2px;
  border-bottom-color: transparent;
}

.prose a::after {
  content: "↗";
  display: inline-block;
  margin-left: 0.2em;
  font-size: 0.78em;
  opacity: 0.55;
  vertical-align: baseline;
  text-decoration: none;
}

/* Device mockup */
.device-mockup {
  position: relative;
  user-select: none;
  flex-shrink: 0;
}

.device-mockup--walkie {
  width: auto;
  height: min(84vh, calc(100vh - var(--header-h) - 1rem));
  max-width: min(400px, 52vw);
  aspect-ratio: 300 / 560;
  container-type: inline-size;
}

.device-mockup--phone {
  width: min(96%, 940px);
  height: auto;
  max-height: min(68vh, calc(100vh - var(--header-h) - 1rem));
  aspect-ratio: 900 / 420;
}

.device-mockup--pc {
  width: min(98%, 960px);
  height: auto;
  max-height: min(72vh, calc(100vh - var(--header-h) - 1rem));
  aspect-ratio: 720 / 460;
}

.device-mockup__screen {
  position: absolute;
  z-index: 2;
  overflow: hidden;
  background: #030303;
}

.device-mockup__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 3;
}

.device-mockup--walkie .device-mockup__frame {
  filter: drop-shadow(0 16px 36px rgba(0,0,0,0.45));
}

.device-mockup--phone .device-mockup__frame {
  filter: drop-shadow(0 24px 50px rgba(0,0,0,0.55));
}

.device-mockup--pc .device-mockup__frame {
  filter: drop-shadow(0 20px 48px rgba(0,0,0,0.5));
}

.device-mockup__brand {
  position: absolute;
  left: 50%;
  top: 17.5%;
  transform: translateX(-50%);
  z-index: 5;
  font-family: Arial, sans-serif;
  font-size: 3.6cqi;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
  pointer-events: none;
  white-space: nowrap;
}

/* Walkie screen hole: x=42 y=118 w=216 h=124 on 300×560 */
.device-mockup__screen--walkie {
  left: 14%;
  top: 21.07%;
  width: 72%;
  height: 22.14%;
  border-radius: 2px;
}

/* PC screen hole: x=28 y=36 w=664 h=324 on 720×460 */
.device-mockup__screen--pc {
  left: 3.89%;
  top: 7.83%;
  width: 92.22%;
  height: 70.43%;
  border-radius: 4px;
}

/* Phone landscape screen hole: x=58 y=22 w=784 h=376 on 900×420 */
.device-mockup__screen--phone {
  left: 6.44%;
  top: 5.24%;
  width: 87.11%;
  height: 89.52%;
  border-radius: 4px;
}

.device-mockup--phone .device-slide img {
  object-fit: contain;
  background: #0a0a0a;
}

/* Carousel */
.device-carousel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.device-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
  pointer-events: none;
}

.device-slide.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.device-slide.slide-out-left {
  opacity: 0;
  transform: translateX(-10px);
}

.device-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.device-mockup--walkie .device-slide img {
  object-fit: contain;
  background: #050505;
}

.device-mockup--pc .device-slide img {
  object-fit: contain;
  background: #0a0a0a;
}

.device-slide.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: var(--text-muted);
  font-size: 0.65rem;
}

/* Screen nav arrows */
.screen-nav {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.screen-nav__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s;
}

.screen-nav__btn:hover { background: rgba(201, 169, 98, 0.8); }
.screen-nav__btn--prev { left: 3px; }
.screen-nav__btn--next { right: 3px; }

.screen-nav__count {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  color: rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.5);
  padding: 1px 6px;
  border-radius: 8px;
}

.empty-state-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
}

.empty-state code { color: var(--accent); }

/* Scrollbar — match site theme */
html,
.showcase-scroll,
.product-info,
.product-content {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

html::-webkit-scrollbar,
.showcase-scroll::-webkit-scrollbar,
.product-info::-webkit-scrollbar,
.product-content::-webkit-scrollbar {
  width: 5px;
}

html::-webkit-scrollbar-track,
.showcase-scroll::-webkit-scrollbar-track,
.product-info::-webkit-scrollbar-track,
.product-content::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-left: 1px solid var(--border);
}

html::-webkit-scrollbar-thumb,
.showcase-scroll::-webkit-scrollbar-thumb,
.product-info::-webkit-scrollbar-thumb,
.product-content::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 100px;
  border: 1px solid transparent;
  background-clip: padding-box;
}

html::-webkit-scrollbar-thumb:hover,
.showcase-scroll::-webkit-scrollbar-thumb:hover,
.product-info::-webkit-scrollbar-thumb:hover,
.product-content::-webkit-scrollbar-thumb:hover {
  background: rgba(201, 169, 98, 0.52);
}

html::-webkit-scrollbar-thumb:active,
.showcase-scroll::-webkit-scrollbar-thumb:active,
.product-info::-webkit-scrollbar-thumb:active,
.product-content::-webkit-scrollbar-thumb:active {
  background: var(--accent);
}

/* Responsive */
@media (max-width: 900px) {
  :root { --wheel-w: 0px; }

  body.page-home { padding-left: 0; }
  .product-wheel { display: none; }
  .site-header { padding-left: 1.5rem !important; }
  .visitor-stat { font-size: 0.65rem; }

  body.page-home { overflow: auto; height: auto; }
  .showcase-scroll { height: auto; scroll-snap-type: none; }
  .product-page { height: auto; min-height: 100vh; overflow: visible; }
  .product-detail { grid-template-columns: 1fr; height: auto; min-height: calc(100vh - var(--header-h)); overflow: visible; }
  .product-showcase {
    min-height: 45vh;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .product-info {
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
  }
  .product-content {
    overflow-y: visible;
  }
  .device-mockup--walkie { width: min(320px, 85vw); height: auto; max-width: none; }
  .device-mockup--phone { width: min(98%, 680px); max-height: none; }
  .device-mockup--pc { width: min(98%, 720px); max-height: none; }
}

@media (max-width: 520px) {
  .screen-nav__btn { width: 22px; height: 22px; font-size: 0.85rem; }
}
