/* =========================================================
   style.css
   ระบบลงนามถวายพระพรออนไลน์
   Design tokens: Navy Royal + Gold Regal + Ivory Silk + Maroon Velvet
   Typography: Prompt (display) + Kanit (body)
   ========================================================= */

:root {
  /* ---------- Color tokens ---------- */
  --navy-royal: #0A1F44;
  --navy-royal-deep: #061530;
  --gold-regal: #C9A227;
  --gold-light: #E8C766;
  --ivory-silk: #FBF6EA;
  --maroon-velvet: #6B1E23;
  --ink: #1B1B1F;
  --ink-soft: #4A4A52;

  --gradient-gold: linear-gradient(135deg, #E8C766 0%, #C9A227 55%, #9C7A1B 100%);
  --gradient-navy: linear-gradient(180deg, #0A1F44 0%, #061530 100%);

  --shadow-royal: 0 20px 50px -12px rgba(10, 31, 68, 0.35);
  --shadow-gold: 0 10px 25px -8px rgba(201, 162, 39, 0.5);

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 8px;

  --font-display: 'Prompt', sans-serif;
  --font-body: 'Kanit', sans-serif;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--ivory-silk);
  background-image:
    radial-gradient(circle at 100% 0%, rgba(201,162,39,0.06), transparent 40%),
    radial-gradient(circle at 0% 100%, rgba(10,31,68,0.05), transparent 40%);
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, .font-display {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--navy-royal);
}

a { text-decoration: none; }

::selection { background: var(--gold-regal); color: #fff; }

/* ---------- Focus visibility (a11y) ---------- */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold-regal);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Topbar ribbon ---------- */
.topbar-ribbon {
  background: var(--gradient-navy);
  color: var(--gold-light);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  padding: 6px 0;
  border-bottom: 1px solid rgba(201,162,39,0.35);
}

/* ---------- Navbar ---------- */
.navbar-royal {
  background: rgba(251, 246, 234, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(201,162,39,0.25);
  transition: box-shadow .3s ease;
}
.navbar-royal.scrolled { box-shadow: 0 8px 24px -12px rgba(10,31,68,0.25); }
.navbar-royal .navbar-brand {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--navy-royal) !important;
  font-size: 1.15rem;
}
.navbar-royal .navbar-brand small { display:block; font-family: var(--font-body); font-weight:400; font-size:.7rem; color: var(--ink-soft); }
.navbar-royal .nav-link {
  font-weight: 500;
  color: var(--ink) !important;
  position: relative;
  margin: 0 4px;
}
.navbar-royal .nav-link::after {
  content: '';
  position: absolute; left: 50%; bottom: -2px; width: 0; height: 2px;
  background: var(--gold-regal); transition: all .25s ease; transform: translateX(-50%);
}
.navbar-royal .nav-link:hover::after, .navbar-royal .nav-link.active::after { width: 70%; }
.navbar-royal .nav-link.active { color: var(--maroon-velvet) !important; }

/* ---------- Hero ---------- */
.hero-royal {
  position: relative;
  background: var(--gradient-navy);
  color: #fff;
  padding: 90px 0 130px;
  overflow: hidden;
  isolation: isolate;
}
.hero-royal::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(201,162,39,0.28), transparent 55%),
    repeating-linear-gradient(120deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 40px);
  z-index: -1;
}
.hero-corner {
  position: absolute; width: 140px; height: 140px; opacity: 0.85;
}
.hero-corner.tl { top: 12px; left: 12px; }
.hero-corner.tr { top: 12px; right: 12px; transform: scaleX(-1); }
.hero-corner.bl { bottom: 12px; left: 12px; transform: scaleY(-1); }
.hero-corner.br { bottom: 12px; right: 12px; transform: scale(-1,-1); }

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-body);
  font-size: 0.82rem; letter-spacing: 0.12em;
  color: var(--gold-light);
  border: 1px solid rgba(232,199,102,0.4);
  padding: 6px 18px; border-radius: 999px;
  background: rgba(232,199,102,0.08);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.25;
  margin: 22px 0 8px;
  background: linear-gradient(180deg, #fff 30%, var(--gold-light) 120%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.hero-sub { color: rgba(255,255,255,0.78); font-size: 1.05rem; max-width: 640px; }

.hero-portrait-frame {
  position: relative;
  width: min(760px, 96vw);
  max-width: 100%;
  aspect-ratio: 16/9;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  padding: 10px;
  background: var(--gradient-gold);
  box-shadow: var(--shadow-royal);
}
.hero-portrait-frame img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 16px;
  border: 3px solid rgba(255,255,255,0.85);
  transition: transform .25s ease, filter .25s ease;
}
.hero-portrait-frame a {
  display: block; width: 100%; height: 100%; cursor: pointer;
}
.hero-portrait-frame a:hover img {
  transform: scale(1.02);
  filter: brightness(1.06);
}
.hero-portrait-frame .frame-tag {
  position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%);
  background: var(--navy-royal); color: var(--gold-light);
  font-size: 0.78rem; padding: 6px 18px; border-radius: 999px;
  white-space: nowrap; box-shadow: var(--shadow-gold);
  border: 1px solid rgba(232,199,102,0.5);
}

/* ---------- Buttons ---------- */
.btn-royal-gold {
  background: var(--gradient-gold);
  border: none; color: var(--navy-royal-deep);
  font-family: var(--font-display); font-weight: 600;
  padding: 12px 32px; border-radius: 999px;
  box-shadow: var(--shadow-gold);
  transition: transform .2s ease, box-shadow .2s ease;
}
.btn-royal-gold:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -8px rgba(201,162,39,0.65); color: var(--navy-royal-deep); }
.btn-royal-outline {
  border: 1.5px solid rgba(255,255,255,0.55); color: #fff;
  font-family: var(--font-display); font-weight: 500;
  padding: 11px 28px; border-radius: 999px; background: transparent;
  transition: all .2s ease;
}
.btn-royal-outline:hover { background: rgba(255,255,255,0.12); color: #fff; border-color: #fff; }

.btn-navy {
  background: var(--navy-royal); color: #fff; font-family: var(--font-display); font-weight: 600;
  padding: 11px 28px; border-radius: 999px; border: none;
}
.btn-navy:hover { background: var(--navy-royal-deep); color: #fff; }

/* ---------- Stat strip ---------- */
.stat-strip {
  background: var(--ivory-silk);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-royal);
  margin-top: -70px;
  position: relative; z-index: 5;
  border: 1px solid rgba(201,162,39,0.25);
}
.stat-item { text-align: center; padding: 26px 10px; }
.stat-item .num {
  font-family: var(--font-display); font-weight: 700; font-size: 2rem; color: var(--navy-royal);
}
.stat-item .lbl { font-size: 0.85rem; color: var(--ink-soft); }
.stat-item + .stat-item { border-left: 1px dashed rgba(201,162,39,0.4); }

/* ---------- Section divider ---------- */
.section-divider { display:flex; align-items:center; justify-content:center; margin: 12px 0 40px; }
.section-divider img { width: 260px; max-width: 70%; }

.section-title { text-align:center; margin-bottom: 6px; }
.section-kicker {
  text-align:center; display:block; color: var(--maroon-velvet);
  font-size: 0.85rem; letter-spacing: 0.1em; font-weight: 600; margin-bottom: 8px;
}

/* ---------- Blessing Card ---------- */
.blessing-card {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid rgba(201,162,39,0.25);
  padding: 24px;
  height: 100%;
  position: relative;
  box-shadow: 0 8px 20px -14px rgba(10,31,68,0.25);
  transition: transform .25s ease, box-shadow .25s ease;
}
.blessing-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-royal); }
.blessing-card::before {
  content: '"';
  position: absolute; top: 6px; left: 18px;
  font-family: Georgia, serif; font-size: 3.2rem; color: rgba(201,162,39,0.28);
  line-height: 1;
}
.blessing-card .msg {
  font-size: 0.96rem; color: var(--ink); line-height: 1.8; margin: 18px 0 16px;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.blessing-card .who { display:flex; align-items:center; gap: 10px; border-top: 1px dashed rgba(201,162,39,0.4); padding-top: 12px; }
.blessing-card .avatar-badge {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--gradient-gold); color: var(--navy-royal-deep);
  display:flex; align-items:center; justify-content:center; font-weight:700; font-family: var(--font-display);
  flex-shrink: 0;
}
.blessing-card .who .name { font-weight: 600; color: var(--navy-royal); font-size: 0.92rem; }
.blessing-card .who .org { font-size: 0.78rem; color: var(--ink-soft); }
.blessing-card .date-tag { position:absolute; top: 16px; right: 16px; font-size: 0.72rem; color: var(--ink-soft); }

/* ---------- Form card (signing form) ---------- */
.sign-card {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-royal);
  border: 1px solid rgba(201,162,39,0.3);
  overflow: hidden;
}
.sign-card .sign-card-head {
  background: var(--gradient-navy); color: #fff; padding: 28px 30px;
  position: relative;
}
.sign-card .sign-card-head::after {
  content: ''; position: absolute; left:0; right:0; bottom:-1px; height: 6px;
  background: var(--gradient-gold);
}
.sign-card .sign-card-body { padding: 30px; }

.form-label-royal { font-weight: 500; color: var(--navy-royal); font-size: 0.9rem; }
.form-control-royal, .form-select-royal {
  border-radius: var(--radius-sm); border: 1.5px solid #e4dcc5; padding: 10px 14px;
  font-family: var(--font-body);
}
.form-control-royal:focus, .form-select-royal:focus {
  border-color: var(--gold-regal); box-shadow: 0 0 0 3px rgba(201,162,39,0.18);
}

/* ---------- QR Card ---------- */
.qr-float-card {
  background: #fff; border-radius: var(--radius-md);
  border: 1px solid rgba(201,162,39,0.3);
  box-shadow: var(--shadow-royal);
  padding: 16px; text-align: center;
}
.qr-float-card img { width: 130px; height: 130px; }

/* ---------- Footer ---------- */
.footer-royal {
  background: var(--gradient-navy); color: rgba(255,255,255,0.75);
  padding: 50px 0 20px; margin-top: 60px;
  border-top: 3px solid var(--gold-regal);
}
.footer-royal h6 { color: var(--gold-light); font-family: var(--font-display); }
.footer-royal a { color: rgba(255,255,255,0.75); }
.footer-royal a:hover { color: var(--gold-light); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.12); margin-top: 30px; padding-top: 18px; font-size: 0.82rem; text-align:center; }

/* ---------- Search / filter bar ---------- */
.search-bar-royal {
  background: #fff; border-radius: 999px; border: 1.5px solid rgba(201,162,39,0.35);
  padding: 6px 8px 6px 20px; box-shadow: 0 8px 24px -16px rgba(10,31,68,0.3);
}
.search-bar-royal input { border: none; }
.search-bar-royal input:focus { box-shadow: none; }

/* ---------- Admin theme (light/dark) ---------- */
[data-admin-theme="light"] {
  --adm-bg: #F5F3EC; --adm-surface: #ffffff; --adm-text: #1B1B1F; --adm-border: #e7e1cf; --adm-sidebar: var(--navy-royal);
}
[data-admin-theme="dark"] {
  --adm-bg: #0F1420; --adm-surface: #161C2C; --adm-text: #EDEDF2; --adm-border: #262E42; --adm-sidebar: #0A0E17;
}
body.admin-body { background: var(--adm-bg); color: var(--adm-text); font-family: var(--font-body); }
.admin-sidebar { background: var(--adm-sidebar); min-height: 100vh; color: #fff; width: 260px; }
.admin-sidebar .brand { padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.admin-sidebar .nav-link { color: rgba(255,255,255,0.75); padding: 11px 20px; border-radius: 10px; margin: 2px 12px; font-size: 0.92rem; }
.admin-sidebar .nav-link i { width: 20px; text-align:center; margin-right: 10px; color: var(--gold-light); }
.admin-sidebar .nav-link:hover, .admin-sidebar .nav-link.active { background: rgba(201,162,39,0.16); color: #fff; }
.admin-topbar { background: var(--adm-surface); border-bottom: 1px solid var(--adm-border); }
.admin-card { background: var(--adm-surface); border: 1px solid var(--adm-border); border-radius: var(--radius-md); }
.admin-kpi { border-radius: var(--radius-md); padding: 22px; color: #fff; position: relative; overflow: hidden; }
.admin-kpi .num { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; }
.theme-toggle-btn { border: 1px solid var(--adm-border); background: var(--adm-surface); color: var(--adm-text); border-radius: 999px; width: 38px; height: 38px; }

/* ---------- Utility ---------- */
.text-gold { color: var(--gold-regal) !important; }
.text-navy { color: var(--navy-royal) !important; }
.bg-navy { background: var(--navy-royal) !important; }
.rounded-royal { border-radius: var(--radius-md) !important; }
.shadow-royal { box-shadow: var(--shadow-royal) !important; }

/* ---------- Animations ---------- */
@keyframes fadeUp { from { opacity:0; transform: translateY(16px); } to { opacity:1; transform: translateY(0); } }
.animate-fade-up { animation: fadeUp .6s ease both; }
.delay-1 { animation-delay: .08s; } .delay-2 { animation-delay: .16s; } .delay-3 { animation-delay: .24s; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .hero-royal { padding: 70px 0 100px; text-align: center; }
  .hero-sub { margin-left: auto; margin-right: auto; }
  .hero-portrait-frame { margin-top: 30px; }
}
@media (max-width: 575.98px) {
  .stat-item + .stat-item { border-left: none; border-top: 1px dashed rgba(201,162,39,0.4); }
  .sign-card .sign-card-body { padding: 20px; }
  .hero-corner { width: 80px; height: 80px; }
}