/* Waddle — Gumdrop Toon 2D, per DESIGN-LANGUAGE.md Part A + STYLESEED locks.
   Palette values are fallbacks; app.js overwrites them from ./theme.json. */

:root {
  --ink: #5A4E6D;
  --ink-soft: #7A6F8D;
  --card: rgba(255, 255, 255, .82);
  --edge: rgba(90, 78, 109, .12);
  --outline: #6B5E86;
  --accent: #C69DEB;           /* lilac — the ONE emphasis color */
  --accent-deep: #A87FD1;
  --blush: rgba(245, 169, 184, .85);
  --bg-base: #FDEFF4;
  --radius-card: 18px;
  --radius-pill: 999px;
  --enter: opacity .45s ease, transform .45s cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  background-color: var(--bg-base);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* dawn gradient on a fixed layer — background-attachment:fixed is flaky on
   mobile Safari and repaints badly with animations */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(120% 90% at 50% 108%, #D8F0F5 0%, transparent 55%),
    radial-gradient(140% 100% at 50% 0%, #FFEDF3 0%, #F3EAFB 48%, #DFF2FA 100%);
}

h1, h2, h3 { font-family: "Baloo 2", "Nunito", sans-serif; margin: 0; }

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

button:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------------------------------------------------------------- topbar */

.topbar { padding: max(10px, env(safe-area-inset-top)) 18px 0; }

.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.brand {
  font-size: 1.7rem;
  font-weight: 800;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .7);
}

.date-line {
  margin: 0;
  color: var(--ink-soft);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .15em;
}

/* ---------------------------------------------------------------- layout */

.layout {
  max-width: 1160px;
  margin: 0 auto;
  padding: 6px 14px 120px;
}

#main { min-width: 0; }

@media (min-width: 900px) {
  .layout {
    display: grid;
    grid-template-columns: 460px minmax(0, 1fr);
    gap: 26px;
    align-items: start;
    padding-top: 12px;
  }
  .layout > .scene-wrap { position: sticky; top: 16px; }
}

@media (min-width: 1180px) {
  .layout { grid-template-columns: 520px minmax(0, 1fr); }
}

/* ----------------------------------------------------------------- scene */

.scene-wrap { position: relative; margin-bottom: 10px; }

#scene svg { display: block; width: 100%; height: auto; }

.bubble-anchor {
  position: absolute;
  top: 6%;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.bubble {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-card);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(122, 104, 156, .18);
  padding: 8px 14px;
  max-width: 78%;
  font-size: .88rem;
  font-weight: 700;
  text-align: center;
  transition: var(--enter);
}

.bubble.hide { opacity: 0; transform: translateY(-8px) scale(.96); }

/* otter & scene animation (CSS transforms live on inner groups only —
   outer groups keep their SVG transform attributes for position) */

.pet-drift { transition: transform 5.5s ease-in-out; }

.pet-anim { animation: float 5s ease-in-out infinite; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  35% { transform: translateY(-6px) rotate(-1.4deg); }
  70% { transform: translateY(2px) rotate(1.2deg); }
}

.pet-anim.cheer { animation: cheer .66s ease-in-out; }

@keyframes cheer {
  0% { transform: translateY(0) scale(1, 1); }
  20% { transform: translateY(3px) scale(1.06, .9); }
  50% { transform: translateY(-18px) scale(.95, 1.06) rotate(-3deg); }
  75% { transform: translateY(2px) scale(1.05, .94); }
  100% { transform: translateY(0) scale(1, 1); }
}

.pet-anim.boop { animation: boop .5s cubic-bezier(.34, 1.56, .64, 1); }

@keyframes boop {
  0% { transform: scale(1, 1); }
  35% { transform: scale(1.1, .86); }
  70% { transform: scale(.96, 1.05); }
  100% { transform: scale(1, 1); }
}

.pet-anim.roll { animation: barrel .95s cubic-bezier(.45, .05, .35, 1); transform-box: fill-box; transform-origin: 45% 55%; }

@keyframes barrel {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.pet-eyes { animation: blink 5.5s infinite; transform-box: fill-box; transform-origin: center; }

@keyframes blink {
  0%, 93.5%, 97.5%, 100% { transform: scaleY(1); }
  95%, 96% { transform: scaleY(.06); }
}

#pupils { transition: transform .18s ease; }

.cradle-anim { animation: cradle-sway 5s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 85%; }

@keyframes cradle-sway {
  0%, 100% { transform: rotate(0deg); }
  30% { transform: rotate(-2.2deg); }
  60% { transform: rotate(2.2deg); }
}

.hold-spin { animation: holdspin 1.3s cubic-bezier(.45, .05, .35, 1); transform-box: fill-box; transform-origin: center; }

@keyframes holdspin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.hold-bonk { animation: bonk .5s cubic-bezier(.34, 1.56, .64, 1); transform-box: fill-box; transform-origin: center; }

@keyframes bonk {
  40% { transform: scale(1.25) rotate(-8deg); }
}

.tail-flick { animation: tailflick .9s ease-in-out; transform-box: fill-box; transform-origin: 10% 80%; }

@keyframes tailflick {
  25% { transform: rotate(-12deg); }
  60% { transform: rotate(7deg); }
}

.bubble-rise {
  fill: #EAF6FD;
  stroke: #fff;
  stroke-width: 2;
  opacity: 0;
  animation: bubble-up 1.3s ease-out forwards;
}

@keyframes bubble-up {
  0% { opacity: 0; transform: translateY(0); }
  15% { opacity: .95; }
  100% { opacity: 0; transform: translateY(-48px); }
}

.kelp-sway { animation: kelp 7s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
.kelp-sway.k2 { animation-duration: 9s; animation-delay: -3s; }

@keyframes kelp {
  from { transform: rotate(-1.6deg); }
  to { transform: rotate(2deg); }
}

.cloud-drift { animation: drift 26s ease-in-out infinite alternate; }
.cloud-drift.slow { animation-duration: 38s; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(26px); }
}

.wave-sway { animation: sway 6s ease-in-out infinite alternate; }

@keyframes sway {
  from { transform: translateX(0); }
  to { transform: translateX(9px); }
}

.zz { animation: zz-float 3.4s ease-in-out infinite; opacity: 0; }
.zz.z2 { animation-delay: 1.1s; }

@keyframes zz-float {
  0% { opacity: 0; transform: translateY(0); }
  25% { opacity: .8; }
  70% { opacity: 0; transform: translateY(-16px); }
  100% { opacity: 0; }
}

.sparkle-tw { animation: twinkle 3.2s ease-in-out infinite; }
.sparkle-tw.t2 { animation-delay: 1.4s; }
.sparkle-tw.t3 { animation-delay: 2.3s; }

@keyframes twinkle {
  0%, 100% { opacity: .25; }
  50% { opacity: .85; }
}

.pebble-pop {
  animation: pebblepop .38s cubic-bezier(.34, 1.56, .64, 1);
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes pebblepop { from { transform: scale(0); } }

/* completion hearts */

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

.heart {
  position: absolute;
  font-size: 20px;
  animation: heart-up 1.15s ease-out forwards;
}

@keyframes heart-up {
  0% { opacity: 0; transform: translateY(6px) scale(.5); }
  18% { opacity: 1; transform: translateY(-6px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-64px) scale(.9) rotate(8deg); }
}

/* ----------------------------------------------------------------- areas */

.area-card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-card);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(122, 104, 156, .18);
  margin-bottom: 14px;
  overflow: hidden;
  transition: var(--enter);
}

.area-card.enter { opacity: 0; transform: translateY(-8px) scale(.96); }

@media (min-width: 1180px) {
  #areas { column-count: 2; column-gap: 14px; }
  .area-card { break-inside: avoid; }
}

.area-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 8px 16px;
}

.area-dot {
  width: 14px;
  height: 12px;                 /* squashed — nothing is perfectly round */
  border-radius: 50%;
  border: 2.5px solid var(--outline);
  flex: none;
}

.area-name { font-size: 1.06rem; font-weight: 800; flex: 1; min-width: 0; overflow-wrap: anywhere; }

.area-count {
  color: var(--ink-soft);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .15em;
  white-space: nowrap;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  flex: none;
}

.icon-btn:active { background: rgba(90, 78, 109, .08); }

.goal-list { padding: 0 8px 10px; }

.goal-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px 2px 6px;
  border-radius: 14px;
  transition: background .2s ease;
}

.goal-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  font: inherit;
  font-size: .98rem;
  font-weight: 700;
  text-align: left;
  border-radius: 14px;
  transition: transform .2s ease;
}

.goal-main:active { transform: scale(.985); }

.goal-row.done-some { background: var(--wash, rgba(126, 217, 160, .13)); }

.goal-row + .goal-row { margin-top: 2px; }

.goal-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.goal-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--edge);
  background: rgba(255, 255, 255, .6);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1);
}

.goal-row.done-some .goal-check { border-color: var(--outline); background: #fff; }

.goal-check svg { display: none; }

.goal-row.done-some .goal-check svg { display: block; }

.goal-row.pop .goal-check { transform: scale(1.35); }

.pebble-row { display: inline-flex; align-items: center; gap: 3px; flex: none; }

.pebble {
  width: 9px;
  height: 7px;                  /* squashed pebble */
  border-radius: 50%;
  background: var(--pebble, #C6BEDA);
  border: 1.5px solid var(--outline);
}

.pebble.ghost { background: transparent; border-color: var(--edge); }

.pebble-more {
  font-size: .72rem;
  font-weight: 800;
  color: var(--ink-soft);
}

/* empty / resting / footer */

.empty-goal {
  display: block;
  width: 100%;
  text-align: left;
  color: var(--ink-soft);
  font-size: .9rem;
  font-weight: 700;
  padding: 12px 10px;
  border-radius: 14px;
}

.empty-goal u { text-decoration-color: var(--accent); text-underline-offset: 3px; }

.main-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 2px 0;
}

.ghost-btn {
  border: 1.5px dashed var(--edge);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  color: var(--ink-soft);
  font-size: .85rem;
  font-weight: 800;
  background: rgba(255, 255, 255, .45);
}

/* big empty state */

.hero-empty {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-card);
  box-shadow: 0 10px 30px rgba(122, 104, 156, .18);
  padding: 28px 22px;
  text-align: center;
}

.hero-empty h2 { font-size: 1.2rem; margin-bottom: 6px; }
.hero-empty p { color: var(--ink-soft); margin: 0 0 16px; font-weight: 700; }

/* loading */

.loading-card {
  text-align: center;
  color: var(--ink-soft);
  font-weight: 800;
  padding: 40px 0;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: .45; } }

/* error banner */

.banner-error {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-card);
  box-shadow: 0 10px 30px rgba(122, 104, 156, .18);
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.banner-error span { flex: 1; }

/* ------------------------------------------------------------------- fab */

.fab {
  position: fixed;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  min-height: 56px;
  padding: 0 20px 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-pill);
  border: 2.5px solid var(--outline);
  box-shadow: 0 10px 30px rgba(122, 104, 156, .35);
  font-size: 1rem;
  font-weight: 800;
  z-index: 40;
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1);
}

.fab:active { transform: scale(.94); }

@media (max-width: 480px) {
  .fab-label { display: none; }
  .fab { width: 60px; height: 60px; padding: 0; justify-content: center; }
}

/* ---------------------------------------------------------------- sheets */

.sheet-backdrop[hidden] { display: none; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(90, 78, 109, .30);
  backdrop-filter: blur(3px);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.sheet {
  background: #FFFDFB;
  border: 1px solid var(--edge);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  box-shadow: 0 -10px 40px rgba(122, 104, 156, .25);
  width: 100%;
  max-width: 560px;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  transition: var(--enter);
}

@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--radius-card); }
}

.sheet.enter { opacity: 0; transform: translateY(24px) scale(.97); }

.sheet h2 { font-size: 1.25rem; margin-bottom: 14px; }

.sheet-label {
  display: block;
  color: var(--ink-soft);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .15em;
  margin: 16px 0 8px;
}

.text-input {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--edge);
  border-radius: 14px;
  padding: 12px 14px;
}

.text-input:focus { border-color: var(--accent); outline: none; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 2px solid var(--edge);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: .9rem;
  font-weight: 800;
  color: var(--ink-soft);
  background: #fff;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1);
}

.chip:active { transform: scale(.95); }

.chip .area-dot { width: 11px; height: 9px; border-width: 2px; }

.chip.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.chip.selected .area-dot { border-color: #fff; }

.stepper { display: flex; align-items: center; gap: 14px; }

.stepper-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--edge);
  background: #fff;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stepper-val { font-weight: 800; font-size: 1.05rem; min-width: 130px; text-align: center; }

.sheet-actions { display: flex; gap: 10px; margin-top: 22px; }

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border: 2.5px solid var(--outline);
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 800;
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1);
}

.btn-primary:active { transform: scale(.96); }

.btn-primary:disabled { opacity: .45; }

.btn-quiet {
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  font-size: .95rem;
  font-weight: 800;
  color: var(--ink-soft);
  background: rgba(90, 78, 109, .07);
}

.sheet-links { margin-top: 18px; display: grid; gap: 4px; }

.sheet-link {
  text-align: left;
  padding: 12px 10px;
  border-radius: 14px;
  font-size: .93rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.sheet-link:active { background: rgba(90, 78, 109, .07); }

.swatch-row { display: flex; flex-wrap: wrap; gap: 10px; }

.swatch {
  width: 34px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid var(--edge);
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1);
}

.swatch.selected { border-color: var(--outline); transform: scale(1.14); }

/* pet sheet */

.stage-road { display: grid; gap: 8px; margin-top: 4px; }

.stage-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: .93rem;
  font-weight: 700;
}

.stage-item .tick { color: var(--ink-soft); font-weight: 800; flex: none; width: 18px; }

.stage-item.reached .tick { color: var(--ink); }

.stage-item .flavor { color: var(--ink-soft); font-weight: 400; }

.stage-item.future { color: var(--ink-soft); }

.recent-days { display: flex; flex-wrap: wrap; gap: 8px; }

.day-pill {
  background: rgba(255, 255, 255, .8);
  border: 1.5px solid var(--edge);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: .8rem;
  font-weight: 800;
  color: var(--ink-soft);
}

/* stage-up card */

.stageup {
  text-align: center;
  padding: 8px 4px 4px;
}

.stageup h2 { font-size: 1.4rem; margin: 10px 0 4px; }
.stageup p { color: var(--ink-soft); font-weight: 700; margin: 0 0 18px; }

/* ----------------------------------------------------------------- toast */

.toast-anchor {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(88px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 55;
}

.toast {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(122, 104, 156, .25);
  padding: 10px 20px;
  font-size: .92rem;
  font-weight: 800;
  transition: var(--enter);
}

.toast.hide { opacity: 0; transform: translateY(-8px) scale(.96); }

/* --------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .pet-anim, .pet-anim.cheer, .pet-anim.boop, .pet-anim.roll, .pet-eyes,
  .cradle-anim, .hold-spin, .hold-bonk, .tail-flick, .bubble-rise, .kelp-sway,
  .cloud-drift, .wave-sway, .zz, .sparkle-tw, .heart, .loading-card,
  .pebble-pop { animation: none; }
  .zz { opacity: .6; }
  * { transition-duration: .01ms !important; }
}
