/* Trạm Cade — trang xem ảnh sau khi quét QR.
   Giao diện PIXEL GAME BOY đồng bộ với app kiosk (thiết kế Canva 22/09/2026): nền giấy ô ly xám,
   chữ đen, tiêu đề xanh Silkscreen, nút cam viền hồng chữ tím, hộp trắng viền đen bóng cứng,
   hoạ tiết pixel (mèo, nấm, sao...) lấy từ assets/sprites (sinh bởi tools/PixelArt/sprites.py).
   Mobile-first. KHÔNG dùng CDN: font nhúng sẵn trong assets/fonts (OFL) vì máy khách có thể
   nối WiFi của booth không có internet. */

@font-face { font-family: "Silkscreen";     src: url("fonts/Silkscreen-Regular.ttf") format("truetype");   font-display: swap; }
@font-face { font-family: "Press Start 2P"; src: url("fonts/PressStart2P-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Pixelify Sans";  src: url("fonts/PixelifySans-Variable.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "VT323";          src: url("fonts/VT323-Regular.ttf") format("truetype");        font-display: swap; }

:root {
  --paper:       #E4E4E4;   /* nền giấy */
  --paper-light: #F2F2F2;
  --grid:        #CBCBCB;   /* vạch ô ly */
  --ink:         #000000;   /* chữ, viền */
  --ink-dim:     #4A4A4A;
  --white:       #FFFFFF;
  --blue:        #1E9BE0;   /* tiêu đề */
  --blue-light:  #A8D8E8;   /* bóng tiêu đề */
  --pink:        #F83080;   /* viền nút */
  --purple:      #8E1F9C;   /* chữ nút */
  --lavender:    #B8B8E8;   /* bóng bong bóng */
  --red:         #E8412C;
  --green:       #5BBF3A;
  --yellow:      #F5C518;
  --btn-grad:    linear-gradient(180deg, #F9B13A 0%, #F58A3E 55%, #EE5F58 100%);
  --btn-grad-dn: linear-gradient(180deg, #E29A2C 0%, #D96F30 55%, #C94C48 100%);
  --title:       "Silkscreen", "VT323", monospace;
  --arcade:      "Press Start 2P", "VT323", monospace;
  --ui:          "Pixelify Sans", "VT323", sans-serif;
  --body:        "VT323", "Courier New", monospace;
  --shadow-hard: 5px 5px 0 var(--ink);
  --shadow-lav:  6px 6px 0 var(--lavender);
  --gap:         10px;
}

* { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px),
                    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: -1px -1px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font: 19px/1.35 var(--body);
  padding-bottom: env(safe-area-inset-bottom);
}

/* [hidden] phải thắng mọi display: của class */
[hidden] { display: none !important; }

img.px, .px { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ---------- Thanh trạng thái Game Boy (như đầu mỗi màn của app) ---------- */
.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 4px;
}
.statusbar .sb-ic { height: 16px; width: auto; display: block; }
.statusbar .sb-clock {
  margin-left: auto;
  font: 12px/1 var(--arcade);
  letter-spacing: 1px;
}

/* ---------- Đầu trang: logo + tên ---------- */
.topbar {
  position: relative;
  padding: 18px 12px 6px;
  text-align: center;
}

.lang {
  position: absolute;
  left: 14px;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  font: 15px/1 var(--body);
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s ease, box-shadow .1s ease;
}
.lang:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.lang-icon { font-size: 12px; opacity: .8; }

.logo {
  display: block;
  width: 64px;
  height: auto;
  margin: 8px auto 0;
}

.wordmark { margin-top: 8px; line-height: 1; }
.wordmark .script {
  display: block;
  font: 11px/1 var(--title);
  letter-spacing: 2px;
  color: var(--blue);
  text-shadow: 2px 2px 0 var(--blue-light);
  margin-bottom: 8px;
}
.wordmark .name {
  display: block;
  font: 46px/1 var(--body);
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--blue-light);
  letter-spacing: 1px;
}

/* ---------- Tab Ảnh / Video: hai nút pixel ---------- */
.tabs {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 18px 16px 6px;
}

.tab {
  min-width: 132px;
  padding: 11px 22px;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  font: 700 18px/1 var(--ui);
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .1s ease, box-shadow .1s ease;
}
.tab:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.tab.is-active { background: var(--btn-grad); border-color: var(--pink); color: var(--purple); }

/* ---------- Nội dung ---------- */
main {
  flex: 1;
  padding: 18px 16px 8px;
}

.hint {
  margin: 0;
  text-align: center;
  font-size: 19px;
  line-height: 1.35;
}
.hint-sub {
  margin-top: 4px;
  font-size: 16px;
  color: var(--ink-dim);
}

.block { margin-top: 26px; }

.caption {
  margin: 12px 0 0;
  text-align: center;
  font: 11px/1.4 var(--title);
  letter-spacing: 1px;
  color: var(--blue);
  text-shadow: 2px 2px 0 var(--blue-light);
}

/* Nút tải: nút pixel cam viền hồng chữ tím (Pixel.NextButton của app) */
.btn-dl {
  display: block;
  margin: 24px auto 0;
  width: 100%;
  max-width: 340px;
  padding: 14px 18px;
  border: 4px solid var(--pink);
  border-radius: 6px;
  background: var(--btn-grad);
  color: var(--purple);
  font: 700 20px/1.2 var(--ui);
  cursor: pointer;
  box-shadow: var(--shadow-hard);
  transition: transform .1s ease, box-shadow .1s ease, opacity .2s ease;
}
.btn-dl:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); background: var(--btn-grad-dn); }
.btn-dl[disabled] { opacity: .6; cursor: default; }

/* Hộp trắng viền đen, bóng tím nhạt (Pixel.Bubble của app) */
.card {
  background: var(--white);
  border: 4px solid var(--ink);
  border-radius: 6px;
  padding: 12px;
  box-shadow: var(--shadow-lav);
}

/* Ảnh ghép (bản in) */
.strip-wrap { display: flex; justify-content: center; }
.strip-wrap img {
  max-width: 62%;
  height: auto;
  display: block;
  border: 3px solid var(--ink);
  background: #fff;
}

/* Lưới ảnh lẻ */
.grid {
  display: grid;
  /* minmax(0,1fr): ảnh gốc rộng hơn cột không được nong cột ra làm card tràn màn */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  justify-items: stretch;
}
.grid img {
  width: 100%;
  min-width: 0;
  aspect-ratio: 3 / 2;      /* ảnh chụp ra là 3:2 */
  object-fit: cover;
  display: block;
  border: 2px solid var(--ink);
  background: var(--paper);
}

/* Video */
.video-wrap { display: flex; justify-content: center; }
.video-wrap video {
  width: 100%;
  max-width: 460px;
  border: 3px solid var(--ink);
  background: #000;
}

/* Giữ chỗ trong lúc tải */
.ph {
  width: 100%;
  aspect-ratio: 3 / 2;
  border: 2px solid var(--grid);
  background: linear-gradient(90deg, #DADADA 25%, #EFEFEF 37%, #DADADA 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0 } to { background-position: 0 0 } }

/* Trạng thái lỗi / hết hạn */
.state {
  margin: 40px auto;
  max-width: 340px;
  padding: 22px 18px;
  border: 4px solid var(--ink);
  border-radius: 6px;
  background: var(--white);
  box-shadow: var(--shadow-lav);
  text-align: center;
  font-size: 19px;
  line-height: 1.45;
}

/* ---------- Chân trang: mèo nằm trên đường kẻ đôi có dấu ✦ (như app) ---------- */
.foot {
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 15px;
  color: var(--ink-dim);
}
.foot-cat {
  display: block;
  width: 92px;
  height: auto;
  margin: 0 auto -4px 22%;
}
.foot .rule {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 auto 14px;
  max-width: 340px;
}
.foot .rule::before, .foot .rule::after {
  content: "";
  flex: 1;
  height: 6px;
  background: var(--ink);
}
.foot .rule img { width: 18px; height: 18px; display: block; }
.foot .foot-by { display: block; margin-top: 8px; letter-spacing: .2px; }

/* Ảnh trong lưới / bản ghép là nút bấm mở ảnh lớn */
.grid button, .strip-wrap button {
  padding: 0; border: 0; background: transparent; cursor: pointer;
  width: 100%; display: block;
}
/* Điện thoại: không cho nhấn giữ lưu ảnh từ LƯỚI (lưới là bản nhỏ, lưu sẽ mờ) -
   lưu ảnh gốc trong khung xem lớn. Ảnh trong lightbox vẫn nhấn giữ được. */
.grid button img, .strip-wrap button img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.strip-wrap button { width: auto; max-width: 62%; }
.strip-wrap button img { max-width: 100%; }
.grid button:active img, .strip-wrap button:active img { opacity: .85; }

/* ---------- Xem ảnh lớn (lightbox) ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(18, 18, 18, .96);
  animation: lbfade .2s ease both;
}
@keyframes lbfade { from { opacity: 0 } to { opacity: 1 } }
.lb-body {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 3px solid var(--white);
  background: #333;
}
.lb-body img.is-loading { opacity: .35; }
.lb-spin {
  position: absolute;
  width: 38px; height: 38px;
  border: 4px solid rgba(255, 255, 255, .25);
  border-top-color: var(--white);
  animation: spin .8s steps(8) infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }
.lb-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  width: 42px; height: 42px;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  font: 20px/1 var(--body);
  cursor: pointer;
  z-index: 1;
  box-shadow: 3px 3px 0 var(--pink);
}
.lb-hint {
  margin: 12px 0 calc(4px + env(safe-area-inset-bottom));
  font-size: 16px;
  color: rgba(255, 255, 255, .75);
  text-align: center;
}
/* Nút tải ảnh gốc trong khung xem lớn (máy tính: chuột phải trên lưới chỉ được ảnh nhỏ) */
.lb-dl {
  margin-top: 12px;
  padding: 11px 26px;
  border: 4px solid var(--pink);
  border-radius: 6px;
  background: var(--btn-grad);
  color: var(--purple);
  font: 700 17px/1 var(--ui);
  text-decoration: none;
  box-shadow: 4px 4px 0 rgba(255, 255, 255, .35);
}
.lb-dl:active { opacity: .85; }

/* ---------- Hiện dần khi mở trang ---------- */
.reveal { animation: reveal .6s steps(6) both; }
.reveal-1 { animation-delay: .05s; }
.reveal-2 { animation-delay: .12s; }
.reveal-3 { animation-delay: .2s; }
.reveal-4 { animation-delay: .3s; }
@keyframes reveal {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
}

/* Màn rộng: giới hạn bề ngang cho dễ nhìn */
@media (min-width: 620px) {
  .statusbar, .topbar, .tabs, main, .foot { max-width: 560px; margin-inline: auto; width: 100%; }
  html { background-size: 24px 24px; }
}
