/* ============================================================
   Kindergarten — Primary-colored, hand-lettered theme
   ------------------------------------------------------------
   Token strategy: every color reference goes through
   `hsl(var(--<token>))` and font-family goes through
   `var(--font-{heading|body|mono}, <fallback-stack>)`.
   ============================================================ */

/* ---- Typography (CSS-variable consumers + fallbacks) ------- */

.kg-page {
    font-family: var(--font-body, "Nunito", "Quicksand", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
    line-height: 1.7;
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
}

.kg-display,
.kg-page h1,
.kg-page h2,
.kg-page h3,
.kg-page h4,
.kg-page h5,
.kg-page h6 {
    font-family: var(--font-heading, "Quicksand", "Sniglet", "Nunito", -apple-system, sans-serif);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.kg-mono {
    font-family: var(--font-mono, "Fira Code", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
}

/* ---- Layout utilities -------------------------------------- */

.kg-section {
    padding-block: 4rem;
}

.kg-container {
    max-width: 72rem;
    margin-inline: auto;
    padding-inline: 1.5rem;
}

/* ---- Rounded primitives ------------------------------------ */

.kg-chip {
    border-radius: 24px;
    padding: 0.5rem 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.kg-card {
    border-radius: 32px;
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground, var(--foreground)));
    padding: 2rem;
    border: 1px solid hsl(var(--border));
    position: relative;
    overflow: hidden;
}

.kg-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background-color: hsl(var(--primary));
}

.kg-hero-panel {
    border-radius: 48px;
    padding: clamp(2rem, 6vw, 4rem);
    position: relative;
    overflow: hidden;
    background-color: hsl(var(--accent) / 0.15);
}

.kg-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.25rem 2.5rem;
    border-radius: 9999px;
    font-family: var(--font-heading, "Quicksand", "Sniglet", "Nunito", sans-serif);
    font-weight: 700;
    font-size: 1.125rem;
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: 0;
    cursor: pointer;
    box-shadow: 0 4px 0 0 hsl(var(--foreground) / 0.15);
    text-decoration: none;
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.kg-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 0 0 hsl(var(--foreground) / 0.15);
}

.kg-pill:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 0 hsl(var(--foreground) / 0.15);
}

.kg-pill:focus-visible {
    outline: 3px solid hsl(var(--ring));
    outline-offset: 3px;
}

/* CTA colorways */
.kg-pill-red    { background-color: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.kg-pill-blue   { background-color: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.kg-pill-yellow { background-color: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.kg-pill-green  { background-color: hsl(145 65% 45%); color: hsl(0 0% 100%); }

/* ---- Crayon underline (utility on headings) ---------------- */

.kg-crayon-underline {
    position: relative;
    display: inline-block;
}

.kg-crayon-underline::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 8px;
    background: linear-gradient(90deg,
        hsl(var(--primary)) 0 22%,
        hsl(var(--accent)) 22% 50%,
        hsl(var(--secondary)) 50% 78%,
        currentColor 78% 100%);
    border-radius: 4px;
    transform: rotate(-1deg);
    z-index: -1;
}

/* ---- Numeral badges ---------------------------------------- */

.kg-numeral {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
    font-family: var(--font-heading, "Quicksand", "Sniglet", sans-serif);
    font-weight: 700;
    font-size: 2.5rem;
    box-shadow: 0 4px 0 0 hsl(var(--foreground) / 0.15);
}

/* ---- Polaroid frame for gallery_of_art --------------------- */

.kg-polaroid {
    background-color: hsl(var(--card));
    border-radius: 16px;
    padding-top: 12px;
    padding-inline: 12px;
    padding-bottom: 36px;
    box-shadow: 0 6px 24px hsl(var(--foreground) / 0.12);
    transform: rotate(-1deg);
    transition: transform 200ms ease;
}

.kg-polaroid:nth-child(2n)   { transform: rotate(1.5deg); }
.kg-polaroid:nth-child(3n)   { transform: rotate(-0.5deg); }
.kg-polaroid:hover           { transform: rotate(0deg); }

.kg-polaroid > img,
.kg-polaroid > .kg-polaroid-image {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    background-color: hsl(var(--muted));
}

.kg-polaroid-caption {
    text-align: center;
    margin-top: 0.75rem;
    font-family: var(--font-heading, "Quicksand", "Sniglet", sans-serif);
    color: hsl(var(--foreground));
}

/* ---- Alphabet strip ---------------------------------------- */

.kg-alphabet-strip {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 1rem;
    scrollbar-width: thin;
}

.kg-alphabet-letter {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 24px;
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    font-family: var(--font-heading, "Quicksand", "Sniglet", sans-serif);
    font-weight: 700;
    font-size: 1.5rem;
    box-shadow: 0 4px 0 0 hsl(var(--foreground) / 0.12);
}

.kg-alphabet-letter:nth-child(4n+1) { background-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.kg-alphabet-letter:nth-child(4n+2) { background-color: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.kg-alphabet-letter:nth-child(4n+3) { background-color: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.kg-alphabet-letter:nth-child(4n+4) { background-color: hsl(145 65% 45%); color: hsl(0 0% 100%); }

.kg-alphabet-mono .kg-alphabet-letter {
    background-color: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

.kg-alphabet-primary .kg-alphabet-letter {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

/* ---- Day schedule pills ------------------------------------ */

.kg-schedule-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    border-radius: 24px;
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    margin-bottom: 0.75rem;
}

.kg-schedule-time {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
    font-family: var(--font-mono, "Fira Code", monospace);
    font-weight: 700;
}

.kg-schedule-activity {
    font-family: var(--font-body, "Nunito", sans-serif);
    color: hsl(var(--foreground));
}

.kg-schedule-icon {
    color: hsl(var(--primary));
}

/* ---- Storybook quote --------------------------------------- */

.kg-storybook {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2rem;
    border-radius: 32px;
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
}

@media (min-width: 768px) {
    .kg-storybook {
        grid-template-columns: 1fr 1fr;
        align-items: center;
    }
}

.kg-storybook-quote {
    font-family: var(--font-heading, "Quicksand", "Sniglet", serif);
    font-size: clamp(1.25rem, 3vw, 2rem);
    line-height: 1.4;
    color: hsl(var(--foreground));
}

.kg-storybook-author {
    margin-top: 1rem;
    color: hsl(var(--muted-foreground));
    font-family: var(--font-body, "Nunito", sans-serif);
}

.kg-storybook-illustration {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 24px;
    background-color: hsl(var(--muted));
}

/* ---- Friendly footer --------------------------------------- */

.kg-footer {
    padding: 3rem 1.5rem;
    background-color: hsl(var(--muted));
    color: hsl(var(--foreground));
    border-top: 6px dashed hsl(var(--primary));
    border-radius: 48px 48px 0 0;
}

.kg-footer-mascot {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-family: var(--font-heading, "Quicksand", sans-serif);
}

.kg-footer-signup {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-block: 1.5rem;
    max-width: 32rem;
}

.kg-footer-signup input {
    flex: 1 1 12rem;
    padding: 0.75rem 1rem;
    border-radius: 9999px;
    border: 2px solid hsl(var(--border));
    background-color: hsl(var(--input));
    color: hsl(var(--foreground));
    font-family: var(--font-body, "Nunito", sans-serif);
}

.kg-footer-signup input:focus-visible {
    outline: 3px solid hsl(var(--ring));
    outline-offset: 2px;
}

.kg-social-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.kg-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    background-color: hsl(var(--card));
    color: hsl(var(--primary));
    border: 1px solid hsl(var(--border));
}

.kg-social-link:focus-visible {
    outline: 3px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* ---- Mascot hero confetti dots ----------------------------- */

.kg-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle, hsl(var(--primary) / 0.5) 8px, transparent 9px),
        radial-gradient(circle, hsl(var(--secondary) / 0.5) 6px, transparent 7px),
        radial-gradient(circle, hsl(var(--accent) / 0.5) 5px, transparent 6px);
    background-size: 80px 80px, 50px 50px, 30px 30px;
    background-position: 10% 20%, 70% 30%, 40% 80%;
    opacity: 0.6;
}

/* ---- Dotted paper layer (page background) ------------------ */

.kg-dotted-paper {
    background-color: hsl(var(--background));
    background-image: radial-gradient(circle, hsl(var(--muted-foreground) / 0.15) 1px, transparent 1.5px);
    background-size: 24px 24px;
}

/* ---- Heading override (numeral badge variant) -------------- */

.kg-heading-stepped {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.kg-heading-step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
    font-family: var(--font-heading, "Quicksand", "Sniglet", sans-serif);
    font-weight: 700;
    font-size: 1.5rem;
    flex: 0 0 auto;
}

/* ---- Text override: rounded selection highlight ------------ */

.kg-text ::selection {
    background-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.kg-text {
    font-family: var(--font-body, "Nunito", sans-serif);
    line-height: 1.7;
    color: hsl(var(--foreground));
}

/* ---- Numbers counter grid ---------------------------------- */

.kg-numbers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 2rem;
    text-align: center;
}

.kg-numbers-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.kg-numbers-label {
    font-family: var(--font-body, "Nunito", sans-serif);
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.875rem;
}

/* ---- Gallery grid ------------------------------------------ */

.kg-gallery-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 640px) { .kg-gallery-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .kg-gallery-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---- Big CTA panel (spec §9 button override) --------------- */

.kg-big-cta {
    text-align: center;
    padding: 3rem 1.5rem;
}

/* ---- Empty-state placeholder ------------------------------- */

.kg-empty {
    text-align: center;
    padding: 2rem;
    border-radius: 24px;
    border: 2px dashed hsl(var(--border));
    color: hsl(var(--muted-foreground));
    font-family: var(--font-body, "Nunito", sans-serif);
}
