@font-face {
  font-family: 'Bricolage';
  src: url('/fonts/bricolage-latin.woff2') format('woff2');
  font-weight: 500 800;
  font-display: swap;
}

:root {
  --cobalt: #2B3FE0;
  --cobalt-deep: #1F2FB0;
  --ink: #151A3B;
  --mist: #EEF0FA;
  --paper: #FFFFFF;
  --lime: #DDF35A;
  --slate: #5B6386;
  --line: #CDD2EA;
  --error: #C2264B;
  --display: 'Bricolage', ui-sans-serif, system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  --pad: clamp(24px, 4vw, 56px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

/* ---------- Layout: split in landscape, stacked in portrait ---------- */
.kiosk {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
}
@media (max-aspect-ratio: 1/1) {
  .kiosk { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
}

.hello {
  background: var(--cobalt);
  color: var(--paper);
  padding: calc(var(--pad) + env(safe-area-inset-top)) var(--pad) calc(var(--pad) + 52px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: hidden;
}
/* A single oversized ring: the booth's "come closer" gesture. */
.hello::after {
  content: '';
  position: absolute;
  width: 140%;
  aspect-ratio: 1;
  right: -70%;
  top: -55%;
  border-radius: 50%;
  border: clamp(28px, 5vw, 64px) solid var(--cobalt-deep);
  pointer-events: none;
}
.hello > * { position: relative; z-index: 1; }

.event {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
  background: var(--lime);
  color: var(--ink);
  border: 0;
  padding: 6px 14px 7px;
  border-radius: 999px;
  cursor: pointer;
}
.event:focus-visible { outline: 3px solid var(--paper); outline-offset: 3px; }

.greeting {
  margin: auto 0 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(44px, 6.2vw, 84px);
  line-height: 0.98;
  letter-spacing: -0.03em;
  font-variation-settings: 'opsz' 96;
}
.greeting-line { display: block; }
.greeting-ask { color: var(--lime); margin-top: 0.12em; }
#greet { transition: opacity 0.25s ease; overflow-wrap: anywhere; }
#greet.swap { opacity: 0; }

.hello-note {
  margin: 0;
  max-width: 34ch;
  font-size: 19px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.86);
}

@media (max-aspect-ratio: 1/1) {
  .hello { gap: 16px; padding-bottom: 28px; position: relative; height: auto; }
  .greeting { font-size: clamp(40px, 7vw, 64px); margin-top: 4px; }
  .hello-note { font-size: 17px; max-width: 46ch; }
  .card { gap: 18px; }
  textarea { min-height: 88px; }
  .hello::after { width: 80%; right: -30%; top: -60%; }
}

/* ---------- Form ---------- */
.card {
  padding: calc(var(--pad) + env(safe-area-inset-top)) var(--pad) calc(var(--pad) + 48px);
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  align-self: center;
}
@media (max-aspect-ratio: 1/1) { .card { padding-top: 36px; align-self: start; } }

.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 620px) { .row.two { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field-label { font-size: 16px; font-weight: 600; color: var(--ink); padding: 0; }
.optional { font-weight: 400; color: var(--slate); }

input, textarea {
  font: inherit;
  font-size: 20px; /* >=16px keeps iOS from zooming on focus */
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 15px 16px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}
textarea { resize: none; line-height: 1.4; min-height: 108px; }
input::placeholder, textarea::placeholder { color: #9AA0BE; }
input:focus, textarea:focus { border-color: var(--cobalt); box-shadow: 0 0 0 4px rgba(43, 63, 224, 0.16); }
.field.has-error input, .field.has-error textarea { border-color: var(--error); }
.field-error { color: var(--error); font-size: 15px; min-height: 0; }
.field-error:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip span {
  display: inline-block;
  padding: 11px 18px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-size: 17px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  user-select: none;
  -webkit-user-select: none;
}
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--lime); }
.chip input:focus-visible + span { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.chip input:active + span { transform: scale(0.97); }
.other-input { margin-top: 4px; }

.actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 6px; }
.submit {
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: var(--lime);
  border: 0;
  border-radius: 999px;
  padding: 20px 40px;
  min-height: 68px;
  cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(21, 26, 59, 0.18);
  transition: transform 0.1s ease;
}
.submit:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(21, 26, 59, 0.18); }
.submit:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; }
.submit[disabled] { opacity: 0.6; }
.consent { margin: 0; font-size: 15px; color: var(--slate); max-width: 30ch; line-height: 1.4; }

/* ---------- Sync status: a dot inside the CES badge ---------- */
.dot { width: 10px; height: 10px; border-radius: 50%; background: #1E9E5A; flex: none; box-shadow: 0 0 0 2px rgba(21, 26, 59, 0.12); }
.event[data-state='waiting'] .dot { background: #E08A00; }
.event[data-state='sending'] .dot { background: var(--cobalt); animation: pulse 1s ease-in-out infinite; }
.event[data-state='problem'] .dot { background: var(--error); }
.status-text { font: 600 15px var(--body); }
.status-text:empty { display: none; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ---------- Thank-you ---------- */
.thanks {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--cobalt);
  color: var(--paper);
  display: grid;
  place-items: center;
  padding: var(--pad);
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.thanks[hidden] { display: none; }
@keyframes rise { from { clip-path: circle(0% at 50% 100%); } to { clip-path: circle(150% at 50% 100%); } }
.thanks-inner { max-width: 760px; text-align: left; }
.thanks-title {
  margin: 0 0 20px;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(56px, 9vw, 120px);
  line-height: 0.95;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}
.thanks-body { margin: 0 0 40px; font-size: 22px; line-height: 1.45; color: rgba(255, 255, 255, 0.9); max-width: 36ch; }
.thanks-body strong { color: var(--lime); font-weight: 600; overflow-wrap: anywhere; }
.next {
  font: 700 22px var(--display);
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 999px;
  padding: 18px 34px;
  cursor: pointer;
}
.countdown { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--cobalt-deep); }
.countdown span { display: block; height: 100%; width: 100%; background: var(--lime); transform-origin: left; }
.countdown span.run { animation: drain var(--dur, 9s) linear forwards; }
@keyframes drain { to { transform: scaleX(0); } }

/* ---------- Staff panel ---------- */
.staff {
  border: 0;
  border-radius: 24px;
  padding: 0;
  width: min(560px, 92vw);
  max-height: 86vh;
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(21, 26, 59, 0.35);
}
.staff::backdrop { background: rgba(21, 26, 59, 0.5); }
.staff-inner { padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.staff h2 { margin: 0; font: 800 30px var(--display); letter-spacing: -0.02em; }
.staff-stats { margin: 0; display: grid; gap: 10px; }
.staff-stats div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.staff-stats dt { color: var(--slate); }
.staff-stats dd { margin: 0; font-weight: 600; text-align: right; }
.staff-error { margin: 0; color: var(--error); font-size: 15px; }
.staff-list { margin: 0; padding: 0; list-style: none; max-height: 180px; overflow: auto; font-size: 15px; }
.staff-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.staff-list li small { color: var(--slate); }
.staff-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.staff-actions button {
  font: 600 17px var(--body);
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  cursor: pointer;
}
.staff-actions button.ghost { background: transparent; color: var(--ink); }
.staff-hint { margin: 0; font-size: 14px; color: var(--slate); line-height: 1.45; }

/* ---------- Add to Home Screen trigger (bottom left) ---------- */
.install-btn {
  position: fixed;
  left: calc(16px + env(safe-area-inset-left));
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 14px var(--body);
  color: var(--ink);
  background: var(--lime);
  border: 0;
  border-radius: 999px;
  padding: 9px 16px 9px 12px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(21, 26, 59, 0.22);
}
.install-btn:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
@media (max-aspect-ratio: 1/1) {
  .install-btn { position: static; align-self: flex-start; margin-top: 8px; box-shadow: none; border: 2px solid var(--line); background: var(--paper); }
}

/* ---------- Add to Home Screen sheet ---------- */
.install {
  border: 0;
  border-radius: 28px;
  padding: 0;
  width: min(600px, 92vw);
  max-height: 90vh;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 30px 80px rgba(21, 26, 59, 0.4);
}
.install::backdrop { background: rgba(31, 47, 176, 0.72); }
.install-inner { padding: 34px 34px 28px; display: flex; flex-direction: column; gap: 18px; }
.install h2 { margin: 0; font: 800 34px/1.05 var(--display); letter-spacing: -0.025em; }
.install-lead { margin: 0; font-size: 18px; line-height: 1.5; color: var(--slate); max-width: 46ch; }
.install-steps { margin: 4px 0 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 12px; }
.install-steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 34px 52px 1fr;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  line-height: 1.4;
  background: var(--mist);
  border-radius: 18px;
  padding: 14px 16px;
}
.install-steps li::before { content: counter(step); grid-column: 1; grid-row: 1; font: 800 26px var(--display); color: var(--cobalt); text-align: center; }
.install-icon { grid-column: 2; grid-row: 1; width: 52px; height: 52px; border-radius: 14px; background: var(--paper); color: #0A84FF; display: grid; place-items: center; }
.install-app img { border-radius: 8px; }
.install-steps li > span:last-child { grid-column: 3; grid-row: 1; }
.install-warn { margin: 0; padding: 14px 16px; border-radius: 14px; background: #FDECEF; color: var(--error); font-size: 16px; line-height: 1.45; }
.install-later {
  align-self: flex-start;
  font: 600 17px var(--body);
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
