/* EpubCraft landing — theme tokens lifted from the app itself
   (slate-950/900/850 + blue-600 accent, see app index.css @theme). */

:root {
  --bg: #020617;
  --bg-elev: #0f172a;
  --bg-card: #16213a;
  --bg-chip: #1e293b;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #cbd5e1;
  --text-strong: #f1f5f9;
  --text-dim: #8fa1b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-text: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --ok: #4ade80;
  --warn: #facc15;
  --code-tag: #60a5fa;
  --code-value: #fb923c;
  --code-string: #86efac;
  --shadow: 0 24px 70px -30px rgba(2, 6, 23, 0.9);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-chip: #eef2f7;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text: #334155;
  --text-strong: #0f172a;
  --text-dim: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-text: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --ok: #16a34a;
  --warn: #ca8a04;
  --code-tag: #2563eb;
  --code-value: #ea580c;
  --code-string: #15803d;
  --shadow: 0 24px 60px -30px rgba(15, 23, 42, 0.25);
  color-scheme: light;
}

/* Thai pages set the whole page in Sarabun — the same family the app's own
   Thai CSS templates use. */
html[lang="th"] {
  --font-body: "Sarabun", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: "Sarabun", Georgia, serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 1.0625rem;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  width: min(1120px, 100% - 3rem);
  margin-inline: auto;
}

/* ---------- Nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-block: 0.7rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-strong);
}

.brand:hover {
  text-decoration: none;
}

.brand img {
  width: 30px;
  height: 30px;
  border-radius: 7px;
}

.nav-links {
  display: flex;
  gap: 1.35rem;
  margin-inline: auto;
  font-size: 0.92rem;
}

.nav-links a {
  color: var(--text-dim);
}

.nav-links a:hover {
  color: var(--text-strong);
  text-decoration: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.lang-switch {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.32rem 0.6rem;
  transition: color 0.15s, border-color 0.15s;
}

.lang-switch:hover {
  color: var(--text-strong);
  border-color: var(--border-strong);
  text-decoration: none;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  color: var(--text-strong);
  border-color: var(--border-strong);
}

.theme-toggle .icon-sun {
  display: none;
}

html[data-theme="light"] .theme-toggle .icon-sun {
  display: block;
}

html[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 600;
  border-radius: 12px;
  padding: 0.72rem 1.3rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  border-color: var(--border-strong);
  color: var(--text-strong);
  background: transparent;
}

.btn-ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent-text);
}

.btn-sm {
  padding: 0.42rem 0.9rem;
  font-size: 0.87rem;
  border-radius: 9px;
}

.btn svg {
  flex: none;
}

.btn-store {
  flex-direction: row;
  text-align: left;
}

.btn-store .store-lines {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.btn-store .store-small {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.85;
}

.btn-store .store-big {
  font-size: 1.02rem;
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  padding-block: 5rem 4.5rem;
  /* The ::before glow bleeds -20% past each side; clip the horizontal bleed so
     it can't create page-wide horizontal scroll on narrow (mobile) viewports.
     overflow-x: clip leaves the vertical glow bleed intact. */
  overflow-x: clip;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -40% -20% 30% -20%;
  background: radial-gradient(
    55% 60% at 30% 30%,
    rgba(37, 99, 235, 0.16),
    transparent 70%
  );
  pointer-events: none;
}

html[data-theme="light"] .hero::before {
  background: radial-gradient(
    55% 60% at 30% 30%,
    rgba(37, 99, 235, 0.08),
    transparent 70%
  );
}

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 3.5rem;
  align-items: center;
}

/* Segmented Source/Visual control — same chrome as the app toolbar. */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-chip);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.6rem;
}

.seg-btn {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  background: none;
  border: none;
  border-radius: 8px;
  padding: 0.38rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn[aria-pressed="true"] {
  background: var(--bg-elev);
  color: var(--accent-text);
  box-shadow: 0 1px 4px rgba(2, 6, 23, 0.4);
}

html[data-theme="light"] .seg-btn[aria-pressed="true"] {
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.hero-title {
  font-size: clamp(2.4rem, 5.2vw, 3.9rem);
  line-height: 1.12;
  color: var(--text-strong);
  font-weight: 600;
  letter-spacing: -0.01em;
  min-height: 2.3em;
}

.hero-title .hero-text {
  font-family: var(--font-display);
  font-weight: 600;
}

html[lang="th"] .hero-title .hero-text {
  font-weight: 700;
}

.hero-title .tag {
  display: none;
  color: var(--code-tag);
  font-weight: 400;
}

/* Source mode: headline becomes real markup. */
.hero.mode-source .hero-title {
  font-family: var(--font-mono);
  font-size: clamp(1.6rem, 3.6vw, 2.7rem);
  font-weight: 500;
  line-height: 1.3;
}

.hero.mode-source .hero-title .hero-text {
  font-family: var(--font-mono);
  font-weight: 500;
}

.hero.mode-source .hero-title .tag {
  display: inline;
  font-family: var(--font-mono);
}

.hero-title.swapping {
  animation: title-swap 0.35s ease;
}

@keyframes title-swap {
  from {
    opacity: 0.2;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero-lede {
  margin-top: 1.4rem;
  font-size: 1.13rem;
  max-width: 34rem;
  color: var(--text-dim);
}

.hero-lede strong {
  color: var(--text);
  font-weight: 600;
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 2rem;
}

.statusline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2.2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
}

.statusline .ok {
  color: var(--ok);
}

.statusline .sep {
  opacity: 0.45;
}

/* Phone frames */

.phone {
  width: min(320px, 78vw);
  padding: 9px;
  border-radius: 46px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}

.phone img {
  border-radius: 38px;
  width: 100%;
}

.hero-phone {
  position: relative;
  margin-inline: auto;
}

.hero-phone .shot {
  transition: opacity 0.45s ease;
}

.hero-phone .shot-visual {
  position: absolute;
  top: 9px;
  left: 9px;
  width: calc(100% - 18px);
  opacity: 0;
}

.hero.mode-visual .hero-phone .shot-visual {
  opacity: 1;
}

/* ---------- Sections ---------- */

.section {
  padding-block: 4.8rem;
  border-top: 1px solid var(--border);
}

.section-plain {
  border-top: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent-text) 30%, transparent);
  border-radius: 8px;
  padding: 0.3rem 0.7rem;
  margin-bottom: 1.1rem;
}

.eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-text);
}

.section h2 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-strong);
  letter-spacing: -0.01em;
  max-width: 30ch;
}

html[lang="th"] .section h2 {
  font-weight: 700;
}

.section .lede {
  margin-top: 0.9rem;
  color: var(--text-dim);
  max-width: 40rem;
  font-size: 1.06rem;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
  margin-top: 2.5rem;
}

.split .phone {
  margin-inline: auto;
}

/* Grid items default to min-width: auto, so a wide child (e.g. the code-card's
   <pre>) can force a track wider than the viewport. Let them shrink instead. */
.split > * {
  min-width: 0;
}

.checklist {
  list-style: none;
  margin-top: 1.6rem;
  display: grid;
  gap: 0.85rem;
}

.checklist li {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
}

.checklist .tick {
  flex: none;
  margin-top: 0.28rem;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid;
  place-items: center;
}

.checklist strong {
  color: var(--text-strong);
  font-weight: 600;
}

/* Mini code card (Global CSS section) */

.code-card {
  margin-top: 1.6rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

html[data-theme="light"] .code-card {
  background: #0f172a;
  color: #cbd5e1;
}

.code-card .code-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
}

html[data-theme="light"] .code-card .code-head {
  color: #8fa1b8;
  border-color: rgba(148, 163, 184, 0.2);
}

.code-card pre {
  padding: 1rem 1.25rem;
  overflow-x: auto;
}

.code-card .c-sel {
  color: var(--code-tag);
}

.code-card .c-val {
  color: var(--code-value);
}

.code-card .c-str {
  color: var(--code-string);
}

html[data-theme="light"] .code-card .c-sel {
  color: #60a5fa;
}

html[data-theme="light"] .code-card .c-val {
  color: #fb923c;
}

html[data-theme="light"] .code-card .c-str {
  color: #86efac;
}

/* ---------- Export format cards ---------- */

.formats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
}

.format-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem 1.25rem;
  transition: border-color 0.2s, transform 0.2s;
}

.format-card:hover {
  border-color: var(--accent-text);
  transform: translateY(-2px);
}

.format-card.is-featured {
  border-color: var(--accent);
  background: linear-gradient(
    160deg,
    var(--accent-soft),
    var(--bg-card) 55%
  );
}

.format-card h3 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1rem;
  color: var(--text-strong);
  font-weight: 650;
}

.format-card h3 svg {
  color: var(--accent-text);
  flex: none;
}

.format-card p {
  margin-top: 0.35rem;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.preflight {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin-top: 1.4rem;
  font-size: 0.88rem;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.preflight .warn {
  color: var(--warn);
  flex: none;
  margin-top: 0.15rem;
}

/* ---------- Feature grid ---------- */

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 2.5rem;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  transition: border-color 0.2s, transform 0.2s;
}

.feature-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.feature-card .icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  margin-bottom: 1rem;
}

.feature-card h3 {
  font-size: 1.05rem;
  color: var(--text-strong);
  font-weight: 650;
}

.feature-card p {
  margin-top: 0.45rem;
  font-size: 0.92rem;
  color: var(--text-dim);
}

/* ---------- Compare table ---------- */

.compare-wrap {
  margin-top: 2.5rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-card);
}

.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  min-width: 560px;
}

.compare th,
.compare td {
  padding: 0.85rem 1.25rem;
  text-align: left;
  border-top: 1px solid var(--border);
}

.compare thead th {
  border-top: none;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

.compare th:nth-child(2),
.compare td:nth-child(2),
.compare th:nth-child(3),
.compare td:nth-child(3) {
  text-align: center;
  width: 7.5rem;
}

.compare .yes {
  color: var(--ok);
  font-weight: 700;
}

.compare .no {
  color: var(--text-dim);
  opacity: 0.6;
}

.compare-notes {
  margin-top: 0.9rem;
  font-size: 0.83rem;
  color: var(--text-dim);
}

/* ---------- FAQ ---------- */

.faq-list {
  margin-top: 2.5rem;
  display: grid;
  gap: 0.8rem;
  max-width: 46rem;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.faq-item summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.05rem 1.3rem;
  font-weight: 600;
  color: var(--text-strong);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  font-family: var(--font-mono);
  color: var(--accent-text);
  font-size: 1.1rem;
  transition: transform 0.2s;
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item .faq-body {
  padding: 0 1.3rem 1.15rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ---------- CTA ---------- */

.cta-card {
  position: relative;
  overflow: hidden;
  text-align: center;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  padding: 4rem 2rem;
}

.cta-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    60% 90% at 50% -10%,
    rgba(37, 99, 235, 0.22),
    transparent 70%
  );
  pointer-events: none;
}

html[data-theme="light"] .cta-card::before {
  background: radial-gradient(
    60% 90% at 50% -10%,
    rgba(37, 99, 235, 0.1),
    transparent 70%
  );
}

.cta-card > * {
  position: relative;
}

.cta-card img {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  margin: 0 auto 1.4rem;
  box-shadow: var(--shadow);
}

.cta-card h2 {
  margin-inline: auto;
}

.cta-card .lede {
  margin-inline: auto;
}

.cta-card .hero-ctas {
  justify-content: center;
}

/* ---------- Footer ---------- */

.footer {
  border-top: 1px solid var(--border);
  padding-block: 2.5rem;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  justify-content: space-between;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.footer-links a {
  color: var(--text-dim);
}

.footer-links a:hover {
  color: var(--text-strong);
  text-decoration: none;
}

/* ---------- Reveal animation ---------- */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.in-view {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .hero-phone .shot,
  .format-card,
  .feature-card {
    transition: none;
  }
  .hero-title.swapping {
    animation: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .nav-links {
    display: none;
  }

  .hero {
    padding-block: 3.5rem 3rem;
  }

  .hero-grid,
  .split {
    grid-template-columns: 1fr;
    gap: 2.6rem;
  }

  .split-media-last {
    order: -1;
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .formats {
    grid-template-columns: 1fr;
  }

  .section {
    padding-block: 3.4rem;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 1rem;
  }

  .nav-inner {
    gap: 0.8rem;
  }

  .btn-store,
  .btn-ghost {
    width: 100%;
  }

  .cta-card {
    padding: 3rem 1.4rem;
  }
}
