/* ==========================================================================
   DESIGN TOKENS
   Concept: "ก่อนแสงแรก" (before first light) — งานวิ่งที่ปล่อยตัวตอนตี 4-5
   สีเข้มโทนป่าเขา/รุ่งอรุณ + สีธงปล่อยตัวสีแดงเป็นจุดเน้น + เหลืองเลนวิ่งเป็นรอง
   ตัวอักษร: Kanit (โปสเตอร์/ป้ายบิบ, มีลักษณะกระชับแบบป้ายกีฬา) + Sarabun (อ่านง่าย)
   ลายเซ็นภาพ: การ์ดประเภทงานวิ่งทรง "เบอร์บิบ" มุมตัดทแยง + เส้นเวลาแบบสต็อปวอตช์
   ========================================================================== */
:root {
  --ink: #14231c;
  --ink-soft: #1f342a;
  --paper: #f4f6f1;
  --paper-dim: #e8ebe3;
  --trail: #1f4b3f;
  --trail-light: #2f6b58;
  --flag: #d6303f;
  --flag-dark: #a82330;
  --track-yellow: #f2b705;
  --ink-text: #16201a;
  --muted: #5b665f;
  --line: rgba(20, 35, 28, 0.14);
  --line-on-dark: rgba(244, 246, 241, 0.18);

  --font-display: "Kanit", "Sarabun", sans-serif;
  --font-body: "Sarabun", "Kanit", sans-serif;

  --radius: 4px;
  --container: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink-text);
  background: var(--paper);
  line-height: 1.6;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0 0 0.5em;
  letter-spacing: 0.01em;
}
.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.section { padding: 88px 0; }
.section--tight { padding: 56px 0; }
.section--dark { background: var(--ink); color: var(--paper); }
.eyebrow {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--flag);
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  background: var(--flag);
  display: inline-block;
}
.section-head { max-width: 640px; margin-bottom: 48px; }
.section-head h2 { font-size: clamp(28px, 4vw, 40px); font-weight: 600; }
.section-head p { color: var(--muted); font-size: 17px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  padding: 14px 28px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:focus-visible { outline: 3px solid var(--track-yellow); outline-offset: 2px; }
.btn--flag { background: var(--flag); color: #fff; box-shadow: 0 6px 0 var(--flag-dark); }
.btn--flag:hover { box-shadow: 0 4px 0 var(--flag-dark); }
.btn--flag:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--flag-dark); }
.btn--outline { background: transparent; color: var(--paper); border: 1.5px solid var(--line-on-dark); }
.btn--outline:hover { border-color: var(--paper); }
.btn--ghost { background: var(--paper-dim); color: var(--ink); }
.btn--full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(20, 35, 28, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-on-dark);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.site-header .brand {
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  color: var(--paper); text-decoration: none; letter-spacing: 0.02em;
}
.site-header .brand span { color: var(--track-yellow); }
.site-nav { display: flex; gap: 28px; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  color: var(--paper); text-decoration: none; font-size: 14.5px; font-weight: 500;
  opacity: 0.85; transition: opacity 0.15s;
}
.site-nav a:hover { opacity: 1; }
.nav-toggle { display: none; }

/* Hero */
.hero {
  background:
    radial-gradient(ellipse 900px 500px at 85% -10%, rgba(242, 183, 5, 0.14), transparent 60%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-soft) 100%);
  color: var(--paper);
  padding: 72px 0 96px;
  position: relative;
  overflow: hidden;
}
.hero-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 56px; align-items: center; }
.hero h1 {
  font-size: clamp(36px, 5.4vw, 62px);
  font-weight: 700;
  line-height: 1.06;
  margin-bottom: 20px;
}
.hero-sub { font-size: 18px; color: rgba(244, 246, 241, 0.78); max-width: 480px; margin-bottom: 32px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 28px; margin-bottom: 36px; }
.hero-meta-item { display: flex; align-items: flex-start; gap: 10px; }
.hero-meta-item .k { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--track-yellow); display: block; margin-bottom: 2px; }
.hero-meta-item .v { font-size: 15px; font-weight: 500; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }

/* Countdown — stopwatch split style */
.countdown-card {
  background: rgba(244, 246, 241, 0.05);
  border: 1px solid var(--line-on-dark);
  border-radius: 8px;
  padding: 28px;
}
.countdown-card .label {
  font-family: var(--font-display);
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--track-yellow); margin-bottom: 18px;
}
.countdown-splits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.split {
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  padding: 14px 4px;
  text-align: center;
  border-top: 3px solid var(--flag);
}
.split .num { font-family: var(--font-display); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.split .unit { font-size: 11px; color: rgba(244,246,241,0.6); text-transform: uppercase; letter-spacing: 0.08em; }

/* Bib-tag category cards */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.bib-card {
  position: relative;
  background: #fff;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  clip-path: polygon(0 0, calc(100% - 26px) 0, 100% 26px, 100% 100%, 0 100%);
}
.bib-card::before {
  content: "";
  position: absolute; top: 0; right: 0;
  width: 26px; height: 26px;
  background: var(--paper);
  border-left: 1.5px dashed var(--line);
  border-bottom: 1.5px dashed var(--line);
}
.bib-card .dist {
  font-family: var(--font-display); font-weight: 700;
  font-size: 44px; color: var(--trail); line-height: 1; margin-bottom: 4px;
}
.bib-card .dist small { font-size: 16px; font-weight: 500; }
.bib-card .name { font-weight: 600; font-size: 16px; margin-bottom: 10px; }
.bib-card .desc { color: var(--muted); font-size: 14px; margin-bottom: 18px; min-height: 20px; }
.bib-card .price-row {
  display: flex; align-items: baseline; justify-content: space-between;
  border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 6px;
}
.bib-card .price { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.bib-card .tier-tag {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--track-yellow); color: var(--ink); padding: 3px 8px; border-radius: 3px;
}
.bib-card .tier-tag.regular { background: var(--paper-dim); color: var(--ink); }
.bib-card .quota { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.bib-card .quota.low { color: var(--flag); font-weight: 600; }
.bib-card .quota.soldout { color: var(--flag); font-weight: 700; }
.bib-card.is-soldout { opacity: 0.6; }
.bib-card .select-btn { width: 100%; }

/* Schedule — stopwatch split list */
.timeline {
  border-left: 2px solid var(--line);
  margin-left: 6px;
}
.timeline-item { position: relative; padding: 0 0 28px 28px; }
.timeline-item::before {
  content: "";
  position: absolute; left: -7px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--flag); border: 3px solid var(--paper);
}
.timeline-item .time { font-family: var(--font-display); font-weight: 700; color: var(--trail); font-size: 15px; }
.timeline-item .desc { color: var(--ink-text); font-size: 15px; }

/* Form */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 32px;
}
.steps-bar { display: flex; gap: 8px; margin-bottom: 32px; }
.steps-bar .step {
  flex: 1; height: 5px; border-radius: 3px; background: var(--paper-dim);
}
.steps-bar .step.active { background: var(--flag); }
.steps-bar .step.done { background: var(--trail); }

.form-row { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
label .req { color: var(--flag); }
input[type="text"], input[type="email"], input[type="tel"], input[type="date"],
select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--font-body); font-size: 15px; background: #fff; color: var(--ink-text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--trail); outline-offset: 1px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.radio-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-chip {
  border: 1.5px solid var(--line); border-radius: 20px; padding: 8px 16px;
  cursor: pointer; font-size: 14px; user-select: none;
}
.radio-chip input { position: absolute; opacity: 0; pointer-events: none; }
.radio-chip.checked { background: var(--trail); color: #fff; border-color: var(--trail); }
.checkbox-row { display: flex; gap: 10px; align-items: flex-start; }
.checkbox-row input { margin-top: 4px; }
.checkbox-row label { font-weight: 400; font-size: 14px; }

.form-actions { display: flex; justify-content: space-between; margin-top: 28px; gap: 12px; }

.qr-box { text-align: center; background: var(--paper-dim); border-radius: 8px; padding: 24px; margin-bottom: 20px; }
.qr-box img { margin: 0 auto 12px; border-radius: 6px; background: #fff; padding: 10px; }
.pay-fee { font-family: var(--font-display); font-size: 32px; font-weight: 700; color: var(--flag); }

.upload-box {
  border: 2px dashed var(--line); border-radius: 8px; padding: 24px; text-align: center;
  cursor: pointer; background: var(--paper-dim);
}
.upload-box.has-file { border-color: var(--trail); background: #eef5f1; }

.result-box { text-align: center; padding: 20px 0; }
.result-box .regid {
  font-family: var(--font-display); font-size: 34px; font-weight: 700; color: var(--trail);
  background: var(--paper-dim); display: inline-block; padding: 14px 28px; border-radius: 8px; margin: 16px 0;
  letter-spacing: 0.03em;
}
.alert { padding: 12px 16px; border-radius: 6px; font-size: 14px; margin-bottom: 18px; }
.alert--error { background: #fdeceb; color: var(--flag-dark); border: 1px solid #f3bcbf; }
.alert--success { background: #eaf4ef; color: var(--trail); border: 1px solid #b9dcc9; }

/* Status lookup */
.status-form { display: flex; gap: 10px; flex-wrap: wrap; }
.status-form input { flex: 1; min-width: 220px; }
.status-result { margin-top: 20px; }
.status-pill { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.status-pill.pending { background: #fdf3d9; color: #8a6300; }
.status-pill.confirmed { background: #eaf4ef; color: var(--trail); }
.status-pill.cancelled { background: #fdeceb; color: var(--flag-dark); }

/* Rules */
.rules-list { columns: 1; }
.rules-list li { margin-bottom: 12px; color: var(--ink-text); }

/* Footer */
.site-footer { background: var(--ink); color: rgba(244,246,241,0.7); padding: 56px 0 28px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; margin-bottom: 40px; }
.footer-grid h4 { color: var(--paper); font-size: 15px; }
.footer-grid a { display: block; color: rgba(244,246,241,0.7); text-decoration: none; margin-bottom: 8px; font-size: 14px; }
.footer-grid a:hover { color: var(--track-yellow); }
.footer-bottom { border-top: 1px solid var(--line-on-dark); padding-top: 20px; font-size: 13px; text-align: center; color: rgba(244,246,241,0.5); }

/* Utility */
.center { text-align: center; }
.mt-24 { margin-top: 24px; }
.hidden { display: none !important; }
.loading-dot::after { content: "…"; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0%,20%{content:"";} 40%{content:".";} 60%{content:"..";} 80%,100%{content:"...";} }

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .site-nav { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .countdown-splits { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
