/* Story Maker — warm picture-book UI. Andika for story text (the book font),
   Quicksand for headings, on a cream barn-side palette. */

@font-face {
  font-family: "Andika";
  src: url("/assets/fonts/Andika-Regular.ttf") format("truetype");
  font-weight: 400;
}
@font-face {
  font-family: "Andika";
  src: url("/assets/fonts/Andika-Bold.ttf") format("truetype");
  font-weight: 700;
}
@font-face {
  font-family: "Quicksand";
  src: url("/assets/fonts/Quicksand-Bold.ttf") format("truetype");
  font-weight: 700;
}

:root {
  --barn: #a5372d;
  --barn-dark: #7c2921;
  --cream: #fbf6ec;
  --hay: #e9d8ae;
  --ink: #3b2f2a;
  --meadow: #4d7c43;
  --sky: #cfe3ef;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Andika", "Comic Sans MS", sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px 6px;
  max-width: 720px; margin: 0 auto;
}
.app-header .logo { width: 56px; height: 56px; border-radius: 14px; box-shadow: 0 2px 8px rgb(0 0 0 / 20%); }
h1 { font-family: "Quicksand", sans-serif; font-size: 1.5rem; margin: 0; color: var(--barn); }
.tagline { margin: 2px 0 0; font-size: .85rem; opacity: .75; }

main { max-width: 720px; margin: 0 auto; padding: 10px 16px 40px; }

.card {
  background: #fff;
  border: 1px solid #eadfce;
  border-radius: 16px;
  padding: 20px;
  margin: 14px 0;
  box-shadow: 0 3px 14px rgb(90 60 30 / 8%);
}
h2 { font-family: "Quicksand", sans-serif; color: var(--barn-dark); margin: 0 0 12px; }
.subtitle { margin: -8px 0 12px; font-style: italic; opacity: .7; }

label { display: block; font-weight: 700; margin: 12px 0 4px; }
.opt { font-weight: 400; opacity: .6; font-size: .85em; }
textarea, input {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 2px solid var(--hay);
  border-radius: 10px;
  background: var(--cream);
  color: var(--ink);
}
textarea:focus, input:focus { outline: none; border-color: var(--meadow); }
.grid3 { display: grid; grid-template-columns: 1fr; gap: 4px; }
@media (min-width: 560px) { .grid3 { grid-template-columns: 1fr 1fr 1fr; gap: 10px; } }

button {
  font-family: "Quicksand", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 18px;
  margin: 14px 8px 0 0;
  cursor: pointer;
  border: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
button.primary { background: var(--barn); color: #fff; }
button.primary:active { background: var(--barn-dark); }
button.ghost { background: transparent; border-color: var(--barn); color: var(--barn); }
button:disabled { opacity: .5; cursor: default; }
.price { font-weight: 400; font-size: .85em; opacity: .85; }
.actions { display: flex; flex-wrap: wrap; }

.banner { border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: .9rem; }
.banner.warn { background: #fdf3d7; border: 1px solid #e5c96b; }
.banner.error { background: #fbe3df; border: 1px solid var(--barn); }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.hidden { display: none !important; }
.fineprint { font-size: .8rem; opacity: .65; margin-top: 14px; }

/* Story review */
.spread-review { margin: 18px 0; padding: 14px; background: var(--cream); border-radius: 12px; }
.spread-review h3 { font-family: "Quicksand", sans-serif; margin: 0 0 8px; color: var(--meadow); }
.spread-review p { margin: 4px 0; }
.spread-review .img-note { font-size: .78rem; opacity: .55; font-style: italic; margin-top: 8px; }

/* Art run */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumb { position: relative; aspect-ratio: 4 / 3; background: var(--hay); border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .label { position: absolute; bottom: 4px; left: 6px; font-size: .7rem; background: rgb(255 255 255 / 80%); padding: 1px 6px; border-radius: 6px; }
.thumb.pending { opacity: .55; }
.thumb.failed { background: #fbe3df; font-size: .8rem; text-align: center; padding: 6px; }
.spinner { width: 26px; height: 26px; border: 4px solid rgb(0 0 0 / 15%); border-top-color: var(--barn); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
progress { width: 100%; accent-color: var(--barn); }

/* The book */
#book .page {
  background: #fff;
  border: 1px solid #eadfce;
  border-radius: 16px;
  margin: 16px 0;
  padding: 22px;
  box-shadow: 0 3px 14px rgb(90 60 30 / 8%);
}
#book .page img { width: 100%; border-radius: 10px; }
#book h3 { font-family: "Quicksand", sans-serif; font-size: 1.3rem; color: var(--barn-dark); margin: 14px 0 10px; }
#book .lines p { margin: 0 0 .55em; font-size: 1.12rem; line-height: 1.45; }
#book .cover { text-align: center; }
#book .cover h2 { font-size: 2rem; margin: 12px 0 2px; color: var(--barn); }
#book .cover .subtitle { font-style: italic; }
#book .cover .dedication { margin-top: 10px; font-size: .9rem; opacity: .7; }

footer { text-align: center; font-size: .8rem; opacity: .6; padding: 20px; }

/* B&W mode: applied to <body> for ink-friendly printing (and preview) */
body.bw #book img { filter: grayscale(1) contrast(1.05); }
body.bw #book, body.bw #book .page { color: #000; }

/* Print: each spread on its own page, chrome hidden */
@media print {
  .no-print, footer { display: none !important; }
  body { background: #fff; padding: 0; }
  main { max-width: none; padding: 0; }
  #book .page {
    border: none; box-shadow: none; border-radius: 0;
    margin: 0; padding: 0 8mm;
    page-break-after: always;
    break-after: page;
  }
  #book .page img { border-radius: 0; max-height: 60vh; object-fit: contain; }
  body.bw #book img { filter: grayscale(1) contrast(1.1); print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
@page { size: letter portrait; margin: 12mm; }
