/* Web gallery — colours from the tablet UI and the LED design (4 Nov blue design: buttons #1C65B5 on the wave background, white 3 px frames like the wall).
   Responsive: 2 columns on phones, more as the screen grows; the lightbox and slideshow fit any shape.
   Motion: transform + opacity only; prefers-reduced-motion turns it off. CSP: no inline styles (JS uses CSSOM only). */
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* .box / .live / the button set display, which would beat the hidden attribute */
html, body { margin: 0; }
:root {
  --brand: #1C65B5;
  --deep: #0B2556;
  --min: 300px;
  --gap: clamp(10px, 1.6vw, 22px);
  --ease: cubic-bezier(.16, 1, .3, 1);
}
body {
  min-height: 100vh; min-height: 100dvh;
  color: #fff; background: #0E3471;
  font: clamp(15px, .95rem + .2vw, 17px)/1.45 system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Sukhumvit Set", sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
.bg { position: fixed; inset: 0; z-index: -1; background: var(--brand) url(assets/bg-led.jpg) center / cover no-repeat; }
button { font: inherit; color: inherit; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.slides-btn svg path { fill: currentColor; stroke: none; }

/* ---- header */
.top {
  display: grid; justify-items: center; gap: 6px;
  padding: max(18px, env(safe-area-inset-top)) 16px 8px;
  text-align: center;
}
.logo { width: min(454px, 70vw); height: auto; animation: float 7s ease-in-out infinite, rise .8s var(--ease) both; }
@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; animation: rise .8s .12s var(--ease) both; }
.count { margin: 0; font-weight: 600; opacity: .92; }
.hint { margin: 2px 0 0; font-size: .88em; opacity: .78; animation: rise .8s .2s var(--ease) both; }   /* front page only */
.hint span { display: block; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: .85em; opacity: .85; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #8FD0FF; animation: beat 2s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: .4; } }
.slides-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 8px 16px;
  background: #fff; color: var(--brand); font-weight: 700; cursor: pointer;
  transition: transform .2s var(--ease);
}
.slides-btn:hover { transform: translateY(-2px); }
.slides-btn:active { transform: scale(.96); }

/* ---- grid */
main { padding: 10px max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); max-width: 1680px; margin: 0 auto; }
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--min)), 1fr)); }
@media (max-width: 680px) { :root { --min: 140px; } }
@media (max-height: 500px) and (min-width: 681px) { :root { --min: 220px; } }   /* phone on its side: 3 columns */
@media (max-height: 500px) { .logo { width: min(250px, 34vw); } .top { padding-top: max(10px, env(safe-area-inset-top)); } }
.grid li { opacity: 0; transform: translateY(22px) scale(.97); }
.grid li.in { opacity: 1; transform: none; transition: opacity .55s ease, transform .7s var(--ease); }
.grid li.new { animation: pop .9s var(--ease); }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
.tile {
  display: block; width: 100%; padding: 0; cursor: zoom-in;
  border: 3px solid #fff; background: var(--deep);
  aspect-ratio: 1264 / 848; overflow: hidden; position: relative;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .5s ease, transform .6s var(--ease); }
.tile img.ok { opacity: 1; }
.tile::after { /* soft shine across on hover */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .22) 50%, transparent 65%);
  transform: translateX(-120%);
}
@media (hover: hover) {
  .tile:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(0, 0, 0, .45); }
  .tile:hover img { transform: scale(1.04); }
  .tile:hover::after { transform: translateX(120%); transition: transform .9s ease; }
}
.tile:focus-visible { outline: 3px solid #8FD0FF; outline-offset: 3px; }
.grid li.new .tile { box-shadow: 0 0 0 3px rgba(255, 255, 255, .5), 0 6px 18px rgba(0, 0, 0, .35); }

.more { display: flex; justify-content: center; gap: 8px; padding: 26px 0 8px; visibility: hidden; }
.more.on { visibility: visible; }
.more span { width: 9px; height: 9px; border-radius: 50%; background: #fff; opacity: .3; animation: dot 1.1s ease-in-out infinite; }
.more span:nth-child(2) { animation-delay: .15s; }
.more span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-5px); } }
.msg { text-align: center; max-width: 520px; margin: 40px auto; padding: 18px 20px; background: rgba(0, 0, 0, .25); border-radius: 10px; }

.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 5;
  translate: -50% 0; padding: 10px 18px; border-radius: 999px;
  background: #fff; color: var(--brand); font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  animation: toast 3.2s var(--ease) both;
}
@keyframes toast { 0% { opacity: 0; transform: translateY(20px); } 12%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(10px); } }

/* ---- lightbox */
.box { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; }
.box-dim { position: absolute; inset: 0; background: rgba(3, 10, 30, .9); opacity: 0; transition: opacity .3s ease; }
.box.on .box-dim { opacity: 1; }
.box-fig { position: relative; margin: 0; width: min(92vw, calc((100dvh - 150px) * 1264 / 848)); }
.box-fig img {
  display: block; width: 100%; height: auto; border: clamp(4px, .6vw, 8px) solid #fff; background: var(--deep);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5); transform-origin: 0 0;
  touch-action: pan-y;
}
.box-fig img.move { transition: transform .42s var(--ease); }
.box-fig img.swap { animation: swap .4s var(--ease); }
@keyframes swap { from { opacity: .2; transform: translateX(var(--dx, 0)) scale(.96); } to { opacity: 1; transform: none; } }
.nav, .x {
  position: absolute; z-index: 1; display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 22px;
  opacity: 0; transition: opacity .3s ease, background .2s ease, transform .2s var(--ease);
}
.box.on .nav, .box.on .x { opacity: 1; }
.nav:hover, .x:hover { background: rgba(255, 255, 255, .28); }
.nav:active, .x:active { transform: scale(.92); }
.prev { left: max(10px, env(safe-area-inset-left)); top: 50%; translate: 0 -50%; }
.next { right: max(10px, env(safe-area-inset-right)); top: 50%; translate: 0 -50%; }
.x { right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); }
.nav[disabled] { opacity: .25 !important; cursor: default; }
.box-bar {
  position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 12px; padding: 0 16px;
  opacity: 0; transform: translateY(12px); transition: opacity .3s ease .1s, transform .4s var(--ease) .1s;
}
.box.on .box-bar { opacity: 1; transform: none; }
.box-n { opacity: .8; min-width: 6em; text-align: center; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: 999px;
  background: #fff; color: var(--brand); font-weight: 700; text-decoration: none;
  transition: transform .2s var(--ease);
}
.pill.ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .7); }
.pill:active { transform: scale(.95); }
@media (max-width: 680px) {
  .nav { top: auto; bottom: max(70px, calc(env(safe-area-inset-bottom) + 56px)); translate: none; width: 46px; height: 46px; }
  .box-fig { width: 94vw; }
}

/* ---- slideshow (full screen; also a stand-by picture for a spare screen) */
.show { position: fixed; inset: 0; z-index: 20; background: #0A2150 url(assets/bg-led.jpg) center / cover no-repeat; cursor: none; overflow: hidden; }
.show-img {
  position: absolute; left: 50%; top: 55%; width: min(86vw, calc(72vh * 1264 / 848)); height: auto;
  translate: -50% -50%; border: clamp(4px, .55vw, 10px) solid #fff; box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  opacity: 0; transition: opacity 1.1s ease;
}
.show-img.on { opacity: 1; animation: kb 7s linear both; }
@keyframes kb { from { transform: scale(1); } to { transform: scale(1.05); } }
.show-logo { position: absolute; left: 50%; top: 2.5vh; width: min(24vw, 32vh); height: auto; translate: -50% 0; animation: float 7s ease-in-out infinite; }
.show-n { position: absolute; right: 2vw; bottom: 1.5vh; margin: 0; opacity: .6; font-size: clamp(12px, 1.4vh, 18px); }
.show.cursor { cursor: default; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .grid li { opacity: 1; transform: none; }
  .tile img { opacity: 1; }
}
