/* My Story Studio: the look of the "Story Museum mock" canvas.
   Ink #2A2250 on lilac, yellow for "go", Ollie purple. Fredoka for
   headings, Lexend for reading, Patrick Hand for her own words. */

@font-face { font-family: "Fredoka"; src: url(/fonts/fredoka.woff2) format("woff2");
  font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Lexend"; src: url(/fonts/lexend.woff2) format("woff2");
  font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Patrick Hand"; src: url(/fonts/patrick-hand.woff2) format("woff2");
  font-weight: 400; font-display: swap; }

:root {
  --ink: #2A2250;
  --ink-soft: #4A4370;
  --ink-muted: #5B5480;
  --ground: #F1EEFF;
  --white: #FFFFFF;
  --yellow: #FFC83D;
  --indigo: #4A44C9;
  --ollie: #8E5BE8;
  --paper-line: #A9C7FF;
  --margin-red: #FF8A8A;
  --her-ink: #2B3A8C;
  /* one colour pair per kind of fix: strong text on a pale fill */
  --capitals: #C8402B;     --capitals-bg: #FFE1DB;    --capitals-text: #9E2E1C;
  --punctuation: #4A44C9;  --punctuation-bg: #E4E2FF; --punctuation-text: #3A35A8;
  --spelling: #A07400;     --spelling-bg: #FFF1C7;    --spelling-text: #7A5700;
  --sentences: #0E7F86;    --sentences-bg: #D5F1EF;   --sentences-text: #0B5F64;
  --good: #1F5E28;         --good-bg: #DDF2DC;
  --display: "Fredoka", "Avenir Next Rounded", ui-rounded, system-ui, sans-serif;
  --body: "Lexend", "Avenir Next", system-ui, sans-serif;
  --hand: "Patrick Hand", "Chalkboard SE", "Comic Sans MS", cursive;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--ground); color: var(--ink);
  font-family: var(--body); font-size: 17px; line-height: 1.5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0; }
h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: clamp(22px, 3vw, 30px); font-weight: 600; }
h3 { font-size: 20px; font-weight: 600; }
p { margin: 0; }
a { color: var(--ink); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--indigo); outline-offset: 3px; }
[hidden] { display: none !important; }

#app { max-width: 1240px; margin: 0 auto; padding: 20px clamp(16px, 3vw, 36px) 40px; }
.loading { padding: 80px 0; text-align: center; color: var(--ink-muted); }

/* --- buttons ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 10px 20px; border: 3px solid var(--ink); border-radius: 999px;
  background: var(--white); font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-big {
  min-height: 68px; border-radius: 22px; padding: 12px 28px; border-width: 4px;
  font-family: var(--display); font-size: 24px; font-weight: 600;
}
.btn-yellow { background: var(--yellow); }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-wide { width: 100%; }
.btn svg { width: 22px; height: 22px; flex: none; }
.link-btn { background: none; border: 0; padding: 8px 4px; min-height: 44px; font-weight: 600;
  text-decoration: underline; cursor: pointer; }

/* --- cards and bars ----------------------------------------------------------- */
.card {
  background: var(--white); border: 3px solid var(--ink); border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink); padding: 24px;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 20px; }
.topbar .who { display: flex; align-items: center; gap: 14px; }
.topbar .who .ollie { width: 52px; height: 56px; }
.topbar .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600;
  text-decoration: none; }
.back svg { width: 20px; height: 20px; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 13px;
  font-weight: 600; background: #E4E2FF; color: #3A35A8; }
.pill.warm { background: var(--spelling-bg); color: var(--spelling-text); }
.pill.fix { background: var(--capitals-bg); color: var(--capitals-text); }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.outline { background: var(--white); color: var(--ink); border: 2px solid var(--ink); }
.error { background: var(--capitals-bg); color: var(--capitals-text); border-radius: 14px;
  padding: 10px 14px; font-weight: 600; }
.note { font-size: 14px; color: var(--ink-muted); }

/* --- sign in ------------------------------------------------------------------- */
.sky { position: fixed; inset: 0; background: var(--indigo); z-index: -1; }
.signin { min-height: calc(100vh - 80px); display: flex; align-items: center; justify-content: center; }
.signin .card { width: min(560px, 100%); border-width: 4px; border-radius: 32px;
  box-shadow: 10px 12px 0 var(--ink); padding: 44px clamp(20px, 5vw, 48px) 36px;
  display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.signin .ollie { width: 140px; height: 150px; }
.signin label { align-self: stretch; text-align: left; display: flex; flex-direction: column;
  gap: 6px; font-size: 14px; font-weight: 600; }

/* --- inputs ---------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field input { min-height: 52px; padding: 10px 14px; border: 3px solid var(--ink);
  border-radius: 14px; font-size: 18px; background: var(--white); }

/* --- shelf ----------------------------------------------------------------------- */
.shelf { display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 1fr); gap: 28px;
  align-items: start; }
.snap { background: var(--yellow); border-width: 4px; border-radius: 28px;
  box-shadow: 8px 8px 0 var(--ink); display: flex; flex-direction: column; gap: 18px; }
.snap-head { display: flex; align-items: center; gap: 16px; }
.snap-head .icon { width: 72px; height: 72px; flex: none; border-radius: 50%; background: var(--white);
  border: 3px solid var(--ink); display: flex; align-items: center; justify-content: center; }
.snap-head .icon svg { width: 36px; height: 36px; }
.tips { background: var(--white); border: 2px solid var(--ink); border-radius: 16px;
  padding: 14px 18px; font-size: 15px; }
.stories { display: flex; flex-direction: column; gap: 14px; }
.story-row { display: flex; align-items: center; gap: 16px; padding: 14px; background: var(--white);
  border: 3px solid var(--ink); border-radius: 20px; text-decoration: none; }
.story-row:hover { transform: translateY(-2px); }
.thumb { width: 72px; height: 88px; flex: none; border: 2px solid var(--ink); border-radius: 10px;
  object-fit: cover; background: repeating-linear-gradient(#FFF 0 11px, var(--paper-line) 11px 12px); }
.story-row .what { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.story-row .title { font-family: var(--display); font-size: 20px; font-weight: 600; }
.empty { padding: 28px; text-align: center; color: var(--ink-muted); border: 3px dashed var(--ink-muted);
  border-radius: 20px; }

/* --- pages ------------------------------------------------------------------------- */
.pages { display: flex; gap: 14px; flex-wrap: wrap; }
.page {
  position: relative; width: 120px; height: 156px; border: 3px solid var(--ink); border-radius: 10px;
  background: repeating-linear-gradient(#FFF 0 14px, var(--paper-line) 14px 15px);
  overflow: hidden; padding: 0; cursor: pointer; display: block;
}
.page img { width: 100%; height: 100%; object-fit: cover; display: block; }
.page .num { position: absolute; left: 6px; bottom: 6px; padding: 3px 8px; border-radius: 999px;
  background: var(--ink); color: var(--white); font-size: 12px; font-weight: 600; }
.page .tick { position: absolute; right: 6px; top: 6px; width: 26px; height: 26px; border-radius: 50%;
  background: #2E7D3A; display: flex; align-items: center; justify-content: center; }
.page .tick svg { width: 14px; height: 14px; }
.page.busy::after { content: "…"; position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; background: rgba(255,255,255,.8); font-size: 32px; font-weight: 700; }
.page.add { border-style: dashed; background: rgba(255,255,255,.55); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; }
.page.add svg { width: 28px; height: 28px; }
.page input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.page:focus-within { outline: 3px solid var(--indigo); outline-offset: 3px; }

/* --- her words on lined paper ----------------------------------------------------- */
.paper {
  position: relative; background: repeating-linear-gradient(#FFF 0 43px, var(--paper-line) 43px 45px);
  border: 3px solid var(--ink); border-radius: 16px; padding: 30px 22px 20px 58px;
  font-family: var(--hand); font-size: 28px; line-height: 45px; color: var(--her-ink);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.paper::before { content: ""; position: absolute; left: 44px; top: 0; bottom: 0; width: 2px;
  background: var(--margin-red); }
.paper .page-label { display: block; font-family: var(--body); font-size: 12px; font-weight: 600;
  letter-spacing: .08em; color: var(--ink-muted); line-height: 45px; }
.paper .unclear { background: #E4E2FF; border-radius: 6px; padding: 0 4px; }
.hl { border-radius: 6px; padding: 0 3px; text-decoration: underline wavy; text-underline-offset: 6px;
  text-decoration-thickness: 2px; }
.n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 50%; font-family: var(--body); font-size: 12px; font-weight: 600; color: var(--white);
  vertical-align: super; margin-left: 2px; line-height: 1; }
.k-capitals.hl { background: var(--capitals-bg); text-decoration-color: var(--capitals); }
.k-punctuation.hl { background: var(--punctuation-bg); text-decoration-color: var(--punctuation); }
.k-spelling.hl { background: var(--spelling-bg); text-decoration-color: var(--spelling); }
.k-sentences.hl { background: var(--sentences-bg); text-decoration-color: var(--sentences); }
.k-capitals.n { background: var(--capitals); }
.k-punctuation.n { background: var(--punctuation); }
.k-spelling.n { background: var(--spelling); }
.k-sentences.n { background: var(--sentences); }
.k-capitals.pill { background: var(--capitals-bg); color: var(--capitals-text); }
.k-punctuation.pill { background: var(--punctuation-bg); color: var(--punctuation-text); }
.k-spelling.pill { background: var(--spelling-bg); color: var(--spelling-text); }
.k-sentences.pill { background: var(--sentences-bg); color: var(--sentences-text); }

/* --- two-column story screens ------------------------------------------------------- */
.split { display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 1fr); gap: 24px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; }

.bubble-row { display: flex; gap: 14px; align-items: flex-start; }
.bubble-row .ollie { width: 76px; height: 82px; flex: none; }
.bubble { flex: 1; background: var(--white); border: 3px solid var(--ink); border-radius: 22px 22px 22px 6px;
  padding: 16px 20px; font-size: 18px; line-height: 1.5; }
.bubble strong { display: block; font-family: var(--display); font-size: 21px; font-weight: 600; }

.levels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.level { background: var(--white); border: 2px solid var(--ink); border-radius: 16px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px; }
.level .name { font-size: 14px; font-weight: 600; }
.level .value { font-family: var(--display); font-size: 19px; font-weight: 600; }
.level .value.super_strong, .level .value.strong { color: var(--good); }
.level .value.growing { color: var(--punctuation-text); }

.hints { display: flex; flex-direction: column; gap: 12px; }
.hint { display: flex; gap: 12px; align-items: flex-start; font-size: 17px; line-height: 1.45; }
.hint .n { vertical-align: baseline; flex: none; margin: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .grow { flex: 1; }

/* --- waiting and held ---------------------------------------------------------------- */
.waiting { min-height: 60vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; text-align: center; }
.waiting .ollie { width: 150px; height: 160px; }
.waiting .ollie.bob { animation: bob 1.2s ease-in-out infinite alternate; transform-origin: 50% 100%; }
@keyframes bob { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
@media (prefers-reduced-motion: reduce) { .waiting .ollie.bob { animation: none; } }
.waiting p { max-width: 560px; font-size: 20px; }

/* --- the grown-up check ------------------------------------------------------------ */
.gate { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(42, 34, 80, .55); }
.gate .card { width: min(520px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center; border-width: 4px; border-radius: 28px; }
.gate .ollie { width: 110px; height: 118px; }

/* --- grown-up corner ------------------------------------------------------------------- */
.grownup { display: flex; flex-direction: column; gap: 24px; }
.hold { display: flex; flex-direction: column; gap: 10px; }
.concern { background: var(--capitals); color: var(--white); border-radius: 12px; padding: 8px 12px;
  font-weight: 600; }
.reasons { margin: 0; padding-left: 20px; }
.person { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; border-top: 2px solid var(--ground); }
.person:first-of-type { border-top: 0; }
.person .row { align-items: flex-end; }
.enrol-link { word-break: break-all; font-family: ui-monospace, monospace; font-size: 13px;
  background: var(--ground); border-radius: 10px; padding: 10px; }
.checks { font-size: 14px; }

@media (max-width: 900px) {
  .shelf, .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .btn-big { font-size: 20px; min-height: 60px; }
  .paper { font-size: 24px; line-height: 39px; padding-left: 50px;
    background: repeating-linear-gradient(#FFF 0 37px, var(--paper-line) 37px 39px); }
  .paper .page-label { line-height: 39px; }
  .paper::before { left: 38px; }
  .page { width: 96px; height: 125px; }
}
