/* ==================== HOMEPAGE HERO BANNERS ====================
   Shared by the storefront slider and the admin preview (public/js/banners.js builds the markup).
   The frame is a size container, so the slide lays itself out from the banner's own width:
   the admin "Phone" preview and a real phone get the same layout.

   Image specification (also shown in the admin Banners tab):
   - Frame ratio 16:5 (desktop/tablet), 3:2 on phones (frame ≤ 640px wide).
   - Desktop image 1920×600, phone image 1080×720. */

.sb-hero-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 5.5;
  container-type: inline-size;
  container-name: sbhero;
  overflow: hidden;
  isolation: isolate;
}
@media (max-width: 640px) {
  .sb-hero-frame { aspect-ratio: 16 / 9; }
}
.sb-hero-frame.sb-hero-frame--desktop { aspect-ratio: 16 / 5.5; }
.sb-hero-frame.sb-hero-frame--phone { aspect-ratio: 16 / 9; }

.sb-hero {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  color: #fff;
  text-decoration: none;
  font-family: "Inter", "Noto Sans Sinhala", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.75s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.75s ease;
  will-change: opacity;
}
.sb-hero.active,
.sb-hero-frame > .sb-hero:only-child {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
  transition: opacity 0.75s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s;
}
a.sb-hero { cursor: pointer; }
a.sb-hero:focus-visible { outline: 3px solid #fff; outline-offset: -6px; }

/* ---------- Colour themes ----------
   --sb-shade: RGB of the theme's darkest tone, used to keep text readable over a photo.
   --sb-pop: the kicker and highlight colour. */
.sb-theme-plum     { --sb-shade: 36, 29, 72;  --sb-pop: #d9d2ff; background: linear-gradient(118deg, #241d48 0%, #4a3f86 48%, #796cbf 100%); }
.sb-theme-midnight { --sb-shade: 11, 17, 33;  --sb-pop: #fcd34d; background: linear-gradient(118deg, #0b1121 0%, #1b2540 52%, #34446b 100%); }
.sb-theme-saffron  { --sb-shade: 92, 30, 8;   --sb-pop: #fde68a; background: linear-gradient(118deg, #5c1e08 0%, #a8400f 50%, #e8890c 100%); }
.sb-theme-forest   { --sb-shade: 6, 40, 31;   --sb-pop: #bbf7d0; background: linear-gradient(118deg, #06281f 0%, #0d4a36 50%, #1a7a4f 100%); }
.sb-theme-rose     { --sb-shade: 69, 9, 32;   --sb-pop: #fecdd3; background: linear-gradient(118deg, #450920 0%, #8a1538 50%, #d43d5f 100%); }
.sb-theme-ocean    { --sb-shade: 7, 38, 64;   --sb-pop: #bae6fd; background: linear-gradient(118deg, #072640 0%, #0b4f7c 50%, #1690c4 100%); }

/* Soft light and a dot grid so a plain theme does not look flat */
.sb-hero-deco {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 78% 30%, rgba(255, 255, 255, 0.16) 0, rgba(255, 255, 255, 0) 34%),
    radial-gradient(circle at 96% 110%, rgba(255, 255, 255, 0.12) 0, rgba(255, 255, 255, 0) 30%),
    radial-gradient(circle at 8% -20%, rgba(255, 255, 255, 0.10) 0, rgba(255, 255, 255, 0) 32%);
}
.sb-hero-deco::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 46%;
  background-image: radial-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1.4px);
  background-size: 18px 18px;
  -webkit-mask-image: linear-gradient(100deg, transparent 0%, #000 60%);
          mask-image: linear-gradient(100deg, transparent 0%, #000 60%);
  opacity: 0.55;
}
.sb-hero--has-bg .sb-hero-deco { display: none; }

/* ---------- Uploaded background (designed banners) ---------- */
.sb-hero-bg {
  position: absolute;
  inset: 0;
  background-image: var(--sb-bg);
  background-size: cover;
  background-position: center;
  transform: scale(1.03);
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}
.sb-hero.active .sb-hero-bg,
.sb-hero-frame > .sb-hero:only-child .sb-hero-bg {
  transform: scale(1);
}
.sb-focal-left .sb-hero-bg { background-position: left center; }
.sb-focal-right .sb-hero-bg { background-position: right center; }
.sb-hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    rgba(var(--sb-shade), 0.88) 0%,
    rgba(var(--sb-shade), 0.62) 38%,
    rgba(var(--sb-shade), 0.12) 70%,
    rgba(var(--sb-shade), 0) 100%);
}

/* ---------- Text ---------- */
.sb-hero-copy {
  position: absolute;
  z-index: 3;
  top: 0; bottom: 0; left: 0;
  width: min(54%, calc(100% - clamp(230px, 32cqw, 380px)));
  box-sizing: border-box;
  /* Leaves room for the slider's prev arrow */
  padding: 0 clamp(16px, 2cqw, 24px) 0 clamp(68px, 6cqw, 84px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(6px, 1.05cqw, 14px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.65s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.65s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: opacity, transform;
}
.sb-hero.active .sb-hero-copy,
.sb-hero-frame > .sb-hero:only-child .sb-hero-copy {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.1s;
}
.sb-hero--no-books .sb-hero-copy { width: 78%; }

.sb-hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(0.72rem, 1.02cqw, 0.85rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sb-pop);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-hero-kicker::before {
  content: "";
  width: clamp(14px, 2cqw, 26px);
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.sb-hero-title {
  margin: 0;
  font-size: clamp(1.2rem, 3.5cqw, 2.85rem);
  line-height: 1.16;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: #fff;
  text-wrap: balance;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sb-hero-title:lang(si) { letter-spacing: 0; line-height: 1.3; }
.sb-hero-sub {
  margin: 0;
  max-width: 34em;
  font-size: clamp(0.8rem, 1.42cqw, 1.1rem);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.86);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sb-hero-btn {
  margin-top: clamp(4px, 0.8cqw, 10px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: clamp(8px, 0.95cqw, 13px) clamp(16px, 2cqw, 26px);
  border-radius: 999px;
  background: #fff;
  color: rgb(var(--sb-shade));
  font-size: clamp(0.8rem, 1.12cqw, 0.95rem);
  font-weight: 700;
  text-shadow: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.sb-hero-btn i { font-size: 1.05em; transition: transform 0.2s ease; }
a.sb-hero:hover .sb-hero-btn { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28); }
a.sb-hero:hover .sb-hero-btn i { transform: translateX(3px); }

/* ---------- Book covers, fanned on the right ---------- */
.sb-hero-books {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: clamp(64px, 6.5cqw, 92px);
  width: clamp(200px, 31cqw, 370px);
  height: 82%;
  transform: translateY(-46%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.75s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.75s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: opacity, transform;
}
.sb-hero.active .sb-hero-books,
.sb-hero-frame > .sb-hero:only-child .sb-hero-books {
  opacity: 1;
  transform: translateY(-50%) scale(1);
  transition-delay: 0.14s;
}
.sb-hero-book {
  position: absolute;
  top: 50%;
  height: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 4px 8px 8px 4px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.38), 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
/* One, two or three covers: the front one is in the middle, the others tilt behind it */
.sb-hero-book:nth-child(1) { left: 50%; z-index: 3; transform: translate(-50%, -50%); }
.sb-hero-book:nth-child(2) { left: 50%; z-index: 2; transform: translate(-105%, -47%) rotate(-7deg) scale(0.86); }
.sb-hero-book:nth-child(3) { left: 50%; z-index: 1; transform: translate(5%, -47%) rotate(7deg) scale(0.86); }
.sb-hero-books[data-count="2"] .sb-hero-book:nth-child(1) { transform: translate(-30%, -50%); }
.sb-hero-books[data-count="2"] .sb-hero-book:nth-child(2) { transform: translate(-95%, -47%) rotate(-6deg) scale(0.88); }
@media (hover: hover) {
  a.sb-hero:hover .sb-hero-book:nth-child(1) { transform: translate(-50%, -52%); }
  a.sb-hero:hover .sb-hero-books[data-count="2"] .sb-hero-book:nth-child(1) { transform: translate(-30%, -52%); }
}

/* ---------- Artwork banners: one finished image ---------- */
.sb-hero--artwork { background: #14151d; }
.sb-hero-ambient {
  position: absolute;
  inset: -30px;
  background-image: var(--sb-bg);
  background-size: cover;
  background-position: center;
  filter: blur(34px) brightness(0.8);
  transform: scale(1.15);
  opacity: 0;
  transition: opacity 0.8s ease, transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: opacity, transform;
}
.sb-hero.active .sb-hero-ambient,
.sb-hero-frame > .sb-hero:only-child .sb-hero-ambient {
  opacity: 1;
  transform: scale(1.08);
}
.sb-hero-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 0.7s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.85s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: opacity, transform;
}
.sb-hero.active .sb-hero-art,
.sb-hero-frame > .sb-hero:only-child .sb-hero-art {
  opacity: 1;
  transform: scale(1);
}
.sb-hero-art--phone { display: none; }

/* ---------- Mid-size frames (small tablets, large phones in landscape) ---------- */
@container sbhero (max-width: 820px) {
  .sb-hero-sub { -webkit-line-clamp: 1; }
}

/* ---------- Phone frames (16:9) ---------- */
@container sbhero (max-width: 640px) {
  .sb-hero-copy {
    width: 60%;
    z-index: 3;
    padding: 0 0 16px 16px;
    gap: 4px;
  }
  .sb-hero--no-books .sb-hero-copy { width: 88%; }
  .sb-hero-title { font-size: clamp(0.95rem, 5.2cqw, 1.4rem); -webkit-line-clamp: 2; line-height: 1.2; }
  .sb-hero-sub { font-size: clamp(0.72rem, 3.2cqw, 0.86rem); -webkit-line-clamp: 1; line-height: 1.3; }
  .sb-hero-kicker { display: block; font-size: 0.68rem; letter-spacing: 0.05em; margin-bottom: 2px; }
  .sb-hero-kicker::before { display: none; }
  .sb-hero-btn { padding: 6px 14px; font-size: 0.76rem; margin-top: 3px; }
  /* Phones: the front cover with one more peeking out on the right, clear of the text */
  .sb-hero-books { right: 5%; width: 34%; height: 72%; top: 50%; z-index: 2; }
  .sb-hero-book:nth-child(1),
  .sb-hero-books[data-count="2"] .sb-hero-book:nth-child(1) { transform: translate(-55%, -50%); }
  .sb-hero-book:nth-child(2) { display: none; }
  .sb-hero-books[data-count="2"] .sb-hero-book:nth-child(2),
  .sb-hero-book:nth-child(3) { display: block; transform: translate(-5%, -46%) rotate(7deg) scale(0.86); }
  .sb-hero-bg { background-image: var(--sb-bg-m, var(--sb-bg)); }
  .sb-hero-bg::after {
    background: linear-gradient(90deg, rgba(var(--sb-shade), 0.92) 0%, rgba(var(--sb-shade), 0.75) 55%, rgba(var(--sb-shade), 0.25) 100%);
  }
  .sb-hero-ambient { background-image: var(--sb-bg-m, var(--sb-bg)); }
  .sb-hero--has-phone-art .sb-hero-art--desktop { display: none; }
  .sb-hero--has-phone-art .sb-hero-art--phone { display: block; }
}
@container sbhero (max-width: 380px) {
  .sb-hero-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sb-hero, .sb-hero.active { transition: none; }
  .sb-hero-copy, .sb-hero-books, .sb-hero-art, .sb-hero-ambient, .sb-hero-bg { transition: none; transform: none; opacity: 1; }
  .sb-hero-book, .sb-hero-btn, .sb-hero-btn i { transition: none; }
}
