/* Daily Build components. See DESIGN.md.
   Built on the semantic tokens (--bg, --surface, --text ...) so every component
   works inside both data-theme="light" and data-theme="space" containers. */

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-3);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* A themed container flips the text and background with it. */
[data-theme] {
  background-color: var(--bg);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--violet-300);
  color: var(--ink);
}

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

img,
svg,
video {
  max-width: 100%;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--lh-tight);
  text-wrap: balance;
}

h1 { font-size: var(--fs-9); }
h2 { font-size: var(--fs-8); }
h3 { font-size: var(--fs-6); }

h4,
h5,
h6 {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 900;
  line-height: var(--lh-snug);
}

h4 { font-size: var(--fs-4); }
h5 { font-size: var(--fs-3); }
h6 { font-size: var(--fs-2); }

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: var(--link);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: transparent;
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--lh-tight);
}

.container {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Keyframes (shared)
   ========================================================================== */

@keyframes db-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes db-pop-big {
  0% { transform: scale(1); }
  35% { transform: scale(1.32); }
  100% { transform: scale(1); }
}

@keyframes db-shake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-7px); }
  36% { transform: translateX(6px); }
  54% { transform: translateX(-4px); }
  72% { transform: translateX(3px); }
  90% { transform: translateX(-1px); }
}

@keyframes db-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes db-ring {
  0% { transform: scale(0.96); opacity: 0.85; }
  100% { transform: scale(1.3); opacity: 0; }
}

@keyframes db-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -4px; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  --btn-bg: var(--violet-500);
  --btn-fg: #fff;
  --btn-lip: var(--violet-600);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 52px;
  padding: 0 var(--sp-5);
  border: 0;
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: 0 var(--lip) 0 var(--btn-lip);
  font-family: var(--font-body);
  font-size: var(--fs-2);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-med) var(--ease-spring),
    box-shadow var(--dur-med) var(--ease-spring),
    background-color var(--dur-fast) linear,
    filter var(--dur-fast) linear;
}

.btn:hover {
  text-decoration: none;
}

@media (hover: hover) {
  .btn:hover {
    filter: brightness(1.06);
  }
}

.btn:active {
  transform: translateY(var(--lip));
  box-shadow: 0 0 0 var(--btn-lip);
  transition-duration: var(--dur-fast), var(--dur-fast), var(--dur-fast), var(--dur-fast);
}

.btn > svg {
  flex: none;
  width: 1.25em;
  height: 1.25em;
}

.btn--primary {
  --btn-bg: var(--violet-500);
  --btn-fg: #fff;
  --btn-lip: var(--violet-600);
}

.btn--reward {
  --btn-bg: var(--sun-400);
  --btn-fg: var(--sun-ink);
  --btn-lip: var(--sun-600);
}

.btn--success {
  --btn-bg: var(--mint-400);
  --btn-fg: var(--mint-ink);
  --btn-lip: var(--mint-600);
}

.btn--danger {
  --btn-bg: var(--pink-400);
  --btn-fg: var(--ink);
  --btn-lip: var(--pink-600);
}

.btn--secondary {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-lip: var(--line-strong);
  border: var(--border) solid var(--line-strong);
}

/* Toggled secondary button, e.g. a mood or filter picker. */
.btn--secondary[aria-pressed="true"] {
  --btn-lip: var(--violet-500);
  border-color: var(--violet-500);
}

[data-theme="space"] .btn--secondary[aria-pressed="true"] {
  --btn-lip: var(--violet-500);
  border-color: var(--violet-300);
}

.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--text-muted);
  background: transparent;
  box-shadow: inset 0 0 0 var(--border) var(--line);
}

@media (hover: hover) {
  .btn--ghost:hover {
    filter: none;
    background: var(--surface-2);
    color: var(--text);
  }
}

.btn--ghost:active {
  transform: none;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 var(--border) var(--line);
}

.btn--sm {
  min-height: 44px;
  padding: 0 var(--sp-4);
  font-size: 15px;
}

.btn--lg {
  min-height: 60px;
  padding: 0 var(--sp-6);
  font-size: var(--fs-3);
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--surface-2);
  color: var(--text-muted);
  box-shadow: 0 var(--lip) 0 var(--line);
  cursor: not-allowed;
  filter: none;
  transform: none;
}

.btn--secondary:disabled,
.btn--secondary[aria-disabled="true"] {
  border-color: var(--line);
}

.btn--ghost:disabled,
.btn--ghost[aria-disabled="true"] {
  background: transparent;
  box-shadow: inset 0 0 0 var(--border) var(--line);
  opacity: 0.6;
}

/* ==========================================================================
   Chip
   ========================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 12px;
  border: var(--border) solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: var(--fs-1);
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.chip--solid {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 0 var(--line);
}

/* ==========================================================================
   Stat (XP, streak)
   ========================================================================== */

.stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: var(--fs-3);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat > svg,
.stat__icon {
  flex: none;
  width: 1.45em;
  height: 1.45em;
  fill: currentColor;
}

.stat--xp > svg,
.stat--xp .stat__icon {
  color: var(--sun-400);
}

.stat--streak > svg,
.stat--streak .stat__icon {
  color: var(--orange-400);
}

.stat__core {
  fill: var(--sun-400);
}

.stat.is-bump {
  animation: db-pop-big var(--dur-med) var(--ease-spring);
}

/* ==========================================================================
   Card
   ========================================================================== */

.card {
  padding: var(--sp-5);
  border: var(--border) solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
}

@media (min-width: 720px) {
  .card {
    padding: var(--sp-6);
  }
}

.card--raised {
  box-shadow: 0 6px 0 var(--line-strong);
}

/* ==========================================================================
   Option (lesson answer)
   ========================================================================== */

.option {
  --opt-border: var(--line-strong);
  --opt-lip: var(--line-strong);
  --opt-bg: var(--surface);
  --opt-key-bg: transparent;
  --opt-key-fg: var(--text-muted);
  --opt-key-border: var(--line-strong);

  display: flex;
  align-items: center;
  gap: var(--sp-4);
  width: 100%;
  min-height: 58px;
  padding: var(--sp-3) var(--sp-4);
  border: var(--border) solid var(--opt-border);
  border-radius: var(--r-md);
  background: var(--opt-bg);
  color: var(--text);
  box-shadow: 0 var(--lip-sm) 0 var(--opt-lip);
  font-family: var(--font-body);
  font-size: var(--fs-3);
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-med) var(--ease-spring),
    box-shadow var(--dur-med) var(--ease-spring),
    border-color var(--dur-fast) linear,
    background-color var(--dur-fast) linear,
    opacity var(--dur-med) var(--ease-out);
}

@media (hover: hover) {
  .option:hover:not(.is-dim) {
    --opt-bg: var(--surface-2);
  }
}

.option:active {
  transform: translateY(var(--lip-sm));
  box-shadow: 0 0 0 var(--opt-lip);
  transition-duration: var(--dur-fast);
}

.option__key {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: var(--border) solid var(--opt-key-border);
  border-radius: var(--r-sm);
  background: var(--opt-key-bg);
  color: var(--opt-key-fg);
  font-size: var(--fs-1);
  font-weight: 900;
  line-height: 1;
  transition: background-color var(--dur-fast) linear, border-color var(--dur-fast) linear;
}

.option__text {
  flex: 1;
  min-width: 0;
}

/* Tints: a hint of the state color over whatever surface the theme gives us. */
.option.is-selected,
.option[aria-pressed="true"]:not(.is-right):not(.is-wrong) {
  --opt-border: var(--violet-500);
  --opt-lip: var(--violet-600);
  --opt-bg: var(--surface-2);
  --opt-key-bg: var(--violet-500);
  --opt-key-fg: #fff;
  --opt-key-border: var(--violet-500);
}

[data-theme="space"] .option.is-selected,
[data-theme="space"] .option[aria-pressed="true"]:not(.is-right):not(.is-wrong) {
  --opt-border: var(--violet-300);
  --opt-lip: var(--violet-500);
}

.option.is-right {
  --opt-border: var(--mint-400);
  --opt-lip: var(--mint-600);
  --opt-bg: var(--surface-2);
  --opt-key-bg: var(--mint-400);
  --opt-key-fg: var(--mint-ink);
  --opt-key-border: var(--mint-400);
  animation: db-pop var(--dur-med) var(--ease-spring);
}

.option.is-wrong {
  --opt-border: var(--pink-400);
  --opt-lip: var(--pink-600);
  --opt-bg: var(--surface-2);
  --opt-key-bg: var(--pink-400);
  --opt-key-fg: var(--ink);
  --opt-key-border: var(--pink-400);
  animation: db-shake var(--dur-slow) var(--ease-out);
}

.option.is-dim {
  opacity: 0.45;
  pointer-events: none;
}

@supports (color: color-mix(in srgb, red, blue)) {
  .option.is-selected,
  .option[aria-pressed="true"]:not(.is-right):not(.is-wrong) {
    --opt-bg: color-mix(in srgb, var(--violet-500) 12%, var(--surface));
  }

  .option.is-right {
    --opt-bg: color-mix(in srgb, var(--mint-400) 14%, var(--surface));
  }

  .option.is-wrong {
    --opt-bg: color-mix(in srgb, var(--pink-400) 14%, var(--surface));
  }
}

/* ==========================================================================
   Feedback bar (slides up after Check)
   ========================================================================== */

.feedback {
  --fb: var(--mint-400);
  --fb-title: var(--mint-600);
  --fb-bg: var(--surface-2);

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4) var(--sp-5);
  padding: var(--sp-5);
  border-top: var(--border) solid var(--fb);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--fb-bg);
  color: var(--text);
  animation: db-slide-up var(--dur-slow) var(--ease-out) both;
}

.feedback--no {
  --fb: var(--pink-400);
  --fb-title: var(--pink-600);
}

[data-theme="space"] .feedback--ok {
  --fb-title: var(--mint-400);
}

[data-theme="space"] .feedback--no {
  --fb-title: var(--pink-400);
}

@supports (color: color-mix(in srgb, red, blue)) {
  .feedback {
    --fb-bg: color-mix(in srgb, var(--fb) 14%, var(--surface));
  }
}

.feedback__main {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex: 1 1 260px;
  min-width: 0;
}

.feedback__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-pill);
  background: var(--fb);
  color: var(--ink);
}

.feedback--ok .feedback__icon {
  color: var(--mint-ink);
}

.feedback__icon > svg {
  width: 26px;
  height: 26px;
}

.feedback__text {
  min-width: 0;
}

.feedback__title {
  color: var(--fb-title);
  font-family: var(--font-display);
  font-size: var(--fs-5);
  font-weight: 400;
  line-height: 1.1;
}

.feedback__body {
  margin-top: var(--sp-1);
  color: var(--text);
  font-size: var(--fs-2);
  font-weight: 700;
  line-height: 1.4;
}

.feedback > .btn {
  flex: none;
}

@media (max-width: 560px) {
  .feedback {
    flex-direction: column;
    align-items: stretch;
  }

  .feedback > .btn {
    width: 100%;
  }
}

/* ==========================================================================
   Progress
   ========================================================================== */

.progress {
  position: relative;
  height: 16px;
  border-radius: 14px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress__fill {
  position: relative;
  height: 100%;
  width: 0;
  border-radius: 14px;
  background: var(--mint-400);
  transition: width var(--dur-slow) var(--ease-spring);
}

.progress__fill::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 8px;
  right: 8px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.42);
}

/* ==========================================================================
   Path node and bubble
   ========================================================================== */

.node-spot {
  position: relative;
  display: inline-block;
}

.node {
  --node-bg: var(--sun-400);
  --node-fg: var(--sun-ink);
  --node-lip: var(--sun-600);
  --node-ring: var(--sun-400);

  position: relative;
  display: inline-grid;
  place-items: center;
  width: 84px;
  height: 80px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--node-bg);
  color: var(--node-fg);
  box-shadow: 0 7px 0 var(--node-lip);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-med) var(--ease-spring),
    box-shadow var(--dur-med) var(--ease-spring);
}

.node > svg,
.node__icon {
  position: relative;
  z-index: 1;
  display: block;
  width: 38px;
  height: 38px;
}

/* soft gloss on the top edge */
.node::after {
  content: "";
  position: absolute;
  top: 9px;
  left: 17px;
  width: 26px;
  height: 7px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.38);
  transform: rotate(-12deg);
}

.node:active {
  transform: translateY(7px);
  box-shadow: 0 0 0 var(--node-lip);
  transition-duration: var(--dur-fast);
}

.node--start::before,
.node--next::before {
  content: "";
  position: absolute;
  inset: -4px;
  border: 4px solid var(--node-ring);
  border-radius: var(--r-pill);
  pointer-events: none;
  animation: db-ring 1.9s var(--ease-out) infinite;
}

.node--start {
  --node-bg: var(--sun-400);
  --node-fg: var(--sun-ink);
  --node-lip: var(--sun-600);
  --node-ring: var(--sun-400);
}

.node--done {
  --node-bg: var(--sun-400);
  --node-fg: var(--sun-ink);
  --node-lip: var(--sun-600);
}

.node--next {
  --node-bg: var(--mint-400);
  --node-fg: var(--mint-ink);
  --node-lip: var(--mint-600);
  --node-ring: var(--mint-400);
}

.node--locked {
  --node-bg: var(--line);
  --node-fg: var(--text-muted);
  --node-lip: var(--line-strong);
  cursor: not-allowed;
}

@supports (color: color-mix(in srgb, red, blue)) {
  .node--locked {
    --node-lip: color-mix(in srgb, var(--line) 80%, var(--ink));
  }
}

.node--locked::after {
  display: none;
}

.node--locked:active {
  transform: none;
  box-shadow: 0 7px 0 var(--node-lip);
}

.bubble {
  --bubble-edge: var(--violet-100);

  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 18px);
  width: max-content;
  max-width: 220px;
  margin-inline: auto;
  padding: 8px 14px;
  border: var(--border) solid var(--bubble-edge);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  animation: db-bob 2.4s ease-in-out infinite;
}

.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-right: var(--border) solid var(--bubble-edge);
  border-bottom: var(--border) solid var(--bubble-edge);
  border-bottom-right-radius: 4px;
  background: inherit;
  transform: rotate(45deg);
}

.bubble--mint {
  --bubble-edge: var(--mint-600);
  background: var(--mint-400);
  color: var(--mint-ink);
}

/* Sentence-case variant for longer labels, like "Free with an account". */
.bubble--text {
  padding: 9px 14px;
  font-size: var(--fs-1);
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: none;
  white-space: normal;
}

/* ==========================================================================
   Unit banner
   ========================================================================== */

.unit-banner {
  --ub-bg: var(--violet-500);
  --ub-fg: #fff;
  --ub-lip: var(--violet-600);

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--ub-bg);
  color: var(--ub-fg);
  box-shadow: 0 6px 0 var(--ub-lip);
}

.unit-banner__title {
  font-family: var(--font-display);
  font-size: var(--fs-6);
  font-weight: 400;
  line-height: var(--lh-tight);
}

.unit-banner__text {
  margin-top: var(--sp-1);
  font-size: var(--fs-2);
  font-weight: 700;
  line-height: 1.4;
}

.unit-banner--violet { --ub-bg: var(--violet-500); --ub-fg: #fff; --ub-lip: var(--violet-600); }
.unit-banner--sun { --ub-bg: var(--sun-400); --ub-fg: var(--sun-ink); --ub-lip: var(--sun-600); }
.unit-banner--mint { --ub-bg: var(--mint-400); --ub-fg: var(--mint-ink); --ub-lip: var(--mint-600); }
.unit-banner--pink { --ub-bg: var(--pink-400); --ub-fg: var(--ink); --ub-lip: var(--pink-600); }
.unit-banner--sky { --ub-bg: var(--sky-400); --ub-fg: var(--ink); --ub-lip: var(--sky-600); }

/* ==========================================================================
   Mascot: Caret, a text cursor with eyes
   --------------------------------------------------------------------------
   Inline SVG in a 64 x 104 box (so the shape is always crisp). Everything
   animates through the individual transform properties (translate, rotate,
   scale), which lets a mood set a static pose AND a looping animation.
   Size it with --mascot-size (the height; width follows at 0.615).
   ========================================================================== */

.mascot {
  --mascot-size: 104px;
  --mascot-shadow: rgba(27, 24, 64, 0.16);

  position: relative;
  display: inline-block;
  flex: none;
  width: calc(var(--mascot-size) * 0.6154);
  height: var(--mascot-size);
  vertical-align: bottom;
}

[data-theme="space"] .mascot {
  --mascot-shadow: rgba(0, 0, 0, 0.38);
}

.mascot__svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.mascot__svg * {
  transform-box: view-box;
}

.mascot__shadow {
  fill: var(--mascot-shadow);
  transform-origin: 32px 108px;
  transition: opacity var(--dur-med) var(--ease-out);
  animation: db-mascot-shadow 2.8s ease-in-out infinite;
}

.mascot__rig {
  transform-origin: 32px 104px;
  animation: db-mascot-bob 2.8s ease-in-out infinite;
}

.mascot__shade { fill: var(--violet-600); }
.mascot__body { fill: var(--violet-500); }
.mascot__shine { fill: #fff; opacity: 0.22; }

.mascot__eyes {
  transform-origin: 32px 40px;
  animation: db-mascot-blink 4.5s infinite;
}

.mascot__eye-white { fill: #fff; }
.mascot__pupil-dot { fill: var(--ink); }
.mascot__glint { fill: #fff; }

.mascot__pupil {
  transform-box: fill-box;
  transform-origin: center;
  transition: translate var(--dur-med) var(--ease-out), scale var(--dur-med) var(--ease-spring);
}

.mascot__brow {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3.4;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity var(--dur-fast) linear;
}

.mascot__cheek {
  fill: var(--pink-400);
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-out);
}

.mascot__mouth {
  opacity: 0;
  transition: opacity var(--dur-fast) linear;
}

.mascot__mouth--smile,
.mascot__mouth--sad {
  fill: none;
  stroke: #fff;
  stroke-width: 3.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mascot__mouth--smile { opacity: 1; }
.mascot__mouth--happy { fill: #fff; }
.mascot__tongue { fill: var(--pink-400); }

.mascot__tear {
  fill: var(--sky-400);
  opacity: 0;
}

.mascot__flame {
  opacity: 0;
  transform-origin: 32px 98px;
  transition: opacity var(--dur-med) var(--ease-out);
}

.mascot__flame-outer { fill: var(--orange-400); }
.mascot__flame-inner { fill: var(--sun-400); }

.mascot__spark {
  fill: var(--sun-400);
  opacity: 0;
}

/* Idle: slow bob, blink every ~4.5s (defaults above). */

@keyframes db-mascot-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}

@keyframes db-mascot-shadow {
  0%, 100% { scale: 1 1; opacity: 1; }
  50% { scale: 0.86 0.86; opacity: 0.7; }
}

@keyframes db-mascot-blink {
  0%, 92%, 100% { scale: 1 1; }
  95.5% { scale: 1 0.08; }
}

/* Happy: one spring jump, then a lively little bounce. */

.mascot--happy .mascot__rig {
  animation:
    db-mascot-jump 900ms var(--ease-out) 1,
    db-mascot-bob 1.6s ease-in-out 900ms infinite;
}

.mascot--happy .mascot__shadow {
  animation: db-mascot-shadow-jump 900ms var(--ease-out) 1;
}

.mascot--happy .mascot__cheek { opacity: 0.75; }
.mascot--happy .mascot__mouth--smile { opacity: 0; }
.mascot--happy .mascot__mouth--happy { opacity: 1; }
.mascot--happy .mascot__pupil { scale: 1.14; translate: 0 -1px; }

@keyframes db-mascot-jump {
  0% { translate: 0 0; scale: 1 1; }
  16% { translate: 0 0; scale: 1.1 0.88; }
  42% { translate: 0 -30px; scale: 0.94 1.08; }
  68% { translate: 0 0; scale: 1.08 0.9; }
  84% { translate: 0 -5px; scale: 0.99 1.02; }
  100% { translate: 0 0; scale: 1 1; }
}

@keyframes db-mascot-shadow-jump {
  0%, 16%, 68%, 100% { scale: 1 1; opacity: 1; }
  42% { scale: 0.6 0.6; opacity: 0.45; }
}

/* Sad: droops and leans over, eyes down, a tear. */

.mascot--sad .mascot__rig {
  rotate: 6deg;
  scale: 1 0.94;
  animation: db-mascot-sad 3.4s ease-in-out infinite;
}

.mascot--sad .mascot__shadow { animation: none; }
.mascot--sad .mascot__mouth--smile { opacity: 0; }
.mascot--sad .mascot__mouth--sad { opacity: 1; }
.mascot--sad .mascot__brow { opacity: 0.6; }
.mascot--sad .mascot__pupil { translate: 0 2.4px; }
.mascot--sad .mascot__tear { animation: db-mascot-tear 2.6s ease-in infinite; }

@keyframes db-mascot-sad {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 1.5px; }
}

@keyframes db-mascot-tear {
  0%, 25% { translate: 0 0; opacity: 0; }
  35% { opacity: 1; }
  100% { translate: 0 22px; opacity: 0; }
}

/* Flying: tilted, flame trail, no ground shadow. */

.mascot--fly .mascot__rig {
  transform-origin: 32px 52px;
  rotate: -12deg;
  animation: db-mascot-fly 2.2s ease-in-out infinite;
}

.mascot--fly .mascot__shadow { opacity: 0; animation: none; }
.mascot--fly .mascot__flame { opacity: 1; animation: db-mascot-flicker 0.36s ease-in-out infinite alternate; }
.mascot--fly .mascot__cheek { opacity: 0.6; }
.mascot--fly .mascot__mouth--smile { opacity: 0; }
.mascot--fly .mascot__mouth--happy { opacity: 1; }
.mascot--fly .mascot__pupil { translate: 1.5px -2.4px; }
.mascot--fly .mascot__spark { animation: db-mascot-spark 1.1s ease-out infinite; }
.mascot--fly .mascot__spark:nth-of-type(2) { animation-delay: 0.45s; }

@keyframes db-mascot-fly {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -8px; }
}

@keyframes db-mascot-flicker {
  from { scale: 1 1; }
  to { scale: 0.88 1.16; }
}

@keyframes db-mascot-spark {
  0% { translate: 0 0; opacity: 0.95; }
  100% { translate: 0 22px; opacity: 0; }
}

/* ==========================================================================
   Nav
   ========================================================================== */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: var(--border) solid transparent;
  background: transparent;
  transition:
    background-color var(--dur-med) var(--ease-out),
    border-color var(--dur-med) var(--ease-out);
}

.nav.is-scrolled {
  border-bottom-color: var(--line);
  background: var(--surface);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  width: 100%;
  max-width: var(--page-max);
  min-height: 72px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.nav__logo {
  color: var(--violet-500);
  font-family: var(--font-display);
  font-size: var(--fs-5);
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
}

.nav__logo:hover {
  text-decoration: none;
}

[data-theme="space"] .nav__logo,
.nav[data-theme="space"] .nav__logo {
  color: var(--sun-400);
}

.nav__right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.nav__link {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: var(--fs-2);
  font-weight: 800;
  text-decoration: none;
}

.nav__link:hover {
  color: var(--text);
  text-decoration: none;
}

@media (max-width: 560px) {
  .nav__link {
    display: none;
  }
}

/* ==========================================================================
   Field
   ========================================================================== */

.field {
  --field-focus: var(--violet-500);
  --field-error: var(--pink-600);

  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

[data-theme="space"] .field {
  --field-focus: var(--sun-400);
  --field-error: var(--pink-400);
}

.field__label {
  color: var(--text);
  font-size: var(--fs-2);
  font-weight: 800;
  line-height: 1.3;
}

.field__input {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--sp-4);
  border: var(--border) solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-2);
  font-weight: 700;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--dur-fast) linear;
}

.field__input::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
}

.field__input:focus,
.field__input:focus-visible {
  border-color: var(--field-focus);
  outline-offset: 2px;
}

.field__error {
  display: none;
  color: var(--field-error);
  font-size: var(--fs-1);
  font-weight: 800;
  line-height: 1.35;
}

.field.is-invalid .field__input {
  border-color: var(--pink-400);
  animation: db-shake var(--dur-slow) var(--ease-out);
}

.field.is-invalid .field__error {
  display: block;
}

/* ==========================================================================
   Speech bubble (from the mascot)
   ========================================================================== */

.speech {
  position: relative;
  display: inline-block;
  max-width: 34ch;
  padding: var(--sp-3) var(--sp-4);
  border: var(--border) solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-2);
  font-weight: 700;
  line-height: 1.4;
}

.speech::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 22px;
  width: 14px;
  height: 14px;
  border-bottom: var(--border) solid var(--line);
  border-left: var(--border) solid var(--line);
  border-bottom-left-radius: 4px;
  background: var(--surface);
  transform: rotate(45deg);
}

/* ==========================================================================
   Reduced motion: everything holds still. Poses stay, loops stop.
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
