/* ============================================
   GALLERY PAGE
   ใช้โทนสีเดียวกับ landing — อบอุ่น ฝนตก โคมส้ม
   ============================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100vh;
  font-family: 'Sukhumvit Set', 'Noto Sans Thai', -apple-system, sans-serif;
  color: #fff8ec;
  background: linear-gradient(160deg, #2c3848 0%, #4a5668 60%, #6b4a38 100%);
  overflow-x: hidden;
}

/* ===== Rain (เหมือน landing) ===== */
.rain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  opacity: 0.55;
}
.rain::before,
.rain::after {
  content: "";
  position: absolute;
  inset: -20% 0 -10% 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><g stroke='white' stroke-width='1.2' stroke-linecap='round'><line x1='15' y1='0' x2='5' y2='30' opacity='0.45'/><line x1='55' y1='20' x2='45' y2='50' opacity='0.35'/><line x1='95' y1='5' x2='85' y2='35' opacity='0.5'/><line x1='130' y1='40' x2='120' y2='70' opacity='0.3'/><line x1='170' y1='15' x2='160' y2='45' opacity='0.4'/><line x1='30' y1='80' x2='20' y2='110' opacity='0.35'/><line x1='75' y1='95' x2='65' y2='125' opacity='0.5'/><line x1='110' y1='110' x2='100' y2='140' opacity='0.3'/><line x1='150' y1='85' x2='140' y2='115' opacity='0.4'/><line x1='185' y1='125' x2='175' y2='155' opacity='0.35'/></g></svg>");
  background-size: 200px 200px;
  background-repeat: repeat;
  animation: rainFall 0.6s linear infinite;
}
.rain::after {
  animation-duration: 0.9s;
  opacity: 0.5;
  transform: translateX(12px) scale(1.3);
}
@keyframes rainFall {
  from { background-position: 0 -200px; }
  to   { background-position: -20px 0; }
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(255,190,110,0.15) 0%, transparent 55%),
    radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.55) 100%);
}

/* ===== Header ===== */
.gallery-header {
  position: relative;
  z-index: 3;
  padding: 56px 20px 28px;
  text-align: center;
  animation: fadeIn 0.8s ease;
}

.gallery-back {
  position: absolute;
  top: 18px;
  left: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 215, 170, 0.08);
  border: 1px solid rgba(255, 215, 170, 0.2);
  border-radius: 999px;
  color: #ffd9a8;
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.3px;
  backdrop-filter: blur(4px);
  transition: background 0.2s ease;
}
.gallery-back:hover {
  background: rgba(255, 215, 170, 0.15);
}

.gallery-header-text {
  max-width: 640px;
  margin: 0 auto;
}

.gallery-kicker {
  display: inline-block;
  padding: 5px 14px;
  margin-bottom: 14px;
  background: linear-gradient(180deg, #7a4f2c 0%, #5d3a1f 100%);
  border: 1.5px solid #3d2510;
  border-radius: 4px;
  box-shadow:
    0 4px 12px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,200,140,0.3);
  color: #ffe0b0;
  font-size: 13px;
  letter-spacing: 2px;
  font-weight: 600;
}

.gallery-title {
  font-size: 32px;
  font-weight: 700;
  color: #fff5dc;
  text-shadow: 0 2px 20px rgba(255,180,100,0.5), 0 2px 8px rgba(0,0,0,0.4);
  letter-spacing: 0.3px;
  margin-bottom: 10px;
}

.gallery-sub {
  font-size: 15px;
  color: #ffd9a8;
  opacity: 0.85;
  letter-spacing: 0.2px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Grid ===== */
.gallery {
  position: relative;
  z-index: 3;
  padding: 20px 20px 60px;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

/* ===== Card ===== */
.char-card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 240, 210, 0.97) 0%, rgba(255, 230, 190, 0.97) 100%);
  border-radius: 18px;
  padding: 18px 16px 16px;
  cursor: pointer;
  overflow: hidden;
  border: 1.5px solid rgba(122, 79, 44, 0.25);
  box-shadow:
    0 6px 20px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.6);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  opacity: 0;
  animation: cardIn 0.5s ease forwards;
}
.char-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 12px 28px rgba(0,0,0,0.45),
    0 0 30px rgba(255, 200, 120, 0.25),
    inset 0 1px 0 rgba(255,255,255,0.6);
}
.char-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(255,200,120,0.25) 0%, transparent 60%);
  pointer-events: none;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.char-card-mbti {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 4px 10px;
  background: #3d2510;
  color: #ffd9a0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.char-card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.char-card-img {
  width: 85%;
  height: 85%;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(80, 45, 20, 0.35));
  transition: transform 0.3s ease;
}
.char-card:hover .char-card-img {
  transform: scale(1.05);
}

.char-card-name {
  position: relative;
  font-size: 17px;
  font-weight: 700;
  color: #3d2510;
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: 0.2px;
}

.char-card-tagline {
  position: relative;
  font-size: 12.5px;
  color: #7a4f2c;
  text-align: center;
  line-height: 1.5;
  opacity: 0.9;
  min-height: 38px;
}

/* ===== Footer CTA ===== */
.gallery-footer {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 30px 20px 60px;
}
.gallery-footer-text {
  color: #ffd9a8;
  font-size: 15px;
  margin-bottom: 14px;
  opacity: 0.9;
}
.gallery-footer-hint {
  color: #d4b890;
  font-size: 12px;
  opacity: 0.7;
  margin-top: 12px;
}
.btn-enter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 36px;
  background: linear-gradient(180deg, #ffcf8a 0%, #e8a858 100%);
  color: #3d2510;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  box-shadow:
    0 8px 24px rgba(232,168,88,0.4),
    0 0 40px rgba(255,200,120,0.3),
    inset 0 1px 0 rgba(255,255,255,0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: 0.5px;
}
.btn-enter:hover {
  transform: translateY(-2px) scale(1.03);
}

/* ===== Modal ===== */
.char-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.char-modal.show { display: flex; }

.char-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 15, 10, 0.78);
  backdrop-filter: blur(6px);
  animation: fadeBg 0.25s ease;
}
@keyframes fadeBg {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.char-modal-box {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #fff5e3 0%, #ffe9cc 100%);
  border: 2px solid #7a4f2c;
  border-radius: 20px;
  padding: 28px 22px 26px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.6),
    0 0 80px rgba(255,200,120,0.2),
    inset 0 1px 0 rgba(255,255,255,0.7);
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.char-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: #7a4f2c;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s ease;
}
.char-modal-close:hover {
  background: rgba(122, 79, 44, 0.12);
}

.char-modal-body {
  color: #3d2510;
}

.modal-img {
  display: block;
  width: 160px;
  height: 160px;
  object-fit: contain;
  margin: 0 auto 14px;
  filter: drop-shadow(0 10px 20px rgba(80, 45, 20, 0.4));
}

.modal-mbti-pill {
  display: inline-block;
  padding: 4px 12px;
  background: #3d2510;
  color: #ffd9a0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

.modal-name {
  font-size: 22px;
  font-weight: 700;
  color: #3d2510;
  margin-bottom: 6px;
  text-align: center;
}
.modal-tagline {
  font-size: 14px;
  color: #7a4f2c;
  text-align: center;
  line-height: 1.6;
  margin-bottom: 20px;
}

.modal-section {
  margin-bottom: 18px;
}
.modal-section-title {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #7a4f2c;
  margin-bottom: 8px;
  padding-bottom: 2px;
  border-bottom: 1.5px dashed #c08a55;
}
.modal-text {
  font-size: 14px;
  line-height: 1.75;
  color: #4a331d;
}

.modal-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.modal-trait {
  padding: 4px 12px;
  background: rgba(122, 79, 44, 0.15);
  border: 1px solid rgba(122, 79, 44, 0.3);
  border-radius: 999px;
  font-size: 12px;
  color: #5d3a1f;
}

.modal-compat {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.modal-compat-pill {
  padding: 4px 12px;
  background: linear-gradient(180deg, #ffcf8a 0%, #e8a858 100%);
  color: #3d2510;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.modal-gentle {
  background: rgba(255, 230, 190, 0.6);
  border-left: 3px solid #c06a1a;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.75;
  color: #5d3a1f;
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}
@media (max-width: 720px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .gallery-header { padding: 64px 16px 20px; }
  .gallery-title { font-size: 24px; }
  .gallery-sub { font-size: 13px; }
  .char-card { padding: 14px 12px 12px; }
  .char-card-name { font-size: 15px; }
  .char-card-tagline { font-size: 11.5px; min-height: 34px; }
  .char-card-mbti { font-size: 10px; padding: 3px 8px; }
}
@media (max-width: 380px) {
  .gallery-grid { gap: 12px; }
  .gallery { padding: 16px 12px 40px; }
}
