/* =========================================================================
   Loyalty Survey — design system
   Clean, premium, animated. Light theme with a living gradient mesh.
   Coded by Quentin Leopold · Bachelor's Thesis 2026
   ========================================================================= */

:root {
  /* Palette */
  --indigo: #6366f1;
  --violet: #8b5cf6;
  --fuchsia: #c026d3;
  --mint: #10b981;
  --rose: #f43f5e;

  --accent: var(--indigo);
  --accent-2: var(--violet);
  --grad: linear-gradient(120deg, var(--indigo), var(--violet) 55%, var(--fuchsia));

  /* Neutrals */
  --bg: #f6f7fb;
  --ink: #14152a;
  --ink-soft: #4b4d6b;
  --ink-faint: #8a8ca6;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --line: rgba(20, 21, 42, 0.08);
  --line-strong: rgba(20, 21, 42, 0.14);

  --shadow-sm: 0 1px 2px rgba(20, 21, 42, 0.06), 0 2px 8px rgba(20, 21, 42, 0.05);
  --shadow-md: 0 8px 30px rgba(72, 50, 160, 0.12);
  --shadow-lg: 0 24px 60px rgba(72, 50, 160, 0.18);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 28px;

  --font: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0d1a;
    --ink: #f2f2fb;
    --ink-soft: #c2c3dd;
    --ink-faint: #8688ad;
    --surface: rgba(28, 29, 51, 0.66);
    --surface-solid: #181a2e;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* overflow-x: clip prevents any horizontal swipe without breaking the
   sticky top bar (unlike overflow: hidden, clip creates no scroll container). */
html { overflow-x: clip; }
body { min-height: 100vh; overflow-x: clip; }

/* Living gradient mesh background ---------------------------------------- */
.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg);
}
.bg-mesh::before,
.bg-mesh::after {
  content: "";
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  will-change: transform;
}
.bg-mesh::before {
  background: radial-gradient(circle at center, var(--violet), transparent 65%);
  top: -20vmax; left: -10vmax;
  animation: drift1 22s var(--ease) infinite alternate;
}
.bg-mesh::after {
  background: radial-gradient(circle at center, var(--indigo), transparent 65%);
  bottom: -25vmax; right: -10vmax;
  animation: drift2 26s var(--ease) infinite alternate;
}
.bg-mesh i {
  position: absolute;
  width: 40vmax; height: 40vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.28;
  background: radial-gradient(circle at center, var(--fuchsia), transparent 65%);
  top: 30%; left: 45%;
  animation: drift3 30s var(--ease) infinite alternate;
}
@keyframes drift1 { to { transform: translate(12vmax, 8vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-10vmax, -6vmax) scale(1.1); } }
@keyframes drift3 { to { transform: translate(-14vmax, 10vmax) scale(0.9); } }

@media (prefers-reduced-motion: reduce) {
  .bg-mesh::before, .bg-mesh::after, .bg-mesh i { animation: none; }
}

/* =========================================================================
   Loader — "by Quentin"
   ========================================================================= */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.7s var(--ease), visibility 0.7s;
}
#loader.is-hidden { opacity: 0; visibility: hidden; }

.loader-inner { text-align: center; padding: 24px; }

.loader-eyebrow {
  font-size: 0.82rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 14px;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease) 0.15s forwards;
}

.loader-name {
  font-size: clamp(2.1rem, 7vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.06em;
}
.loader-name span {
  display: inline-block;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0;
  transform: translateY(22px) rotate(4deg);
  animation: letterIn 0.7s var(--ease) forwards;
}
.loader-name .space { width: 0.32em; }

.loader-line {
  height: 2px;
  width: 0;
  margin: 22px auto 0;
  background: var(--grad);
  border-radius: 2px;
  animation: lineGrow 1.5s var(--ease) 0.5s forwards;
}

.loader-progress {
  margin: 26px auto 0;
  width: 190px;
  height: 4px;
  border-radius: 99px;
  background: var(--line-strong);
  overflow: hidden;
}
.loader-progress b {
  display: block;
  height: 100%;
  width: 30%;
  border-radius: 99px;
  background: var(--grad);
  animation: indeterminate 1.3s var(--ease) infinite;
}

@keyframes letterIn { to { opacity: 1; transform: translateY(0) rotate(0); } }
@keyframes lineGrow { to { width: min(280px, 70vw); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(420%); }
}

/* =========================================================================
   App shell
   ========================================================================= */
.app { max-width: 760px; margin: 0 auto; padding: 28px 20px 80px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  margin: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; gap: 14px; max-width: 760px; margin: 0 auto; }
.brand {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand .by { color: var(--ink-faint); font-weight: 500; }
.brand .name {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.step-label { margin-left: auto; font-size: 0.8rem; color: var(--ink-faint); white-space: nowrap; }

.progress {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 12px;
}
.progress b {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--grad);
  transition: width 0.6s var(--ease);
}

/* =========================================================================
   Screens / step transitions
   ========================================================================= */
.screen { display: none; }
.screen.active { display: block; animation: stepIn 0.55s var(--ease); }
.screen.leaving { animation: stepOut 0.35s var(--ease) forwards; }
@keyframes stepIn { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: translateY(0); } }
@keyframes stepOut { to { opacity: 0; transform: translateY(-18px); } }

/* Welcome / hero -------------------------------------------------------- */
.hero { padding-top: 36px; }
.eyebrow {
  display: inline-block;
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--surface);
}
.hero h1 {
  font-size: clamp(2rem, 6vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 22px 0 0;
  font-weight: 800;
}
.hero h1 .grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .sub { font-size: 1.08rem; color: var(--ink-soft); margin-top: 16px; max-width: 56ch; line-height: 1.6; }

.facts { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.fact {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
}
.fact svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
.fact b { font-weight: 700; }
.fact span { color: var(--ink-faint); display: block; font-size: 0.78rem; }

.app-version {
  margin-top: 28px;
  text-align: center;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  opacity: 0.7;
}

.consent {
  margin-top: 26px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.6;
}
.consent b { color: var(--ink); }

/* =========================================================================
   Cards & questions
   ========================================================================= */
.section-head { margin: 8px 0 22px; }
.section-tag {
  font-size: 0.74rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent); font-weight: 700;
}
.section-head h2 {
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  letter-spacing: -0.02em;
  margin: 6px 0 0;
  font-weight: 800;
}
.section-head p { color: var(--ink-soft); margin: 10px 0 0; line-height: 1.55; }

.q {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 16px;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease), opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.q.invalid { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.12); }
.q.hidden-dep { display: none; }
.q-num {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em;
  color: #fff; background: var(--grad);
  width: 30px; height: 22px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
}
.q-title { display: flex; align-items: baseline; gap: 10px; }
.q-title h3 { font-size: 1.05rem; font-weight: 650; line-height: 1.45; margin: 0; letter-spacing: -0.01em; }
.q-note { font-size: 0.8rem; color: var(--ink-faint); margin: 8px 0 0 40px; font-style: italic; }
.q-body { margin-top: 16px; }

/* Single / multiple choice options -------------------------------------- */
.options { display: grid; gap: 10px; }
.opt {
  position: relative;
  display: flex; align-items: center; gap: 13px;
  padding: 14px 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  cursor: pointer;
  user-select: none;
  font-size: 0.96rem;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.12s var(--ease), box-shadow 0.2s var(--ease);
}
.opt:hover { border-color: var(--accent); transform: translateY(-1px); }
.opt:active { transform: translateY(0) scale(0.995); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .mark {
  flex: none;
  width: 22px; height: 22px;
  border: 2px solid var(--line-strong);
  display: grid; place-items: center;
  transition: all 0.2s var(--ease);
}
.opt[data-type="single"] .mark { border-radius: 50%; }
.opt[data-type="multiple"] .mark { border-radius: 7px; }
.opt .mark svg { width: 13px; height: 13px; color: #fff; opacity: 0; transform: scale(0.4); transition: all 0.2s var(--ease); }
.opt .mark .dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; opacity: 0; transform: scale(0.2); transition: all 0.2s var(--ease); }
.opt.selected {
  border-color: transparent;
  background: linear-gradient(var(--surface-solid), var(--surface-solid)) padding-box,
              var(--grad) border-box;
  box-shadow: var(--shadow-md);
}
.opt.selected .mark { background: var(--grad); border-color: transparent; }
.opt.selected .mark svg, .opt.selected .mark .dot { opacity: 1; transform: scale(1); }
.opt .opt-text { line-height: 1.4; }

/* Likert scale ---------------------------------------------------------- */
.likert { display: flex; align-items: stretch; gap: 8px; }
.likert button {
  flex: 1;
  border: 1.5px solid var(--line-strong);
  background: var(--surface-solid);
  border-radius: var(--radius-sm);
  padding: 14px 6px 11px;
  cursor: pointer;
  font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  transition: all 0.18s var(--ease);
  color: var(--ink-soft);
}
.likert button .num {
  font-weight: 800; font-size: 1.1rem;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--line-strong);
  transition: all 0.18s var(--ease);
}
.likert button .lab { font-size: 0.66rem; line-height: 1.15; text-align: center; color: var(--ink-faint); min-height: 1.6em; }
.likert button:hover { border-color: var(--accent); transform: translateY(-2px); }
.likert button.selected { border-color: transparent; background: var(--grad); color: #fff; box-shadow: var(--shadow-md); }
.likert button.selected .num { background: #fff; color: var(--accent); border-color: #fff; }
.likert button.selected .lab { color: rgba(255, 255, 255, 0.92); }

.likert-legend {
  display: flex; justify-content: space-between;
  font-size: 0.72rem; color: var(--ink-faint);
  margin: 0 4px 14px;
}

/* Text input ------------------------------------------------------------ */
.q textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 14px 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.98rem;
  color: var(--ink);
  background: var(--surface-solid);
  line-height: 1.55;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.q textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16); }
.char-count { text-align: right; font-size: 0.74rem; color: var(--ink-faint); margin-top: 6px; }

/* =========================================================================
   Buttons / nav
   ========================================================================= */
.btn {
  appearance: none;
  font-family: inherit;
  font-weight: 650;
  font-size: 1rem;
  border: none;
  border-radius: 99px;
  padding: 15px 30px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  transition: transform 0.14s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-md); }
.btn-primary:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.nav { display: flex; align-items: center; gap: 12px; margin-top: 28px; }
.nav .spacer { flex: 1; }

.toast-err {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #b00020;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  display: none;
}
.toast-err.show { display: block; animation: stepIn 0.3s var(--ease); }
@media (prefers-color-scheme: dark) { .toast-err { color: #ff9eb0; } }

/* =========================================================================
   Thank-you screen
   ========================================================================= */
.done { text-align: center; padding-top: 50px; }
.done .check {
  width: 96px; height: 96px;
  margin: 0 auto 26px;
  border-radius: 50%;
  background: var(--grad);
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  animation: pop 0.6s var(--ease);
}
.done .check svg { width: 48px; height: 48px; color: #fff; }
.done .check svg path { stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw 0.6s var(--ease) 0.25s forwards; }
.done h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -0.02em; margin: 0; }
.done p { color: var(--ink-soft); margin: 16px auto 0; max-width: 46ch; line-height: 1.6; }
.done .sig { margin-top: 34px; font-size: 0.85rem; color: var(--ink-faint); }
.done .sig b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }
@keyframes pop { 0% { transform: scale(0); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px;
  width: 9px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0.2; } }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 560px) {
  .app { padding: 20px 14px 64px; }
  .topbar { margin: 0; padding: 12px 14px; }
  .q { padding: 18px 16px; }
  .likert { gap: 5px; }
  .likert button { padding: 11px 2px 9px; }
  .likert button .num { width: 30px; height: 30px; font-size: 1rem; }
  .likert button .lab { display: none; }
  .likert-legend { margin-bottom: 12px; }
  .nav .btn { flex: 1; justify-content: center; padding: 14px 18px; }
  .q-note { margin-left: 0; }
}

/* Stagger helper for questions appearing */
.q { animation: qIn 0.5s var(--ease) backwards; }
@keyframes qIn { from { opacity: 0; transform: translateY(16px); } }
