/* แกลเลอรี (/gallery/, /gallery/category/<slug>/, /gallery/<slug>/) — ต่อจาก site.css (โทเค็นสี ปุ่ม ชิป แถบ CTA)
   lightbox / สไลเดอร์ก่อน-หลัง / fade-in อยู่ใน lightbox.css (ใช้ร่วมกับหน้าบทความ)
   ความกว้างที่ใช้ในไฟล์นี้ต้องตรงกับ sizes ใน lib/render/gallery-page.cjs (CARD_SIZES, BENTO_SPANS, TIERS) */

.gl-ico { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- หัวหน้า /gallery/ ---------- */
.gl-hero { position: relative; isolation: isolate; padding: 32px 0 56px; overflow: hidden; }
.gl-hero::before, .gl-hero::after { content: ''; position: absolute; z-index: -1; pointer-events: none; aspect-ratio: 1; border-radius: 50%; }
.gl-hero::before { right: -18%; top: -45%; width: 80vw; max-width: 980px; background: radial-gradient(closest-side, rgba(0,147,254,.26), transparent 72%); }
.gl-hero::after { left: -14%; bottom: -40%; width: 56vw; max-width: 680px; background: radial-gradient(closest-side, rgba(var(--acc-rgb),.09), transparent 72%); }
.gl-hero-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px 48px; flex-wrap: wrap; margin-bottom: 28px; }
.gl-hero-copy { max-width: 720px; }
.gl-h1 { margin: 0 0 14px; font-size: clamp(2.1rem, 5.4vw, 3.7rem); font-weight: 700; line-height: 1.12; letter-spacing: -.01em; }
.gl-h1-mark { display: block; color: var(--acc); }
.gl-lead { margin: 0; max-width: 620px; color: var(--sn-muted); font-size: clamp(1rem, 1.6vw, 1.125rem); }
.gl-stats { display: flex; gap: 10px; margin: 0; }
.gl-stats div { min-width: 96px; padding: 12px 16px; border-radius: 16px; background: rgba(255,255,255,.04); border: 1px solid var(--sn-line); }
.gl-stats dt { margin: 0; font-size: .78rem; color: var(--sn-muted); }
.gl-stats dd { margin: 2px 0 0; font-size: 1.7rem; font-weight: 700; line-height: 1.1; color: #fff; font-variant-numeric: tabular-nums; }
.gl-stats div:first-child dd { color: var(--acc); }

/* bento: มือถือ 2 คอลัมน์ (รูปแรกเต็มแถว สูง 2 แถว), ≥720px 4 คอลัมน์ 2 แถวตามจำนวนรูป */
.gl-bento { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 30vw; gap: 8px; }
.gl-bento-tile { position: relative; isolation: isolate; display: block; overflow: hidden; border-radius: 14px; background: var(--sn-surface); animation: gl-rise .8s var(--sn-ease) both; }
.gl-bento-tile:nth-child(2) { animation-delay: .06s; }
.gl-bento-tile:nth-child(3) { animation-delay: .12s; }
.gl-bento-tile:nth-child(4) { animation-delay: .18s; }
.gl-bento-tile:nth-child(5) { animation-delay: .24s; }
.gl-bento-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 1s var(--sn-ease); }
.gl-bento-tile::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(1,11,20,.78)); pointer-events: none; }
.gl-bento-tile::before { content: ''; position: absolute; inset: 0; z-index: 2; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); pointer-events: none; transition: box-shadow .3s; }
.gl-bento-cap { position: absolute; left: 12px; right: 12px; bottom: 10px; z-index: 1; color: #fff; font-size: .8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 10px rgba(0,0,0,.55); }
.gl-bento-tile:hover .gl-bento-img { transform: scale(1.05); }
.gl-bento-tile:hover::before { box-shadow: inset 0 0 0 2px rgba(var(--acc-rgb),.7); }
/* เคลื่อนด้วย transform อย่างเดียว — opacity 0 ตอนเริ่มจะทำให้ LCP ช้า */
@keyframes gl-rise { from { transform: translateY(18px) scale(.985); } }
@media (max-width: 719px) {
  .gl-bento-tile:first-child { grid-column: 1 / -1; grid-row: span 2; }
  .gl-bento[data-n="2"] .gl-bento-tile:last-child,
  .gl-bento[data-n="4"] .gl-bento-tile:last-child { grid-column: 1 / -1; }
}
@media (min-width: 720px) {
  .gl-bento { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr); grid-auto-rows: auto; height: clamp(380px, 40vw, 520px); gap: 10px; }
  .gl-bento[data-n="1"] { grid-template-areas: "a a a a" "a a a a"; }
  .gl-bento[data-n="2"] { grid-template-areas: "a a b b" "a a b b"; }
  .gl-bento[data-n="3"] { grid-template-areas: "a a b b" "a a c c"; }
  .gl-bento[data-n="4"] { grid-template-areas: "a a b b" "a a c d"; }
  .gl-bento[data-n="5"] { grid-template-areas: "a a b c" "a a d e"; }
  .gl-bento-tile:nth-child(1) { grid-area: a; }
  .gl-bento-tile:nth-child(2) { grid-area: b; }
  .gl-bento-tile:nth-child(3) { grid-area: c; }
  .gl-bento-tile:nth-child(4) { grid-area: d; }
  .gl-bento-tile:nth-child(5) { grid-area: e; }
  .gl-bento-tile { border-radius: 18px; }
  .gl-bento-cap { left: 18px; right: 18px; bottom: 14px; font-size: .9rem; }
}

/* ---------- รายการอัลบั้ม ---------- */
.gl-list-head { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin: 0 0 24px; }
.gl-h2 { margin: 0; font-size: clamp(1.4rem, 2.6vw, 1.85rem); }
.gl-chip-n { margin-left: 8px; padding: 0 7px; border-radius: 999px; font-size: .72rem; font-weight: 600; line-height: 1.7; background: rgba(255,255,255,.08); color: var(--sn-muted); }
.sn-chip[aria-current] .gl-chip-n { background: rgba(2,21,37,.14); color: var(--acc-ink); }

.gl-cards { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 640px) { .gl-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; } }
@media (min-width: 1024px) { .gl-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.gl-card { position: relative; isolation: isolate; display: block; aspect-ratio: 4 / 3; border-radius: 20px; overflow: hidden; color: #fff; text-decoration: none; background: var(--sn-surface); box-shadow: 0 10px 30px rgba(0,0,0,.25); transition: transform .4s var(--sn-ease), box-shadow .4s var(--sn-ease); }
.gl-card::before { content: ''; position: absolute; inset: 0; z-index: 3; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); pointer-events: none; transition: box-shadow .35s; }
.gl-card::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(180deg, rgba(1,11,20,.38) 0%, transparent 26%, transparent 42%, rgba(1,11,20,.9) 100%); }
.gl-card-media { position: absolute; inset: 0; }
.gl-card-img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 1s var(--sn-ease); }
.gl-card-ph { display: grid; place-items: center; width: 100%; height: 100%; font-size: 52px; color: rgba(124,200,255,.35); background: radial-gradient(120% 90% at 80% 0%, #0c2e49, #07233a 60%, #021525); }
.gl-card-top { position: absolute; top: 14px; left: 14px; right: 14px; z-index: 2; display: flex; gap: 8px; }
.gl-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 11px; border-radius: 999px; font-size: .78rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(2,21,37,.55); border: 1px solid rgba(255,255,255,.16); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.gl-pill .gl-ico { font-size: 15px; }
.gl-pill-count { margin-left: auto; flex: none; }
.gl-card-body { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; flex-direction: column; gap: 4px; padding: 20px 74px 20px 22px; }
.gl-card-title { margin: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gl-card-meta { font-size: .85rem; color: rgba(234,243,251,.78); }
.gl-card-go { position: absolute; right: 18px; bottom: 22px; z-index: 2; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; font-size: 20px; background: var(--acc); color: var(--acc-ink); opacity: 0; transform: translateX(-8px) scale(.9); transition: opacity .35s, transform .35s var(--sn-ease); }
.gl-card:hover, .gl-card:focus-visible { transform: translateY(-4px); box-shadow: 0 24px 50px rgba(0,0,0,.42); }
.gl-card:hover::before, .gl-card:focus-visible::before { box-shadow: inset 0 0 0 1px rgba(var(--acc-rgb),.55); }
.gl-card:hover .gl-card-img, .gl-card:focus-visible .gl-card-img { transform: scale(1.06); }
.gl-card:hover .gl-card-go, .gl-card:focus-visible .gl-card-go { opacity: 1; transform: none; }
@media (hover: none) { .gl-card-go { opacity: 1; transform: none; } }

/* ---------- หน้าอัลบั้ม ---------- */
.gl-album-head { padding-top: 28px; padding-bottom: 28px; }
.gl-album-top { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin-bottom: 18px; }
.gl-album-top .sn-crumbs { margin: 0; }
.gl-back { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px 6px 10px; border-radius: 999px; border: 1px solid var(--sn-line); background: rgba(255,255,255,.03); color: #d3e3f2; text-decoration: none; font-size: .875rem; font-weight: 500; transition: color .15s, border-color .15s; }
.gl-back .gl-ico { font-size: 18px; transition: transform .2s var(--sn-ease); }
.gl-back:hover { color: #fff; border-color: rgba(124,200,255,.5); }
.gl-back:hover .gl-ico { transform: translateX(-3px); }
.gl-album-title { max-width: 960px; margin: 0 0 16px; font-size: clamp(1.9rem, 4.6vw, 3.1rem); line-height: 1.2; letter-spacing: -.01em; }
.gl-facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; }
.gl-facts li { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid var(--sn-line); color: #d3e3f2; font-size: .9rem; }
.gl-facts .gl-ico { font-size: 17px; color: var(--sn-sky); }
.gl-desc { max-width: 760px; color: var(--sn-muted); font-size: 1.0625rem; }
.gl-desc p { margin: 0 0 12px; }
@media (max-width: 599px) { .gl-album-top .sn-crumbs { display: none; } }

/* justified rows: lib/render/gallery-page.cjs จัดแถวไว้ล่วงหน้า 3 ระดับ (s <600px, m 600–999px, l ≥1000px)
   แล้วส่ง --f? (สัดส่วนความกว้างในแถว) --g? (จำนวนช่องว่างในแถว) --x? (ภาพสุดท้ายของแถว ยืดเก็บเศษ) มากับแต่ละภาพ
   ความกว้าง = (กล่อง − ช่องว่าง) × สัดส่วน, ความสูงมาจาก aspect-ratio → ภาพในแถวสูงเท่ากันและรู้ขนาดก่อนโหลด (CLS 0) */
.gl-photos { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
.gl-rows { --gap: 6px; display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--gap); }
.gl-rows + .gl-rows { margin-top: var(--gap); }
.gl-tile { position: relative; isolation: isolate; display: block; flex: var(--xs, 0) 0 auto; width: calc((100% - var(--gs, 0) * var(--gap)) * var(--fs, .5)); aspect-ratio: var(--ar); overflow: hidden; border-radius: 6px; background-color: var(--sn-surface); background-size: cover; background-position: center; cursor: zoom-in; }
.gl-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gl-img.sn-fade { transition: transform .8s var(--sn-ease), opacity .5s ease; }
.gl-tile::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, transparent 50%, rgba(1,11,20,.72)); opacity: 0; transition: opacity .3s; }
.gl-tile-cap { position: absolute; left: 12px; right: 12px; bottom: 10px; z-index: 1; color: #fff; font-size: .85rem; line-height: 1.45; opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s var(--sn-ease); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gl-tile-zoom { position: absolute; top: 10px; right: 10px; z-index: 1; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; color: #fff; background: rgba(2,21,37,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; transform: scale(.85); transition: opacity .25s, transform .25s var(--sn-ease); }
.gl-tile:focus-visible { outline-offset: 3px; }
.gl-tile:focus-visible .gl-tile-zoom { opacity: 1; transform: none; }
@media (hover: hover) {
  .gl-tile:hover .gl-img { transform: scale(1.04); }
  .gl-tile:hover::after, .gl-tile:hover .gl-tile-cap, .gl-tile:hover .gl-tile-zoom { opacity: 1; transform: none; }
}
@media (min-width: 521px) { .gl-photos { padding: 0 24px; } }
@media (min-width: 600px) {
  .gl-rows { --gap: 8px; }
  .gl-tile { flex-grow: var(--xm, 0); width: calc((100% - var(--gm, 0) * var(--gap)) * var(--fm, .25)); border-radius: 10px; }
}
@media (min-width: 1000px) {
  .gl-rows { --gap: 10px; }
  .gl-tile { flex-grow: var(--xl, 0); width: calc((100% - var(--gl, 0) * var(--gap)) * var(--fl, .2)); }
}

/* คู่ก่อน/หลังคั่นระหว่างบล็อกรูป — สไตล์ของตัวสไลเดอร์อยู่ใน lightbox.css */
.gl-pair { max-width: 960px; margin: 40px auto; }
.gl-pair:first-child { margin-top: 8px; }
.gl-pair:last-child { margin-bottom: 8px; }

.gl-hint { margin-top: 18px; margin-bottom: 0; color: var(--sn-muted); font-size: .85rem; text-align: center; }
.gl-more { margin-top: 80px; }
.gl-link { display: inline-flex; align-items: center; gap: 6px; color: var(--sn-sky); text-decoration: none; font-weight: 600; }
.gl-link .gl-ico { transition: transform .2s var(--sn-ease); }
.gl-link:hover { color: #fff; }
.gl-link:hover .gl-ico { transform: translateX(3px); }
.gl-cta-btn .gl-ico { font-size: 18px; }

/* หน้าตัวอย่างในหลังบ้าน (/admin/preview/albums/<id>) */
.gl-preview-bar { position: sticky; top: 72px; z-index: 40; padding: 10px 24px; background: var(--acc); color: var(--acc-ink); text-align: center; font-size: .9rem; }
.gl-preview-bar a { color: var(--acc-ink); font-weight: 700; }
