/* ─── Layers ───────────────────────────────────────────────── */
@layer reset, tokens, base, layout, components, utilities;

/* ─── Reset ────────────────────────────────────────────────── */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  img, video { max-width: 100%; display: block; }
  ul, ol { list-style: none; }
  button, input, select, textarea { font: inherit; }
}

/* ─── Tokens ────────────────────────────────────────────────── */
@layer tokens {
  :root {
    --red:        #E31837;
    --red-dark:   #b8102b;
    --dark:       #1A1A2E;
    --dark-mid:   #252540;

    --text:       #111827;
    --text-mid:   #374151;
    --text-muted: #6b7280;

    --border:     #e5e7eb;
    --border-mid: #d1d5db;
    --surface:    #f9fafb;
    --white:      #ffffff;

    --radius-sm:  6px;
    --radius:     8px;
    --radius-lg:  12px;

    --max-w:      1024px;
    --pad-x:      1.25rem;
  }
}

/* ─── Base ──────────────────────────────────────────────────── */
@layer base {
  html { scroll-behavior: smooth; }

  body {
    font-family: 'Sarabun', sans-serif;
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text);
    background: var(--white);
    -webkit-font-smoothing: antialiased;
  }

  h1 { font-size: clamp(1.5rem, 4vw, 2rem);   font-weight: 700; line-height: 1.3; }
  h2 { font-size: clamp(1.1rem, 3vw, 1.3rem); font-weight: 600; line-height: 1.4; }
  h3 { font-size: 1rem;                         font-weight: 600; line-height: 1.4; }

  p  { color: var(--text-mid); }
  a  { color: var(--red); text-decoration: none; }
  a:hover { text-decoration: underline; }

  strong { font-weight: 600; color: var(--text); }
}

/* ─── Layout ────────────────────────────────────────────────── */
@layer layout {
  .page-wrap {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  main { flex: 1; }

  .container {
    width: 100%;
    max-width: var(--max-w);
    margin-inline: auto;
    padding-inline: var(--pad-x);
  }
}

/* ─── Components ────────────────────────────────────────────── */
@layer components {

  /* Reserve space before Web Components define — prevents layout shift (CLS) */
  site-header:not(:defined) { visibility: hidden; min-height: 52px; display: block; }
  site-footer:not(:defined) { visibility: hidden; display: block; }

  /* Nav */
  site-header { display: block; }

  .nav {
    background: var(--dark);
    padding: 0.75rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .nav__inner {
    max-width: var(--max-w);
    margin-inline: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .nav__logo {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
  }
  .nav__logo span { color: var(--red); }

  .nav__links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
  }

  .nav__links a {
    font-size: 0.8125rem;
    color: #9ca3af;
    transition: color 0.15s;
  }
  .nav__links a:hover,
  .nav__links a[aria-current="page"] { color: #fff; text-decoration: none; }

  .nav__cta {
    background: var(--red);
    color: #fff !important;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    white-space: nowrap;
  }
  .nav__cta:hover { background: var(--red-dark); text-decoration: none; }

  /* Hero */
  .hero {
    background: var(--dark);
    padding: 3rem var(--pad-x) 2.5rem;
  }

  .hero__inner { max-width: var(--max-w); margin-inline: auto; }

  .hero__label {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 0.75rem;
  }

  .hero h1 { color: #fff; margin-bottom: 1rem; }

  .hero__meta {
    font-size: 0.8125rem;
    color: #9ca3af;
    margin-bottom: 1rem;
  }

  .hero__pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
  }

  .pill {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #d1d5db;
    font-size: 0.75rem;
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
  }

  /* Buttons */
  .btn {
    display: inline-block;
    font-weight: 600;
    padding: 0.6rem 1.35rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    cursor: pointer;
    border: none;
    text-decoration: none;
  }

  .btn-primary {
    background: var(--red);
    color: #fff;
  }
  .btn-primary:hover { background: var(--red-dark); text-decoration: none; }

  .btn-outline {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
  }
  .btn-outline:hover { background: rgba(255,255,255,0.08); text-decoration: none; }

  /* TOC */
  .toc {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem var(--pad-x);
  }

  .toc__inner { max-width: var(--max-w); margin-inline: auto; }

  .toc__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
  }

  .toc__list {
    list-style: decimal;
    padding-left: 1.1rem;
    columns: 2;
    column-gap: 1.5rem;
    font-size: 0.8125rem;
  }

  .toc__list li { margin-bottom: 0.2rem; break-inside: avoid; }
  .toc__list a { color: var(--red); }

  /* Article body */
  .article {
    max-width: var(--max-w);
    margin-inline: auto;
    padding: 2rem var(--pad-x) 3rem;
  }

  .article h2 {
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
    padding-top: 0.25rem;
    color: var(--text);
  }

  .article h2:first-child { margin-top: 0; }

  .article h3 {
    margin-top: 1.25rem;
    margin-bottom: 0.4rem;
    color: var(--text);
  }

  .article p { margin-bottom: 0.75rem; }

  .article ul,
  .article ol {
    list-style: disc;
    padding-left: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--text-mid);
    font-size: 0.9375rem;
  }

  .article ol { list-style: decimal; }
  .article li { margin-bottom: 0.3rem; }

  .article hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
  }

  /* Callout boxes */
  .box {
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border-left: 3px solid;
    font-size: 0.875rem;
    line-height: 1.65;
  }

  .box p { margin: 0; font-size: inherit; }
  .box strong { font-size: inherit; }

  .box--info    { background: #eff6ff; border-color: #3b82f6; color: #1e3a5f; }
  .box--warn    { background: #fffbeb; border-color: #f59e0b; color: #78350f; }
  .box--success { background: #f0fdf4; border-color: #16a34a; color: #14532d; }
  .box--neutral { background: var(--surface); border-color: var(--border-mid); color: var(--text-mid); }

  /* Tables */
  .table-wrap { overflow-x: auto; margin-bottom: 1rem; }

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
  }

  th {
    background: var(--dark);
    color: #fff;
    padding: 0.55rem 0.85rem;
    text-align: left;
    font-weight: 600;
  }

  td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.85rem;
    color: var(--text-mid);
  }

  tr:nth-child(even) td { background: var(--surface); }

  /* Steps */
  .steps { margin-bottom: 1.5rem; }

  .step {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .step__num {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    background: var(--red);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 0.2rem;
  }

  .step__title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.1rem;
    font-size: 0.9375rem;
  }

  .step__desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
  }

  /* CTA block */
  .cta-block {
    background: var(--dark);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    margin: 2rem 0;
  }

  .cta-block__title { font-size: 1.1rem; font-weight: 600; color: #fff; margin-bottom: 0.4rem; }
  .cta-block__sub   { font-size: 0.8125rem; color: #9ca3af; margin-bottom: 1.25rem; }

  /* FAQ */
  .faq { border-top: 1px solid var(--border); }

  .faq details {
    border-bottom: 1px solid var(--border);
  }

  .faq summary {
    padding: 0.9rem 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    user-select: none;
  }

  .faq summary::-webkit-details-marker { display: none; }

  .faq summary::after {
    content: '+';
    color: var(--text-muted);
    font-size: 1.25rem;
    font-weight: 400;
    flex-shrink: 0;
    transition: transform 0.2s;
  }

  .faq details[open] summary::after { content: '−'; }

  .faq__answer {
    font-size: 0.875rem;
    color: var(--text-mid);
    line-height: 1.7;
    padding-bottom: 1rem;
  }

  /* Link grid */
  .link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.6rem;
    margin-top: 1.25rem;
  }

  .link-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    text-decoration: none;
    transition: border-color 0.15s;
    display: block;
  }

  .link-card:hover { border-color: var(--red); text-decoration: none; }

  .link-card__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.15rem;
  }

  .link-card__desc {
    font-size: 0.75rem;
    color: var(--text-muted);
  }

  /* Card grid (homepage) */
  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
  }

  .card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: block;
    color: var(--text);
  }

  .card:hover { border-color: var(--red); box-shadow: 0 2px 12px rgba(0,0,0,0.06); text-decoration: none; }

  .card__icon { font-size: 1.5rem; margin-bottom: 0.6rem; }
  .card__title { font-size: 0.9375rem; font-weight: 600; color: var(--text); margin-bottom: 0.3rem; }
  .card__desc  { font-size: 0.8125rem; color: var(--text-muted); }

  /* Section heading */
  .section-heading {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
  }

  /* Footer */
  site-footer { display: block; }

  .footer {
    background: var(--dark);
    color: #9ca3af;
    padding: 3rem var(--pad-x) 2rem;
    margin-top: auto;
  }

  .footer__inner {
    max-width: var(--max-w);
    margin-inline: auto;
  }

  .footer__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
  }

  .footer__logo {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.5rem;
  }
  .footer__logo span { color: var(--red); }

  /* Tagline under footer logo */
  .footer__tagline { color: #d1d5db; font-size: 0.8125rem; }

  .footer__col-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #e5e7eb;
    margin-bottom: 0.75rem;
  }

  .footer__links {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.8125rem;
  }

  .footer__links a {
    color: #9ca3af;
    transition: color 0.15s;
  }
  .footer__links a:hover { color: #fff; text-decoration: none; }

  .footer__bottom {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 1.5rem;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .footer__bottom p { color: #9ca3af; margin: 0; }

  /* Breadcrumb — inside hero sections */
  .hero-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.75rem;
  }

  .hero-breadcrumb a {
    color: #94a3b8;
    transition: color 0.15s;
  }
  .hero-breadcrumb a:hover { color: #fff; text-decoration: none; }
  .hero-breadcrumb span { color: #475569; }

  /* Nav separator before actions cluster */
  .nav__sep {
    width: 1px;
    height: 1.25rem;
    background: rgba(255,255,255,0.15);
    flex-shrink: 0;
  }

  /* Lang switcher */
  .lang-switch {
    font-size: 0.75rem;
    font-weight: 600;
    color: #e5e7eb;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
    letter-spacing: 0.03em;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
  }
  .lang-switch:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.5); text-decoration: none; }

  /* Placeholder pages */
  .placeholder {
    max-width: var(--max-w);
    margin-inline: auto;
    padding: 4rem var(--pad-x);
    text-align: center;
  }

  .placeholder h1 { margin-bottom: 0.75rem; }
  .placeholder p  { color: var(--text-muted); margin-bottom: 1.5rem; }
}

/* ─── Sticky CTA ────────────────────────────────────────────── */
.sticky-cta {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 900;
  background: var(--dark);
  border-top: 1px solid rgba(255,255,255,.15);
  padding: .65rem var(--pad-x) calc(.65rem + env(safe-area-inset-bottom, 0px));
  align-items: center;
  gap: .75rem;
  /* Initial hidden state — JS controls show/hide via inline styles */
  opacity: 0;
  visibility: hidden;
  transform: translateY(110%);
  pointer-events: none;
}
.sticky-cta__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.sticky-cta__btn {
  display: block;
  background: var(--red);
  color: #fff;
  text-align: center;
  padding: .6rem 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: .9rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sticky-cta__btn:hover { background: var(--red-dark); color: #fff; text-decoration: none; }
.sticky-cta__risk {
  font-size: .65rem;
  color: rgba(255,255,255,.38);
  line-height: 1.3;
  text-align: center;
}
.sticky-cta__close {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: .25rem .5rem;
}
@media (min-width: 1024px) {
  .sticky-cta {
    justify-content: center;
    gap: 1.5rem;
    padding: .75rem var(--pad-x);
  }
  .sticky-cta__body {
    flex: 0 0 auto;
    align-items: center;
    text-align: center;
  }
  .sticky-cta__btn {
    padding: .65rem 2.5rem;
    font-size: .95rem;
  }
}

/* ─── Risk note (below hero CTA) ───────────────────────────── */
.risk-note {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  margin-top: 0.45rem;
  line-height: 1.4;
}

/* ─── Utilities ─────────────────────────────────────────────── */
@layer utilities {
  .sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
  }

  .mt-0 { margin-top: 0 !important; }
  .mb-0 { margin-bottom: 0 !important; }
  .text-sm { font-size: 0.875rem; }
  .text-muted { color: var(--text-muted); }
}

/* ─── Payment grid (review + tutorial) ─────────────────────── */
.payment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .65rem;
  margin: 1rem 0;
}
.payment-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem .75rem .7rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .4rem;
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.payment-card:hover {
  border-color: var(--border-mid);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.payment-card__icon {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: .1rem;
}
.payment-card__icon img {
  height: 32px;
  width: auto;
  max-width: 90px;
  object-fit: contain;
}
.payment-card__name { font-size: .8rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.payment-card__speed { font-size: .7rem; color: #16a34a; font-weight: 500; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav__links { display: none; }
  .toc__list  { columns: 1; }
  .footer__grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .hero { padding: 1rem var(--pad-x) !important; }
  .review-hero { padding: 1rem var(--pad-x) !important; }
}
