:root {
  --paper: #F5EFE5;
  --paper-2: #FBF7F1;
  --ink: #0B2A57;
  --ink-soft: #4E6280;
  --ink-faint: #8C9AB0;
  --line: rgba(11, 42, 87, 0.14);
  --amber: #E8A53A;
  --petal: #F4C63D;
  --terra: #A9603F;
  --sans: 'Didact Gothic', 'Noto Sans Ethiopic', system-ui, sans-serif;
  --serif: 'Cookie', 'Noto Sans Ethiopic', cursive;
  --script: 'Cookie', cursive; /* the Latin "Kidan" wordmark, in both languages */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --panel-w: min(680px, 54vw);
  color-scheme: light;
}

html:lang(am) {
  --sans: 'Noto Sans Ethiopic', 'Didact Gothic', system-ui, sans-serif;
  --serif: 'Noto Sans Ethiopic', 'Didact Gothic', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #14110F;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }

/* ---------- Photo carousel ---------- */
.carousel {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #14110F;
  transition: left 0.9s var(--ease), bottom 0.9s var(--ease);
}
.mode-quiz .carousel, .mode-done .carousel { left: var(--panel-w); }
.slides, .slide { position: absolute; inset: 0; margin: 0; }
.slide { opacity: 0; transition: opacity 1.4s ease; }
.slide.active { opacity: 1; z-index: 1; }
.slide.leaving { opacity: 1; z-index: 0; transition: none; }
.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: var(--origin);
  transform: scale(1.12);
}
.slide.active img, .slide.leaving img { animation: kenburns 9s cubic-bezier(0.2, 0.6, 0.3, 1) forwards; }
@keyframes kenburns { from { transform: scale(1.12); } to { transform: scale(1); } }
.carousel::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(10, 8, 6, 0.55) 0%, rgba(10, 8, 6, 0) 22%),
    linear-gradient(0deg, rgba(10, 8, 6, 0.5) 0%, rgba(10, 8, 6, 0) 32%);
}
.mode-welcome .carousel::after {
  background:
    linear-gradient(90deg, rgba(10, 8, 6, 0.8) 0%, rgba(10, 8, 6, 0.35) 55%, rgba(10, 8, 6, 0) 78%),
    linear-gradient(180deg, rgba(10, 8, 6, 0.5) 0%, rgba(10, 8, 6, 0) 22%),
    linear-gradient(0deg, rgba(10, 8, 6, 0.6) 0%, rgba(10, 8, 6, 0) 40%);
}
.carousel-ui {
  position: absolute;
  z-index: 3;
  right: 28px;
  bottom: 26px;
  display: flex;
  align-items: center;
  gap: 18px;
  color: #fff;
}
.slide-label {
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.slide-label.in { opacity: 1; transform: none; }
.dots { display: flex; gap: 8px; }
.dot {
  width: 8px; height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: width 0.4s var(--ease), background 0.3s;
}
.dot[aria-current='true'] { width: 26px; background: #fff; }
#confetti {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 30;
  pointer-events: none;
}

/* ---------- Loader ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  gap: 14px;
  justify-items: center;
  background: var(--paper);
  transition: opacity 0.9s var(--ease), visibility 0.9s;
}
.loader-name { font-family: var(--script); font-size: 52px; line-height: 1; }
.loader-line { width: 120px; height: 2px; background: var(--line); overflow: hidden; border-radius: 2px; }
.loader-line span { display: block; height: 100%; width: 40%; background: var(--ink); animation: load 1.1s var(--ease) infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
body:not(.is-loading) .loader { opacity: 0; visibility: hidden; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  z-index: 10;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px 28px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.01em;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { font-family: var(--script); font-size: 34px; line-height: 1; letter-spacing: 0; }
.tagline { color: var(--ink-soft); font-weight: 400; }
.lang { justify-self: end; display: flex; gap: 6px; align-items: center; color: var(--ink-faint); }
.lang button {
  background: none; border: 0; padding: 4px 2px; cursor: pointer; color: var(--ink-faint);
  font-weight: 400; border-bottom: 1.5px solid transparent;
}
.lang button[aria-pressed='true'] { color: var(--ink); border-bottom-color: var(--ink); }
/* Over the photo, the top bar turns light. */
.mode-welcome .topbar, .mode-welcome .tagline { color: #fff; }
.mode-welcome .lang, .mode-quiz .lang, .mode-done .lang,
.mode-welcome .lang button, .mode-quiz .lang button, .mode-done .lang button { color: rgba(255, 255, 255, 0.65); }
.mode-welcome .lang button[aria-pressed='true'], .mode-quiz .lang button[aria-pressed='true'], .mode-done .lang button[aria-pressed='true'] { color: #fff; border-bottom-color: #fff; }
.mode-quiz .tagline, .mode-done .tagline { visibility: hidden; }

/* ---------- Progress ---------- */
.progress {
  position: fixed;
  z-index: 11;
  top: 0; left: 0;
  width: var(--panel-w);
  height: 3px;
  background: transparent;
  opacity: 0;
  transition: opacity 0.4s;
}
.progress span {
  display: block; height: 100%; background: var(--amber);
  transform-origin: left; transform: scaleX(0);
  transition: transform 0.7s var(--ease);
}
.mode-quiz .progress, .mode-done .progress { opacity: 1; }

/* ---------- App / panel ---------- */
#app {
  position: fixed;
  z-index: 5;
  inset: 0;
  pointer-events: none;
}
.screen {
  pointer-events: auto;
  position: absolute;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Welcome: text over the 3D room, bottom left */
.welcome {
  left: 0; bottom: 0;
  width: min(640px, 100%);
  padding: 0 28px 44px;
  overflow: visible;
}
.welcome::before {
  content: '';
  position: absolute;
  inset: -120px -160px -40px -80px;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(10, 8, 6, 0.45), rgba(10, 8, 6, 0.2) 60%, rgba(10, 8, 6, 0));
  pointer-events: none;
}
.eyebrow {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1.1;
  color: var(--ink-soft);
}
.display {
  margin: 0 0 18px;
  font-size: clamp(44px, 6.4vw, 92px);
  line-height: 0.95;
  font-weight: 400;
  letter-spacing: -0.025em;
}
/* Amharic: the script-font accents switch to Noto Sans Ethiopic at text sizes. */
html:lang(am) .eyebrow, html:lang(am) .kicker { font-size: 18px; font-weight: 600; line-height: 1.45; }
html:lang(am) .poke { font-size: 15px; line-height: 1.45; }
html:lang(am) .slide-label { font-size: 17px; font-weight: 500; }
html:lang(am) .display { font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; font-size: clamp(36px, 5vw, 72px); }
.lede { margin: 0 0 26px; font-size: 17px; line-height: 1.55; color: var(--ink-soft); max-width: 46ch; }
.welcome-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.welcome .eyebrow { color: #F1D9A8; }
.welcome .display { color: #fff; }
.welcome .lede { color: rgba(255, 255, 255, 0.84); }
.welcome .btn.primary { background: var(--paper); color: var(--ink); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); }
.welcome .poke { color: rgba(255, 255, 255, 0.72); }
.poke { font-family: var(--serif); font-size: 26px; color: var(--ink-faint); }

/* Quiz panel: a sheet of paper sliding over the left of the room */
.mode-quiz #app::before, .mode-done #app::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--panel-w);
  background: var(--paper);
  box-shadow: 30px 0 80px rgba(80, 55, 20, 0.08);
  animation: panelIn 0.9s var(--ease) both;
}
@keyframes panelIn { from { transform: translateX(-102%); } }

.step, .done, .center {
  left: 0; top: 0; bottom: 0;
  width: var(--panel-w);
  padding: 96px clamp(28px, 4.5vw, 64px) 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.step > *, .done > * { flex-shrink: 0; }
.center { align-items: flex-start; gap: 8px; }

.step-meta {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 22px;
  font-size: 13px; font-weight: 400; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-soft); font-weight: 400; font-size: 13px; }
.link:hover { color: var(--ink); }
.kicker { margin: 0 0 6px; font-family: var(--serif); font-size: 32px; line-height: 1.1; color: var(--terra); }
.q-title {
  margin: 0 0 14px;
  font-size: clamp(30px, 3.3vw, 50px);
  line-height: 1.04;
  font-weight: 400;
  letter-spacing: -0.02em;
  max-width: 22ch;
}
html:lang(am) .q-title { font-weight: 700; letter-spacing: 0; line-height: 1.3; font-size: clamp(24px, 2.6vw, 38px); max-width: 24ch; }
.help, .hint { margin: 0 0 18px; color: var(--ink-soft); font-size: 15px; }
.hint { font-size: 13px; font-weight: 400; color: var(--ink-faint); margin-bottom: 12px; }

/* Options */
.options { display: grid; gap: 10px; margin: 10px 0 8px; max-width: 520px; }
.options.grid { grid-template-columns: 1fr 1fr; max-width: 560px; }
.opt {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: var(--paper-2);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  font-size: 16px; font-weight: 400; line-height: 1.3;
  transition: transform 0.35s var(--ease), border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.3s;
}
.opt:hover { border-color: var(--ink); transform: translateX(4px); box-shadow: 0 6px 18px rgba(11, 42, 87, 0.07); }
.opt:active, .opt.flash { transform: scale(0.98); }
.opt .key {
  flex: none;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  font-size: 12px; font-weight: 400;
  color: var(--ink-soft);
  background: #fff;
  transition: inherit;
}
.opt.selected { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.opt.selected .key { background: var(--petal); border-color: var(--petal); color: var(--ink); }

.other-field { display: none; margin: 4px 0 8px; max-width: 520px; }
.other-field.show { display: block; animation: rise 0.4s var(--ease); }
.other-field span { display: block; font-size: 13px; font-weight: 400; color: var(--ink-soft); margin-bottom: 6px; }

input[type='text'], input[type='tel'] {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  padding: 13px 15px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(11, 42, 87, 0.08); }
.big-input {
  max-width: 520px;
  font-size: clamp(24px, 2.6vw, 34px) !important;
  font-weight: 400;
  padding: 10px 2px !important;
  border: 0 !important;
  border-bottom: 2px solid var(--line) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  margin: 8px 0 14px;
}
.big-input:focus { border-bottom-color: var(--ink) !important; }
.big-input::placeholder { color: var(--ink-faint); opacity: 0.6; }

/* Contact */
.contact { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; max-width: 560px; margin-top: 6px; }
.field { display: block; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span { display: block; font-size: 13px; font-weight: 400; color: var(--ink-soft); margin-bottom: 7px; }
.field em { font-style: normal; font-weight: 400; color: var(--ink-faint); margin-left: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  font-size: 14px; font-weight: 400;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.chip:hover { border-color: var(--ink); }
.chip.selected { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.error-msg { color: #B3261E; font-size: 14px; font-weight: 400; margin: 12px 0 0; }

/* Actions */
.actions { display: flex; align-items: center; gap: 16px; margin-top: 22px; }
.actions.quiet { display: none; }
.enter-hint { font-size: 12px; font-weight: 400; color: var(--ink-faint); }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 15px 24px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  font-weight: 400; font-size: 16px;
  transition: transform 0.35s var(--ease), background 0.2s, opacity 0.2s, box-shadow 0.3s;
}
.btn.primary { background: var(--ink); color: var(--paper); box-shadow: 0 10px 30px rgba(11, 42, 87, 0.22); }
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(11, 42, 87, 0.28); }
.btn.primary span { transition: transform 0.35s var(--ease); }
.btn.primary:hover span { transform: translateX(4px); }
.step .btn.primary:not(.ready) { opacity: 0.35; box-shadow: none; }

/* Done */
.done .display { font-size: clamp(42px, 5.4vw, 84px); max-width: 10ch; }
html:lang(am) .done .display { max-width: 14ch; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--ink);
  animation: spin 0.9s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Motion ---------- */
.w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.w > span { display: inline-block; transform: translateY(105%); transition: transform 0.85s var(--ease); transition-delay: calc(var(--i) * 32ms + 80ms); }
.in .w > span { transform: none; }
.reveal, .opt { opacity: 0; transform: translateY(14px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.reveal { transition-delay: 0.28s; }
.opt { transition-delay: calc(var(--i) * 45ms + 0.25s); }
.in .reveal, .in .opt { opacity: 1; transform: none; }
.in .opt { transition: transform 0.35s var(--ease), border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.3s, opacity 0.6s var(--ease) calc(var(--i) * 45ms + 0.25s); }
.welcome .reveal { transition-delay: 0.55s; }
.welcome .lede.reveal { transition-delay: 0.45s; }
.instant, .instant * { transition: none !important; }
.screen.out { opacity: 0; transform: translateY(-16px); transition: opacity 0.25s ease, transform 0.25s ease; }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Hold the welcome until the loader fades */
.is-loading #app { visibility: hidden; }

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

/* ---------- Mobile ---------- */
@media (max-width: 759px) {
  :root { --panel-w: 100vw; }
  .topbar { padding: 14px 16px; grid-template-columns: 1fr auto; }
  .tagline { display: none; }
  .welcome { padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }
  .welcome::before { inset: -80px -40px -40px -40px; }
  .display { font-size: clamp(40px, 12vw, 56px); }
  html:lang(am) .display { font-size: clamp(32px, 9vw, 44px); }
  .lede { font-size: 16px; }
  .eyebrow, .kicker { font-size: 27px; }

  .mode-quiz #app::before, .mode-done #app::before {
    top: 30vh; top: 30dvh;
    width: 100%;
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -20px 60px rgba(80, 55, 20, 0.1);
    animation-name: sheetIn;
  }
  @keyframes sheetIn { from { transform: translateY(102%); } }
  .mode-quiz .carousel, .mode-done .carousel { left: 0; bottom: calc(70vh - 28px); bottom: calc(70dvh - 28px); }
  .mode-quiz .brand, .mode-done .brand { color: #fff; }
  .carousel-ui { top: 60px; bottom: auto; right: 16px; gap: 12px; }
  .slide-label { font-size: 24px; }
  .mode-quiz .carousel-ui, .mode-done .carousel-ui { top: auto; bottom: 42px; }
  .progress { top: 30vh; top: 30dvh; left: 28px; width: calc(100% - 56px); border-radius: 3px; }
  .step, .done, .center {
    top: 30vh; top: 30dvh;
    width: 100%;
    padding: 26px 16px calc(28px + env(safe-area-inset-bottom));
    justify-content: flex-start;
  }
  .q-title { font-size: clamp(26px, 7.4vw, 34px); max-width: none; }
  html:lang(am) .q-title { font-size: clamp(21px, 6vw, 28px); }
  .options.grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .options.grid .opt { padding: 12px; gap: 10px; font-size: 14px; }
  .options.grid .opt .key { display: none; }
  .opt .key { width: 24px; height: 24px; }
  .opt:hover { transform: none; }
  .contact { grid-template-columns: 1fr; }
  .enter-hint { display: none; }
  .step-meta { margin-bottom: 14px; }
  .done .display { font-size: clamp(38px, 11vw, 52px); }
}
