/*
 * Shared, presentation-only foundation for the "Thế giới mầm non" themes.
 * Each package supplies the art direction and may override these tokens. The
 * CMS, routes, forms and tenant data stay outside this stylesheet.
 */
@layer worlds-reset, worlds-shell, worlds-components, worlds-theme;

@layer worlds-reset {
    :root {
        --theme-primary: #3d7b67;
        --theme-secondary: #8ccfe3;
        --theme-accent: #ef9c7e;
        --theme-background: #fffaf2;
        --theme-surface: #fff;
        --theme-text: #243b36;
        --theme-text-muted: #61716c;
        --theme-on-primary: #fff;
        --theme-focus: #67539b;
        --theme-radius-sm: .75rem;
        --theme-radius-md: 1.35rem;
        --theme-radius-lg: 2.25rem;
        --theme-shadow: 0 1.15rem 3.2rem rgb(36 59 54 / 12%);
        --theme-shadow-soft: 0 .65rem 2rem rgb(36 59 54 / 8%);
        --theme-shadow-float: 0 1.35rem 3.5rem rgb(36 59 54 / 16%);
        --theme-border: color-mix(in srgb, var(--theme-primary) 14%, transparent);
        --theme-glass: color-mix(in srgb, var(--theme-surface) 86%, transparent);
        --theme-heading-font: Georgia, "Times New Roman", serif;
        --theme-body-font: "Trebuchet MS", Arial, sans-serif;
        --world-shell: 76rem;
        --world-gutter: clamp(1rem, 3vw, 2rem);
        --world-section-space: clamp(2.5rem, 3.5vw, 3.25rem);
    }

    *, *::before, *::after { box-sizing: border-box; }
    html { scroll-behavior: smooth; }
    body.template-worlds {
        margin: 0;
        min-width: 0;
        color: var(--theme-text);
        background: var(--theme-background);
        font-family: var(--theme-body-font);
        font-size: 1rem;
        line-height: 1.65;
        overflow-wrap: anywhere;
        text-rendering: optimizeLegibility;
    }
    .template-worlds img, .template-worlds svg { display: block; max-width: 100%; }
    .template-worlds img { height: auto; }
    .template-worlds a { color: inherit; text-decoration-thickness: .08em; text-underline-offset: .18em; }
    .template-worlds button, .template-worlds input, .template-worlds textarea, .template-worlds select {
        color: inherit;
        font: inherit;
    }
    .template-worlds button, .template-worlds a { -webkit-tap-highlight-color: transparent; }
    .template-worlds h1, .template-worlds h2, .template-worlds h3, .template-worlds h4 {
        margin-block: 0 .65em;
        font-family: var(--theme-heading-font);
        line-height: 1.12;
        text-wrap: balance;
    }
    .template-worlds p { margin-block: 0 1rem; }
    .template-worlds ::selection { color: var(--theme-on-primary); background: var(--theme-primary); }
    .template-worlds :focus-visible { outline: .2rem solid var(--theme-focus); outline-offset: .2rem; }
    .world-sr-only {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }
    .world-honeypot { position: absolute !important; left: -10000px !important; }
}

@media (forced-colors: active) {
    .template-worlds :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
        outline: 2px solid Highlight !important;
        outline-offset: 3px !important;
        box-shadow: none !important;
    }
}

@layer worlds-shell {
    .world-shell { width: min(calc(100% - (2 * var(--world-gutter))), var(--world-shell)); margin-inline: auto; }
    .world-skip-link {
        position: fixed;
        z-index: 10000;
        top: .6rem;
        left: .6rem;
        translate: 0 -180%;
        padding: .7rem 1rem;
        border-radius: var(--theme-radius-sm);
        color: var(--theme-on-primary);
        background: var(--theme-primary);
        font-weight: 800;
    }
    .world-skip-link:focus { translate: 0; }
    .world-ribbon { display: flex; height: .35rem; background: var(--theme-primary); overflow: hidden; }
    .world-ribbon span { flex: 1; background: var(--theme-primary); }
    .world-ribbon span:nth-child(2) { background: var(--theme-secondary); }
    .world-ribbon span:nth-child(3) { background: var(--theme-accent); }
    .world-header {
        position: sticky;
        z-index: 1000;
        top: 0;
        border-bottom: 1px solid color-mix(in srgb, var(--theme-primary) 12%, transparent);
        background: color-mix(in srgb, var(--theme-background) 90%, transparent);
        backdrop-filter: blur(1rem);
        isolation: isolate;
        transition: box-shadow .25s ease, background .25s ease, border-color .25s ease;
    }
    .world-header.is-scrolled { border-color: transparent; background: color-mix(in srgb, var(--theme-surface) 94%, transparent); box-shadow: 0 .8rem 2.4rem rgb(20 40 35 / 10%); }
    .world-header__inner { display: flex; min-height: 5.25rem; align-items: center; justify-content: space-between; gap: 1.5rem; }
    .world-brand { display: inline-flex; min-width: 0; align-items: center; gap: .8rem; text-decoration: none; }
    .world-brand__mark {
        display: grid;
        width: 3.55rem;
        height: 3.55rem;
        flex: 0 0 auto;
        place-items: center;
        padding: .35rem;
        border-radius: 42% 58% 48% 52%;
        background: color-mix(in srgb, var(--theme-primary) 14%, var(--theme-surface));
        box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--theme-primary) 10%, transparent), var(--theme-shadow-soft);
        transition: border-radius .3s ease, rotate .3s ease, scale .3s ease;
    }
    .world-brand:hover .world-brand__mark { border-radius: 58% 42% 55% 45%; rotate: -3deg; scale: 1.04; }
    .world-brand__mark img { width: 100%; height: 100%; object-fit: contain; }
    .world-brand__text { display: grid; min-width: 0; }
    .world-brand__text strong { max-width: 18rem; overflow: hidden; color: var(--theme-primary-ink); font-family: var(--theme-heading-font); font-size: clamp(1.05rem, 2vw, 1.35rem); line-height: 1.12; text-overflow: ellipsis; white-space: nowrap; }
    .world-brand__text small { max-width: 18rem; overflow: hidden; color: var(--theme-text-muted); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
    .world-nav { display: flex; align-items: center; gap: clamp(.45rem, 1vw, 1rem); }
    .world-nav > a { position: relative; padding: .65rem .15rem; font-size: .91rem; font-weight: 750; text-decoration: none; white-space: nowrap; transition: color .2s ease, opacity .2s ease; }
    .world-nav > a:not(.world-button)::after { position: absolute; right: 50%; bottom: .35rem; left: 50%; height: .14rem; border-radius: 1rem; background: var(--theme-accent); content: ""; transition: right .2s ease, left .2s ease; }
    .world-nav > a:hover::after, .world-nav > a.is-active::after { right: .1rem; left: .1rem; }
    .world-nav-toggle { display: none; width: 3rem; height: 3rem; border: 1px solid var(--theme-border); border-radius: 50%; background: var(--theme-glass); box-shadow: var(--theme-shadow-soft); cursor: pointer; backdrop-filter: blur(.8rem); transition: scale .2s ease, box-shadow .2s ease; }
    .world-nav-toggle:hover { scale: 1.04; box-shadow: var(--theme-shadow); }
    .world-nav-toggle > span:not(.world-sr-only) { display: block; width: 1.25rem; height: .13rem; margin: .25rem auto; border-radius: 1rem; background: var(--theme-primary); transition: transform .2s ease, opacity .2s ease; }
    .world-footer { position: relative; padding-top: clamp(3.5rem, 7vw, 6rem); color: color-mix(in srgb, var(--theme-text) 88%, #000); background: linear-gradient(155deg, color-mix(in srgb, var(--theme-primary) 11%, var(--theme-surface)), color-mix(in srgb, var(--theme-accent) 7%, var(--theme-surface))); overflow: hidden; }
    .world-footer::after { position: absolute; right: -8rem; bottom: -12rem; width: 26rem; height: 26rem; border: 1px solid color-mix(in srgb, var(--theme-primary) 13%, transparent); border-radius: 50%; box-shadow: 0 0 0 4rem color-mix(in srgb, var(--theme-accent) 4%, transparent), 0 0 0 8rem color-mix(in srgb, var(--theme-primary) 3%, transparent); content: ""; pointer-events: none; }
    .world-footer__grid, .world-footer__bottom { position: relative; z-index: 1; }
    .world-footer__grid { display: grid; grid-template-columns: minmax(14rem, 1.5fr) repeat(3, minmax(10rem, 1fr)); gap: clamp(1.5rem, 4vw, 3.5rem); }
    .world-footer h3 { font-size: 1.15rem; }
    .world-footer ul { display: grid; gap: .55rem; padding: 0; margin: 0; list-style: none; }
    .world-footer a { text-decoration: none; }
    .world-footer a { transition: color .2s ease, translate .2s ease; }
    .world-footer li > a:hover { color: var(--theme-primary-ink); translate: .18rem 0; }
    .world-brand--footer { display: flex; width: fit-content; }
    .world-brand--footer .footer-brand__slogan { display: block; max-width: 28rem; margin-top: .25rem; color: inherit; font-family: var(--theme-body-font); font-size: .86rem; font-weight: 400; line-height: 1.45; white-space: normal; }
    .world-brand--footer .world-brand__mark { background: var(--theme-surface); }
    .world-footer__bottom { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 1.35rem; margin-top: 3rem; border-top: 1px solid color-mix(in srgb, var(--theme-primary) 16%, transparent); font-size: .82rem; }
    .world-footer__bottom p { margin: 0; }
    .world-footer__bottom .footer-legal-links { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; padding-inline-end: 4.75rem; }
    .world-footer__bottom .footer-legal-links span { opacity: .62; }
}

@layer worlds-components {
    .world-button {
        position: relative;
        display: inline-flex;
        min-height: 3rem;
        align-items: center;
        justify-content: center;
        padding: .72rem 1.25rem;
        border: 2px solid var(--theme-primary);
        border-radius: 999px;
        color: var(--theme-on-primary);
        background: linear-gradient(135deg, color-mix(in srgb, var(--theme-primary) 88%, #fff), var(--theme-primary));
        box-shadow: 0 .55rem 1.15rem color-mix(in srgb, var(--theme-primary) 24%, transparent);
        font-weight: 800;
        line-height: 1.1;
        text-align: center;
        text-decoration: none;
        isolation: isolate;
        overflow: hidden;
        transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
    }
    .world-button::after { position: absolute; z-index: -1; top: -180%; left: -40%; width: 38%; height: 460%; background: linear-gradient(90deg, transparent, rgb(255 255 255 / 34%), transparent); content: ""; rotate: 18deg; translate: -220% 0; transition: translate .55s ease; }
    .world-button:hover { transform: translateY(-3px); box-shadow: 0 1rem 1.9rem color-mix(in srgb, var(--theme-primary) 28%, transparent); filter: saturate(1.04); }
    .world-button:hover::after { translate: 570% 0; }
    .world-button:active { transform: translateY(-1px) scale(.985); }
    .world-button--small { min-height: 2.65rem; padding: .62rem 1rem !important; }
    .world-button--ghost { color: var(--theme-primary-ink); background: color-mix(in srgb, var(--theme-surface) 72%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--theme-primary) 12%, transparent); backdrop-filter: blur(.75rem); }
    .world-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
    .world-eyebrow { margin-bottom: .65rem; color: var(--theme-primary-ink); font-size: .75rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
    .world-section { padding-block: var(--world-section-space); }
    .world-section--surface { background: linear-gradient(180deg, var(--theme-surface), color-mix(in srgb, var(--theme-primary) 2.5%, var(--theme-surface))); }
    .world-section__heading { max-width: 44rem; margin-bottom: clamp(2rem, 5vw, 3.5rem); }
    .world-section__heading h2 { font-size: clamp(2rem, 5vw, 3.65rem); }
    .world-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(1rem, 2.5vw, 1.8rem); }
    .world-card { position: relative; overflow: hidden; border: 1px solid color-mix(in srgb, var(--theme-primary) 13%, transparent); border-radius: var(--theme-radius-md); background: color-mix(in srgb, var(--theme-surface) 94%, transparent); box-shadow: var(--theme-shadow-soft); transition: border-color .25s ease, box-shadow .25s ease, transform .25s ease; }
    .world-card:hover { border-color: color-mix(in srgb, var(--theme-primary) 28%, transparent); box-shadow: var(--theme-shadow-float); transform: translateY(-.35rem); }
    .world-card__body { padding: clamp(1.1rem, 3vw, 1.65rem); }
    .world-card__media { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
    .world-prose { width: min(calc(100% - (2 * var(--world-gutter))), 48rem); margin-inline: auto; padding-block: clamp(3rem, 7vw, 6rem); }
    .world-prose > * + * { margin-top: 1.1em; }
    .world-prose h1 { font-size: clamp(2.25rem, 6vw, 4.7rem); }
    .world-prose h2 { margin-top: 1.6em; font-size: clamp(1.65rem, 4vw, 2.45rem); }
    .world-prose img { width: 100%; margin-block: 1.5rem; border-radius: var(--theme-radius-md); }
    .world-form, .template-worlds form[data-world-form] { display: grid; gap: 1rem; }
    .world-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
    .world-field { display: grid; gap: .4rem; }
    .world-field label { font-weight: 800; }
    .world-field input, .world-field textarea, .world-field select,
    .world-newsletter input {
        width: 100%;
        min-height: 3.15rem;
        padding: .75rem .95rem;
        border: 1px solid color-mix(in srgb, var(--theme-primary) 30%, #d8dfdc);
        border-radius: var(--theme-radius-sm);
        color: var(--theme-text);
        background: color-mix(in srgb, var(--theme-surface) 94%, var(--theme-background));
        box-shadow: inset 0 1px 0 rgb(255 255 255 / 65%);
        transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
    }
    .world-field input:hover, .world-field textarea:hover, .world-field select:hover,
    .world-newsletter input:hover { border-color: color-mix(in srgb, var(--theme-primary) 48%, #d8dfdc); }
    .world-field input:focus, .world-field textarea:focus, .world-field select:focus,
    .world-newsletter input:focus { border-color: var(--theme-focus); background: var(--theme-surface); box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--theme-focus) 15%, transparent); outline: 0; }
    .world-field textarea { min-height: 8rem; resize: vertical; }
    .world-newsletter { display: flex; }
    .world-newsletter input { border-radius: 999px 0 0 999px; }
    .world-newsletter button { width: 3.2rem; flex: 0 0 auto; border: 0; border-radius: 0 999px 999px 0; color: var(--theme-on-primary); background: var(--theme-primary); cursor: pointer; }
    .world-global-cta { position: relative; padding-block: clamp(3rem, 7vw, 5.5rem); color: var(--theme-text); background: linear-gradient(125deg, color-mix(in srgb, var(--theme-primary) 14%, var(--theme-surface)), color-mix(in srgb, var(--theme-accent) 18%, var(--theme-surface))); isolation: isolate; overflow: hidden; }
    .world-global-cta::before, .world-global-cta::after { position: absolute; z-index: -1; width: clamp(15rem, 32vw, 30rem); aspect-ratio: 1; border-radius: 42% 58% 61% 39%; content: ""; filter: blur(.15rem); opacity: .5; }
    .world-global-cta::before { top: -65%; left: -7%; background: radial-gradient(circle, color-mix(in srgb, var(--theme-primary) 22%, transparent), transparent 68%); }
    .world-global-cta::after { right: -5%; bottom: -90%; background: radial-gradient(circle, color-mix(in srgb, var(--theme-accent) 28%, transparent), transparent 68%); rotate: 45deg; }
    .world-global-cta__inner { display: grid; grid-template-columns: minmax(0, 1.4fr) auto; align-items: center; gap: 2rem; }
    .world-global-cta h2 { max-width: 45rem; font-size: clamp(2rem, 5vw, 3.6rem); }
    .world-global-cta p:not(.world-eyebrow) { max-width: 42rem; color: var(--theme-text-muted); }
    .world-flashes { position: fixed; z-index: 1100; top: 6.25rem; right: var(--world-gutter); display: grid; width: min(28rem, calc(100% - (2 * var(--world-gutter)))); gap: .65rem; pointer-events: none; }
    .world-flash { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: .9rem 1rem; border: 1px solid color-mix(in srgb, var(--theme-primary) 24%, transparent); border-radius: var(--theme-radius-sm); background: var(--theme-surface); box-shadow: var(--theme-shadow); pointer-events: auto; transition: opacity .25s ease, translate .25s ease; }
    .world-flash p { margin: 0; }
    .world-flash button { border: 0; background: transparent; cursor: pointer; }
    .world-flash--success { border-left: .35rem solid #26805d; }
    .world-flash--error { border-left: .35rem solid #b43f4c; }
    .world-flash--leaving { opacity: 0; translate: 1rem 0; }
    .world-floating-contact { position: fixed; z-index: 900; right: 1rem; bottom: 1rem; display: grid; width: 3.5rem; height: 3.5rem; place-items: center; border: 3px solid var(--theme-surface); border-radius: 50%; color: var(--theme-on-primary); background: linear-gradient(145deg, color-mix(in srgb, var(--theme-primary) 84%, #fff), var(--theme-primary)); box-shadow: var(--theme-shadow); font-size: 1.35rem; text-decoration: none; transition: scale .2s ease, box-shadow .2s ease, rotate .2s ease; }
    .world-floating-contact:hover { scale: 1.08; rotate: -5deg; box-shadow: var(--theme-shadow-float); }
    .world-reveal { opacity: 0; translate: 0 1.2rem; transition: opacity .6s ease, translate .6s ease; }
    .world-reveal.is-visible { opacity: 1; translate: 0; }
}

@media (max-width: 68rem) {
    .world-nav-toggle { display: block; }
    .world-nav {
        position: absolute;
        top: calc(100% + .4rem);
        right: var(--world-gutter);
        left: var(--world-gutter);
        display: none;
        max-height: calc(100vh - 7rem);
        align-items: stretch;
        padding: .75rem;
        border: 1px solid color-mix(in srgb, var(--theme-primary) 18%, transparent);
        border-radius: var(--theme-radius-md);
        background: var(--theme-surface);
        box-shadow: var(--theme-shadow);
        overflow-y: auto;
    }
    body.nav-open .world-nav { display: grid; }
    body.nav-open .world-nav-toggle > span:nth-child(1) { transform: translateY(.38rem) rotate(45deg); }
    body.nav-open .world-nav-toggle > span:nth-child(2) { opacity: 0; }
    body.nav-open .world-nav-toggle > span:nth-child(3) { transform: translateY(-.38rem) rotate(-45deg); }
    .world-nav > a { padding: .75rem 1rem; }
    .world-nav > a:not(.world-button)::after { display: none; }
    .world-nav > a.is-active:not(.world-button) { border-radius: var(--theme-radius-sm); background: color-mix(in srgb, var(--theme-primary) 10%, var(--theme-surface)); }
    .world-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .world-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 42rem) {
    :root { --world-gutter: 1rem; }
    .world-header__inner { min-height: 4.65rem; }
    .world-brand__mark { width: 3rem; height: 3rem; }
    .world-brand__text strong, .world-brand__text small { max-width: min(60vw, 15rem); }
    .world-brand__text small { display: none; }
    .world-grid, .world-form-grid, .world-global-cta__inner, .world-footer__grid { grid-template-columns: 1fr; }
    .world-global-cta__inner { align-items: start; }
    .world-footer__bottom { align-items: flex-start; flex-direction: column; padding-bottom: 5.5rem; }
    .world-footer__bottom .footer-legal-links { padding-inline-end: 0; }
    .world-actions { width: 100%; }
    .world-actions .world-button { flex: 1 1 12rem; }
}

.template-worlds :is(.fairy-map__heading, .dream-map header, .animal-map header, .science-map__heading, .nature-map__heading, .family-map__heading, .space-map__heading) h2 {
    white-space: nowrap;
}

@media (max-width: 42rem) {
    .template-worlds :is(.fairy-map__heading, .dream-map header, .animal-map header, .science-map__heading, .nature-map__heading, .family-map__heading, .space-map__heading) h2 {
        white-space: normal;
    }
}

.template-worlds :is(.fairy-prose, .dream-prose, .safari-prose, .science-prose, .nature-prose, .family-prose, .space-prose) {
    width: 100%;
    max-width: 72ch;
    justify-self: start;
}
.template-worlds :is(.fairy-pagination, .dream-pagination, .safari-pagination, .science-pagination, .nature-pagination, .family-pagination, .space-pagination) a {
    min-width: 2.75rem;
    min-height: 2.75rem;
}
.template-worlds :is(.fairy-consent, .dream-consent, .safari-consent, .science-consent, .nature-consent, .family-consent, .space-consent),
.template-worlds :is(.fairy-consent, .dream-consent, .safari-consent, .science-consent, .nature-consent, .family-consent, .space-consent) > span {
    font-size: .875rem !important;
    line-height: 1.6 !important;
}
.template-worlds .world-brand__text small { font-size: .875rem !important; line-height: 1.45 !important; }
.template-worlds :is(.fairy-share, .dream-share, .safari-share, .science-share, .nature-share, .family-share, .space-share) :is(a, button) {
    min-width: 2.75rem;
    min-height: 2.75rem;
}
.template-worlds :is(.fairy-article__heading, .dream-article__heading, .safari-article__heading, .science-article__heading, .nature-article__heading, .family-article__heading, .space-article__heading) > p {
    max-width: 72ch;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .template-worlds *, .template-worlds *::before, .template-worlds *::after {
        scroll-behavior: auto !important;
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
    .world-reveal { opacity: 1; translate: none; }
}

@media print {
    .world-ribbon, .world-nav-toggle, .world-nav, .world-global-cta, .world-floating-contact, .world-flashes { display: none !important; }
    .world-header { position: static; box-shadow: none; }
    .template-worlds { color: #000 !important; background: #fff !important; }
}
