:root {
  --cobalt: #1f2bff;
  --deep: #0a0f5c;
  --ink: #060a4a;
  --pearl: #f4f1ff;
  --lilac: #e4e0ff;
  --peach: #ffb89a;
  --danger: #b3122b;
  --pad: 20px;

  /* overridden per language from lang/*.json -> _meta */
  --font-lang: "Bricolage Grotesque";
  --tracking: -0.03em;
  --leading: 1.02;
  --h1-scale: 1;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--cobalt);
  color: var(--pearl);
}

body {
  font-family: var(--font-lang), "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--peach); outline-offset: 3px; }

#gl {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- layout ---------- */

.app {
  position: fixed; inset: 0; z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  pointer-events: none;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(var(--pad), env(safe-area-inset-right)) 0 max(var(--pad), env(safe-area-inset-left));
}

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px;
  color: var(--pearl); text-decoration: none;
  font-size: 1.5rem; font-weight: 700; font-stretch: 85%;
  letter-spacing: -0.04em;
  pointer-events: auto;
}
.mark {
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff 0 14%, var(--pearl) 26%, #aab0ff 62%, var(--peach) 100%);
}

main {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
}

#stage { position: relative; min-height: 0; }

.copy {
  display: grid; gap: 18px;
  padding: 0 max(var(--pad), env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left));
}

h1 {
  margin: 0;
  font-size: calc(clamp(2rem, 9.4vw, 3rem) * var(--h1-scale));
  font-weight: 650; font-stretch: 85%;
  line-height: var(--leading);
  letter-spacing: var(--tracking);
  text-wrap: balance;
}

.hint {
  position: absolute; inset-inline: 0; bottom: 4px; margin: 0;
  text-align: center; font-size: 0.85rem; opacity: 0.75;
  transition: opacity 0.5s;
}
.touched .hint { opacity: 0; }

/* ---------- controls ---------- */

.lang { position: relative; display: inline-flex; align-items: center; color: var(--pearl); pointer-events: auto; }
.lang select {
  appearance: none; -webkit-appearance: none;
  min-height: 44px;
  padding-block: 0; padding-inline: 40px 38px;
  border-radius: 999px;
  border: 1.5px solid rgb(244 241 255 / 0.4);
  background: rgb(255 255 255 / 0.08);
  color: var(--pearl);
  font: inherit; font-size: 0.95rem; font-weight: 550;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.lang option { color: var(--ink); background: var(--pearl); }
.lang svg { position: absolute; top: 50%; translate: 0 -50%; pointer-events: none; }
.lang .globe { inset-inline-start: 14px; width: 18px; height: 18px; }
.lang .chev  { inset-inline-end: 14px; width: 14px; height: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 44px; padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid rgb(244 241 255 / 0.4);
  background: rgb(255 255 255 / 0.06);
  color: inherit;
  font: inherit; font-size: 0.92rem; font-weight: 550;
  cursor: pointer; pointer-events: auto;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}
.chip[aria-pressed="true"] { background: var(--pearl); color: var(--cobalt); border-color: var(--pearl); }

.cta {
  width: 100%; min-height: 60px;
  border: 0; border-radius: 999px;
  background: var(--pearl); color: var(--cobalt);
  font: inherit; font-size: 1.1rem; font-weight: 650;
  cursor: pointer; pointer-events: auto;
  transition: transform 0.15s, background 0.2s;
}
.cta:active { transform: scale(0.97); }
@media (hover: hover) { .cta:hover { background: #fff; } }

/* ---------- no-WebGL fallback ---------- */

.orb { display: none; }
.no-gl .orb {
  display: block;
  position: absolute; left: 50%; top: 50%;
  width: min(86%, 86vh, 420px); aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 32% 28%, #fff 0 6%, var(--pearl) 14%, #8d96ff 42%, var(--deep) 80%);
  box-shadow: 0 0 120px rgb(255 184 154 / 0.35);
  animation: float 6s ease-in-out infinite;
}
@keyframes float { 50% { transform: translate(-50%, -54%); } }

/* ---------- contact sheet ---------- */

dialog {
  border: 0; padding: 0;
  margin: auto auto 0;
  width: 100%; max-width: 560px; max-height: 92dvh;
  overflow: auto;
  background: var(--pearl); color: var(--ink);
  border-radius: 28px 28px 0 0;
  font-family: inherit;
  touch-action: auto;
}
dialog[open] { animation: sheet-up 0.38s cubic-bezier(0.2, 0.9, 0.2, 1); }
dialog.closing { animation: sheet-down 0.18s ease-in forwards; }
dialog::backdrop { background: rgb(6 10 74 / 0.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
dialog :focus-visible { outline-color: var(--cobalt); }

@keyframes sheet-up   { from { transform: translateY(100%); } }
@keyframes sheet-down { to   { transform: translateY(100%); } }

.sheet {
  position: relative;
  padding: 26px var(--pad) calc(var(--pad) + env(safe-area-inset-bottom));
}
form, .sent { display: grid; gap: 16px; }

.sheet h2 {
  margin: 0; padding-inline-end: 52px;
  font-size: 1.6rem; font-weight: 650; font-stretch: 85%;
  line-height: calc(var(--leading) + 0.08);
  letter-spacing: var(--tracking);
  outline: none;
}
.sent p { margin: 0; font-size: 1.05rem; line-height: 1.5; }

.close {
  position: absolute; top: 14px; inset-inline-end: 14px;
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%;
  background: rgb(31 43 255 / 0.08); color: var(--cobalt);
  cursor: pointer;
}
.close svg { width: 20px; height: 20px; }

.field { display: grid; gap: 6px; }
label { font-size: 0.92rem; font-weight: 560; }
input, textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid transparent; border-radius: 16px;
  background: var(--lilac); color: var(--ink);
  font: inherit; font-size: 1rem;
  resize: vertical;
  user-select: text; -webkit-user-select: text;
}
input:focus-visible, textarea:focus-visible {
  outline: none; background: #fff; border-color: var(--cobalt);
  box-shadow: 0 0 0 4px rgb(31 43 255 / 0.2);
}
[aria-invalid="true"] { border-color: var(--danger); }
.err { margin: 0; color: var(--danger); font-size: 0.88rem; }
.err:empty { display: none; }
.status { margin: 0; min-height: 0; color: var(--danger); font-size: 0.95rem; line-height: 1.4; }
.status:empty { display: none; }

.hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

.send {
  min-height: 58px; width: 100%;
  border: 0; border-radius: 999px;
  background: var(--cobalt); color: var(--pearl);
  font: inherit; font-size: 1.05rem; font-weight: 650;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
}
.send:active { transform: scale(0.98); }
.send[disabled] { opacity: 0.65; cursor: progress; }

/* ---------- wide / landscape ---------- */

@media (min-aspect-ratio: 1/1) and (min-width: 640px) {
  .bar { padding-inline: clamp(24px, 5vw, 72px); }
  main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  #stage { grid-column: 2; grid-row: 1; }
  .copy {
    grid-column: 1; grid-row: 1; align-self: end;
    max-width: 44rem;
    padding: 0 clamp(24px, 5vw, 72px) clamp(24px, 6vh, 64px);
    gap: 22px;
  }
  h1 { font-size: calc(clamp(2.1rem, min(5.6vw, 9.5vh), 5.6rem) * var(--h1-scale)); }
  .cta { width: auto; justify-self: start; padding-inline: 38px; }
  dialog { margin: auto; border-radius: 28px; }
}
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  h1 { font-size: calc(min(5.6vw, 8vh) * var(--h1-scale)); }
  .copy { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  dialog[open], dialog.closing, .no-gl .orb { animation: none; }
  .hint, .chip, .cta, .send { transition: none; }
}
