/* ============================================================
   Bipolaroid — mobile-first face-rating task
   ============================================================ */
:root {
  --bg: #fbf5ec;
  --bg-2: #f6ecdd;
  --surface: #ffffff;
  --surface-2: #fbf3e6;
  --line: #ecdfcb;
  --text: #2a2238;
  --muted: #6d6481;
  --muted-2: #998faa;

  --primary: #7c5cf6;
  --primary-soft: #ebe3ff;
  --primary-deep: #5c3fd6;

  --pos: #34b27b;
  --pos-soft: #d8f1e3;
  --neg: #e26060;
  --neg-soft: #fbdcdc;
  --warn: #e9a23b;

  --radius: 22px;
  --radius-sm: 14px;
  --shadow-sm: 0 4px 14px -4px rgba(58, 39, 109, 0.16);
  --shadow: 0 18px 40px -18px rgba(58, 39, 109, 0.32);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  /* Soft chunky display face — used for headings, brand, big numbers,
     primary CTAs. Body stays Nunito (a rounded humanist sans) for legibility
     at small sizes. */
  --font-display: "Momo Trust Display", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    system-ui, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(120% 70% at 0% 0%, #fff4e4 0%, transparent 60%),
    radial-gradient(120% 70% at 100% 100%, #efe6ff 0%, transparent 55%),
    var(--bg) fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  position: relative;
}

/* ---------- screens ---------- */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(20px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  animation: fade 0.4s var(--ease);
}
.screen[hidden] {
  display: none;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- typography / helpers ---------- */
h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400; /* Jua only ships one weight — already chunky */
  letter-spacing: 0;
  color: var(--text);
  line-height: 1.2;
}
.small {
  font-size: 14.5px;
}
.muted {
  color: var(--muted);
}
strong {
  color: var(--text);
  font-weight: 800;
}

/* ============================================================
   INTRO
   ============================================================ */
.screen--intro {
  justify-content: flex-start;
}
.intro-wrap {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.brand__hero {
  width: 200px;
  max-width: 64vw;
  height: auto;
  /* The artwork has its own soft shadow built in via the warm radial behind
     the figure; we add a tiny extra to lift it off the page subtly. */
  filter: drop-shadow(0 18px 26px rgba(124, 92, 246, 0.18));
  margin-top: 4px;
  pointer-events: none;
  user-select: none;
}
.brand__name {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 400;
  background: linear-gradient(120deg, var(--primary-deep), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.05;
  letter-spacing: 0.01em;
}
.brand__tag {
  color: var(--muted);
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.card-intro {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.card-intro p {
  margin: 0;
  font-size: 19px;
  line-height: 1.5;
}

.swipe-legend {
  display: flex;
  gap: 10px;
}
.swipe-legend__side {
  flex: 1;
  border-radius: var(--radius-sm);
  padding: 16px 10px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.swipe-legend__side span {
  font-size: 24px;
}
.swipe-legend__side--neg {
  background: var(--neg-soft);
  color: var(--neg);
}
.swipe-legend__side--pos {
  background: var(--pos-soft);
  color: var(--pos);
}

/* "self-reflection" illustration block lower on the intro */
.reflect-block {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, var(--primary-soft) 0%, #fff5f5 100%);
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid rgba(124, 92, 246, 0.18);
}
.reflect-block__img {
  width: 96px;
  height: auto;
  flex: none;
  filter: drop-shadow(0 6px 12px rgba(124, 92, 246, 0.2));
  pointer-events: none;
  user-select: none;
}
.reflect-block__txt {
  font-size: 17px;
  color: var(--text);
  line-height: 1.5;
  font-weight: 600;
}
.reflect-block__txt b {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 23px;
  margin-bottom: 4px;
  color: var(--primary-deep);
}

/* buttons */
.btn {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: 0.01em;
  border: 0;
  border-radius: 18px;
  padding: 20px;
  cursor: pointer;
  transition: transform 0.12s var(--ease), filter 0.2s, opacity 0.2s,
    box-shadow 0.2s;
}
.btn:active {
  transform: translateY(1px) scale(0.99);
}
.btn--primary {
  background: linear-gradient(180deg, #8d70ff 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 10px 22px -10px rgba(124, 92, 246, 0.7),
    inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}
.btn--primary:hover {
  filter: brightness(1.04);
}
.btn--ghost {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.disclaimer {
  text-align: center;
  line-height: 1.55;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

/* ============================================================
   TEST
   ============================================================ */
.screen--test {
  justify-content: flex-start;
  position: relative;
  overflow: hidden;
}
.test-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.icon-btn {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity 0.2s, color 0.2s, transform 0.12s;
  box-shadow: var(--shadow-sm);
}
.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}
.icon-btn:not(:disabled):active {
  transform: scale(0.94);
}
.progress {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.progress__bar {
  height: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.progress__bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #b8a6ff);
  border-radius: 99px;
  transition: width 0.35s var(--ease);
}
.progress__count {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--muted);
  text-align: center;
}

/* deck / cards */
.deck {
  flex: 1;
  position: relative;
  margin: 18px 0;
  min-height: 0;
}
.card {
  position: absolute;
  inset: 0;
  margin: auto;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  will-change: transform;
  touch-action: none;
  user-select: none;
  display: flex;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}
/* depth for stacked cards */
.card[data-depth="1"] {
  transform: scale(0.94) translateY(14px);
  filter: brightness(0.96);
}
.card[data-depth="2"] {
  transform: scale(0.88) translateY(28px);
  filter: brightness(0.92);
}

/* Swipe-direction overlays. Anchored to the TEST SCREEN (not the deck) so
   they extend to the screen edges. Sit above the card with a soft tint —
   the face stays visible underneath, but the colour + label make the
   meaning of "this side" obvious in peripheral vision. */
.swipe-hint {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 60%;
  display: flex;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  transition: opacity 0.08s linear;
}
.swipe-hint span {
  font-family: var(--font-display);
  font-size: 44px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 14px 20px;
  border-radius: 18px;
  border: 4px solid currentColor;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px -10px rgba(58, 39, 109, 0.35);
}
.swipe-hint--neg {
  left: 0;
  justify-content: flex-start;
  padding-left: 18px;
  color: var(--neg);
  background: linear-gradient(
    to right,
    rgba(226, 96, 96, 0.4) 0%,
    rgba(226, 96, 96, 0.18) 50%,
    transparent 100%
  );
}
.swipe-hint--pos {
  right: 0;
  justify-content: flex-end;
  padding-right: 18px;
  color: var(--pos);
  background: linear-gradient(
    to left,
    rgba(52, 178, 123, 0.4) 0%,
    rgba(52, 178, 123, 0.18) 50%,
    transparent 100%
  );
}
.swipe-hint--neg span {
  transform: rotate(-8deg);
}
.swipe-hint--pos span {
  transform: rotate(8deg);
}

/* choice buttons */
.choice-prompt {
  text-align: center;
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.005em;
}
.choice-row {
  display: flex;
  gap: 14px;
}
.choice {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.2s, border-color 0.2s,
    box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}
.choice:active {
  transform: scale(0.96);
}
.choice__icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.choice__label {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 400;
  margin-top: 4px;
}
.choice--neg:active,
.choice--neg.flash {
  background: var(--neg-soft);
  border-color: var(--neg);
  color: var(--neg);
}
.choice--pos:active,
.choice--pos.flash {
  background: var(--pos-soft);
  border-color: var(--pos);
  color: var(--pos);
}
.hint {
  text-align: center;
  margin: 14px 0 0;
  font-size: 15px;
  font-weight: 600;
}

/* ============================================================
   RESULTS
   ============================================================ */
.results-wrap {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 8px;
}
.results-wrap h2 {
  font-size: 40px;
  text-align: center;
}

.result-hero {
  display: flex;
  justify-content: center;
  margin: 4px 0 -6px;
}
.result-hero img {
  width: 220px;
  max-width: 70vw;
  height: auto;
  filter: drop-shadow(0 18px 26px rgba(124, 92, 246, 0.18));
  animation: rise 0.6s var(--ease) both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
}

.score-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
@property --val {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}
.ring {
  --val: 0;
  --ring-color: var(--primary);
  width: 168px;
  height: 168px;
  margin: 6px auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(closest-side, var(--surface) 78%, transparent 79%),
    conic-gradient(var(--ring-color) calc(var(--val) * 1%), var(--surface-2) 0);
  transition: --val 1s var(--ease);
}
.ring__inner {
  text-align: center;
}
.ring__num {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 400;
  line-height: 1;
  color: var(--text);
}
.ring__pct {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--muted);
}
.ring__label {
  font-size: 15px;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 700;
}
.band {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  padding: 10px 22px;
  border-radius: 99px;
  margin-bottom: 12px;
}
.score-card p {
  margin: 10px 0 0;
  font-size: 17px;
  color: var(--muted);
  line-height: 1.5;
}

/* stat grid */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.stat__num {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 400;
  color: var(--text);
}
.stat__label {
  font-size: 14.5px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 600;
  line-height: 1.35;
}

/* insight + history blocks */
.block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.block h3 {
  font-size: 26px;
  margin-bottom: 12px;
}
.block p {
  margin: 0;
  font-size: 17px;
  color: var(--muted);
  line-height: 1.55;
}

/* history list / sparkline */
.spark {
  width: 100%;
  height: 60px;
  margin-top: 6px;
  overflow: visible;
}
.history-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-list li {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.history-list li:first-child {
  border-top: 0;
  padding-top: 0;
}
.history-list b {
  color: var(--text);
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 2px;
}

/* prior-runs teaser on intro */
.mini-history {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.mini-history__txt {
  font-size: 17px;
  color: var(--muted);
  font-weight: 600;
}
.mini-history__txt b {
  font-family: var(--font-display);
  color: var(--text);
  font-size: 24px;
  font-weight: 400;
}

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