/* ==========================================================================
   Matsuri Barcelona — Galería page (page-galeria.php)

   New page, 2026-11-17/18. Went through 3 design rounds with the user
   before this was built as real theme code:
     1. A bento-style placeholder grid (galeria_mock.html) — approved.
     2. An alternate "marquee" concept (galeria_marquee_mock.html), a dark
        hero with 3 photo columns scrolling vertically (center reversed
        vs. the sides) flanked by 2 vertical hashtag text columns — shown
        as an independent alternative, approved.
     3. Combined per the user: the marquee hero on top, then a white
        "divider" section (big bold title + continuing text bands,
        inspired by a reference site's own white "chapter break" between
        hero sections), then the bento grid below that
        (galeria_full_mock.html) — approved, with two follow-up notes:
          a) the left/right text bands should run the WHOLE page (header
             to footer), not just inside the hero, with the hero's photo
             columns AND the grid stretching edge-to-edge to meet them
             (no more centered .container gutter on the grid) — the
             bottom CTA band was also dropped entirely;
          b) the band text itself should be real Matsuri Barcelona facts,
             not generic festival hashtags, and Spanish only (no JP
             accent line) — see the band defaults in the ACF field group
             (inc/acf-fields.php, group_matsuri_page_galeria) for the
             actual copy used.

   This file is only enqueued on page-galeria.php (functions.php), same
   gating pattern as front-page.css on is_front_page().
   ========================================================================== */

/* --------------------------------------------------------------------
   Page frame — the two vertical text bands run the full height of the
   page's content (hero + divider + grid combined), pinned to the
   viewport via position:sticky while that content scrolls past, then
   releasing at the very end together with it. Everything in the middle
   column (the hero's photo tracks, the grid) fills the remaining width
   edge-to-edge, so there's no separate centered .container gutter here.
   -------------------------------------------------------------------- */
.gallery-page-frame {
  display: flex;
}

.gallery-page-frame__band {
  width: 64px;
  flex: 0 0 auto;
  background: #15112b;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow: hidden;
}

.gallery-page-frame__main {
  flex: 1 1 0;
  min-width: 0;
}

.band-track {
  display: flex;
  flex-direction: column;
  height: 100%;
  animation: galeria-marquee-scroll 22s linear infinite;
  will-change: transform;
}
.gallery-page-frame__band--right .band-track {
  animation-direction: reverse;
}

@keyframes galeria-marquee-scroll {
  from { transform: translateY(0); }
  to   { transform: translateY(-50%); }
}

.marquee-textcol {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 46px;
  padding-block: 30px;
}
.marquee-textcol span {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  color: rgba(255, 255, 255, .85);
  font-family: var(--font-sans);
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .gallery-page-frame__band {
    display: none;
  }
}

/* --------------------------------------------------------------------
   1. Hero — a dark, full-bleed section with 3 vertical photo columns
   that loop endlessly (center column reversed vs. the two sides, per
   the user's own reference). Each column loops up to 4 real photos
   (matsuri_galeria_hero_track() in inc/template-tags.php), falling back
   to a decorative placeholder cycle for any column with none uploaded.
   Gaps between columns and between tiles (both widened per the user,
   2026-11-18, who shared the dodasports.doda.jp reference again to show
   the breathing room its own columns/tiles have — ours were flush
   against each other) let the dark .marquee-hero background show
   through, same as that reference.
   -------------------------------------------------------------------- */
.marquee-hero {
  position: relative;
  height: 760px;
  overflow: hidden;
  background: var(--ink);
  display: flex;
  gap: 16px;
}
.marquee-col {
  position: relative;
  overflow: hidden;
  height: 100%;
  flex: 1 1 0;
}
.marquee-track {
  display: flex;
  flex-direction: column;
  animation: galeria-marquee-scroll 34s linear infinite;
  will-change: transform;
}
.marquee-col--center .marquee-track {
  animation-direction: reverse;
}

.marquee-tile {
  flex: 0 0 auto;
  width: 100%;
  height: 240px;
  /* Applied to EVERY tile, including the very last one in the doubled
     (pass 0 + pass 1) track — not CSS `gap`, which only inserts space
     BETWEEN items and would throw off the translateY(-50%) seamless-
     loop math by half a gap at the seam between the two passes. */
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
  /* The placeholder gradient recipe (no real photo in this slot) — a
     real photo (matsuri_duotone(), no 'light'/'content' variant, same
     treatment as the homepage's own Hero) fills the tile via the rule
     below instead and this background just sits unused underneath it. */
  background: linear-gradient(var(--ph-angle, 120deg), var(--ph-a) 0%, var(--ph-a) 30%, var(--ph-b) 100%);
}
.marquee-tile .photo-duotone {
  position: absolute;
  inset: 0;
}
.marquee-hero__scrim {
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 55% at 50% 58%, rgba(10, 8, 25, .78) 0%, rgba(10, 8, 25, .4) 55%, rgba(10, 8, 25, 0) 78%);
  pointer-events: none;
  z-index: 2;
}
.marquee-hero__copy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 56px;
  z-index: 3;
  text-align: center;
  padding-inline: 32px;
}
.marquee-hero__copy .kicker {
  color: rgba(255, 255, 255, .75);
}
.marquee-hero__title {
  margin: 10px 0 0;
  color: #fff;
  font-family: var(--font-sans);
  font-weight: 700;
  text-transform: uppercase;
  font-size: clamp(2.4rem, 1.6rem + 4vw, 5rem);
  line-height: 0.96;
  letter-spacing: 0;
  text-wrap: balance;
}
.marquee-hero__subtitle {
  margin: 18px auto 0;
  max-width: 46ch;
  color: rgba(255, 255, 255, .82);
  font-size: 1rem;
  line-height: 1.6;
}
.marquee-hero__jp {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, .5);
  font-family: var(--font-jp);
  font-size: .8125rem;
}

/* --------------------------------------------------------------------
   2. Divider — a white/paper "chapter break" between the dark hero and
   the grid. Just a centered title/subtitle block: the vertical text
   bands that used to live inside this section in the design mock are
   now the same ones running the whole page (see .gallery-page-frame
   above), so nothing band-related needs to live here anymore.
   -------------------------------------------------------------------- */
.gallery-divider {
  position: relative;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  /* Not 104px/104px — reported by the user, 2026-11-18, as looking
     uneven even though the BOX padding was already perfectly
     symmetric (measured and confirmed). The real cause is optical:
     .gallery-divider__title's tight line-height (0.94, below the
     font's own natural line height) sits its all-caps glyphs closer
     to the bottom of their line box than the top — most Latin fonts
     reserve more line-box space above the cap-height (for ascenders/
     diacritics that MOMENTOS, having none, never uses) than below the
     baseline. Measured via canvas TextMetrics
     (fontBoundingBoxAscent/Descent + actualBoundingBoxAscent/Descent):
     with symmetric 104px/104px padding the visible top gap renders at
     ~112px and the bottom at ~105px — a ~7px optical deficit at the
     bottom. This 100px/108px split cancels that out instead of
     changing the typography itself. */
  padding-block: 100px 108px;
  overflow: hidden;
}
.gallery-divider__copy {
  max-width: 720px;
  padding-inline: 32px;
}
.gallery-divider__title {
  margin: 10px 0 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(2.6rem, 1.8rem + 4.4vw, 5.5rem);
  line-height: 0.94;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.gallery-divider__subtitle {
  margin: 18px auto 0;
  max-width: 52ch;
  color: #55506f;
  font-size: 1rem;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .marquee-hero { height: 560px; gap: 8px; }
  .marquee-tile { height: 160px; margin-bottom: 10px; }
  .marquee-hero__copy { bottom: 36px; }
  .gallery-divider { padding-block: 62px 66px; } /* same top/bottom optical correction as the desktop rule above, scaled down */
}

/* --------------------------------------------------------------------
   3. Grid — the real photo gallery, looping the same `gallery_item` CPT
   as the homepage's own teaser bento (template-parts/section-gallery.php)
   but showing every item, not just the first 5, in a self-packing
   grid-auto-flow:dense layout so it adapts to any photo count without
   per-item placement rules. Edge-to-edge within .gallery-page-frame__main
   (no .container here) per the user's "the columns should stretch to
   meet the bands" note.
   -------------------------------------------------------------------- */
.gallery-section {
  position: relative;
  /* No top value here (was 72px) — .gallery-divider right above already
     ends in its own 108px of bottom padding (see that rule's comment),
     so a top value here was just stacking a second, redundant gap on
     top of it (108+72 = 180px between "Momentos" and the first photo).
     Reported by the user, 2026-11-18, while inspecting .gallery-divider
     itself and noticing the extra padding showed up one section further
     down instead. The bottom value (96px) is unrelated — the gap AFTER
     the grid, before whatever follows — and is unchanged. */
  padding-block: 0 96px;
  padding-inline: 28px;
  overflow: hidden;
}
/* Confetti — falls top-to-bottom through the section and loops back to
   the top, swaying side to side and tumbling as it falls, rather than
   just hovering/swaying in place — per the user, 2026-11-18 ("上から下
   に舞っているようにできる？今は空中に漂ってる感じ"). Shared by both
   this section's own scatter and .gallery-divider's larger one above.
   `top` is animated as a PERCENTAGE (-8% to 108%), which resolves
   against the containing block's (.gallery-divider/.gallery-section,
   both position:relative + overflow:hidden) height — so the fall
   always spans the full section regardless of its actual height,
   unlike a transform: translateY() in px/%, which would resolve
   against the tiny confetti piece's own box instead. Horizontal sway
   + tumble ride along on `transform`, piece-relative, independent of
   that. Each piece's starting angle comes through the --c-rot custom
   property rather than a literal `transform:` on the element, because
   a CSS animation's output for a property overrides even a non-
   !important INLINE value for that same property — baking the angle
   into rotate(var(--c-rot)) is what lets each piece keep its own
   distinct starting angle instead of snapping to the keyframes' own
   literal value. animation-duration/-delay (including NEGATIVE delays,
   used below to start each piece already mid-fall instead of every
   piece beginning at the top in lockstep) aren't touched by that rule —
   they configure the animation rather than being animated themselves —
   so each piece still sets those inline for a staggered, organic fall. */
.gallery-divider .confetti,
.gallery-section .confetti {
  position: absolute;
  top: -8%;
  border-radius: 1px;
  pointer-events: none;
  animation-name: galeria-confetti-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes galeria-confetti-fall {
  0%   { top: -8%;  transform: translateX(0)      rotate(var(--c-rot, 0deg)); }
  20%  {            transform: translateX(9px)     rotate(calc(var(--c-rot, 0deg) + 70deg)); }
  40%  {            transform: translateX(-8px)    rotate(calc(var(--c-rot, 0deg) + 150deg)); }
  60%  {            transform: translateX(9px)     rotate(calc(var(--c-rot, 0deg) + 230deg)); }
  80%  {            transform: translateX(-7px)    rotate(calc(var(--c-rot, 0deg) + 300deg)); }
  100% { top: 108%; transform: translateX(0)       rotate(calc(var(--c-rot, 0deg) + 380deg)); }
}
@media (prefers-reduced-motion: reduce) {
  .gallery-divider .confetti,
  .gallery-section .confetti {
    animation: none;
    top: 30%;
    transform: rotate(var(--c-rot, 0deg));
  }
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 160px;
  grid-auto-flow: dense;
  gap: 14px;
  position: relative;
  z-index: 1;
}
.gallery-tile {
  position: relative;
  margin: 0;
  grid-column: span 1;
  grid-row: span 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(34, 28, 67, .08);
  transition: transform 260ms var(--ease-out), box-shadow 260ms var(--ease-out), z-index 0s;
}
.gallery-tile:nth-child(8n+2) { grid-column: span 2; grid-row: span 2; }
.gallery-tile:nth-child(8n+4) { grid-row: span 2; }
.gallery-tile:nth-child(8n+5) { grid-column: span 2; }
.gallery-tile:nth-child(8n+8) { grid-row: span 2; }

/* Placeholder-only tiles (no real photo uploaded yet) cycle through 5
   of the site's brand gradient combos so a grid full of placeholders
   doesn't read as one flat repeated block — a real uploaded photo
   renders .photo-duotone instead of .photo-placeholder and ignores
   this entirely.
   The pop-in entrance animation (below) lives on THESE elements, not
   on .gallery-tile itself — see the note above @keyframes
   galeria-tile-pop for why that split matters for :hover. */
.gallery-tile .photo-duotone,
.gallery-tile .photo-placeholder {
  position: absolute;
  inset: 0;
  opacity: 0;
  animation: galeria-tile-pop 560ms var(--ease-out) forwards;
}
.gallery-tile:nth-child(5n+1) .photo-placeholder { background: linear-gradient(115deg, var(--ink) 0%, var(--ink) 30%, var(--amber) 100%); }
.gallery-tile:nth-child(5n+2) .photo-placeholder { background: linear-gradient(150deg, var(--vermillion) 0%, var(--vermillion) 30%, var(--ink) 100%); }
.gallery-tile:nth-child(5n+3) .photo-placeholder { background: linear-gradient(100deg, var(--amber) 0%, var(--amber) 30%, var(--vermillion-dark) 100%); }
.gallery-tile:nth-child(5n+4) .photo-placeholder { background: linear-gradient(160deg, var(--ink) 0%, var(--ink) 30%, var(--vermillion) 100%); }
.gallery-tile:nth-child(5n)   .photo-placeholder { background: linear-gradient(135deg, var(--vermillion-dark) 0%, var(--vermillion-dark) 30%, var(--amber) 100%); }

/* Staggered pop-in on load — the "賑やかで楽しい動き" ask isn't only a
   hover affordance, the grid itself should feel alive as it appears.
   This animation targets the PHOTO/PLACEHOLDER layer, not .gallery-tile
   itself: an `animation ... forwards` on .gallery-tile would keep
   overriding that element's own `transform` forever (CSS animations
   win the cascade for the properties they fill, even after they
   finish), which silently cancelled the :hover zoom below — caught
   2026-11-18 after the user reported hovering no longer enlarges the
   tile. Putting the entrance animation one layer down fixes that
   without losing the pop-in effect. */
@keyframes galeria-tile-pop {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.gallery-tile:nth-child(1)  .photo-duotone, .gallery-tile:nth-child(1)  .photo-placeholder { animation-delay: 0ms; }
.gallery-tile:nth-child(2)  .photo-duotone, .gallery-tile:nth-child(2)  .photo-placeholder { animation-delay: 40ms; }
.gallery-tile:nth-child(3)  .photo-duotone, .gallery-tile:nth-child(3)  .photo-placeholder { animation-delay: 80ms; }
.gallery-tile:nth-child(4)  .photo-duotone, .gallery-tile:nth-child(4)  .photo-placeholder { animation-delay: 120ms; }
.gallery-tile:nth-child(5)  .photo-duotone, .gallery-tile:nth-child(5)  .photo-placeholder { animation-delay: 160ms; }
.gallery-tile:nth-child(6)  .photo-duotone, .gallery-tile:nth-child(6)  .photo-placeholder { animation-delay: 200ms; }
.gallery-tile:nth-child(7)  .photo-duotone, .gallery-tile:nth-child(7)  .photo-placeholder { animation-delay: 240ms; }
.gallery-tile:nth-child(8)  .photo-duotone, .gallery-tile:nth-child(8)  .photo-placeholder { animation-delay: 280ms; }
.gallery-tile:nth-child(9)  .photo-duotone, .gallery-tile:nth-child(9)  .photo-placeholder { animation-delay: 320ms; }
.gallery-tile:nth-child(10) .photo-duotone, .gallery-tile:nth-child(10) .photo-placeholder { animation-delay: 360ms; }
.gallery-tile:nth-child(11) .photo-duotone, .gallery-tile:nth-child(11) .photo-placeholder { animation-delay: 400ms; }
.gallery-tile:nth-child(12) .photo-duotone, .gallery-tile:nth-child(12) .photo-placeholder { animation-delay: 440ms; }
.gallery-tile:nth-child(n+13) .photo-duotone, .gallery-tile:nth-child(n+13) .photo-placeholder { animation-delay: 480ms; }

/* Hover — enlarge + lift + a small playful tilt, raised above its
   neighbors so the zoom never gets clipped by the grid gap. */
.gallery-tile:hover {
  transform: scale(1.08) rotate(-1.2deg) translateY(-3px);
  box-shadow: 0 18px 34px rgba(34, 28, 67, .28);
  z-index: 5;
}
.gallery-tile:nth-child(even):hover {
  transform: scale(1.08) rotate(1.2deg) translateY(-3px);
}
.gallery-tile:hover .photo-duotone__img {
  filter: brightness(1.06) saturate(1.08);
}

.gallery-tile__mark {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-family: var(--font-jp);
  font-size: 11px;
  color: rgba(255, 255, 255, .35);
  letter-spacing: .04em;
  pointer-events: none;
  z-index: 1;
}

/* .gallery-tile__caption (a title/filename pill that faded in on
   hover) was removed per the user, 2026-11-18 — hovering a tile should
   simply enlarge the photo (see .gallery-tile:hover above), not reveal
   its title/filename. */

@media (max-width: 900px) {
  .gallery-section { padding-inline: 16px; }
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 150px;
    gap: 10px;
  }
  .gallery-tile:nth-child(8n+5) { grid-column: span 1; }
}
