/* Khai design system v2 -- Editorial-craftsman
   Palette: paper/ink/clay. Fonts: Fraunces + Geist Sans + Geist Mono.
   No em-dash (U+2014), no en-dash (U+2013) anywhere.
   Target gzip < 8KB. */

/* ---- Google Fonts loaded via <link> tags in HTML head for faster LCP, see preconnect setup ---- */

/* ---- Color palette ---- */
:root {
  --paper:      #FAF7F1;
  --ink:        #1C1814;
  --ink-soft:   #443A30;
  --muted:      #6F6457;
  --surface:    #F0EADE;
  --border:     #DBD2BF;
  --clay:       #B5462D;
  --clay-soft:  #E89F87;
  --ink-cta:    #1E40AF;
  --ink-cta-hover: #1D3FA3;
  --moss:       #4F6E3B;

  /* Legacy aliases (keeps account.js skeleton classnames working) */
  --color-primary:  var(--ink-cta);
  --color-accent:   var(--clay);
  --color-surface:  var(--paper);
  --color-text:     var(--ink);
  --color-muted:    var(--muted);
  --color-border:   var(--border);

  /* Type */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Geist Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono:    'Geist Mono', 'Courier New', monospace;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

/* ---- Paper-grain texture overlay ---- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* ---- Base ---- */
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Focus ring ---- */
:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ---- Accessibility ---- */
.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;
}
.hidden { display: none !important; }

/* ---- Typography scale ---- */
.text-display {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 700;
  font-style: normal;
  font-optical-sizing: auto;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.text-headline {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.5vw, 2.75rem);
  font-weight: 600;
  font-optical-sizing: auto;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.text-subhead {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  font-weight: 400;
  font-style: italic;
  font-optical-sizing: auto;
  color: var(--ink-soft);
  line-height: 1.35;
}

/* Mono label style (tier names, captions) */
.label-mono {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Decorative section marker (01. 02. 03.) */
.section-marker {
  font-family: var(--font-display);
  font-size: clamp(4rem, 10vw, 9rem);
  font-weight: 800;
  font-style: italic;
  font-optical-sizing: auto;
  color: var(--clay);
  opacity: 0.15;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

/* ---- Container ---- */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.container-narrow {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---- Section padding ---- */
.section { padding: 6rem 0; }
.section-sm { padding: 3rem 0; }
@media (max-width: 768px) {
  .section { padding: 4rem 0; }
  .section-sm { padding: 2rem 0; }
}

/* ---- Wordmark ---- */
.wordmark {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  font-style: italic;
  font-optical-sizing: auto;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.wordmark .dot { color: var(--clay); }
.wordmark:hover { color: var(--clay); }

/* ---- Navigation ---- */
.nav-link {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  position: relative;
  transition: color 0.2s;
}
.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--ink);
  transition: width 0.25s ease;
}
.nav-link:hover { color: var(--ink); }
.nav-link:hover::after { width: 100%; }
.nav-link.active { color: var(--ink); }
.nav-link.active::after { width: 100%; }

/* ---- Sticky header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 247, 241, 0.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.site-header.scrolled { border-bottom-color: var(--border); }

/* ---- Mobile menu ---- */
.mobile-menu {
  position: fixed;
  inset: 0;
  background: var(--paper);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.5rem 2.5rem;
  gap: 1.75rem;
  overflow-y: auto;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9375rem;
  border-radius: 6px;
  padding: 0.7rem 1.5rem;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.1s;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* Primary CTA: electric blue intentional contrast against warm bg */
.btn-primary,
.btn-cta {
  background: var(--ink-cta);
  color: #fff;
  border-color: var(--ink-cta);
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.22);
}
.btn-primary:hover,
.btn-cta:hover {
  background: var(--ink-cta-hover);
  box-shadow: 0 4px 18px rgba(30, 64, 175, 0.32);
}

/* Clay accent button */
.btn-clay {
  background: var(--clay);
  color: #fff;
  border-color: var(--clay);
  box-shadow: 0 2px 8px rgba(181, 70, 45, 0.22);
}
.btn-clay:hover {
  background: #a33d27;
  box-shadow: 0 4px 16px rgba(181, 70, 45, 0.3);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}
.btn-outline:hover {
  border-color: var(--ink-soft);
  background: var(--surface);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--ink); background: var(--surface); }

/* Accent aliases (backward compat with common.js) */
.btn-accent { background: var(--clay); color: #fff; border-color: var(--clay); box-shadow: 0 2px 8px rgba(181,70,45,0.22); }
.btn-accent:hover { background: #a33d27; }

/* ---- Forms ---- */
.input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  padding: 0.7rem 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.18s, box-shadow 0.18s;
  outline: none;
  line-height: 1.5;
}
.input:focus { border-color: var(--ink-soft); box-shadow: 0 0 0 3px rgba(68,58,48,0.08); }
.input.error { border-color: #C0392B; }
.input-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.input-error {
  font-size: 0.8125rem;
  color: #C0392B;
  margin-top: 0.3rem;
}

/* ---- Tier radio card ---- */
.tier-card {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  background: #fff;
}
.tier-card:has(input:checked) {
  border-color: var(--ink-cta);
  background: #EFF3FC;
}
.tier-card.selected {
  border-color: var(--ink-cta);
  background: #EFF3FC;
}

/* ---- Pricing cards ---- */
.pricing-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 2rem 1.75rem;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  position: relative;
}
.pricing-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(181, 70, 45, 0.08), 0 2px 8px rgba(28, 24, 20, 0.06);
}
.pricing-card.card-popular {
  border-color: var(--clay);
  background: #fff;
}
.pricing-card.card-popular:hover {
  box-shadow: 0 8px 32px rgba(181, 70, 45, 0.14), 0 2px 8px rgba(28, 24, 20, 0.06);
}

/* Popular badge */
.badge-popular {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  background: var(--moss);
  padding: 3px 10px;
  border-radius: 99px;
  line-height: 1.8;
}

/* Price display */
.price-display {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: clamp(3.5rem, 6vw, 5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}
.price-display .currency {
  font-size: 0.45em;
  font-weight: 500;
  vertical-align: super;
  line-height: 0;
  color: var(--ink-soft);
}
.price-display .period {
  font-family: var(--font-mono);
  font-size: 0.28em;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.05em;
}

/* ---- Check marks ---- */
.check-yes {
  color: var(--moss);
  font-size: 0.875rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.check-no {
  color: var(--border);
  font-size: 0.875rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ---- Comparison table ---- */
.compare-table { width: 100%; border-collapse: collapse; }
.compare-table th,
.compare-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  font-size: 0.9rem;
}
.compare-table th {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table td:first-child { color: var(--ink-soft); }
.compare-table .col-pro { background: rgba(240, 234, 222, 0.5); }

/* ---- FAQ accordion ---- */
.faq-answer {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 0;
  opacity: 0;
}
.faq-answer.open {
  max-height: 600px;
  opacity: 1;
}

/* ---- Toggle switch (pricing) ---- */
.toggle-track {
  width: 52px;
  height: 28px;
  background: var(--border);
  border-radius: 99px;
  position: relative;
  transition: background 0.2s;
  cursor: pointer;
  border: none;
}
.toggle-track.on { background: var(--ink-cta); }
.toggle-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.toggle-track.on .toggle-thumb { transform: translateX(24px); }

/* ---- Account sidebar layout ---- */
.account-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 60px);
}
@media (max-width: 768px) {
  .account-layout { grid-template-columns: 1fr; }
}

.account-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
@media (max-width: 768px) {
  .account-sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
  cursor: pointer;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}
.sidebar-nav-item:hover { color: var(--ink); background: var(--paper); }
.sidebar-nav-item.active { color: var(--clay); border-left-color: var(--clay); background: var(--paper); font-weight: 500; }

/* ---- Status cards (account overview) ---- */
.status-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
}

/* ---- Step circle ---- */
.step-circle {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  font-optical-sizing: auto;
  color: var(--clay);
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--surface);
}

/* ---- Inline alerts ---- */
.alert {
  padding: 0.8rem 1rem;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.5;
}
.alert-error { background: #FEF2F0; color: #9B2C2C; border: 1px solid #FED7D2; }
.alert-success { background: #F0FAF4; color: #1B5E3B; border: 1px solid #B7EBD0; }
.alert-info { background: #EFF4FF; color: #1E3A8A; border: 1px solid #BFDBFE; }

/* ---- Skeleton loader ---- */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 5px;
  min-height: 1em;
  display: inline-block;
  width: 100%;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Spinner ---- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Cookie banner ---- */
#cookie-banner {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 999;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.85rem;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(28,24,20,0.22);
}
#cookie-banner a { color: var(--clay-soft); text-underline-offset: 3px; }
#cookie-banner .cookie-btns { display: flex; gap: 0.6rem; }
#cookie-banner .btn-cookie-all {
  background: var(--ink-cta); color: #fff; border: none; border-radius: 5px;
  padding: 0.45rem 0.9rem; font-size: 0.8125rem; font-weight: 500; cursor: pointer; font-family: var(--font-body);
}
#cookie-banner .btn-cookie-ess {
  background: transparent; color: var(--border); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 5px; padding: 0.45rem 0.9rem; font-size: 0.8125rem; cursor: pointer; font-family: var(--font-body);
}

/* ---- Geo-block ---- */
.blocked-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

/* ---- Footer decorative wordmark ---- */
.footer-wordmark-bg {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: clamp(4rem, 12vw, 10rem);
  font-weight: 900;
  font-style: italic;
  color: var(--border);
  opacity: 0.55;
  line-height: 0.9;
  user-select: none;
  pointer-events: none;
  overflow: hidden;
  white-space: nowrap;
}

/* ---- Scroll-reveal animation ---- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.reveal.visible {
  opacity: 1;
  transform: none;
}

/* ---- Page-load stagger (hero only, CSS-driven) ---- */
.stagger-1 { animation: fadeUp 0.6s 0.05s both ease; }
.stagger-2 { animation: fadeUp 0.6s 0.12s both ease; }
.stagger-3 { animation: fadeUp 0.6s 0.2s both ease; }
.stagger-4 { animation: fadeUp 0.6s 0.28s both ease; }
.stagger-5 { animation: fadeUp 0.6s 0.36s both ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---- Legal prose ---- */
.prose h2 {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 600;
  font-optical-sizing: auto;
  color: var(--ink);
  margin: 2.5rem 0 0.75rem;
}
.prose h3 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--ink);
  margin: 1.75rem 0 0.5rem;
}
.prose p { margin: 0.85rem 0; color: var(--ink-soft); line-height: 1.75; }
.prose ul, .prose ol { padding-left: 1.4rem; margin: 0.85rem 0; }
.prose li { margin: 0.4rem 0; color: var(--ink-soft); line-height: 1.7; }
.prose a { color: var(--ink-cta); text-underline-offset: 3px; }
.prose strong { color: var(--ink); }
.prose code { font-family: var(--font-mono); font-size: 0.875em; background: var(--surface); padding: 1px 5px; border-radius: 3px; }

/* ---- Responsive helpers ---- */
@media (max-width: 680px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
}
@media (min-width: 681px) {
  .mobile-only { display: none !important; }
}

/* ---- Print ---- */
@media print {
  nav, footer, #cookie-banner, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}

/* ---- Max tier card (white bg with clay accent) ---- */
.pricing-card.card-max {
  border-color: var(--clay);
  background: #fff;
}
.pricing-card.card-max:hover {
  box-shadow: 0 8px 32px rgba(181, 70, 45, 0.14), 0 2px 8px rgba(28, 24, 20, 0.06);
}

/* ---- Language switcher ---- */
#lang-switcher button:hover { color: var(--ink) !important; }
#lang-switcher-mobile { margin-top: 0.35rem; }

/* ---- Promo code section ---- */
#promo-section { animation: fadeUp 0.3s ease both; }
#promo-toggle-btn:hover { color: var(--ink-cta) !important; }
#promo-feedback { display: block; }
