/* ==========================================================================
   KANAM — Album Viewer (albums.html)
   ========================================================================== */

/* ---------- Hero / header block ---------- */

.album-hero {
  padding: 160px 64px 48px;
  text-align: center;
}

.album-hero__eyebrow {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--a-gold);
  margin-bottom: 16px;
}

.album-hero__title {
  font-weight: 600;
  font-size: 40px;
  max-width: 720px;
  margin: 0 auto 16px;
}

.album-hero__subhead {
  font-size: 16px;
  color: var(--a-text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Album picker grid ---------- */

.album-picker {
  padding: 24px 64px 120px;
}

.album-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 40px;
}

.album-card {
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
  opacity: 0;
}

html:not(.js) .album-card { opacity: 1; }

.album-card__cover {
  position: relative;
  aspect-ratio: 1000 / 1300;
  border-radius: 4px 8px 8px 4px;
  overflow: hidden;
  background: var(--a-surface);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
  transition: transform 300ms ease, box-shadow 300ms ease;
}

.album-card__cover::before {
  /* spine shadow */
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 18px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  z-index: 2;
}

.album-card__cover::after {
  /* gold hairline frame */
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(212, 175, 55, 0.35);
  pointer-events: none;
  z-index: 2;
}

.album-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-card:hover .album-card__cover,
.album-card:focus-visible .album-card__cover {
  transform: translateY(-6px);
  box-shadow: 0 28px 56px rgba(0, 0, 0, 0.6);
}

.album-card:focus-visible {
  outline: 1px solid var(--a-gold);
  outline-offset: 4px;
  border-radius: 8px;
}

.album-card__meta {
  padding-top: 18px;
  text-align: center;
}

.album-card__title {
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 22px;
  margin-bottom: 4px;
}

.album-card__subtitle {
  font-size: 13px;
  letter-spacing: 0.5px;
  color: var(--a-text-secondary);
}

/* ---------- Viewer overlay ---------- */

.album-viewer {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: stretch;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease, visibility 300ms ease;
}

.album-viewer.is-open {
  opacity: 1;
  visibility: visible;
}

.album-viewer__backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, #171410 0%, #0A0908 75%);
}

.album-viewer__stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.album-viewer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--a-divider);
  flex-shrink: 0;
}

.album-viewer__back {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: var(--a-text-secondary);
}

.album-viewer__back:hover { color: var(--a-gold); }

.album-viewer__title {
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 18px;
  color: var(--a-text-primary);
  text-align: center;
  flex: 1;
}

.album-viewer__controls {
  display: flex;
  gap: 10px;
}

.album-viewer__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--a-divider);
  color: var(--a-text-secondary);
  transition: border-color 200ms ease, color 200ms ease;
}

.album-viewer__icon-btn:hover,
.album-viewer__icon-btn:focus-visible {
  border-color: var(--a-gold);
  color: var(--a-gold);
}

.album-viewer__book-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px 64px;
  min-height: 0;
}

.album-viewer__book {
  /* Page aspect ratio (width / height) of the open album — set per-album by
     albums.js from the measured cover image; defaults fit a 1000x1300 page. */
  --page-ratio: 0.7692;
  --spread-ratio: 1.5385;
  position: relative;
  width: 100%;
  /* Must equal the two-page spread exactly, or StPageFlip's turn animation
     hinges off-centre and a gap opens beside the turning page. The library
     inlines width/max-width on this element, hence the !important. */
  max-width: min(900px, calc((100vh - 190px) * var(--spread-ratio))) !important;
  /* Height must equal the rendered book exactly, or the flip's 3D perspective
     origin sits off-centre and the turning cover visibly jumps upward. */
  height: auto;
  aspect-ratio: var(--spread-ratio);
  margin: 0 auto;
}

.album-viewer__book .stf__parent { margin: 0 auto; }

/* Spine/gutter shadow — painted on the pages themselves (never on empty
   backdrop): StPageFlip tags resting pages with .--left / .--right. */
.album-viewer__book .stf__wrapper.--landscape .album-page.--left::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.3), transparent 9%);
}

.album-viewer__book .stf__wrapper.--landscape .album-page.--right::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.3), transparent 9%);
}

/* ---------- StPageFlip page contents ---------- */

.album-page {
  position: relative;
  background: var(--a-surface);
  overflow: hidden;
  /* static depth in place of the library's painted flip shadow */
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.album-page__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.album-page--back-cover {
  background: var(--a-surface);
  position: relative;
}

.album-page--back-cover::before {
  /* gold hairline frame, consistent with .album-card__cover::after */
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(212, 175, 55, 0.35);
  pointer-events: none;
}

.album-viewer__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--a-gold);
  color: var(--a-gold);
  transition: background 200ms ease, color 200ms ease;
}

.album-viewer__arrow:hover,
.album-viewer__arrow:focus-visible {
  background: var(--a-gold);
  color: #141311;
}

.album-viewer__footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  flex-shrink: 0;
}

.album-viewer__counter {
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--a-text-secondary);
}

/* ---------- No-JS / fallback crossfade viewer ---------- */

.album-fallback {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.album-fallback__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  opacity: 1;
  transition: opacity 220ms ease;
}

.album-fallback__img.is-fading {
  opacity: 0;
}

/* ---------- Body scroll lock while viewer is open ---------- */

body.album-viewer-open {
  overflow: hidden;
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .album-hero { padding: 140px 40px 40px; }
  .album-picker { padding: 24px 40px 96px; }
  .album-viewer__bar { padding: 16px 24px; }
  .album-viewer__book-wrap { padding: 16px 24px; gap: 12px; }
}

@media (max-width: 640px) {
  .album-hero { padding: 120px 20px 32px; }
  .album-hero__title { font-size: 30px; }
  .album-picker { padding: 20px 20px 72px; }
  .album-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; }
  .album-card__title { font-size: 17px; }
  .album-viewer__title { font-size: 14px; }
  .album-viewer__bar { padding: 12px 16px; gap: 8px; }
  .album-viewer__back span { display: none; }
  .album-viewer__book-wrap { padding: 8px 8px; gap: 6px; }
  .album-viewer__arrow { width: 36px; height: 36px; }
  .album-viewer__icon-btn { width: 32px; height: 32px; }
}

@media (max-width: 580px) {
  /* Below ~580px the book is single-page portrait (container < 480px flips
     StPageFlip to portrait mode) — match the container to one page. */
  .album-viewer__book {
    max-width: min(450px, calc((100vh - 190px) * var(--page-ratio))) !important;
    aspect-ratio: var(--page-ratio);
  }
}

@media (prefers-reduced-motion: reduce) {
  .album-card__cover,
  .album-viewer,
  .album-fallback__img {
    transition: none !important;
  }
}
