/* ============================================================
   M4 Exam System — Kawaii Pastel Green + Gold
   Design tokens & shared components
   ============================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

:root {
  /* Pastel Green */
  --g50:  #F3FAF4;
  --g100: #E3F4E7;
  --g200: #CDEAD3;
  --g300: #A7D9B0;
  --g400: #7DC294;
  --g500: #5CA778;
  --g600: #468C61;
  --g700: #2E6B48;

  /* Mint (supplementary green) */
  --m100: #D8F5EA;
  --m200: #BAEBD5;
  --m300: #8BDDBB;

  /* Gold */
  --au50:  #FFFBEB;
  --au100: #FEF3C7;
  --au200: #FDE68A;
  --au300: #FCD34D;
  --au400: #F5BF3F;
  --au500: #E3A32E;
  --au600: #B88420;
  --au700: #8B6414;

  /* Cream / Neutrals */
  --cream:  #FFFDF5;
  --cream2: #FAF6EA;
  --sand:   #F5EFDB;

  /* Text */
  --ink:   #2E3B2F;
  --ink2:  #3F4F42;
  --mute:  #6B7A6C;
  --light: #9AA79D;

  /* Accents */
  --red:    #E85A5A;
  --red-bg: #FFECEC;
  --blue:   #5B9BD5;

  /* Lines & shadows */
  --line: rgba(93,167,120,.22);
  --sm:   0 2px 8px rgba(70,140,97,.08);
  --md:   0 8px 22px rgba(70,140,97,.12);
  --lg:   0 20px 44px -14px rgba(46,107,72,.25);
  --au-sm: 0 4px 12px rgba(245,191,63,.25);
  --au-md: 0 8px 22px rgba(245,191,63,.30);

  /* Fonts */
  --font:      'Kanit','Prompt','Sarabun',system-ui,sans-serif;
  --font-body: 'Sarabun','Kanit','Prompt',system-ui,sans-serif;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse 70% 50% at 10% 10%,  rgba(167,217,176,.38) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 80%,  rgba(252,211,77,.32)  0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 50% 50%,  rgba(243,250,244,.6)  0%, transparent 60%),
    linear-gradient(180deg, var(--cream) 0%, #F3FAF4 100%);
  background-attachment: fixed;
}
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(252,211,77,.06) 0, transparent 2px),
    radial-gradient(circle at 80% 70%, rgba(167,217,176,.08) 0, transparent 2px);
  background-size: 80px 80px, 120px 120px;
  opacity: .7;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,253,245,.9);
  backdrop-filter: blur(18px);
  border-bottom: 2px solid var(--g200);
  padding: .75rem 1rem;
  box-shadow: 0 2px 14px rgba(70,140,97,.08);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font); font-weight: 700; color: var(--g700);
  font-size: 1rem; text-decoration: none;
}
.nav-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--g300), var(--au300));
  display: grid; place-items: center; font-size: 1.3rem;
  box-shadow: var(--sm);
}
.nav-links {
  display: flex; gap: .4rem; flex-wrap: wrap; list-style: none;
  align-items: center;
}
.nav-links a {
  color: var(--g700); text-decoration: none;
  font-size: .85rem; font-weight: 600; font-family: var(--font);
  padding: 6px 14px; border-radius: 99px;
  border: 1.5px solid var(--g200); background: #fff;
  transition: all .2s;
}
.nav-links a:hover {
  background: var(--g50);
  border-color: var(--g400);
}
.nav-links a.active {
  background: linear-gradient(135deg, var(--g100), var(--au100));
  border-color: var(--g400); color: var(--g700);
}
.nav-links a.cta {
  background: linear-gradient(135deg, var(--au300), var(--au400));
  color: #5c4315; border-color: var(--au400); font-weight: 700;
  box-shadow: var(--au-sm);
}
.nav-links a.cta:hover {
  background: linear-gradient(135deg, var(--au400), var(--au500));
  transform: translateY(-1px);
}
.nav-links a.buy {
  background: linear-gradient(135deg, #FFE0EC, #FFD1DC);
  color: #C44569; border-color: #F8A5C2; font-weight: 700;
  box-shadow: 0 3px 10px rgba(196,69,105,.2);
  position: relative;
}
.nav-links a.buy::after {
  content: '🔥';
  position: absolute; top: -6px; right: -6px;
  font-size: .8rem;
  background: #fff; border-radius: 50%;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  animation: pulse-hot 1.5s ease-in-out infinite;
}
.nav-links a.buy:hover {
  background: linear-gradient(135deg, #FFD1DC, #FFB3C8);
  transform: translateY(-1px);
  border-color: #F48FB1;
}
@keyframes pulse-hot {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.nav-toggle {
  display: none; background: none; border: none;
  font-size: 1.5rem; cursor: pointer; color: var(--g700);
}
@media (max-width: 780px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none; width: 100%;
    flex-direction: column; align-items: stretch;
    gap: .35rem; padding-top: .5rem;
  }
  .nav-links.open { display: flex; }
  .nav-links a { text-align: center; }
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; font-family: var(--font); font-weight: 700;
  font-size: .95rem; padding: .8rem 1.6rem;
  border-radius: 99px; border: none; cursor: pointer;
  text-decoration: none;
  transition: all .25s cubic-bezier(.34,1.56,.64,1);
}
.btn-gold {
  background: linear-gradient(135deg, var(--au300), var(--au400));
  color: #5c4315; box-shadow: var(--au-sm);
}
.btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: var(--au-md);
  color: #2F2107;
}
.btn-green {
  background: linear-gradient(135deg, var(--g400), var(--g500));
  color: #fff;
  box-shadow: 0 4px 12px rgba(93,167,120,.28);
}
.btn-green:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(93,167,120,.4);
}
.btn-outline {
  background: #fff; color: var(--g700);
  border: 2px solid var(--g300);
}
.btn-outline:hover {
  border-color: var(--g500); background: var(--g50);
  transform: translateY(-2px);
}
.btn-ghost {
  background: transparent; color: var(--g700);
}
.btn-ghost:hover {
  background: var(--g50);
}
.btn-lg { padding: 1rem 2rem; font-size: 1.05rem; }
.btn-sm { padding: .5rem 1rem; font-size: .8rem; }
.btn-danger {
  background: linear-gradient(135deg, #F48888, var(--red));
  color: #fff;
  box-shadow: 0 4px 12px rgba(232,90,90,.25);
}
.btn-danger:hover {
  transform: translateY(-2px);
}

/* ============================================================
   CONTAINER / LAYOUT
   ============================================================ */
.container {
  max-width: 1200px; margin: 0 auto;
  padding: 1.5rem 1rem;
  position: relative; z-index: 1;
}
.narrow { max-width: 720px; }
.medium { max-width: 900px; }

/* ============================================================
   HERO / BANNERS
   ============================================================ */
.hero {
  text-align: center; padding: 3rem 1rem 2rem;
  position: relative; z-index: 1;
}
.hero-deco {
  position: absolute; pointer-events: none; opacity: .55;
  font-size: 26px;
}
.hero-deco.s1 { top: 14%; left: 8%;  animation: twirl 8s ease-in-out infinite; }
.hero-deco.s2 { top: 18%; right: 10%; animation: twirl 10s ease-in-out infinite reverse; }
.hero-deco.s3 { bottom: 18%; left: 6%;  animation: wiggle 7s ease-in-out infinite; }
.hero-deco.s4 { bottom: 14%; right: 7%; animation: wiggle 6s ease-in-out infinite reverse; }
.hero-deco.s5 { top: 50%; left: 4%;   font-size: 22px; animation: twirl 9s ease-in-out infinite; }
.hero-deco.s6 { top: 55%; right: 5%;  font-size: 22px; animation: wiggle 8s ease-in-out infinite reverse; }

@keyframes twirl { 0%,100%{transform:rotate(-8deg) translateY(0)} 50%{transform:rotate(8deg) translateY(-8px)} }
@keyframes wiggle { 0%,100%{transform:rotate(-4deg)} 50%{transform:rotate(6deg)} }

.hero-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--g100), var(--au100));
  border: 1.5px dashed var(--g400); color: var(--g700);
  font-family: var(--font); font-weight: 700; font-size: .8rem;
  padding: 6px 18px; border-radius: 99px; margin-bottom: 1rem;
}
.hero h1 {
  font-family: var(--font);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800; line-height: 1.25;
  color: var(--g700); margin-bottom: .6rem;
}
.hero h1 em {
  color: transparent; font-style: normal;
  background: linear-gradient(135deg, var(--g600) 0%, var(--au500) 100%);
  -webkit-background-clip: text; background-clip: text;
}
.hero p {
  max-width: 700px; margin: 0 auto 1.6rem;
  color: var(--ink2); font-size: 1rem; line-height: 1.85;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: #fff;
  border: 1.5px solid var(--g200);
  border-radius: 20px;
  padding: 1.4rem 1.5rem;
  box-shadow: var(--sm);
  transition: all .25s;
}
.card:hover {
  border-color: var(--g400);
  box-shadow: var(--md);
}
.card-gold {
  background: linear-gradient(135deg, var(--au50), #fff);
  border-color: var(--au300);
}
.card-green {
  background: linear-gradient(135deg, var(--g50), #fff);
}

/* ============================================================
   FORM FIELDS
   ============================================================ */
.field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 1rem;
}
.field label {
  font-family: var(--font); font-weight: 600;
  color: var(--g700); font-size: .9rem;
}
.field label .required { color: var(--red); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid var(--g200);
  border-radius: 12px;
  background: #fff;
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--ink);
  transition: all .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--g500);
  box-shadow: 0 0 0 4px rgba(93,167,120,.15);
}
.field .hint {
  font-size: .78rem; color: var(--mute);
}

/* ============================================================
   BADGES / CHIPS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font); font-weight: 700;
  font-size: .75rem;
  padding: 4px 12px; border-radius: 99px;
}
.badge-gold {
  background: linear-gradient(135deg, var(--au200), var(--au300));
  color: var(--au700);
}
.badge-green {
  background: linear-gradient(135deg, var(--g100), var(--g200));
  color: var(--g700);
}
.badge-rank-1 {
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #fff;
  box-shadow: 0 3px 8px rgba(255,165,0,.3);
}
.badge-rank-2 {
  background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
  color: #fff;
  box-shadow: 0 3px 8px rgba(160,160,160,.3);
}
.badge-rank-3 {
  background: linear-gradient(135deg, #CD7F32, #A0522D);
  color: #fff;
  box-shadow: 0 3px 8px rgba(160,82,45,.3);
}

/* ============================================================
   STATS ROW
   ============================================================ */
.stat-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1rem; margin: 1.5rem 0;
}
@media (max-width: 720px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: #fff; border: 1.5px solid var(--g200);
  border-radius: 16px; padding: 1.1rem 1rem;
  text-align: center; box-shadow: var(--sm);
  transition: all .25s;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--md);
  border-color: var(--g400);
}
.stat-card .num {
  font-family: var(--font);
  font-size: 1.8rem; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--g600), var(--au500));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-card .lbl {
  color: var(--mute); font-size: .82rem; margin-top: 4px;
}
.stat-card .ic {
  font-size: 1.6rem; margin-bottom: 4px;
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.sec-head { text-align: center; margin-bottom: 2rem; }
.sec-tag {
  display: inline-block;
  background: linear-gradient(135deg, var(--g100), var(--au100));
  border: 1.5px dashed var(--g400); color: var(--g700);
  font-family: var(--font); font-weight: 700; font-size: .78rem;
  padding: 5px 14px; border-radius: 99px;
  margin-bottom: .6rem;
}
.sec-head h2 {
  font-family: var(--font);
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 700; color: var(--g700);
  margin-bottom: .4rem;
}
.sec-head p {
  color: var(--mute); max-width: 580px; margin: 0 auto;
  font-size: .95rem;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress {
  height: 10px; background: var(--g100);
  border-radius: 99px; overflow: hidden;
  border: 1px solid var(--g200);
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--g400), var(--au400));
  border-radius: 99px;
  transition: width .4s ease;
  position: relative; overflow: hidden;
}
.progress-bar::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent);
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 1rem 1.2rem; border-radius: 14px;
  border: 1.5px dashed; margin-bottom: 1rem;
  display: flex; gap: 12px; align-items: flex-start;
  font-size: .92rem;
}
.alert-info {
  background: linear-gradient(135deg, var(--g50), #fff);
  border-color: var(--g400); color: var(--g700);
}
.alert-warn {
  background: linear-gradient(135deg, var(--au50), #fff);
  border-color: var(--au400); color: var(--au700);
}
.alert-error {
  background: var(--red-bg);
  border-color: var(--red); color: var(--red);
}
.alert .alert-icon { font-size: 1.4rem; flex-shrink: 0; }

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  background: rgba(255,253,245,.75);
  backdrop-filter: blur(10px);
  border-top: 2px solid var(--g200);
  padding: 2rem 1rem 1.5rem;
  margin-top: 3rem;
  text-align: center;
  position: relative; z-index: 1;
}
footer p {
  color: var(--mute); font-size: .88rem; margin-bottom: .3rem;
}
footer a {
  color: var(--g700); text-decoration: none; font-weight: 600;
}
footer a:hover { color: var(--au600); text-decoration: underline; }

/* ============================================================
   CONFETTI (canvas overlay)
   ============================================================ */
#confetti-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(46,107,72,.35);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; animation: fadeIn .2s; }
.modal {
  background: #fff;
  border: 2px solid var(--g300);
  border-radius: 24px;
  padding: 2rem;
  max-width: 440px; width: 100%;
  box-shadow: var(--lg);
  text-align: center;
  animation: slideUp .3s cubic-bezier(.34,1.56,.64,1);
}
.modal h3 {
  font-family: var(--font);
  color: var(--g700); font-size: 1.3rem;
  margin-bottom: .6rem;
}
.modal p {
  color: var(--ink2); margin-bottom: 1.4rem;
}
.modal-actions {
  display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes slideUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }

/* ============================================================
   BACK TO TOP
   ============================================================ */
#btt {
  position: fixed; bottom: 22px; right: 22px; z-index: 90;
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, var(--g400), var(--g500));
  color: #fff; display: grid; place-items: center;
  text-decoration: none; font-size: 1.3rem; font-weight: 800;
  box-shadow: 0 8px 20px rgba(70,140,97,.3);
  opacity: 0; pointer-events: none; transition: all .3s;
  border: none; cursor: pointer;
}
#btt.visible { opacity: 1; pointer-events: auto; }
#btt:hover { transform: translateY(-3px); }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center { text-align: center; }
.text-muted  { color: var(--mute); }
.text-gold   { color: var(--au600); }
.text-green  { color: var(--g700); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: .5rem; }
.gap    { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.mb-sm  { margin-bottom: .5rem; }
.mb     { margin-bottom: 1rem; }
.mb-lg  { margin-bottom: 1.5rem; }
.mt-sm  { margin-top: .5rem; }
.mt     { margin-top: 1rem; }
.mt-lg  { margin-top: 1.5rem; }
.w-100  { width: 100%; }

/* ============================================================
   FADE / SLIDE ANIMATIONS
   ============================================================ */
.fade-in { animation: fadeIn .4s ease-out; }
.slide-up { animation: slideUp .4s cubic-bezier(.34,1.56,.64,1); }

/* ============================================================
   BUY BANNER (ชวนซื้อข้อสอบเก่า)
   ============================================================ */
.buy-banner {
  max-width: 760px;
  margin: 2.5rem auto;
  background:
    linear-gradient(135deg, #FFF8E1 0%, #FFFBEB 50%, #FFF5F8 100%);
  border: 3px dashed var(--au400);
  border-radius: 28px;
  padding: 2rem 2rem 2rem 1.8rem;
  box-shadow: var(--md);
  display: flex; align-items: center; gap: 1.5rem;
  position: relative; overflow: hidden;
  animation: buyPulse 3s ease-in-out infinite;
}
@keyframes buyPulse {
  0%,100% { box-shadow: var(--md); }
  50% { box-shadow: 0 12px 34px -6px rgba(245,191,63,.4); }
}
.buy-banner::before {
  content: ''; position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(252,211,77,.3), transparent 65%);
  border-radius: 50%;
  pointer-events: none;
}
.buy-banner::after {
  content: ''; position: absolute;
  bottom: -50px; left: -50px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(167,217,176,.25), transparent 65%);
  border-radius: 50%;
  pointer-events: none;
}
.buy-banner .bb-deco {
  font-size: 5rem;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(227,163,46,.3));
  animation: bookBounce 3s ease-in-out infinite;
  position: relative; z-index: 1;
}
@keyframes bookBounce {
  0%,100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-8px) rotate(5deg); }
}
.buy-banner .bb-content {
  flex: 1; position: relative; z-index: 1;
}
.buy-banner .bb-badge {
  display: inline-block;
  background: linear-gradient(135deg, #FFE0EC, #FFC9DD);
  color: #C44569;
  font-family: var(--font); font-weight: 700;
  font-size: .78rem;
  padding: 5px 14px;
  border-radius: 99px;
  border: 1.5px dashed #F48FB1;
  margin-bottom: .6rem;
}
.buy-banner h3 {
  font-family: var(--font);
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  font-weight: 800;
  color: var(--g700);
  line-height: 1.35;
  margin-bottom: .6rem;
}
.buy-banner h3 em {
  color: transparent; font-style: normal;
  background: linear-gradient(135deg, var(--au500), #C44569);
  -webkit-background-clip: text; background-clip: text;
}
.buy-banner p {
  color: var(--ink2);
  font-size: .95rem;
  line-height: 1.75;
  margin-bottom: 1.1rem;
}
.buy-banner .btn {
  box-shadow: 0 6px 18px rgba(245,191,63,.35);
  animation: buyBtnGlow 2s ease-in-out infinite;
}
@keyframes buyBtnGlow {
  0%,100% { box-shadow: 0 6px 18px rgba(245,191,63,.35); }
  50%     { box-shadow: 0 10px 26px rgba(245,191,63,.55); }
}
@media (max-width: 640px) {
  .buy-banner {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem 1.3rem;
  }
  .buy-banner .bb-deco { font-size: 3.5rem; }
}

/* ===== Footer menu links (shared across pages) ===== */
.footer-links {
  display: flex; gap: 1.2rem; justify-content: center;
  flex-wrap: wrap; margin: 1rem 0 .5rem;
}
.footer-links a {
  color: var(--g700); font-family: var(--font);
  font-weight: 600; font-size: .92rem;
  text-decoration: none;
  padding: .45rem .95rem;
  border: 1.5px dashed var(--g300);
  border-radius: 99px;
  transition: all .25s;
}
.footer-links a:hover {
  border-color: var(--au400);
  background: var(--au50);
  color: var(--au600);
}
.footer-links a .ic { margin-right: 4px; }

/* ===== Reviews grid ===== */
.reviews-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 1.5rem 0 3rem;
}
@media (max-width: 900px) { .reviews-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .reviews-grid { grid-template-columns: 1fr 1fr; gap: .6rem; } }
.review-card {
  background: #fff;
  border: 2px solid var(--g200);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--sm);
  transition: all .3s;
  aspect-ratio: 1 / 1.2;
}
.review-card:hover {
  transform: translateY(-4px); box-shadow: var(--md);
  border-color: var(--au400);
}
.review-card img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  background: linear-gradient(135deg, var(--g100), var(--au100));
}
