/* ── Home view layout ───────────────────────────────────────── */
#home-view {
  position: relative;
  overflow: hidden;
  background: #ffffff;
}

/* ── Mobile background image (hidden on desktop) ────────────── */
.home-mobile-bg {
  display: none;
}

/* ── Mobile gear row (hidden on desktop) ────────────────────── */
.home-mobile-gear-row {
  display: none;
}

/* ── View all categories button (hidden on desktop) ─────────── */
.home-view-all-btn {
  display: none;
}

/* ── Gallery mobile header (hidden on desktop) ───────────────── */
.gallery-mobile-header {
  display: none;
}

.home-header-gear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  color: #222;
}

/* ── Background blobs ───────────────────────────────────────── */
.home-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url('../assets/home-bg.png');
  background-size: cover;
  background-position: center;
}

/* ── Scroll wrapper (on top of background) ──────────────────── */
.home-scroll {
  position:       absolute;
  inset:          0;
  z-index:        1;
  overflow-y:     auto;
  display:        flex;
  flex-direction: column;
}

/* ── Home header ────────────────────────────────────────────── */
.home-header {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  color: #222;
  transition: opacity 0.15s;
}

.home-header-btn:hover {
  opacity: 0.6;
}

.home-header-divider {
  color: #aaa;
  font-size: 1rem;
  user-select: none;
}

/* ── Main content ───────────────────────────────────────────── */
.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 32px 4px;
  position: relative;
  z-index: 1;
  gap: 20px;
}

/* ── Hero text ──────────────────────────────────────────────── */
.hero-text {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.hero-subtitle {
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 600;
  font-size: 18px;
  color: #111;
  max-width: 320px;
  line-height: 1.5;
}

/* Title is rendered as SVG strokes by coloringTitle.js */
#coloring-book-title,
#gallery-title {
  width: min(60vw, 420px);
}

@media (min-width: 768px) {
  #gallery-title {
    margin-top: 70px;
  }
}

/* ── Cards box ──────────────────────────────────────────────── */
.home-cards-box {
  width: 100%;
  max-width: 960px;
  background: #ffffff;
  border: 1px solid #111;
  border-radius: 40px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  /* No horizontal padding — scroll container runs edge-to-edge so cards
     clip behind the rounded border as they scroll */
  padding: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

/* ── Cards scroll container ─────────────────────────────────── */
.cards-scroll {
  display: grid;
  grid-template-columns: repeat(5, max-content);
  gap: 32px 28px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Vertical padding so rotated card corners aren't clipped by overflow;
     horizontal padding sets the initial inset from the box border */
  padding: 24px 36px 24px;
}

.cards-scroll::-webkit-scrollbar {
  display: none;
}

/* ── Scroll controls ────────────────────────────────────────── */
.scroll-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 36px;
}

.scroll-controls.scroll-controls-disabled {
  opacity: 0.3;
  pointer-events: none;
}

.scroll-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  transition: background 0.15s;
}

.scroll-btn:hover {
  background: #f0f0ee;
}

/* Horizontal slider */
.scroll-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  border-radius: 99px;
  outline: none;
  cursor: pointer;
  /* No border on the element itself — avoids the black excess at the ends */
  background: transparent;
}

/* WebKit track */
.scroll-slider::-webkit-slider-runnable-track {
  height: 16px;
  border-radius: 99px;
  border: 1px solid #111;
  background: linear-gradient(to right, #111 var(--fill-pct, 0%), #fff var(--fill-pct, 0%));
}

.scroll-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #111;
  cursor: pointer;
  margin-top: -6px;
  transition: transform 0.15s;
}

.scroll-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

/* Firefox track */
.scroll-slider::-moz-range-track {
  height: 16px;
  border-radius: 99px;
  border: 1px solid #111;
  background: #fff;
}

.scroll-slider::-moz-range-progress {
  height: 16px;
  border-radius: 99px 0 0 99px;
  background: #111;
}

.scroll-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #111;
  border: none;
  cursor: pointer;
}

/* Arrow buttons grouped to the right of the slider */
.scroll-arrows {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Category card ──────────────────────────────────────────── */
.cat-card {
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  /* width set by the inner card-layers */
}

.cat-card:hover {
  transform: scale(1.05);
}

.cat-card:active {
  transform: scale(0.95);
}

/* The stacking container */
.card-layers {
  position: relative;
  width: 158px;
  height: 196px;
}

/* All three colored layers share base styles */
.card-layer {
  position: absolute;
  width: 135px;
  height: 175px;
  border-radius: 17px;
  border: 1px solid #111;
  box-shadow: 0 3.4px 3.4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
  /* background-color comes from inline style */
}

/* Back layer — most rotated, darkest */
.card-back {
  top: 0;
  left: 0;
  filter: brightness(0.82);
  /* transform set via inline style: rotate(Xdeg) */
}

/* Mid layer — half rotation, slightly brighter */
.card-mid {
  top: 5px;
  left: 6px;
  filter: brightness(0.92);
  /* transform set via inline style */
}

/* Front layer — no rotation, brightest */
.card-front {
  top: 9px;
  left: 12px;
}

/* On hover: all layers straighten to 0 */
.cat-card:hover .card-back,
.cat-card:hover .card-mid {
  transform: rotate(0deg) !important;
}

/* Card title */
.card-title {
  position: absolute;
  top: 19px;
  left: 23px;
  z-index: 10;
  font-family: 'Baloo Thambi 2', system-ui, sans-serif;
  font-weight: 500;
  font-size: 15px;
  color: #111;
  white-space: nowrap;
  pointer-events: none;
}

/* Card image preview */
.card-image-frame {
  position: absolute;
  top: 50px;
  left: 22px;
  width: 113px;
  height: 110px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #111;
  z-index: 10;
  pointer-events: none;
  background: #fff;
}

.card-image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Mobile overrides (≤ 767px) ─────────────────────────────── */
@media (max-width: 767px) {

  /* Hide desktop background */
  .home-bg {
    display: none;
  }

  /* Mobile background — pinned to top, behind scroll view */
  .home-mobile-bg {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 0;
    pointer-events: none;
  }

  /* Scroll view — no extra top padding, content overlays background image */
  .home-scroll {
    padding-top: 24px;
    background: transparent;
  }

  /* Reduce top padding so frame99 sits close to background */
  .home-main {
    padding: 0 12px 4px;
    justify-content: flex-start;
    gap: 16px;
  }

  /* Hide hero subtitle */
  .hero-subtitle {
    display: none;
  }

  /* Hide desktop header buttons */
  .home-header-btn,
  .home-header-divider {
    display: none;
  }

  /* Show gear row, aligned right */
  .home-mobile-gear-row {
    display: flex;
    justify-content: flex-end;
    padding: 0 12px;
  }

  /* ── Home cards: 2-column grid, no horizontal scroll ── */
  #home-view .cards-scroll {
    display: grid;
    grid-template-columns: repeat(2, 158px);
    justify-content: center;
    gap: 16px;
    overflow-x: hidden;
    padding: 20px 0 20px 12px;
  }

  /* Show only first 6 categories */
  #home-view .cat-card:nth-child(n+7) {
    display: none;
  }

  /* When show-all is active, show all cards and hide the button */
  #cards-scroll.show-all .cat-card {
    display: block;
  }

  #cards-scroll.show-all ~ .home-view-all-btn {
    display: none;
  }

  /* Hide scroll controls (slider + arrows) */
  #home-view .scroll-controls {
    display: none;
  }

  /* Remove bottom padding reserved for scroll controls */
  #home-view .home-cards-box {
    padding-bottom: 8px;
  }

  /* ── Gallery mobile top (same treatment as home) ── */
  #gallery-view .gallery-header {
    display: none;
  }

  .gallery-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
  }

  /* View all categories button */
  .home-view-all-btn {
    display: block;
    margin: 8px auto 16px;
    padding: 13px 60px;
    width: fit-content;
    background: #58C1B9;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    text-align: center;
  }
}
