/* Daily Affirmations - calm morning aesthetic, mobile first, no build step. */

:root {
  --sky1: #FFE3C4;
  --sky2: #FFC9C2;
  --sky3: #E9C7F0;
  --ink: #3A2A22;
  --ink-soft: #6A554A;
  --card: rgba(255, 255, 255, 0.58);
  --card-line: rgba(255, 255, 255, 0.75);
  --bright: #FFD9A0;      /* bright button fill -> needs near-black text */
  --bright-hi: #FFE6BD;
  --dark: #3A2A22;        /* dark button fill -> needs light text */
  --on-bright: #241109;   /* near-black label on bright fill */
  --on-dark: #FFF6E8;     /* light label on dark fill */
  --radius: 22px;
  --ease: cubic-bezier(.22, .8, .32, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100svh;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI",
               system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(170deg, var(--sky1) 0%, var(--sky2) 52%, var(--sky3) 100%);
  background-attachment: fixed;
  transition: background 1.2s var(--ease);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- background ---------- */

.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.cloud {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  filter: blur(18px);
  opacity: .45;
  animation: drift linear infinite;
}
.cloud-1 { width: 260px; height: 90px;  top: 9%;  left: -30%; animation-duration: 90s; }
.cloud-2 { width: 180px; height: 66px;  top: 26%; left: -30%; animation-duration: 126s; animation-delay: -40s; opacity: .32; }
.cloud-3 { width: 320px; height: 100px; top: 63%; left: -40%; animation-duration: 150s; animation-delay: -80s; opacity: .28; }

@keyframes drift { from { transform: translateX(0); } to { transform: translateX(170vw); } }

.motes { position: absolute; inset: 0; }
.motes i {
  position: absolute;
  left: var(--x);
  bottom: -12vh;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: #fff;
  opacity: var(--o);
  filter: blur(.4px);
  animation: rise var(--d) linear infinite;
  animation-delay: var(--delay);
}
@keyframes rise {
  0%   { transform: translate3d(0, 0, 0) scale(.8); opacity: 0; }
  12%  { opacity: var(--o); }
  88%  { opacity: var(--o); }
  100% { transform: translate3d(14px, -118vh, 0) scale(1.15); opacity: 0; }
}

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

.app {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.top { margin: 0; }
.date {
  margin: 0;
  font-size: .82rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: .85;
}
.who {
  margin: 4px 0 0;
  font-size: .96rem;
  font-weight: 700;
  color: var(--ink);
}
.who-sep { opacity: .4; margin: 0 4px; }
.tagline { font-weight: 500; font-size: .84rem; color: var(--ink-soft); }

.stage {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 0;
}

.mascot-wrap {
  width: min(74vw, 300px);
  max-height: 44svh;
  display: grid;
  place-items: center;
}
.mascot {
  width: 100%;
  height: auto;
  max-height: 44svh;
  overflow: visible;
  filter: drop-shadow(0 12px 22px rgba(90, 50, 30, .16));
}

/* ---------- affirmation card ---------- */

.say { width: 100%; }
.affirmation {
  margin: 0;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--card-line);
  box-shadow: 0 10px 30px rgba(120, 70, 40, .10);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: clamp(1.12rem, 4.6vw, 1.5rem);
  line-height: 1.42;
  font-weight: 600;
  letter-spacing: .002em;
  min-height: 4.6em;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  align-items: center;
  justify-content: center;
  column-gap: .26em;
}

.affirmation .w {
  display: inline-block;
  opacity: 0;
  transform: translateY(8px);
  animation: wordIn .5s var(--ease) forwards;
  animation-delay: var(--wd, 0s);
}
@keyframes wordIn { to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */

.controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 2px;
}
.row { display: flex; gap: 10px; }
.row .btn { flex: 1 1 0; }

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  padding: 15px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  line-height: 1;
  transition: transform .14s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible { outline: 3px solid #2C1A10; outline-offset: 3px; }

/* bright fill -> near-black label (never same hue on same hue) */
.btn-primary,
a.btn-primary,
.btn-primary:link,
.btn-primary:visited {
  background: var(--bright);
  color: var(--on-bright);
  box-shadow: 0 8px 20px rgba(160, 100, 40, .28);
  font-size: 1.02rem;
}
.btn-primary:hover { background: var(--bright-hi); }

/* dark fill -> light label */
.btn-ghost,
a.btn-ghost,
.btn-ghost:link,
.btn-ghost:visited {
  background: var(--dark);
  color: var(--on-dark);
  box-shadow: 0 6px 16px rgba(70, 40, 25, .22);
  font-size: .93rem;
}
.btn-ghost:hover { background: #4B372D; }

/* any anchor styled as a button keeps its own label colour */
a.btn, .btn:link, .btn:visited { text-decoration: none; }

/* keep the label dark on the bright fill even while disabled (contrast rule) */
.btn[disabled] { cursor: default; filter: saturate(.75); box-shadow: none; }
.ico { display: inline-flex; }

.hint {
  margin: 6px 0 0;
  font-size: .78rem;
  color: var(--ink-soft);
  opacity: .75;
  min-height: 1.1em;
}

/* ---------- mascot animation contract ---------- */

.c-body {
  transform-box: fill-box;
  transform-origin: 50% 92%;
  animation: breathe 4.4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  50%      { transform: translateY(-1.5px) scale(1.014, .988); }
}

.c-head {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: bob 6.2s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: rotate(-1.1deg) translateY(0); }
  50%      { transform: rotate(1.1deg) translateY(-2px); }
}

.c-eye {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: blink 6s infinite;
}
.c-eye-r { animation-delay: .04s; }
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%           { transform: scaleY(.08); }
  96%           { transform: scaleY(1); }
  97.6%         { transform: scaleY(.08); }
  99%           { transform: scaleY(1); }
}

/* pivots are given in viewBox user units, so this must be view-box not fill-box */
.c-accent {
  transform-box: view-box;
  transform-origin: var(--ox, 150px) var(--oy, 150px);
}
.acc-tail   { animation: tailSwish 3.4s ease-in-out infinite; }
.acc-sway   { animation: armSway 7.5s ease-in-out infinite; }
.acc-twitch { animation: earTwitch 5.2s ease-in-out infinite; }

@keyframes tailSwish {
  0%, 100% { transform: rotate(-5deg); }
  50%      { transform: rotate(7deg); }
}
@keyframes armSway {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(5deg); }
}
@keyframes earTwitch {
  0%, 62%, 100% { transform: rotate(0deg); }
  68%           { transform: rotate(-4deg) translateY(-2px); }
  74%           { transform: rotate(2.5deg); }
  80%           { transform: rotate(0deg); }
}

/* mouth is driven live from audio amplitude via --mouth (0..1) */
.mascot { --mouth: 0; }
.c-mouth-closed {
  opacity: calc(1 - var(--mouth));
  transition: opacity .06s linear;
}
.c-mouth-open {
  transform-box: fill-box;
  transform-origin: 50% 4%;
  opacity: var(--mouth);
  transform: scaleY(calc(.32 + var(--mouth) * .78)) scaleX(calc(.9 + var(--mouth) * .12));
  transition: opacity .06s linear;
}

/* talking bounce */
.is-talking .c-body { animation-duration: 2.6s; }

/* character swap */
.mascot-wrap.swap .mascot { animation: pop .5s var(--ease); }
@keyframes pop {
  0%   { opacity: 0; transform: translateY(10px) scale(.94); }
  100% { opacity: 1; transform: none; }
}

/* ---------- larger screens ---------- */

@media (min-width: 700px) {
  .app { max-width: 620px; gap: 12px; padding-top: 34px; }
  .mascot-wrap { width: min(46vh, 360px); max-height: 46svh; }
  .mascot { max-height: 46svh; }
  .affirmation { font-size: 1.6rem; padding: 24px 28px; }
  .controls { max-width: 460px; }
}

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

@media (prefers-reduced-motion: reduce) {
  .cloud, .motes i,
  .c-body, .c-head, .c-eye, .c-accent,
  .mascot-wrap.swap .mascot {
    animation: none !important;
  }
  .affirmation .w {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
  .btn { transition: none; }
}
