/* ============================================================================
   kids-home.css — "Soft Pastel Cloud World" for the Kids entry page (kids.html)
   ----------------------------------------------------------------------------
   Design goals (kindergarten-first):
     • First screen fills the viewport (100dvh): header + category icons + the
       main carousel, spread evenly. Card size DERIVES from that height. Themed
       shelves (Storybooks / Activities / Games) stack BELOW and the page scrolls
       vertically to reach them; the first peeks above the fold as a hint. Each
       carousel still scrolls horizontally inside itself.
     • Picture-first. Big art, short rounded-font labels, huge tap targets.
     • Calm but delightful: drifting clouds, a bobbing sun, one orchestrated
       entrance animation. All CSS-only and disabled under reduced-motion.
   Scoped to the kids home only; tool pages still use kids.css until phase 2.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Quicksand:wght@500;600;700&display=swap');

:root {
    /* Sky gradient: peach → sky-blue → mint */
    --sky-peach: #FFE3D3;
    --sky-blue:  #A8DEFF;
    --sky-mint:  #CFF6E2;
    /* Sun + accents */
    --sun:       #FFD86B;
    --sun-glow:  #FFE9A8;
    --coral:     #FF9E7D;
    /* Soft navy ink (never pure black) */
    --ink:       #34466B;
    --ink-soft:  #6E7EA0;
    /* Per-category card tints */
    --cat-stories:    #EADBFF;  /* lavender */
    --cat-stories-dk: #B79CF0;
    --cat-play:       #FFD9C7;  /* warm peach */
    --cat-play-dk:    #F6A887;
    --cat-creations:  #CFE9FF;  /* aqua */
    --cat-creations-dk:#86C4F0;
    --card-radius: 30px;
    --soft-shadow: 0 10px 26px rgba(52, 70, 107, 0.16);
    --gutter: clamp(14px, 3vw, 34px);
    /* How much of the first themed shelf peeks above the fold (scroll hint). */
    --peek: clamp(60px, 10vh, 110px);
}

* { box-sizing: border-box; }
/* The `hidden` attribute must win over the author display rules below
   (.kids-empty / .kids-stage-content / .kids-row / .kids-hero all set display). */
[hidden] { display: none !important; }

body.kids-bg {
    margin: 0;
    min-height: 100dvh;
    /* Vertical document scroll reveals the themed shelves; clip the carousels'
       right-edge bleed so it never adds a horizontal scrollbar. */
    overflow-x: hidden;
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--ink);
    background: linear-gradient(170deg, var(--sky-peach) 0%, var(--sky-blue) 52%, var(--sky-mint) 100%);
    -webkit-tap-highlight-color: transparent;
}

/* ---- Sky atmosphere: fixed full-bleed layer behind everything ------------ */
/* The sky's contents (day sun+clouds / night moon+stars) and the bottom-right
   background picker are built by js/kids-sky-bg.js; their visuals live in
   css/kids-sky-bg.css. This just positions the container. */
.kids-sky {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ---- App shell: viewport-locked flex column ---------------------------- */
/* Header (logo + greeting) and the category icon strip stay parked at the
   top of the viewport; the carousel stage below them absorbs all leftover
   vertical space. This keeps the greeting + filter buttons in a stable
   position regardless of how many carousels render — when there are only
   one or two shelves, the empty space falls AT the bottom of the stage
   instead of being smeared into giant gaps above the icons. */
.kids-app {
    position: relative;
    /* Sits above .kids-extra (z-index: 1) so the fixed-position kid picker
       inside this stacking context (.kids-menu at z-index: 70) still wins
       hit-testing against carousels that scroll under it. Without this,
       .kids-app and .kids-extra would tie at z-index: 1 and DOM order
       would give .kids-extra the upper layer — its cards then catch the
       click that should have hit the picker. */
    z-index: 2;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: clamp(10px, 2vh, 22px);
    padding: clamp(8px, 1.5vh, 18px) 0;
}
/* When themed shelves follow, give back `--peek` of the first screen so the
   next carousel shows above the fold. The main carousel keeps its (vh-derived)
   size; only the even whitespace between header/icons/carousel tightens. */
body.kids-has-extra .kids-app { height: calc(100dvh - var(--peek)); }

/* When the main "What's new" shelf is empty (kids-home.js hides .kids-stage and
   sets this flag), stop forcing the first screen to fill the viewport — let
   .kids-app shrink to its header + category icons so the themed shelves below
   rise up directly under them instead of after a full-viewport blank band.
   The compound selector outranks the has-extra height rule above. */
body.kids-stage-empty .kids-app,
body.kids-has-extra.kids-stage-empty .kids-app { height: auto; }

/* ---- Themed shelves (stacked carousels below the first screen) ----------- */
/* Same carousel look + size as the main shelf, stacked vertically. Sits in the
   normal document flow after .kids-app, so the page scrolls to reach them. */
.kids-extra {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2.6vh, 30px);
    padding-bottom: clamp(20px, 4vh, 48px);
}
.kids-extra:empty { display: none; }

/* ---- Shelf = a section title + its carousel ------------------------------ */
/* Wraps every carousel (main + themed) so the title sits ABOVE the fixed-height
   row without shrinking the cards. */
.kids-shelf {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}
/* Playful but simple: centered Baloo 2 ink text (emoji is part of the title
   string). */
.kids-shelf-title {
    margin: 0 0 clamp(4px, 1vh, 10px);
    padding: 0 var(--gutter);
    text-align: center;
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(18px, 2.7vh, 27px);
    line-height: 1.1;
    color: var(--ink);
}

/* Head zone: the logo + greeting, kept together as one block. */
.kids-headzone {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}

/* ---- Top bar ------------------------------------------------------------- */
.kids-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 var(--gutter);
}
/* Top bar: big centered logo, key icon at top-right. */
.kids-topbar {
    position: relative;
    justify-content: flex-end;        /* key icon sits at the right */
    min-height: clamp(66px, 10.5vh, 108px);
}
.kids-logo-img {
    position: absolute;               /* centered independent of the key icon */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    height: clamp(66px, 10.5vh, 108px);   /* large + centered */
    width: auto;
    filter: drop-shadow(0 4px 8px rgba(52,70,107,0.22));
}

/* Friendly greeting under the logo — "Hi <name>!" */
.kids-greeting {
    flex: 0 0 auto;
    margin-top: clamp(4px, 1vh, 10px);   /* small breathing room under the logo */
    text-align: center;
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(20px, 3.6vh, 34px);
    line-height: 1.1;
    color: var(--ink);
    text-shadow: 0 2px 6px rgba(52,70,107,0.12);
}
.kids-greeting:empty { display: none; }   /* no name yet → reclaim the space */

/* The top-right child badge + dropdown styles live in css/kids-menu.css (shared
   with the kids coloring page); the markup is built by js/kids-menu.js. */

/* ---- Stage: the carousel — absorbs all leftover vertical space below
   the header + category strip, so the kids-app no longer relies on
   space-evenly to fill the viewport. ------------------------------------- */
.kids-stage {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ---- Rows (carousels) — full-bleed, run off the right edge ------------- */
.kids-rows {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(12px, 2.6vh, 30px);
}

/* Category icon links: the primary nav — its own evenly-spaced block. */
.kids-cats {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: clamp(14px, 4vw, 56px);
    row-gap: clamp(6px, 1.2vh, 12px);
    padding: 0 var(--gutter);
}
.kids-cat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: var(--ink);
    transition: transform 0.15s ease;
    /* Button reset — these are now <button>s acting as filter toggles. */
    background: transparent;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}
.kids-cat:hover { transform: translateY(-4px) scale(1.05); }
/* Active filter state — the icon picks up a coral ring + lift, the label
   bolds and shifts to coral so the selected filter reads at a glance. */
.kids-cat--active { transform: translateY(-4px) scale(1.05); }
.kids-cat--active .kids-cat-icon {
    box-shadow: 0 0 0 4px var(--coral, #FF8A65), var(--soft-shadow);
}
.kids-cat--active .kids-cat-label {
    color: var(--coral, #FF8A65);
    font-weight: 800;
}
.kids-cat-icon {
    width: clamp(54px, 8.5vh, 82px);
    height: clamp(54px, 8.5vh, 82px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(26px, 4.6vh, 44px);
    box-shadow: var(--soft-shadow);
    border: 4px solid #fff;
}
.kids-cat--stories   { background: var(--cat-stories); }
.kids-cat--play      { background: var(--cat-play); }
.kids-cat--creations { background: var(--cat-creations); }
.kids-cat-label {
    font-family: 'Baloo 2', cursive;
    font-weight: 700;
    font-size: clamp(12px, 1.7vh, 16px);
    color: var(--ink);
}
.kids-row {
    flex: 0 0 auto;                   /* fixed, shorter rows (not full-height) */
    height: clamp(170px, 30vh, 300px);
    display: flex;
    flex-direction: column;
}
/* Top row slightly larger, bottom row slightly smaller. */
.kids-row--top    { height: clamp(186px, 33vh, 330px); }
.kids-row--bottom { height: clamp(150px, 26vh, 260px); }
.kids-carousel {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    align-items: center;
}
.kids-track {
    position: relative;
    height: 100%;
    width: 100%;          /* always span the carousel so few-item rows can center */
    overflow: hidden;
    /* Vertical padding gives the card shadows + hover lift room (overflow:hidden
       would otherwise clip them). Symmetric top/bottom so the cards' center sits
       at 50% and the carousel arrows line up with them. Left gutter insets the
       first card; the right side bleeds off-screen by design. */
    padding: clamp(22px, 3.4vh, 34px) 0 clamp(22px, 3.4vh, 34px) var(--gutter);
    touch-action: pan-y;   /* JS handles horizontal drag; vertical gestures pass */
}
.kids-track-inner {
    display: flex;
    gap: clamp(20px, 2.6vw, 38px);   /* horizontal space → side shadows show */
    height: 100%;
    width: max-content;
    will-change: transform;
}
/* When the items don't fill the row, center them on the page instead of
   left-aligning at the gutter (added by JS when the track doesn't overflow). */
.kids-track--center {
    display: flex;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

/* A card: a square image tile (no caption). Height fills the row; width
   follows via aspect-ratio, so many fit across and bleed off the edge. */
.kids-card {
    flex: 0 0 auto;
    height: 100%;
    aspect-ratio: 1 / 1;
    position: relative;
    display: block;
    text-decoration: none;
    background: #fff;
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--soft-shadow);
    border: 4px solid #fff;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.kids-card:hover { transform: translateY(-5px) rotate(-1deg) scale(1.03); box-shadow: 0 16px 30px rgba(52,70,107,0.22); }
.kids-card-art {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.kids-card-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Icon-only cards: lift the emoji so it clears the bottom title scrim. */
.kids-card-art .emoji { font-size: clamp(40px, 9vh, 96px); margin-bottom: clamp(18px, 3.6vh, 36px); }

/* Faded title overlay — a soft ink scrim across the bottom of the card with up
   to two lines of Baloo 2 white text. Decorative (aria-hidden): the title is
   already in the card's aria-label. Bottom corners are free of the badges. */
.kids-card-title {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    padding: clamp(26px, 6vh, 54px) clamp(8px, 1.6vh, 14px) clamp(7px, 1.4vh, 12px);
    background: linear-gradient(to top,
        rgba(52, 70, 107, 0.74) 0%,
        rgba(52, 70, 107, 0.52) 42%,
        rgba(52, 70, 107, 0) 100%);
    color: #fff;
    font-family: 'Baloo 2', cursive;
    font-weight: 600;
    font-size: clamp(11px, 1.7vh, 15px);
    line-height: 1.12;
    text-align: center;
    text-shadow: 0 1px 3px rgba(52, 70, 107, 0.5);
    /* Two lines max, then ellipsis. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    pointer-events: none;       /* taps pass through to the card link */
}

/* Type overlay — a small icon chip, top-left, says what kind of thing it is */
.kids-card-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    width: clamp(28px, 4.4vh, 40px);
    height: clamp(28px, 4.4vh, 40px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(15px, 2.4vh, 22px);
    box-shadow: 0 2px 6px rgba(52,70,107,0.28);
}

/* Category tint shows behind icon-only (image-less) cards + on hover frame */
.kids-card--stories   .kids-card-art { background: var(--cat-stories); }
.kids-card--stories:hover   { border-color: var(--cat-stories-dk); }
.kids-card--play      .kids-card-art { background: var(--cat-play); }
.kids-card--play:hover      { border-color: var(--cat-play-dk); }
.kids-card--creations .kids-card-art { background: var(--cat-creations); }
.kids-card--creations:hover { border-color: var(--cat-creations-dk); }

/* "New" sparkle badge — top-right, wordless */
.kids-card-ribbon {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 2;
    font-size: clamp(16px, 2.6vh, 24px);
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

/* Puffy cloud nav arrows */
.kids-arrow {
    position: absolute;
    /* Center vertically via auto margins (deterministic — translateY(-50%) was
       landing a few px low against the padded track). */
    top: 0;
    bottom: 0;
    margin-top: auto;
    margin-bottom: auto;
    z-index: 4;
    width: 56px;
    height: 56px;
    border: 4px solid #fff;          /* bold ring so it reads on busy art */
    border-radius: 50%;
    background: var(--coral);        /* bold fill — easy to see + tap */
    color: #fff;
    font-size: 24px;
    line-height: 0;                  /* let flexbox do the centering, no glyph leading */
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(52,70,107,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
.kids-arrow:hover { transform: scale(1.12); background: var(--coral); filter: brightness(1.05); }
.kids-arrow.prev { left: 10px; }
.kids-arrow.next { right: 10px; }
.kids-arrow[disabled] { opacity: 0; pointer-events: none; }

/* ---- Empty state --------------------------------------------------------- */
.kids-empty {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
}
.kids-empty-emoji { font-size: 96px; animation: balloonBob 3s ease-in-out infinite; }
.kids-empty-text {
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(18px, 3vh, 26px);
    color: var(--ink);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
    margin-top: 4px;
}
.kids-empty-sub {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(13px, 2vh, 17px);
    color: var(--ink);
    opacity: 0.78;
    max-width: 320px;
    text-align: center;
    line-height: 1.35;
    margin-top: 2px;
    padding: 0 12px;
}
.kids-empty-sub:empty { display: none; }

@keyframes balloonBob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-7px); }
}

/* ---- Orchestrated entrance ---------------------------------------------- */
.kids-app .kids-row {
    animation: riseIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.kids-app .kids-row:nth-of-type(1) { animation-delay: 0.12s; }
.kids-app .kids-row:nth-of-type(2) { animation-delay: 0.24s; }
.kids-app .kids-row:nth-of-type(3) { animation-delay: 0.36s; }
@keyframes riseIn {
    from { opacity: 0; transform: translateY(22px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Parent-unlock modal ------------------------------------------------- */
.kids-unlock-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(52, 70, 107, 0.55);
    backdrop-filter: blur(3px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.kids-unlock-modal {
    background: #fff;
    border-radius: 32px;
    padding: 32px 30px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 60px rgba(52,70,107,0.35);
    animation: riseIn 0.3s ease both;
}
.kids-unlock-icon { font-size: 44px; }
.kids-unlock-title { font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 26px; color: var(--ink); margin-top: 6px; }
.kids-unlock-subtitle { font-family: 'Quicksand', sans-serif; font-weight: 600; font-size: 15px; color: var(--ink-soft); margin-top: 4px; }
.kids-unlock-question {
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: 32px;
    color: var(--coral);
    margin: 18px 0 10px;
}
.kids-unlock-input {
    width: 100%;
    font-family: 'Baloo 2', cursive;
    font-size: 26px;
    font-weight: 700;
    text-align: center;
    color: var(--ink);
    border: 3px solid var(--sky-blue);
    border-radius: 16px;
    padding: 12px;
    outline: none;
}
.kids-unlock-input:focus { border-color: var(--sun); }
.kids-unlock-error {
    display: none;
    color: #d6336c;
    font-weight: 700;
    font-size: 14px;
    margin-top: 10px;
}
.kids-unlock-actions { display: flex; gap: 10px; margin-top: 18px; }
.kids-unlock-cancel, .kids-unlock-submit {
    flex: 1;
    border: none;
    border-radius: 14px;
    padding: 14px;
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
}
.kids-unlock-cancel { background: #EEF1F6; color: var(--ink-soft); }
.kids-unlock-submit { background: var(--sun); color: var(--ink); box-shadow: 0 4px 0 #E9B93B; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 720px) {
    .kids-logo-img { height: clamp(46px, 8vh, 72px); }
}

/* Very short / landscape phones: top-align + scroll rather than spread thin or
   crush cards below a tappable size. */
@media (max-height: 520px) {
    body.kids-bg { overflow-y: auto; }
    .kids-app,
    body.kids-has-extra .kids-app {
        height: auto;
        min-height: 100dvh;
        justify-content: flex-start;
        gap: clamp(10px, 2.5vh, 18px);
        padding: 12px 0 18px;
    }
    .kids-card { min-height: 150px; }
}

/* ---- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    .kids-empty-emoji,
    .kids-app .kids-row, .kids-unlock-modal {
        animation: none !important;
    }
}
