/* Home Schooling Kids — the app screens (loaded after app.css) */

.app-body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.app-wrap { width: min(1120px, 100% - 2 * var(--gut)); margin-inline: auto; padding-bottom: 40px; }
.app-view { outline: none; min-height: 60vh; }

/* ---------- header ---------- */
.app-head { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--paper) 94%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 3px 0 rgb(31 42 68 / .08); padding-top: env(safe-area-inset-top); }
.app-head-in { width: min(1120px, 100% - 2 * var(--gut)); margin-inline: auto; display: flex; align-items: center; gap: 12px; min-height: 66px; }
.app-head .brand { margin-right: auto; }
.app-head .brand b { display: none; }
@media (min-width: 420px) { .app-head .brand b { display: block; } }
.app-tools { display: flex; align-items: center; gap: 8px; }
.icon-btn { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--sky); color: var(--ink); }
.icon-btn:hover { background: var(--sky-2); }
.who-chip { display: none; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border-radius: 99px; background: var(--sky); text-decoration: none; font: 600 1rem/1 var(--display); }
.who-chip .av { width: 38px; height: 38px; }
@media (min-width: 860px) { .who-chip { display: inline-flex; } }
.av { display: inline-block; width: 56px; height: 56px; flex: none; }
.av svg { width: 100%; height: 100%; }

.app-tabs { display: none; gap: 4px; }
.app-tabs a, .tabbar a { text-decoration: none; font: 600 1rem/1 var(--display); }
.app-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 14px; }
.app-tabs a:hover { background: var(--sky); }
.app-tabs a[aria-current="page"] { background: var(--ink); color: #fff; }
.app-tabs .tab-who { display: none; }
@media (min-width: 860px) { .app-tabs { display: flex; } .tabbar { display: none !important; } .app-body { padding-bottom: 0; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--paper); box-shadow: 0 -3px 0 rgb(31 42 68 / .08); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 60px; border-radius: 16px; font-size: .82rem; color: var(--ink-2); }
.tabbar a .icon, .tabbar a .av { width: 28px; height: 28px; }
.tabbar a[aria-current="page"] { color: var(--ink); background: var(--sky); }
.tabbar a[aria-current="page"] .icon { color: var(--coral-d); }
body.is-reading .app-head, body.is-reading .tabbar { display: none; }
body.is-reading { padding-bottom: 0; background: var(--night); }

/* ---------- who's reading ---------- */
.who { position: relative; text-align: center; padding: clamp(36px, 8vw, 80px) var(--gut) 40px; overflow: hidden; }
.who-sun { position: absolute; width: 260px; right: -70px; top: -80px; opacity: .9; animation: spin 60s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.who h1 { position: relative; font-size: clamp(2rem, 7vw, 3.2rem); }
.who .sub { margin: 10px auto 0; }
.who-grid { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(18px, 4vw, 34px); margin: 40px auto 0; max-width: 760px; }
.who-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px; width: 132px; padding: 0; border: 0; background: none; cursor: pointer;
  font: 600 1.15rem/1.2 var(--display); color: var(--ink); animation: pop .5s var(--ease-paper) both; animation-delay: calc(var(--i) * 70ms);
}
.who-card .av { width: 120px; height: 120px; transition: transform .25s var(--ease-paper); }
.who-card:hover .av, .who-card:focus-visible .av { transform: translateY(-6px) rotate(-4deg) scale(1.04); }
.who-card:active .av { transform: scale(.94); }
.who-card .av.plus { display: grid; place-items: center; border-radius: 50%; border: 4px dashed #9fb3c8; color: var(--ink-2); }
.who-card .av.plus .icon { width: 44px; height: 44px; }
@keyframes pop { from { opacity: 0; transform: scale(.6) translateY(20px); } }
.parents-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 44px; font-weight: 800; color: var(--ink-2); min-height: 44px; }

/* ---------- overlay ---------- */
.ov { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; background: rgb(31 42 68 / .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fade .2s ease both; overflow: hidden; }
@keyframes fade { from { opacity: 0; } }
.ov-card { width: min(520px, 100%); max-height: calc(100svh - 36px); overflow: auto; background: var(--paper); border-radius: 26px; padding: clamp(22px, 5vw, 34px); box-shadow: 0 10px 0 rgb(0 0 0 / .18); animation: rise .35s var(--ease-paper) both; }
.ov-card h2 { font-size: 1.7rem; }
.ov-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 24px; }
.field { display: grid; gap: 8px; margin-top: 20px; font-weight: 800; }
.field input { min-height: 56px; border: 3px solid var(--sky-2); border-radius: 16px; padding: 0 16px; font: 600 1.2rem var(--body); color: var(--ink); background: #fff; }
.field input:focus { outline: none; border-color: var(--sea); }
.new-reader fieldset { border: 0; padding: 0; margin: 22px 0 0; }
.new-reader legend { font-weight: 800; margin-bottom: 10px; }
.av-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.av-opt { position: relative; display: grid; place-items: center; padding: 8px; border-radius: 20px; cursor: pointer; }
.av-opt input { position: absolute; opacity: 0; pointer-events: none; }
.av-opt .av { width: 78px; height: 78px; transition: transform .2s var(--ease-paper); }
.av-opt:has(input:checked) { background: var(--sky); box-shadow: inset 0 0 0 3px var(--sea); }
.av-opt:has(input:checked) .av { transform: scale(1.08) rotate(-4deg); }
.av-opt:has(input:focus-visible) { outline: 3px solid var(--sea); outline-offset: 2px; }

/* ---------- child home ---------- */
.kid-hero { background: linear-gradient(var(--sky), var(--sky)); padding: clamp(22px, 5vw, 44px) 0 8px; }
.kid-hero-in { width: min(1120px, 100% - 2 * var(--gut)); margin-inline: auto; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px 20px; }
.kid-hero .av.big { width: 84px; height: 84px; animation: pop .5s var(--ease-paper) both; }
.kid-hero h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); }
.kid-hero .sub { margin-top: 4px; font-size: 1.05rem; }
.sticker-pill { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: 12px; justify-self: start; padding: 8px 18px 8px 8px; background: var(--paper); border-radius: 99px; text-decoration: none; box-shadow: var(--cut); }
.sticker-pill svg { width: 46px; height: 46px; }
.sticker-pill b { display: block; font: 600 1rem/1.1 var(--display); }
.sticker-pill small { color: var(--meadow-d); font-weight: 800; }
@media (min-width: 760px) { .kid-hero-in { grid-template-columns: auto 1fr auto; } .sticker-pill { grid-column: auto; justify-self: end; } }

.row-sec { margin-top: clamp(30px, 6vw, 52px); }
.row-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.row-sec h2 { font-size: clamp(1.4rem, 4.2vw, 1.9rem); }
.row-sec .shelf { padding-top: 18px; padding-bottom: 22px; }
@media (min-width: 860px) { .row-sec .shelf { grid-template-columns: repeat(4, 1fr); } }
.continue { display: grid; gap: 14px; margin-top: 16px; }
@media (min-width: 760px) { .continue { grid-template-columns: repeat(2, 1fr); } }
.cont-card { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 16px; padding: 12px; background: var(--paper); border-radius: 20px; text-decoration: none; box-shadow: var(--cut); transition: transform .2s var(--ease-paper); }
.cont-card:hover { transform: translateY(-3px); }
.cont-card:active { transform: translateY(2px); }
.cont-card img { width: 92px; height: 92px; border-radius: 10px; object-fit: cover; }
.cc-txt { display: grid; gap: 4px; min-width: 0; }
.cc-txt b { font: 600 1.15rem/1.2 var(--display); }
.cc-txt small { color: var(--ink-2); font-weight: 700; }
.cc-play { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--sun); box-shadow: 0 4px 0 rgb(31 42 68 / .2); }
.cc-play .icon { width: 24px; height: 24px; margin-left: 3px; }
.pbar { display: block; height: 8px; border-radius: 9px; background: var(--sky-2); overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--meadow); border-radius: inherit; }
.book-3d .pbar { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 2; background: rgb(255 255 255 / .7); }
.feature { display: grid; gap: 18px; margin-top: 16px; padding: 16px; border-radius: 26px; background: var(--paper); text-decoration: none; box-shadow: var(--cut-lg); }
.feature img { width: 100%; max-width: 360px; border-radius: 14px; }
.feature b { display: block; font: 600 clamp(1.5rem, 4.5vw, 2.1rem)/1.1 var(--display); }
.feature small { display: block; margin: 10px 0 18px; font-size: 1.05rem; color: var(--ink-2); }
@media (min-width: 760px) { .feature { grid-template-columns: 300px 1fr; align-items: center; gap: 32px; padding: 22px; } }

.badge { position: absolute; z-index: 2; top: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border-radius: 99px; font: 800 .78rem/1 var(--body); }
.badge .icon { width: 1em; height: 1em; }
.badge.done { left: 18px; background: var(--meadow-d); color: #fff; }
.badge.fav { right: 8px; background: var(--paper); color: var(--coral-d); padding: 6px; }

/* ---------- book page bits ---------- */
.fav-btn[aria-pressed="true"] { --bg: #ffe6e9; color: var(--coral-d); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 4px; border: 0; background: none; cursor: pointer; font-weight: 800; color: var(--ink-2); text-decoration: underline; text-underline-offset: 4px; }
.link-btn.danger { color: var(--coral-d); }
.win { display: flex; align-items: center; gap: 14px; margin-top: 26px; padding: 12px 16px 12px 12px; border-radius: 20px; background: var(--paper); box-shadow: 0 3px 0 rgb(31 42 68 / .08); max-width: 30rem; }
.win .st { width: 64px; height: 64px; flex: none; filter: grayscale(1); opacity: .45; }
.win.won .st { filter: none; opacity: 1; transform: rotate(-6deg); }
.win b { display: block; font: 600 1.1rem/1.2 var(--display); }
.win small { color: var(--ink-2); font-weight: 700; }

/* ---------- reader extras ---------- */
.r-thumbs { position: absolute; inset: 0; z-index: 12; background: rgb(36 52 94 / .94); overflow: auto; padding: 16px var(--gut); }
.r-thumbs-in { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px; max-width: 900px; margin: 0 auto; }
.r-thumbs button { padding: 0; border: 0; background: none; color: #fff; cursor: pointer; display: grid; gap: 6px; font: 600 .95rem var(--display); }
.r-thumbs .th { display: block; aspect-ratio: 1; border-radius: 8px; background: rgb(255 255 255 / .1) center / cover; box-shadow: 0 4px 0 rgb(0 0 0 / .25); }
.r-thumbs button.on .th { outline: 4px solid var(--sun); outline-offset: 2px; }
.r-top .btn[aria-pressed="true"] { --bg: var(--sun); --fg: var(--ink); }
@media (max-width: 560px) { .hide-sm { display: none !important; } }
:fullscreen .reader, .reader:fullscreen { background: var(--night); }

/* ---------- reward ---------- */
.reward-ov .ov-card { text-align: center; position: relative; overflow: visible; }
.reward h2 { font-size: clamp(1.8rem, 6vw, 2.4rem); margin-top: 6px; }
.reward p { margin-top: 8px; color: var(--ink-2); font-size: 1.1rem; }
.reward .ov-actions { justify-content: center; }
.rw-sticker { width: 170px; margin: -90px auto 0; filter: drop-shadow(0 8px 0 rgb(0 0 0 / .15)); }
.rw-sticker.new { animation: stick 1s var(--ease-paper) both; }
@keyframes stick {
  0% { transform: translateY(-60px) rotate(-30deg) scale(1.5); opacity: 0; }
  60% { transform: translateY(6px) rotate(6deg) scale(.95); opacity: 1; }
  100% { transform: rotate(-4deg) scale(1); }
}
.confetti { position: absolute; top: 0; width: 10px; height: 14px; border-radius: 2px; pointer-events: none; z-index: 90; }

/* ---------- album ---------- */
.album-head { padding-top: clamp(28px, 6vw, 56px); display: grid; gap: 6px; }
.album-head h1 { font-size: clamp(2rem, 6.5vw, 3.2rem); }
.album-count { font: 600 1.3rem var(--display); color: var(--ink-2); }
.album-count b { font-size: 2.2rem; color: var(--ink); }
.album-page {
  margin-top: 24px; padding: clamp(20px, 5vw, 44px); border-radius: 26px;
  background: #fffdf8 radial-gradient(circle at 1px 1px, #e6dccb 1.2px, transparent 1.4px) 0 0 / 22px 22px;
  box-shadow: var(--cut-lg); display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px 18px;
}
@media (min-width: 700px) { .album-page { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .album-page { grid-template-columns: repeat(4, 1fr); } }
.slot { display: grid; justify-items: center; text-align: center; gap: 8px; text-decoration: none; }
.slot .st { position: relative; width: min(150px, 100%); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; }
.slot .st svg { width: 100%; height: 100%; }
.slot:not(.won) .st svg { filter: grayscale(1) brightness(1.15); opacity: .28; }
.slot:not(.won) .st::after { content: "?"; position: absolute; font: 650 3rem/1 var(--display); color: var(--ink-2); opacity: .55; }
.slot:not(.won) .st { outline: 3px dashed #d6cbb6; outline-offset: -3px; }
.slot.won .st { transform: rotate(var(--r)); animation: stuck .6s var(--ease-paper) both; animation-delay: calc(var(--i) * 90ms); }
@keyframes stuck { from { transform: rotate(calc(var(--r) - 20deg)) scale(1.3); opacity: 0; } }
.slot b { font: 600 1.02rem/1.2 var(--display); }
.slot small { color: var(--ink-2); font-weight: 700; font-size: .85rem; }

/* ---------- parents ---------- */
.gate { text-align: center; padding-top: clamp(40px, 9vw, 90px); }
.gate-ic { display: inline-grid; place-items: center; width: 74px; height: 74px; border-radius: 22px; background: var(--ink); color: #fff; }
.gate-ic .icon { width: 34px; height: 34px; }
.gate h1 { margin-top: 16px; font-size: clamp(1.8rem, 6vw, 2.6rem); }
.gate-form { margin: 26px auto 0; max-width: 26rem; display: grid; gap: 14px; font-size: 1.15rem; font-weight: 700; }
.gate-row { display: flex; gap: 10px; justify-content: center; }
.gate-row input { width: 110px; min-height: 56px; text-align: center; border: 3px solid var(--sky-2); border-radius: 16px; font: 650 1.6rem var(--display); color: var(--ink); background: #fff; }
.gate-row input:focus { outline: none; border-color: var(--sea); }
.gate-err { min-height: 1.5em; color: var(--coral-d); font-size: 1rem; }
.parents h1 { font-size: clamp(2rem, 6vw, 3rem); margin-top: 8px; }
.p-sec { margin-top: 30px; padding: clamp(18px, 4vw, 30px); background: var(--paper); border-radius: 24px; box-shadow: var(--cut); }
.p-sec h2 { font-size: 1.45rem; margin-bottom: 14px; }
.readers { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 16px; }
.readers li { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding-bottom: 16px; border-bottom: 2px solid var(--sky); }
.readers .av { width: 64px; height: 64px; }
.rd-name { font: 600 1.25rem var(--display); }
.rd-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 16px; margin: 8px 0 0; }
.rd-stats dt { font-size: .82rem; font-weight: 700; color: var(--ink-2); }
.rd-stats dd { margin: 0; font: 600 1rem/1.3 var(--display); }
.rd-actions, .danger-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 6px; }
.confirm { font-weight: 800; }
.danger-btn { --bg: var(--coral-d); --fg: #fff; min-height: 44px; font-size: 1rem; }
.rename { display: flex; gap: 8px; }
.rename input { min-height: 46px; border: 3px solid var(--sky-2); border-radius: 12px; padding: 0 12px; font: 600 1.1rem var(--body); width: min(220px, 100%); }
.rename .btn { min-height: 46px; padding: 0 14px; }
.setting { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; padding: 14px 0; border-bottom: 2px solid var(--sky); font-weight: 700; }
.seg { display: inline-flex; background: var(--sky); border-radius: 14px; padding: 4px; gap: 2px; }
.seg button { min-height: 42px; min-width: 84px; padding: 0 14px; border: 0; border-radius: 11px; background: none; cursor: pointer; font: 600 .98rem var(--display); }
.seg button[aria-checked="true"] { background: var(--ink); color: #fff; }
.privacy { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; color: var(--ink-2); font-weight: 700; }
.privacy .icon { color: var(--meadow-d); width: 24px; height: 24px; }
.danger-zone { margin-top: 18px; }

/* the app reuses the library + book styles from app.css */
.app-view .lib-head { padding-top: clamp(26px, 5vw, 56px); }
.app-view .bk { padding-top: 12px; }

@supports (view-transition-name: none) {
  ::view-transition-old(root) { animation: vt-out .18s ease both; }
  ::view-transition-new(root) { animation: vt-in .28s var(--ease-paper) both; }
  @keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
  @keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }
}
@media (prefers-reduced-motion: reduce) { .who-sun { animation: none; } }

/* touch-ups */
.app-view .reader { color: #fff; background: var(--night); }
@media (max-width: 560px) {
  .r-top .t-close { min-width: 46px; padding: 0; border-radius: 50%; aspect-ratio: 1; }
  .r-top .t-close span, [data-r="auto"] .lbl { display: none; }
  [data-r="auto"] { min-width: 50px; padding: 0 .8em; }
}
.who-sun { width: 210px; right: -90px; top: -100px; opacity: .55; z-index: 0; }
.who h1, .who .sub, .who-grid, .parents-link { position: relative; z-index: 1; }
