/* BP Scout Camp 2026 · design system */
:root {
  --ink: #2A1B5C;
  --ink-2: #3A2A73;
  --purple: #5B3FA8;
  --gold: #F2C230;
  --gold-deep: #D9A916;
  --paper: #FBF8F1;
  --card: #FFFFFF;
  --line: #E6DCC6;
  --line-soft: #EFE7D6;
  --zebra: #FAF6EE;
  --muted: #6B5E45;
  --text: #2A2233;
  --green: #22B04B;
  --m1: #8A5A2B;
  --m2: #B8461C;
  --m3: #1E63B0;
  --dark: #140D2E;
  --warn-bg: #FFF7DC;
  --warn-bg-2: #FFF1C9;
  --warn-ink: #5C4600;
  --warn-ink-2: #7A5300;
  --warn-ink-3: #9A6B00;
  --medal-gold: #F2C230;
  --medal-silver: #C9C4D9;
  --medal-bronze: #C98A5A;
  --lv: var(--purple);          /* สีชั้นที่กำลังใช้ (ตั้งผ่าน style) */
  --radius: 14px;
  --shadow: 0 1px 2px rgba(42, 27, 92, .06), 0 4px 16px rgba(42, 27, 92, .05);
  --f-head: 'Anuphan', 'Noto Sans Thai Looped', system-ui, sans-serif;
  --f-body: 'Noto Sans Thai Looped', 'Anuphan', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font-family: var(--f-body); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .head { font-family: var(--f-head); line-height: 1.25; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--purple); }
.num { font-family: var(--f-head); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.gap { display: inline-block; width: .7em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }

/* ---------------------------------------------------------------- header */
.topbar {
  background: var(--ink); color: #fff;
  padding: 12px max(16px, env(safe-area-inset-left));
}
.topbar-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.crest {
  width: 46px; height: 46px; border-radius: 50%; background: #fff; flex: none;
  display: grid; place-items: center; box-shadow: 0 0 0 2px rgba(255,255,255,.18);
}
.crest img { height: 36px; width: auto; display: block; }
.brand { min-width: 0; flex: 1; }
.brand-title { font-family: var(--f-head); font-weight: 700; font-size: 18px; letter-spacing: .1px; }
.brand-sub { font-size: 12.5px; color: rgba(255,255,255,.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px; padding: 9px 16px;
  font-family: var(--f-head); font-weight: 600; font-size: 14.5px; line-height: 1.2;
  text-decoration: none; white-space: nowrap; transition: transform .08s ease, background .15s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { background: #F6CD4E; }
.btn-ghost-light { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.22); }
.btn-ghost-light:hover { background: rgba(255,255,255,.16); }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: var(--ink-2); }
.btn-line { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-line:hover { border-color: #D6C9AC; }
.btn-lv { background: var(--lv); color: #fff; }
.btn-danger { background: #9A3412; color: #fff; }
.btn-danger:hover { background: #7F2A0E; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 16.5px; border-radius: 14px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--purple); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- layout & cards */
.wrap { max-width: 1180px; margin: 0 auto; padding: 18px 16px 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-title { font-family: var(--f-head); font-weight: 700; font-size: 17px; color: var(--ink); }
.stack > * + * { margin-top: 16px; }

/* ---------------------------------------------------------------- pills / segmented */
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  border: 1.5px solid var(--line); background: #fff; color: var(--text);
  border-radius: 999px; padding: 7px 14px; font-family: var(--f-head); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.pill:hover { border-color: #D6C9AC; }
.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill.lv { color: var(--lv); border-color: color-mix(in srgb, var(--lv) 35%, white); }
.pill.lv[aria-pressed="true"] { background: var(--lv); border-color: var(--lv); color: #fff; }

.lvtag {
  display: inline-block; font-family: var(--f-head); font-weight: 700; font-size: .82em;
  color: #fff; background: var(--lv); border-radius: 6px; padding: 1px 6px; line-height: 1.35; vertical-align: .05em;
}

/* ---------------------------------------------------------------- progress */
.bar { height: 6px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--lv); border-radius: inherit; transition: width .6s ease; }

/* ---------------------------------------------------------------- tent progress card */
.tents { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tent-card { padding: 14px 16px; display: flex; gap: 14px; align-items: center; }
.tent-card svg { width: 64px; height: 59px; flex: none; }
.tent-meta { flex: 1; min-width: 0; }
.tent-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.tent-lv { font-family: var(--f-head); font-weight: 700; font-size: 19px; color: var(--lv); }
.tent-pct { font-family: var(--f-head); font-weight: 700; font-size: 22px; color: var(--ink); }
.tent-pct small { font-size: 13px; color: var(--muted); font-weight: 600; }
.tent-note { font-size: 12.5px; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tent-note.done { color: var(--green); font-weight: 600; }

/* ---------------------------------------------------------------- toast */
.toast-host { position: fixed; left: 0; right: 0; bottom: max(20px, env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; z-index: 90; pointer-events: none; }
.toast {
  background: rgba(24, 16, 46, .94); color: #fff; border-radius: 999px; padding: 11px 18px;
  font-size: 14.5px; max-width: min(92vw, 520px); box-shadow: 0 8px 28px rgba(0,0,0,.22);
  animation: toast-in .22s ease-out both;
}
.toast.out { animation: toast-out .25s ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------------- dialog */
.modal-back { position: fixed; inset: 0; background: rgba(20, 13, 46, .45); z-index: 70; display: grid; place-items: center; padding: 16px; animation: fade .15s ease both; }
.modal { background: #fff; border-radius: 18px; width: min(420px, 100%); padding: 20px; box-shadow: 0 20px 60px rgba(20,13,46,.3); }
.modal h3 { font-size: 19px; color: var(--ink); margin-bottom: 6px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }

/* ---------------------------------------------------------------- notice boxes */
.note { border-radius: 12px; padding: 11px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.note-warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid #F3E2A6; }
.note-info { background: #F3F0FB; color: var(--ink); border: 1px solid #E2DBF3; }
.note .icon { margin-top: 2px; }

/* ---------------------------------------------------------------- empty / loading */
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .tents { gap: 8px; }
  .tent-card { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 10px 9px; }
  .tent-card svg { width: 46px; height: 42px; align-self: center; }
  .tent-lv { font-size: 16px; }
  .tent-pct { font-size: 18px; }
  .tent-note { font-size: 11px; margin-top: 4px; white-space: normal; line-height: 1.35; }
  .tent-note .end { display: block; }
  .brand-title { font-size: 16px; }
  .crest { width: 40px; height: 40px; }
  .crest img { height: 31px; }
  .top-actions .btn { padding: 8px 12px; font-size: 13.5px; }
  .hide-sm { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
