:root {
  --primary: #29576c;
  --primary-light: #375e72;
  --background: #f2f7fa;
  --surface-container: #e8f0f4;
  --outline: #64748b;
  --on-surface: #1a1c1a;
  --on-surface-variant: #475569;
  --book-radius-sm: 8px;
  --book-radius-lg: 18px;
  --book-page-radius: var(--book-radius-sm) var(--book-radius-lg) var(--book-radius-lg) var(--book-radius-sm);
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

body {
  background-color: var(--background);
  color: var(--on-surface);
  overflow: hidden;
  font-family: 'Roboto', sans-serif;
  overscroll-behavior: none;
}

.book-wrapper {
  perspective: 1800px;
  perspective-origin: 50% 50%;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #f2f7fa 0%, #e8f0f4 100%);
  touch-action: pan-y pinch-zoom;
}

.header-logo {
  height: 2rem;
  width: auto;
  display: block;
  border-radius: 6px;
}

.book {
  position: relative;
  width: 90%;
  height: 80vh;
  height: 80dvh;
  max-width: 500px;
  transform-style: preserve-3d;
  border-radius: var(--book-page-radius);
  touch-action: none;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.page-stack {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.page-stack.is-empty {
  opacity: 0;
}

.page-stack-layer {
  --offset: calc(var(--i, 0) + 1);
  position: absolute;
  top: calc(var(--offset) * 3px);
  right: calc(var(--offset) * -7px);
  width: 100%;
  height: calc(100% - var(--offset) * 2px);
  background: color-mix(in srgb, var(--surface-container) 88%, #b8d4e0 calc(var(--i, 0) * 8%));
  border-radius: var(--book-page-radius);
  transition:
    top 0.4s ease,
    right 0.4s ease,
    height 0.4s ease,
    opacity 0.35s ease;
}

.page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotateY(0deg) translateZ(0.1px);
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.45, 0.05, 0.25, 1);
  background-color: transparent;
  border-radius: var(--book-page-radius);
  overflow: visible;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.page.page-turning-forward {
  z-index: 1000 !important;
  transition: transform 1.05s cubic-bezier(0.45, 0.05, 0.25, 1);
}

.page.page-turning-forward .page-content {
  box-shadow:
    inset 6px 0 8px rgba(0, 0, 0, 0.04),
    8px 0 28px rgba(41, 87, 108, 0.14);
}

.page.active {
  transform: rotateY(0deg) translateZ(0.1px);
  pointer-events: auto;
}

.page.flipped {
  transform: rotateY(-180deg) translateZ(0.1px);
  pointer-events: none;
}

.page.upcoming {
  transform: rotateY(0deg) translateZ(0);
  pointer-events: none;
}

.page.page-ahead {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.page::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, #e8f0f4 0%, #c5d8e0 55%, #b0ccd6 100%);
  transform: rotateY(180deg);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.page-content {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  background-color: #ffffff;
  border-radius: inherit;
  overflow: hidden;
  box-shadow: inset 6px 0 8px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  -webkit-transform: translateZ(0.1px);
  transform: translateZ(0.1px);
}

.page-content::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 100%;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.03), transparent);
  pointer-events: none;
  z-index: 1;
}

.product-page {
  position: relative;
  height: 100%;
  overflow: hidden;
}

/* --- Layout cũ: overlay --- */
.product-page--overlay .product-image-frame {
  position: absolute;
  inset: 0;
  background-color: #f4f3f1;
}

.product-page--overlay .product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.product-page--overlay .product-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 35%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 1.25rem 1.25rem;
  background: transparent;
  pointer-events: none;
}

.product-page--overlay .product-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.72) 0%,
    rgba(0, 0, 0, 0.35) 45%,
    transparent 100%
  );
  pointer-events: none;
}

.product-page--overlay .product-overlay > * {
  pointer-events: auto;
}

.product-page--overlay .product-overlay h3 {
  color: #ffffff;
  font-family: 'EB Garamond', serif;
  font-size: 1.75rem;
  line-height: 1.2;
  margin-bottom: 0.25rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.product-page--overlay .product-desc {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* --- Layout mới: hero + detail inset --- */
.product-page--hero-detail .product-hero {
  position: absolute;
  inset: 0;
  background-color: #f4f3f1;
}

.product-page--hero-detail .product-hero .product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.product-page--hero-detail .product-bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem 1rem;
  align-items: end;
  padding: 3.5rem 1.25rem 1.25rem;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.82) 0%,
    rgba(0, 0, 0, 0.45) 52%,
    transparent 100%
  );
  pointer-events: none;
}

.product-page--hero-detail .product-info,
.product-page--hero-detail .product-aside {
  pointer-events: auto;
}

.product-page--hero-detail .product-info h3 {
  color: #ffffff;
  font-family: 'EB Garamond', serif;
  font-size: 1.75rem;
  line-height: 1.15;
  margin-bottom: 0.2rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.product-page--hero-detail .product-info .product-desc {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-bottom: 0.35rem;
  max-width: 16rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.product-page--hero-detail .product-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  min-width: 5.5rem;
}

.product-page--hero-detail .product-detail-inset {
  margin: 0;
  text-align: right;
}

.product-page--hero-detail .product-detail-image {
  display: block;
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  object-position: center;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.38);
}

.product-page--hero-detail .product-detail-caption {
  margin-top: 0.35rem;
  max-width: 5.5rem;
  margin-left: auto;
  font-size: 0.5625rem;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.product-page--hero-detail .page-counter {
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* --- Layout dual: 2 ảnh lớn xếp dọc --- */
.product-page--dual .product-dual-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1.05fr 0.95fr;
  gap: 3px;
  background: #d8e4ea;
}

.product-page--dual .product-dual-panel {
  position: relative;
  overflow: hidden;
  background-color: #f4f3f1;
}

.product-page--dual .product-image--primary,
.product-page--dual .product-image--secondary {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-page--dual .product-image--primary {
  object-position: center center;
}

.product-page--dual .product-image--secondary {
  object-position: center top;
}

.product-page--dual .product-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 1.25rem 1.25rem;
  pointer-events: none;
}

.product-page--dual .product-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.78) 0%,
    rgba(0, 0, 0, 0.4) 50%,
    transparent 100%
  );
  pointer-events: none;
}

.product-page--dual .product-overlay > * {
  pointer-events: auto;
}

.product-page--dual .product-overlay h3 {
  color: #ffffff;
  font-family: 'EB Garamond', serif;
  font-size: 1.75rem;
  line-height: 1.2;
  margin-bottom: 0.25rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.product-page--dual .product-desc {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* --- Chung --- */
.product-image,
.product-detail-image,
.product-image--primary,
.product-image--secondary {
  opacity: 1;
  transform: scale(1);
  transition:
    opacity 0.38s ease,
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}

.product-image.is-swapping,
.product-detail-image.is-swapping,
.product-image--primary.is-swapping,
.product-image--secondary.is-swapping {
  opacity: 0;
  transform: scale(1.04);
}

.product-price-tag {
  display: inline-block;
  margin-bottom: 0.45rem;
  font-size: 1rem;
  font-weight: 300;
  color: #ffffff;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition:
    opacity 0.18s ease,
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.product-price-tag.is-changing {
  opacity: 0;
  transform: translateY(4px);
}

.color-options {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.color-swatches {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.product-overlay .color-label,
.product-info .color-label {
  min-width: 4.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition:
    opacity 0.18s ease,
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.product-overlay .color-label.is-changing,
.product-info .color-label.is-changing {
  opacity: 0;
  transform: translateY(4px);
}

.product-overlay .color-swatch,
.product-info .color-swatch,
.product-overlay .avatar-swatch,
.product-info .avatar-swatch {
  position: relative;
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.24s cubic-bezier(0.34, 1.4, 0.64, 1),
    border-color 0.22s ease,
    box-shadow 0.22s ease;
  -webkit-tap-highlight-color: transparent;
}

.product-overlay .avatar-swatch,
.product-info .avatar-swatch {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
}

.product-overlay .avatar-swatch img,
.product-info .avatar-swatch img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-overlay .color-swatch::before,
.product-info .color-swatch::before,
.product-overlay .avatar-swatch::before,
.product-info .avatar-swatch::before {
  content: '';
  position: absolute;
  inset: -6px;
}

.product-overlay .color-swatch:active,
.product-info .color-swatch:active,
.product-overlay .avatar-swatch:active,
.product-info .avatar-swatch:active {
  transform: scale(0.88);
}

.product-overlay .color-swatch[aria-pressed='true'],
.product-info .color-swatch[aria-pressed='true'],
.product-overlay .avatar-swatch[aria-pressed='true'],
.product-info .avatar-swatch[aria-pressed='true'] {
  border-color: #ffffff;
  transform: scale(1.14);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.28),
    0 3px 12px rgba(0, 0, 0, 0.45);
}

.product-overlay .color-swatch-check,
.product-info .color-swatch-check {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transform: scale(0.5);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.5L6.5 11.5L12.5 4.5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 11px no-repeat;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
  transition:
    opacity 0.2s ease,
    transform 0.24s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.product-overlay .color-swatch[aria-pressed='true'] .color-swatch-check,
.product-info .color-swatch[aria-pressed='true'] .color-swatch-check {
  opacity: 1;
  transform: scale(1);
}

.page-fold-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, transparent 50%, rgba(41, 87, 108, 0.06) 50%, rgba(41, 87, 108, 0.12) 100%);
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
  border-bottom-right-radius: var(--book-radius-lg);
  cursor: pointer;
  z-index: 25;
}

.glass-panel {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(41, 87, 108, 0.1);
  border-radius: 9999px;
}

@keyframes subtle-glow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(41, 87, 108, 0.1)); }
  50% { filter: drop-shadow(0 0 15px rgba(41, 87, 108, 0.2)); }
}

.brand-glow {
  animation: subtle-glow 4s infinite ease-in-out;
}

.social-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.social-btn:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}

.page-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background-color: rgba(41, 87, 108, 0.2);
  transition: all 0.3s ease;
}

.page-dot.active {
  width: 8px;
  height: 8px;
  background-color: var(--primary);
}

/* ─── Video feature ─────────────────────────────────── */

/* Video frame: sits above image (z-index 1) below overlay (z-index 2) */
.product-video-frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.has-video-active .product-video-frame {
  opacity: 1;
  pointer-events: auto;
}

.product-video-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.product-video-frame:not(.is-loading) video {
  opacity: 1;
}

/* Shimmer loading */
.product-video-shimmer {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #0d1117;
  overflow: hidden;
}

.product-video-shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.055) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: video-shimmer 1.8s ease-in-out infinite;
}

.product-video-frame:not(.is-loading) .product-video-shimmer {
  display: none;
}

@keyframes video-shimmer {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}

/* Video swatch button */
.product-overlay .video-swatch,
.product-info .video-swatch {
  position: relative;
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 2px solid rgba(255,255,255,0.42);
  border-radius: 9999px;
  cursor: pointer;
  background: rgba(0,0,0,0.55);
  box-shadow: 0 1px 6px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.24s cubic-bezier(0.34,1.4,0.64,1), border-color 0.22s ease, box-shadow 0.22s ease;
  -webkit-tap-highlight-color: transparent;
}

.product-overlay .video-swatch::before,
.product-info .video-swatch::before {
  content: '';
  position: absolute;
  inset: -6px;
}

.product-overlay .video-swatch:active,
.product-info .video-swatch:active {
  transform: scale(0.88);
}

.product-overlay .video-swatch[aria-pressed='true'],
.product-info .video-swatch[aria-pressed='true'] {
  border-color: #ffffff;
  transform: scale(1.14);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.28), 0 3px 12px rgba(0,0,0,0.45);
}

/* Play triangle icon */
.video-swatch-icon {
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4.5px 0 4.5px 8px;
  border-color: transparent transparent transparent #fff;
  margin-left: 2px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
