/* Homepage era carousels — palace burgundy / black / gold
   Ming = Ken Burns · Minguo = stack · Taiwan = film */

html { scroll-padding-top: calc(var(--nav-h) + 12px); }

.era-carousel {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  max-width: 640px;
}

/* Shared stage backdrop — never white letterbox */
.kb-stage,
.stack-card,
.film-frame {
  background: radial-gradient(ellipse at center, #4a1820 0%, #12080a 75%);
  scroll-margin-top: calc(var(--nav-h) + 16px);
}

/* ===== A · Ken Burns ===== */
.era-carousel--kb .kb-stage {
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: min(72vh, calc(100vh - var(--nav-h) - 9rem));
  margin: 0 auto;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(26, 23, 20, 0.22), inset 0 0 0 1px rgba(166, 137, 90, 0.55);
  touch-action: pan-y;
  user-select: none;
}
.era-carousel--kb .kb-stage::before,
.era-carousel--kb .kb-stage::after {
  content: "";
  position: absolute; z-index: 5; pointer-events: none;
  width: 26px; height: 26px;
  border: 1.5px solid var(--gold);
  opacity: .85;
}
.era-carousel--kb .kb-stage::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.era-carousel--kb .kb-stage::after { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }
.kb-frame-ornament {
  position: absolute; inset: 8px; z-index: 4; pointer-events: none;
  border: 1px solid rgba(166, 137, 90, 0.3);
}
.kb-slide {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity 1.4s ease;
  display: flex; align-items: center; justify-content: center;
}
.kb-slide.active { opacity: 1; z-index: 2; }
.kb-slide img {
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center center;
  transform: scale(1);
  transition: transform 7.5s ease-out;
  will-change: transform;
}
.kb-slide.active img.ken { transform: scale(1.04) translate3d(0.6%, -0.4%, 0); }
.kb-slide.active img.ken-alt { transform: scale(1.035) translate3d(-0.6%, 0.4%, 0); }
.kb-caption {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 2.2rem 1rem .85rem;
  background: linear-gradient(transparent, rgba(10, 6, 8, 0.88));
  text-align: center; pointer-events: none;
  color: #f3ebe0;
}
.kb-caption .alt { font-size: 0.82rem; letter-spacing: 0.12em; }
.kb-caption .meta { color: var(--gold-light); font-size: 0.65rem; letter-spacing: 0.22em; margin-top: 0.2rem; }
.kb-controls {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  margin-top: 0.85rem;
}
.kb-dot {
  width: 7px; height: 7px; border-radius: 50%; padding: 0; border: 0;
  background: rgba(26, 23, 20, 0.22);
  cursor: pointer; transition: .25s;
}
.kb-dot[aria-current="true"] { background: var(--crimson); transform: scale(1.25); }
.kb-nav { display: flex; gap: 0.5rem; margin-top: 0.55rem; }
.kb-btn {
  flex: 1; padding: 0.55rem 0.75rem;
  border: 1px solid rgba(166, 137, 90, 0.45);
  background: rgba(122, 46, 46, 0.08);
  color: var(--ink); font: inherit; font-size: 0.78rem; letter-spacing: 0.12em;
  border-radius: 2px; cursor: pointer;
}
.kb-btn:hover { background: rgba(122, 46, 46, 0.14); }

/* ===== B · Stack ===== */
.era-carousel--stack { max-width: 400px; }
.stack-wrap {
  position: relative;
  height: min(68vh, calc(100vh - var(--nav-h) - 10rem), 560px);
  margin: 0 auto;
  perspective: 1200px;
  touch-action: none;
}
.stack-card {
  position: absolute; inset: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid rgba(166, 137, 90, 0.6);
  box-shadow: 0 18px 40px rgba(26, 23, 20, 0.28),
    inset 0 0 0 6px rgba(13, 10, 11, 0.45),
    inset 0 0 0 7px rgba(166, 137, 90, 0.28);
  transition: transform .55s cubic-bezier(.22,1,.36,1), opacity .45s ease;
  display: flex; align-items: center; justify-content: center;
  will-change: transform;
}
.stack-card img {
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center center;
  pointer-events: none;
  filter: saturate(0.78) contrast(1.04) sepia(0.12);
}
.stack-card .label {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 2rem 1rem .85rem;
  background: linear-gradient(transparent, rgba(8, 4, 6, 0.9));
  text-align: center; font-size: 0.8rem; letter-spacing: 0.1em;
  color: #f3ebe0; pointer-events: none;
}
.stack-card .label small {
  display: block; color: var(--gold-light); font-size: 0.62rem;
  letter-spacing: 0.2em; margin-top: 0.2rem;
}
.stack-hint {
  text-align: center; color: var(--ink-muted);
  font-size: 0.75rem; margin-top: 0.85rem; letter-spacing: 0.08em;
}
.stack-progress {
  display: flex; justify-content: center; gap: 0.4rem; margin-top: 0.75rem;
}
.stack-progress i {
  display: block; width: 18px; height: 2px;
  background: rgba(26, 23, 20, 0.18);
  transition: background .25s, width .25s;
}
.stack-progress i.on { background: var(--gold); width: 28px; }

/* ===== C · Film ===== */
.era-carousel--film { max-width: none; }
.film-hint {
  text-align: center; color: var(--ink-muted);
  font-size: 0.72rem; margin: 0 0 0.65rem; letter-spacing: 0.08em;
}
.film {
  display: flex; gap: 1rem;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 0.35rem 1.1rem 1rem;
  margin: 0 -1.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}
.film::-webkit-scrollbar { height: 4px; }
.film::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 2px; }
.film-frame {
  flex: 0 0 min(78vw, 320px);
  scroll-snap-align: center;
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: calc(100vh - var(--nav-h) - 10rem);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(26, 23, 20, 0.2);
  border: 1px solid rgba(166, 137, 90, 0.55);
  transition: transform .5s ease, box-shadow .5s ease;
  cursor: zoom-in;
}
.film-frame::before {
  content: ""; position: absolute; inset: 7px; z-index: 3; pointer-events: none;
  border: 1px solid rgba(166, 137, 90, 0.35);
}
.film-frame::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 14px; z-index: 4;
  background:
    radial-gradient(circle at 18px 7px, #0d0a0b 3px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 18px) 7px, #0d0a0b 3px, transparent 3.5px),
    linear-gradient(var(--gold), var(--gold));
  background-size: auto, auto, 100% 1px;
  background-repeat: no-repeat;
  background-position: 0 0, 0 0, 0 13px;
  opacity: .85;
  pointer-events: none;
}
.film-frame.is-active {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 22px 50px rgba(26, 23, 20, 0.28), 0 0 0 1px rgba(166, 137, 90, 0.65);
}
.film-frame img {
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center center;
  padding-top: 14px;
  background: radial-gradient(ellipse at center, #4a1820, #10080a 75%);
  transition: transform 8s ease-out;
}
.film-frame.is-active img.pan { transform: scale(1.04); }
.film-frame .cap {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 2.2rem .85rem .75rem;
  background: linear-gradient(transparent, rgba(8, 4, 6, 0.9));
  text-align: center; font-size: 0.78rem; letter-spacing: 0.08em;
  color: #f3ebe0; pointer-events: none;
}
.film-frame .cap small {
  display: block; color: var(--gold-light); font-size: 0.6rem;
  letter-spacing: 0.18em; margin-top: 0.2rem;
}

@media (min-width: 800px) {
  .era-carousel--kb .kb-stage { aspect-ratio: 4 / 5; }
  .film-frame { flex-basis: min(42vw, 360px); }
}

@media (prefers-reduced-motion: reduce) {
  .kb-slide { transition: opacity .2s; }
  .kb-slide img,
  .kb-slide.active img.ken,
  .kb-slide.active img.ken-alt,
  .stack-card,
  .film-frame,
  .film-frame img {
    transform: none !important;
    transition: none !important;
  }
}
