/* ===========================================================================
   Evie & Theo — whimsical, colorful storybook builder
   =========================================================================== */

:root {
  --pink: #ff7eb6;
  --purple: #a48cf0;
  --blue: #6cc7ff;
  --teal: #5fe3c0;
  --yellow: #ffd86b;
  --orange: #ff9f6b;
  --ink: #3a2d5c;
  --ink-soft: #6b5b8f;
  --card: #ffffff;
  --cream: #fff9f0;
  --shadow: 0 12px 30px rgba(92, 60, 140, 0.18);
  --radius: 22px;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --font-book: "Lora", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(160deg, #c8efff 0%, #e6dcff 38%, #ffe6f3 70%, #fff3dd 100%);
  background-size: 100% 220%;
  background-attachment: fixed;
  overflow-x: hidden;
  animation: sky-shift 28s ease-in-out infinite alternate;
}

@keyframes sky-shift {
  0% { background-position: 50% 0%; }
  100% { background-position: 50% 100%; }
}

/* ---- floating background ------------------------------------------------- */
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.float {
  position: absolute;
  font-size: 2.4rem;
  opacity: 0.7;
  animation: bob 7s ease-in-out infinite;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.08));
  will-change: transform, opacity;
}

/* default gentle bob, varied per element via positions + delays */
.f1 { top: 12%; left: 8%; animation-duration: 8s; animation-delay: 0s; }
.f2 { top: 22%; right: 10%; font-size: 3rem; animation-duration: 9s; animation-delay: 1s; }
.f3 { top: 60%; left: 5%; font-size: 3.4rem; animation-duration: 11s; animation-delay: 2s; }
.f4 { top: 75%; right: 8%; font-size: 2.2rem; animation-duration: 6.5s; animation-delay: 0.5s; }
.f5 { top: 40%; left: 14%; font-size: 2.6rem; animation-duration: 10s; animation-delay: 1.5s; }
.f6 { top: 50%; right: 16%; animation-duration: 7.5s; animation-delay: 2.5s; }
.f7 { top: 85%; left: 20%; font-size: 2.8rem; animation-duration: 12s; animation-delay: 3s; }
.f8 { top: 8%; right: 26%; font-size: 2.6rem; animation-duration: 9.5s; animation-delay: 3.5s; }
.f9 { top: 33%; left: 46%; font-size: 2rem; animation-duration: 8.5s; animation-delay: 0.8s; }
.f10 { top: 68%; right: 30%; font-size: 2.9rem; animation-duration: 13s; animation-delay: 2.2s; }

/* gentle vertical bob (default) */
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-22px) rotate(4deg); }
}

/* drift slowly sideways while bobbing */
.float.drift { animation-name: drift; }
@keyframes drift {
  0%   { transform: translate(0, 0) rotate(-3deg); }
  25%  { transform: translate(26px, -16px) rotate(3deg); }
  50%  { transform: translate(8px, -28px) rotate(-2deg); }
  75%  { transform: translate(-22px, -14px) rotate(4deg); }
  100% { transform: translate(0, 0) rotate(-3deg); }
}

/* twinkle: bob plus opacity pulse */
.float.twinkle { animation-name: twinkle; }
@keyframes twinkle {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.45; }
  50% { transform: translateY(-16px) scale(1.18); opacity: 0.95; }
}

/* slow full rotation */
.float.spin { animation-name: spin; animation-timing-function: linear; }
@keyframes spin {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-14px) rotate(180deg); }
  100% { transform: translateY(0) rotate(360deg); }
}

/* ---- layout -------------------------------------------------------------- */
main {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 18px 60px;
}

.site-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 38px 18px 10px;
}

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 9vw, 4.6rem);
  margin: 0;
  line-height: 1;
  background: linear-gradient(90deg, var(--pink), var(--purple), var(--blue), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.45);
}
.logo .amp {
  -webkit-text-fill-color: var(--yellow);
  color: var(--yellow);
}
.tagline {
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.6vw, 1.4rem);
  color: var(--ink-soft);
  margin: 8px 0 0;
}
.tagline em {
  color: var(--pink);
  font-style: normal;
  font-weight: 600;
}

.intro {
  text-align: center;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 6px auto 26px;
  max-width: 560px;
}

/* ---- cards / fieldsets ---------------------------------------------------- */
.card {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 24px;
  margin: 0 0 22px;
}
.card legend {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--ink);
  padding: 6px 16px;
  background: var(--cream);
  border-radius: 999px;
  box-shadow: 0 4px 0 rgba(164, 140, 240, 0.25);
}
.hint {
  margin: 2px 0 14px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1.4fr 0.7fr 1fr;
}
.grid.two {
  grid-template-columns: 1fr 1fr;
}
.grid.main-grid {
  grid-template-columns: 1.6fr 0.8fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field:last-child {
  margin-bottom: 0;
}
.field > span,
.field-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
}
.field-label {
  display: block;
  margin: 4px 0 10px;
}

input[type="text"],
input[type="number"],
textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  background: #fbfaff;
  border: 2.5px solid #ece7fb;
  border-radius: 14px;
  padding: 12px 14px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
textarea {
  resize: vertical;
  line-height: 1.5;
}
input::placeholder,
textarea::placeholder {
  color: #b7afca;
  font-weight: 500;
  font-style: italic;
  opacity: 1;
}
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(164, 140, 240, 0.22);
}

/* ---- character rows ------------------------------------------------------ */
.character-row {
  display: grid;
  grid-template-columns: 1fr 1.7fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  animation: pop 0.18s ease-out;
}
.character-row .field {
  margin-bottom: 0;
}
.remove-btn {
  font-size: 1.2rem;
  line-height: 1;
  background: #fff0f5;
  border: 2.5px solid #ffd4e5;
  color: var(--pink);
  border-radius: 12px;
  height: 48px;
  width: 48px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}
.remove-btn:hover {
  background: #ffe0ec;
  transform: scale(1.06);
}

@keyframes pop {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---- flavor chips -------------------------------------------------------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chip {
  cursor: pointer;
}
.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.chip span {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 1rem;
  padding: 10px 16px;
  border-radius: 999px;
  background: #f4f0ff;
  border: 2.5px solid #e7e0fb;
  color: var(--ink-soft);
  transition: transform 0.08s, background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover span {
  transform: translateY(-2px);
}
.chip input:checked + span {
  background: linear-gradient(90deg, var(--pink), var(--purple));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px rgba(164, 140, 240, 0.4);
}
.chip input:focus-visible + span {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* ---- buttons ------------------------------------------------------------- */
.create-btn {
  display: block;
  width: 100%;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 18px 24px;
  cursor: pointer;
  background: linear-gradient(90deg, var(--orange), var(--pink), var(--purple));
  background-size: 200% auto;
  box-shadow: 0 10px 24px rgba(255, 126, 182, 0.45);
  transition: transform 0.1s, box-shadow 0.15s, background-position 0.4s;
}
.create-btn:hover {
  background-position: right center;
  transform: translateY(-2px) scale(1.01);
}
.create-btn:active {
  transform: translateY(0) scale(0.99);
}
.create-btn:disabled {
  filter: grayscale(0.4) opacity(0.7);
  cursor: wait;
}
.create-btn.small {
  font-size: 1.15rem;
  padding: 12px 28px;
  width: auto;
}

.ghost-btn {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  color: var(--purple);
  background: #fff;
  border: 2.5px dashed #d9cffb;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
}
.ghost-btn:hover {
  background: #f6f1ff;
  transform: translateY(-1px);
}
.ghost-btn.big {
  font-size: 1.15rem;
  padding: 14px 24px;
  border-style: solid;
}

.turnstile-wrap {
  display: flex;
  justify-content: center;
  margin: 0 0 18px;
  min-height: 65px;
}

.form-error {
  background: #fff0f4;
  color: #c23d6b;
  border: 2px solid #ffd0df;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  margin: 0 0 16px;
  text-align: center;
}

/* ---- loading ------------------------------------------------------------- */
.loading {
  text-align: center;
  padding: 70px 20px;
}
.cauldron {
  font-size: 4.5rem;
  display: inline-block;
  animation: stir 1.4s ease-in-out infinite;
}
@keyframes stir {
  0%, 100% { transform: rotate(-12deg) scale(1); }
  50% { transform: rotate(12deg) scale(1.12); }
}
.loading-msg {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--ink);
  margin: 18px 0 12px;
  min-height: 1.6em;
}
.dots {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.dots span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--purple);
  animation: jump 1s ease-in-out infinite;
}
.dots span:nth-child(2) { background: var(--pink); animation-delay: 0.15s; }
.dots span:nth-child(3) { background: var(--teal); animation-delay: 0.3s; }
@keyframes jump {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-12px); opacity: 1; }
}

/* ---- storybook ----------------------------------------------------------- */
.storybook {
  animation: fadein 0.5s ease;
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.book {
  background: var(--cream);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px clamp(24px, 6vw, 56px) 48px;
  position: relative;
  border: 1px solid #f0e6d6;
}
.book::before {
  /* a soft "spine" down the left edge */
  content: "";
  position: absolute;
  left: 14px;
  top: 24px;
  bottom: 24px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--pink), var(--purple), var(--blue));
  opacity: 0.5;
}
.story-title {
  font-family: var(--font-book);
  font-weight: 600;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  text-align: center;
  color: var(--ink);
  margin: 0 0 28px;
  line-height: 1.2;
}
.story-body {
  font-family: var(--font-book);
  font-size: clamp(1.12rem, 2.6vw, 1.3rem);
  line-height: 1.85;
  color: #2f2647;
}

/* ---- illustrated scenes -------------------------------------------------- */
.scene {
  margin: 0 0 38px;
}
.scene:last-child {
  margin-bottom: 0;
}
.scene-illus {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #fff;
  box-shadow: 0 8px 20px rgba(92, 60, 140, 0.15);
  background: linear-gradient(120deg, #f3ecff, #ffe9f3, #e9f6ff);
  background-size: 200% 200%;
  animation: shimmer 2.4s ease-in-out infinite;
}
.scene-illus.ready {
  animation: none;
  background: #fff;
}
.illus-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  color: var(--ink-soft);
  font-size: 1rem;
}
.illus-emoji {
  font-size: 2.4rem;
  animation: stir 1.4s ease-in-out infinite;
}
.scene-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: fadein 0.5s ease;
}
@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.scene-text p {
  margin: 0 0 1.1em;
}
.scene-text p:last-child {
  margin-bottom: 0;
}
.scene:first-child .scene-text p:first-child::first-letter {
  font-size: 3.2em;
  font-weight: 600;
  float: left;
  line-height: 0.8;
  padding: 6px 10px 2px 0;
  color: var(--pink);
}

.book-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 26px 0 0;
}

/* ---- modal --------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(58, 45, 92, 0.45);
  backdrop-filter: blur(3px);
  padding: 20px;
  animation: fadein 0.2s ease;
}
.modal-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  max-width: 420px;
  text-align: center;
  animation: pop 0.25s ease-out;
}
.modal-emoji {
  font-size: 3rem;
}
.modal-card h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 8px 0 10px;
  color: var(--ink);
}
.modal-card p {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 1.08rem;
  margin: 0 0 22px;
}

/* ---- feedback ------------------------------------------------------------ */
.feedback {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 22px auto 0;
  padding: 14px 22px;
  max-width: 460px;
  background: #fff;
  border: 2.5px dashed #e7e0fb;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(92, 60, 140, 0.1);
}
.feedback > span {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--ink-soft);
}
.feedback button {
  font-size: 1.5rem;
  line-height: 1;
  background: #f4f0ff;
  border: 2.5px solid #e7e0fb;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
.feedback button:hover {
  transform: translateY(-2px) scale(1.08);
  background: #ece4ff;
}
.feedback button:active {
  transform: scale(0.96);
}
.feedback button.selected {
  background: linear-gradient(90deg, var(--pink), var(--purple));
  border-color: transparent;
  box-shadow: 0 6px 14px rgba(164, 140, 240, 0.4);
}
.feedback button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* ---- standalone content pages (about / contact) -------------------------- */
.page {
  position: relative;
  z-index: 1;
}
.page-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 5vw, 2.3rem);
  text-align: center;
  color: var(--ink);
  margin: 6px auto 22px;
  line-height: 1.25;
}
.prose p {
  font-size: 1.08rem;
  line-height: 1.75;
  color: #463a64;
  margin: 0 0 1em;
}
.prose p:last-child {
  margin-bottom: 0;
}
.prose-head {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--ink);
  margin: 0 0 14px;
}
.steps {
  margin: 0;
  padding-left: 1.2em;
  color: #463a64;
}
.steps li {
  font-size: 1.06rem;
  line-height: 1.7;
  margin-bottom: 10px;
}
.steps li:last-child {
  margin-bottom: 0;
}

/* ---- tip jar ------------------------------------------------------------- */
.tip-jar {
  text-align: center;
  background: linear-gradient(150deg, #fff9f0, #fff);
}
.tip-jar-emoji {
  font-size: 3rem;
  animation: bob 6s ease-in-out infinite;
}
.tip-jar .prose-head {
  margin-top: 4px;
}
.tip-jar p {
  font-size: 1.06rem;
  line-height: 1.72;
  color: #463a64;
  margin: 0 auto 1em;
  max-width: 520px;
}
.tip-soft {
  color: var(--ink-soft) !important;
  font-weight: 600;
}
.tip-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}
.tip-btn {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.1rem;
  text-decoration: none;
  color: #fff;
  padding: 12px 26px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), var(--pink), var(--purple));
  background-size: 200% auto;
  box-shadow: 0 8px 18px rgba(255, 126, 182, 0.4);
  transition: transform 0.1s, box-shadow 0.15s, background-position 0.4s;
}
.tip-btn:hover {
  background-position: right center;
  transform: translateY(-2px) scale(1.03);
}
.tip-btn:active {
  transform: translateY(0) scale(0.98);
}
.tip-btn:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.back-link {
  text-align: center;
  margin: 26px 0 0;
}
.back-link a {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--purple);
  text-decoration: none;
  border-bottom: 2px dashed #d9cffb;
  padding-bottom: 2px;
  transition: color 0.15s, border-color 0.15s;
}
.back-link a:hover {
  color: var(--pink);
  border-color: var(--pink);
}

/* ---- logo as link (sub-pages) ------------------------------------------- */
.logo-link {
  text-decoration: none;
  display: inline-block;
}

/* ---- contact form -------------------------------------------------------- */
.optional {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.required-mark {
  font-weight: 700;
  color: var(--pink);
  font-size: 0.85rem;
}
input[type="email"] {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  background: #fbfaff;
  border: 2.5px solid #ece7fb;
  border-radius: 14px;
  padding: 12px 14px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="email"]:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(164, 140, 240, 0.22);
}
.contact-status {
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  margin: 0 0 16px;
  text-align: center;
}
.contact-status.ok {
  background: #eafaf3;
  color: #1f8f6b;
  border: 2px solid #bdeddc;
}
.contact-status.err {
  background: #fff0f4;
  color: #c23d6b;
  border: 2px solid #ffd0df;
}

/* ---- footer -------------------------------------------------------------- */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 10px 18px 40px;
  font-size: 0.92rem;
}
.footer-links {
  margin-top: 8px;
  font-family: var(--font-display);
}
.footer-links a {
  color: var(--purple);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}
.footer-links a:hover {
  color: var(--pink);
  text-decoration: underline;
}
.footer-links .dot {
  margin: 0 10px;
  color: #c9bef0;
}

[hidden] {
  display: none !important;
}

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 560px) {
  .grid,
  .grid.two {
    grid-template-columns: 1fr;
  }
  .character-row {
    grid-template-columns: 1fr 1fr;
  }
  .character-row .remove-btn {
    grid-column: 2;
    justify-self: end;
  }
}

@media (prefers-reduced-motion: reduce) {
  body,
  .float,
  .float.drift,
  .float.twinkle,
  .float.spin,
  .cauldron,
  .dots span,
  .scene-illus,
  .illus-emoji {
    animation: none !important;
  }
}

/* ---- print: just the storybook ------------------------------------------- */
@media print {
  body {
    background: #fff;
  }
  .sky,
  .site-header,
  .site-footer,
  .builder,
  .loading,
  .book-actions,
  .feedback,
  .modal {
    display: none !important;
  }
  main {
    max-width: none;
    padding: 0;
  }
  .book {
    box-shadow: none;
    border: none;
    background: #fff;
    padding: 0;
  }
  .book::before {
    display: none;
  }
  /* don't print empty/loading illustration boxes; keep scenes intact */
  .scene-illus:not(.ready) {
    display: none;
  }
  .scene-illus {
    animation: none;
    box-shadow: none;
    border: none;
    break-inside: avoid;
  }
  .scene {
    break-inside: avoid;
  }
}
