/* ---------- theme ---------- */

:root {
  --ink: #33261c;
  --ink-soft: #6b5949;
  --paper: #faf3e7;
  --card: #fffdf8;
  --shadow: rgba(80, 50, 20, 0.13);
}

/* mode palettes */
body[data-mode="original"] {
  --accent: #d4502e;
  --accent-soft: #f6d9c6;
  --sky-top: #f8ead3;
  --sky-bottom: #f3d9b8;
  --robin-breast: #e2603f;
}
body[data-mode="kid"] {
  --accent: #2f8fbf;
  --accent-soft: #cfe9f5;
  --sky-top: #e3f3fa;
  --sky-bottom: #c9e6f2;
  --robin-breast: #f0904f;
}
body[data-mode="risque"] {
  --accent: #8e4a73;
  --accent-soft: #e8d3df;
  --sky-top: #f0e2ea;
  --sky-bottom: #ddc3d2;
  --robin-breast: #c45a55;
}

/* ---------- base ---------- */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Nunito Sans", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
  transition: background 0.6s ease;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* drifting clouds */
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  filter: blur(2px);
  animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.c1 { width: 150px; height: 38px; top: 10%; animation-duration: 85s; }
.c1::before { width: 60px; height: 60px; top: -28px; left: 28px; }
.c1::after  { width: 44px; height: 44px; top: -18px; left: 76px; }
.c2 { width: 110px; height: 30px; top: 26%; animation-duration: 120s; animation-delay: -50s; }
.c2::before { width: 46px; height: 46px; top: -22px; left: 20px; }
.c2::after  { width: 34px; height: 34px; top: -14px; left: 58px; }
.c3 { width: 90px; height: 26px; top: 64%; animation-duration: 100s; animation-delay: -25s; }
.c3::before { width: 38px; height: 38px; top: -18px; left: 16px; }
.c3::after  { width: 28px; height: 28px; top: -12px; left: 48px; }

@keyframes drift {
  from { transform: translateX(-200px); }
  to   { transform: translateX(calc(100vw + 200px)); }
}

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

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  padding: clamp(20px, 5vh, 44px) 20px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 2.6vh, 24px);
}

/* ---------- masthead ---------- */

.title {
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 2.9rem);
  text-align: center;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.title::after {
  content: "";
  display: block;
  width: 64px;
  height: 3px;
  margin: 8px auto 0;
  border-radius: 2px;
  background: var(--accent);
  transition: background 0.5s ease;
}

.tagline {
  margin-top: 10px;
  text-align: center;
  font-size: clamp(0.95rem, 3.6vw, 1.05rem);
  color: var(--ink-soft);
}

/* ---------- mode pills ---------- */

.modes {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.5);
  padding: 5px;
  border-radius: 999px;
  box-shadow: 0 2px 10px var(--shadow);
}

.mode-pill {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.mode-pill[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

/* ---------- question card ---------- */

.stage {
  width: 100%;
  display: flex;
  justify-content: center;
  flex: 1 0 auto;
}

.card {
  width: 100%;
  min-height: clamp(170px, 26vh, 250px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--accent-soft);
  border-radius: 22px;
  padding: clamp(22px, 5vw, 36px);
  box-shadow: 0 12px 32px var(--shadow);
  position: relative;
}

/* speech-bubble tail pointing down at the robin */
.card::after {
  content: "";
  position: absolute;
  bottom: -11px;
  left: 50%;
  width: 22px;
  height: 22px;
  transform: translateX(2px) rotate(45deg);
  background: var(--card);
  border-right: 1px solid var(--accent-soft);
  border-bottom: 1px solid var(--accent-soft);
  border-bottom-right-radius: 5px;
}
.card::before {
  content: "“";
  position: absolute;
  top: 4px;
  left: 18px;
  font-family: "Fraunces", serif;
  font-size: 3.4rem;
  line-height: 1;
  color: var(--accent-soft);
  transition: color 0.5s ease;
}

.card-text {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: clamp(1.25rem, 5.4vw, 1.7rem);
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  animation: rise 0.45s ease both;
}
.card[data-state="welcome"] .card-text,
.card[data-state="error"] .card-text {
  font-family: "Nunito Sans", system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(1rem, 4.2vw, 1.15rem);
  color: var(--ink-soft);
  line-height: 1.55;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card.is-leaving .card-text {
  animation: sink 0.18s ease both;
}
@keyframes sink {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-10px); }
}

.card-hint {
  display: block;
  margin-top: 14px;
  font-family: "Nunito Sans", system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(0.88rem, 3.6vw, 1rem);
  line-height: 1.5;
  color: var(--ink-soft);
}
.card-hint::before {
  content: "";
  display: block;
  width: 34px;
  height: 2px;
  margin: 0 auto 12px;
  border-radius: 1px;
  background: var(--accent-soft);
}

.card-attr {
  display: block;
  margin-top: 12px;
  font-family: "Nunito Sans", system-ui, sans-serif;
  font-weight: 600;
  font-style: italic;
  font-size: clamp(0.78rem, 3.2vw, 0.86rem);
  color: var(--ink-soft);
  opacity: 0.75;
}

.retry-btn {
  margin-top: 14px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
}

/* ---------- robin ---------- */

.robin-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.robin {
  width: clamp(120px, 30vw, 160px);
  height: auto;
  filter: drop-shadow(0 10px 14px var(--shadow));
  animation: bob 3.2s ease-in-out infinite;
  transform-origin: 50% 90%;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.robin-head {
  transform-origin: 158px 66px;
  transition: transform 0.2s ease;
}
.robin-btn:active .robin-head { transform: rotate(10deg); }

.robin.is-pecking { animation: peck 0.5s ease; }
@keyframes peck {
  0%   { transform: translateY(0) rotate(0deg); }
  30%  { transform: translateY(6px) rotate(-7deg); }
  60%  { transform: translateY(-8px) rotate(3deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

.robin-hint {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  transition: color 0.5s ease;
}

/* ---------- suggest a question ---------- */

.suggest {
  width: 100%;
  text-align: center;
}

.suggest-summary {
  display: inline-block;
  list-style: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 4px;
  -webkit-tap-highlight-color: transparent;
}
.suggest-summary::-webkit-details-marker { display: none; }
.suggest[open] .suggest-summary,
.suggest-summary:hover { color: var(--accent); }

.suggest-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.suggest-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  padding: 12px 18px;
  outline: none;
  box-shadow: 0 2px 8px var(--shadow);
}
.suggest-input:focus { border-color: var(--accent); }
.suggest-input::placeholder { color: var(--ink-soft); opacity: 0.6; }

.suggest-btn {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.suggest-btn:active { transform: scale(0.92); }

.suggest-note {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  opacity: 0.8;
}

/* ---------- footer / share ---------- */

.footer { padding-bottom: 4px; }

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.share-btn:hover { color: var(--accent); }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 10;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .robin, .cloud { animation: none; }
}
