:root {
  --bg: #FAF8F3;
  --surface: #FFFFFF;
  --ink: #17251C;
  --muted: #5E6B62;
  --line: #E3DDD0;
  --deep: #14482D;
  --deep-hover: #0F3A24;
  --green: #2E7D4A;
  --gold: #E3A325;
  --gold-text: #8A5A00;
  --gold-soft: #FBEFD6;
  --error: #B42318;
  --error-bg: #FDECEA;
  --font: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-si: "Noto Sans Sinhala", "Nunito Sans", system-ui, sans-serif;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

body.lang-si { font-family: var(--font-si); }

a { color: inherit; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============ One-screen layout ============ */
/* Fits one screen on phones and desktops; on very short screens
   (or with the keyboard open) the page can still scroll instead of cutting content. */
body.cs {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow-x: hidden;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

/* ============ Cursor glow (mouse / trackpad only) ============ */
.cursor-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: radial-gradient(
    420px circle at var(--x, 50%) var(--y, 40%),
    rgba(227, 163, 37, 0.26),
    rgba(227, 163, 37, 0.10) 45%,
    transparent 70%
  );
}

body.glow-on .cursor-glow { opacity: 1; }

/* ============ Click burst: gold ripple + sparkles ============ */
.click-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.fx-ripple {
  position: absolute;
  width: 0;
  height: 0;
  border: 2px solid rgba(227, 163, 37, 0.9);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(227, 163, 37, 0.18), transparent 70%);
  transform: translate(-50%, -50%);
  animation: fx-ripple 2.2s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.fx-ripple.late {
  animation-delay: 0.3s;
  animation-duration: 2.6s;
  border-color: rgba(227, 163, 37, 0.55);
  background: none;
}

@keyframes fx-ripple {
  to { width: 320px; height: 320px; opacity: 0; }
}

.fx-spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #E3A325;
  box-shadow: 0 0 8px rgba(227, 163, 37, 0.8);
  transform: translate(-50%, -50%);
  animation: fx-spark 1.8s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}

@keyframes fx-spark {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  65% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.4);
  }
}

.cs-top,
.cs-main,
.cs-foot {
  position: relative;
  z-index: 1;
}

/* ============ Top bar ============ */
.cs-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.brand-mark { width: 32px; height: 32px; }

.brand-name {
  font-family: var(--font);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--deep);
  letter-spacing: 0.2px;
}

.brand-name span { color: var(--gold-text); }

.lang-toggle {
  min-height: 40px;
  padding: 10px 14px;
  font: 600 0.875rem/1 var(--font-si);
  color: var(--deep);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.lang-toggle:hover { border-color: #CFC7B6; }

/* ============ Centre content ============ */
.cs-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(4px, 2vh, 32px) var(--gutter) clamp(20px, 6vh, 64px);
  text-align: center;
}

.badge {
  margin: 0 0 clamp(12px, 2.4vh, 20px);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--gold-text);
  background: var(--gold-soft);
}

body.lang-si .badge { letter-spacing: 0; font-size: 0.8rem; text-transform: none; }

h1 {
  margin: 0 0 clamp(20px, 4vh, 36px);
  font-size: clamp(1.9rem, 8.4vw, 3.1rem);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--deep);
  text-wrap: balance;
}

body.lang-si h1 {
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  line-height: 1.35;
  letter-spacing: 0;
}

.lead {
  max-width: 30em;
  margin: 0 0 clamp(18px, 3.6vh, 32px);
  font-size: clamp(1rem, 4vw, 1.125rem);
  color: var(--muted);
  text-wrap: pretty;
}

/* ============ Sign-up ============ */
.panel { width: 100%; }

.join {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.join input[type="email"] {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 0 18px;
  font: inherit;
  font-size: 1rem; /* 16px stops iOS zooming on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
}

.join input::placeholder { color: #8C978F; }

.join input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 125, 74, 0.15);
}

.btn {
  min-height: 52px;
  padding: 0 24px;
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  color: #FFFFFF;
  background: var(--deep);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, transform 0.1s;
}

.btn:hover { background: var(--deep-hover); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.7; cursor: progress; }

@media (min-width: 480px) {
  .join { flex-direction: row; }
  .join input[type="email"],
  .btn { min-height: 50px; }
}

.btn:focus-visible,
.lang-toggle:focus-visible,
.region:focus-visible,
.link-btn:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(46, 125, 74, 0.45);
  outline-offset: 2px;
}

.hp {
  position: absolute;
  left: -10000px;
  width: 1px; height: 1px;
  opacity: 0;
}

/* Step 2 — region */
.step-q {
  margin: 0 0 12px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--deep);
}

.step-q:focus,
.done-title:focus { outline: none; }

.regions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (min-width: 480px) {
  .regions { grid-template-columns: repeat(3, 1fr); }
}

.region {
  min-height: 46px;
  padding: 0 12px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.region:hover { border-color: var(--green); }

.region[aria-pressed="true"] {
  color: #FFFFFF;
  background: var(--deep);
  border-color: var(--deep);
}

.region[disabled] { cursor: progress; }

.link-btn {
  margin-top: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}

/* Step 3 — done */
.done {
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.done-title {
  margin: 0 0 4px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--deep);
}

.tick {
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  margin-right: 4px;
  border-radius: 50%;
  font-size: 0.95rem;
  color: #FFFFFF;
  background: var(--green);
  vertical-align: 2px;
}

.done-sub {
  margin: 0;
  color: var(--muted);
}

.done-sub a {
  font-weight: 700;
  color: var(--green);
  text-decoration: none;
  white-space: nowrap;
}

.msg {
  margin: 10px 0 0;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--error);
  background: var(--error-bg);
  border-radius: 10px;
}

.fine {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.fine a { color: var(--ink); }

/* Trust row */
.trust {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  margin: clamp(18px, 3.4vh, 32px) 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.trust li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trust svg {
  width: 16px; height: 16px;
  fill: none;
  stroke: var(--green);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============ Footer ============ */
.cs-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 10px;
  padding: 12px var(--gutter) 16px;
  font-size: 0.8rem;
  color: var(--muted);
}

.cs-foot a {
  font-weight: 600;
  text-decoration: none;
}

.cs-foot a:hover { color: var(--ink); text-decoration: underline; }

/* Short screens (small phones, landscape): tighten so it still fits */
@media (max-height: 720px) {
  .cs-top { padding-top: 12px; padding-bottom: 4px; }
  h1 { font-size: clamp(1.7rem, 7.4vw, 2.6rem); }
  body.lang-si h1 { font-size: clamp(1.45rem, 6.2vw, 2.2rem); }
}

/* While choosing a region on a short screen, hide extras so the step fits */
@media (max-height: 760px) {
  body[data-step="region"] .badge,
  body[data-step="region"] .lead,
  body[data-step="region"] .trust { display: none; }
  .region { min-height: 42px; font-size: 0.9rem; }
}

@media (max-height: 620px) {
  .brand-mark { width: 28px; height: 28px; }
  .badge { margin-bottom: 10px; }
  .lead { font-size: 0.95rem; }
  .trust { display: none; }
  body[data-step="done"] .badge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .cursor-glow,
  .click-fx { display: none; }
}

/* ============ Privacy page ============ */
.doc-top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.doc-top .cs-top { max-width: 760px; }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px var(--gutter) 56px;
}

.page h1 {
  font-size: 2rem;
  letter-spacing: -0.01em;
}

.page h2 {
  margin-top: 28px;
  font-size: 1.2rem;
  color: var(--deep);
}

.page a { color: var(--green); font-weight: 600; }
