/**
 * CalmKidRoutine global presentation layer.
 *
 * This file contains the brand tokens and the smallest reusable visual
 * primitives shared by DP Starter templates. Page and section-specific rules
 * belong in their own files as the migration progresses.
 */

/* ==========================================================================
   1. Brand tokens and DP Starter compatibility map
   ========================================================================== */

:root:root {
    /* Brand palette. */
    --ckr-cream: #fff8f2;
    --ckr-cream-soft: #f3eadc;
    --ckr-card: #fffdf8;
    --ckr-white: #ffffff;
    --ckr-ink: #2a1f17;
    --ckr-ink-forest: #10221b;
    --ckr-muted: #55615a;
    --ckr-muted-light: #718078;
    --ckr-sage: #6b9480;
    --ckr-sage-deep: #557968;
    --ckr-sage-dark: #3f5f51;
    --ckr-sage-soft: #e4ebe1;
    --ckr-terra: #c4614a;
    --ckr-terra-deep: #a84f3a;
    --ckr-terra-soft: #f5dfd2;
    --ckr-gold: #d4943e;
    --ckr-gold-soft: #f3e7cb;
    --ckr-line: #e4d9c3;
    --ckr-dark-text: #e4ebe1;
    --ckr-dark-text-soft: #c9d6cd;
    --cream: var(--ckr-cream);
    --sage: var(--ckr-sage);
    --sage-soft: var(--ckr-sage-soft);
    --terra: var(--ckr-terra);
    --terra-soft: var(--ckr-terra-soft);
    --amber: var(--ckr-gold);
    --gold: var(--ckr-gold);
    --ink: var(--ckr-ink);
    --muted: var(--ckr-muted);
    --line: var(--ckr-line);

    /* Typography: follow DP Starter's native choices with resilient fallbacks. */
    --ckr-font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    --ckr-font-body: "DM Sans", var(--dp-font-body, var(--ckr-font-sans));
    --ckr-font-heading: "Cormorant Garamond", var(--dp-font-heading, Georgia, serif);

    /* Spacing scale. */
    --ckr-space-1: 0.25rem;
    --ckr-space-2: 0.5rem;
    --ckr-space-3: 0.75rem;
    --ckr-space-4: 1rem;
    --ckr-space-5: 1.5rem;
    --ckr-space-6: 2rem;
    --ckr-space-7: 2.5rem;
    --ckr-space-8: 3rem;
    --ckr-space-9: 4rem;
    --ckr-space-10: 5rem;
    --ckr-space-11: 6rem;
    --ckr-space-12: 7.5rem;

    /* Shape and elevation. */
    --ckr-radius-sm: 0.625rem;
    --ckr-radius-md: 1rem;
    --ckr-radius-lg: 1.5rem;
    --ckr-radius-xl: 2rem;
    --ckr-radius-pill: 999px;
    --ckr-shadow-sm: 0 1px 3px rgba(58, 51, 49, 0.06), 0 4px 14px rgba(58, 51, 49, 0.05);
    --ckr-shadow-md: 0 6px 24px rgba(58, 51, 49, 0.10);
    --ckr-shadow-cta: 0 4px 16px rgba(198, 90, 60, 0.30);

    /* DP Starter variable map. Sage remains the structural accent. */
    --dp-bg: var(--ckr-cream);
    --dp-bg-soft: var(--ckr-cream-soft);
    --dp-panel: var(--ckr-card);
    --dp-ink: var(--ckr-ink);
    --dp-black: var(--ckr-ink);
    --dp-muted: var(--ckr-muted);
    --dp-muted-2: var(--ckr-muted-light);
    --dp-line: var(--ckr-line);
    --dp-line-strong: #d4c6af;
    --dp-gold: var(--ckr-sage);
    --dp-gold-strong: var(--ckr-sage-deep);
    --dp-bronze: var(--ckr-sage-dark);
    --dp-danger-soft: var(--ckr-terra-soft);
    --dp-dark-bg: var(--ckr-ink-forest);
    --dp-dark-text: var(--ckr-dark-text);
    --dp-dark-text-soft: var(--ckr-dark-text-soft);
    --dp-dark-link: var(--ckr-dark-text-soft);
    --dp-gold-hover: var(--ckr-sage-deep);
    --dp-gold-rgb: 107, 148, 128;
    --dp-gold-strong-rgb: 76, 107, 88;
    --dp-white-rgb: 255, 255, 255;
    --dp-black-rgb: 42, 31, 23;
    --dp-dark-bg-rgb: 18, 29, 24;
    --dp-shadow-rgb: 58, 51, 49;
    --dp-ink-rgb: 15, 26, 23;
    --dp-radius: var(--ckr-radius-md);
    --dp-max: 1180px;
    --dp-narrow: 760px;
    /* Header colors only. Header structure remains a separate migration step. */
    --dp-header-bg: rgba(255, 255, 255, 0.94);
    --dp-header-text: var(--ckr-ink);
    --dp-header-link: var(--ckr-muted);
    --dp-header-hover: var(--ckr-ink);
    --dp-header-accent: var(--ckr-terra);

    color-scheme: light;
}

/* ==========================================================================
   2. Global type, rhythm and accessibility
   ========================================================================== */

html {
    scroll-behavior: smooth;
    text-size-adjust: 100%;
}

body {
    color: var(--ckr-ink);
    background: var(--ckr-cream);
    font-family: var(--ckr-font-body);
    font-size: 1rem;
    line-height: 1.65;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.dp-site :where(h1, h2, h3, h4, h5, h6) {
    color: var(--ckr-ink);
    font-family: var(--ckr-font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.dp-site h1 {
    max-width: 860px;
    font-size: clamp(2.25rem, 5vw, 3.75rem);
    line-height: 1.08;
}

.dp-site h2 {
    font-size: clamp(1.625rem, 3.4vw, 2.375rem);
    line-height: 1.14;
}

.dp-site h3 {
    font-size: clamp(1.1875rem, 2vw, 1.5rem);
    line-height: 1.2;
}

.dp-site :where(p, li, dd) {
    color: var(--ckr-muted);
}

.dp-lede {
    max-width: 640px;
    color: var(--ckr-muted);
    font-size: clamp(1.025rem, 1.8vw, 1.125rem);
    line-height: 1.65;
}

.dp-kicker,
.ckr-overline {
    margin-bottom: var(--ckr-space-4);
    color: var(--ckr-sage-deep);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    line-height: 1.3;
    text-transform: uppercase;
}

.dp-site a {
    text-underline-offset: 0.18em;
}

.dp-site a:not([class]):hover {
    color: var(--ckr-sage-dark);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--ckr-sage);
    outline-offset: 3px;
}

::selection {
    color: var(--ckr-white);
    background: var(--ckr-terra);
}

/* ==========================================================================
   3. Layout rhythm and surfaces
   ========================================================================== */

.dp-shell,
.dp-narrow {
    width: min(var(--dp-max), calc(100% - 48px));
}

.dp-narrow {
    width: min(var(--dp-narrow), calc(100% - 48px));
}

.dp-section {
    padding-block: clamp(var(--ckr-space-9), 8vw, var(--ckr-space-11));
}

.dp-section-soft {
    background: var(--ckr-cream-soft);
}

.dp-section-dark,
.dp-final-cta {
    color: var(--ckr-dark-text);
    background-color: var(--ckr-ink-forest);
}

.dp-section-dark :where(h1, h2, h3, h4, h5, h6),
.dp-final-cta :where(h1, h2, h3, h4, h5, h6) {
    color: var(--ckr-white);
}

.dp-section-dark :where(p, li),
.dp-final-cta :where(p, li) {
    color: var(--ckr-dark-text-soft);
}

/* ==========================================================================
   4. Buttons and conversion hierarchy
   ========================================================================== */

.dp-button,
.wp-block-button__link,
.ckr-button,
.dp-site input[type="submit"] {
    display: inline-flex;
    min-height: 52px;
    align-items: center;
    justify-content: center;
    gap: var(--ckr-space-3);
    padding: 0.875rem 2rem;
    border: 1px solid transparent;
    border-radius: var(--ckr-radius-pill);
    font-family: var(--ckr-font-heading);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

/* Terracotta is reserved for lead, purchase and other primary actions. */
.dp-button-primary,
.wp-block-button:not(.is-style-outline) .wp-block-button__link,
.ckr-button-primary,
.dp-site input[type="submit"] {
    color: var(--ckr-white);
    background: var(--ckr-terra);
    box-shadow: var(--ckr-shadow-cta);
}

.dp-button-primary:hover,
.wp-block-button:not(.is-style-outline) .wp-block-button__link:hover,
.ckr-button-primary:hover,
.dp-site input[type="submit"]:hover {
    color: var(--ckr-white);
    background: var(--ckr-terra-deep);
    box-shadow: 0 8px 22px rgba(166, 72, 48, 0.28);
    transform: translateY(-2px);
}

/* DP Starter's secondary action becomes the quiet, non-conversion action. */
.dp-button-secondary,
.wp-block-button.is-style-outline .wp-block-button__link,
.ckr-button-ghost {
    color: var(--ckr-ink);
    border-color: var(--ckr-line);
    background: transparent;
    box-shadow: none;
}

.dp-button-secondary:hover,
.wp-block-button.is-style-outline .wp-block-button__link:hover,
.ckr-button-ghost:hover {
    color: var(--ckr-sage-dark);
    border-color: var(--ckr-sage);
    background: var(--ckr-card);
    transform: translateY(-2px);
}

.ckr-button-secondary {
    color: var(--ckr-white);
    background: var(--ckr-sage);
}

.ckr-button-secondary:hover {
    color: var(--ckr-white);
    background: var(--ckr-sage-deep);
    transform: translateY(-2px);
}

.dp-button:active,
.wp-block-button__link:active,
.ckr-button:active {
    box-shadow: none;
    transform: translateY(0);
}

/* ==========================================================================
   5. Cards, badges and reusable feedback surfaces
   ========================================================================== */

.dp-card,
.dp-resource-card,
.dp-featured-post,
.dp-newsletter-band,
.ckr-card {
    border: 1px solid var(--ckr-line);
    border-radius: var(--ckr-radius-lg);
    background: var(--ckr-card);
    box-shadow: var(--ckr-shadow-sm);
}

.dp-card,
.dp-resource-card,
.dp-featured-post,
.ckr-card {
    transition: border-color 200ms ease, box-shadow 200ms ease, transform 200ms ease;
}

.dp-card:hover,
.dp-resource-card:hover,
.dp-featured-post:hover,
.ckr-card:hover {
    border-color: #d7c8b0;
    box-shadow: var(--ckr-shadow-md);
    transform: translateY(-4px);
}

.dp-card-body,
.ckr-card-body {
    padding: var(--ckr-space-6);
}

.dp-pill,
.ckr-badge {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 0.375rem 0.875rem;
    border: 0;
    border-radius: var(--ckr-radius-pill);
    color: var(--ckr-sage-dark);
    background: var(--ckr-sage-soft);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    line-height: 1.2;
    text-transform: uppercase;
}

.ckr-badge-terra {
    color: var(--ckr-terra-deep);
    background: var(--ckr-terra-soft);
}

.ckr-notice,
.dp-empty-state {
    padding: var(--ckr-space-5);
    border: 1px solid var(--ckr-line);
    border-radius: var(--ckr-radius-md);
    color: var(--ckr-muted);
    background: var(--ckr-cream-soft);
}

/* ==========================================================================
   6. Forms
   ========================================================================== */

.dp-site :where(input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]), select, textarea) {
    width: 100%;
    min-height: 50px;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--ckr-line);
    border-radius: var(--ckr-radius-md);
    color: var(--ckr-ink);
    background: var(--ckr-white);
    font-family: var(--ckr-font-body);
    font-size: 1rem;
    line-height: 1.45;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.dp-site textarea {
    min-height: 140px;
    resize: vertical;
}

.dp-site :where(input, select, textarea)::placeholder {
    color: var(--ckr-muted-light);
    opacity: 1;
}

.dp-site :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus {
    border-color: var(--ckr-sage);
    outline: 0;
    box-shadow: 0 0 0 4px rgba(94, 127, 106, 0.14);
}

/* ==========================================================================
   7. CalmKidRoutine header and footer
   ========================================================================== */

.ckr-site-header {
    min-height: 76px;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 28px;
    padding-block: 0;
    border-bottom: 1px solid var(--ckr-line);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 1px 0 rgba(58, 51, 49, 0.02);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.ckr-site-brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 0.625rem;
    color: var(--ckr-ink);
    font-family: var(--ckr-font-heading);
    font-weight: 700;
    line-height: 1.15;
    text-decoration: none;
}

.ckr-site-brand:hover,
.ckr-site-brand:visited {
    color: var(--ckr-ink);
}

.ckr-site-brand__mark-wrap {
    display: block;
    flex: 0 0 auto;
}

.ckr-site-brand__mark {
    width: 42px;
    height: 42px;
    border: 1px solid var(--ckr-line);
    border-radius: 50%;
    background: var(--ckr-cream);
    object-fit: cover;
}

.ckr-site-brand__text {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.ckr-site-brand__name {
    color: var(--ckr-ink);
    font-size: 1.15rem;
    white-space: nowrap;
}

.ckr-site-brand__name > span {
    color: var(--ckr-terra);
}

.ckr-site-brand__tagline {
    margin-top: 0.15rem;
    color: var(--ckr-sage-deep);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    white-space: nowrap;
}

.ckr-site-header .dp-desktop-nav {
    justify-self: center;
}

.ckr-site-header .dp-menu {
    gap: 28px;
}

.ckr-site-header .dp-menu a,
.ckr-site-header .dp-menu a:visited {
    color: var(--ckr-muted) !important;
    font-size: 0.94rem;
    font-weight: 600;
}

.ckr-site-header .dp-menu a:hover {
    color: var(--ckr-ink) !important;
}

.ckr-site-header .dp-menu .current-menu-item > a,
.ckr-site-header .dp-menu .current_page_item > a {
    color: var(--ckr-terra) !important;
}

.ckr-site-header .dp-menu a::after {
    background: var(--ckr-terra);
}

.ckr-site-header .dp-header-cta,
.ckr-site-header .dp-header-cta:visited {
    min-height: 44px;
    padding-inline: 1.4rem;
    color: var(--ckr-white) !important;
    border-radius: var(--ckr-radius-pill);
    background: var(--ckr-terra);
    box-shadow: var(--ckr-shadow-cta);
    font-family: var(--ckr-font-heading);
    font-weight: 700;
}

.ckr-site-header .dp-header-cta:hover {
    color: var(--ckr-white) !important;
    background: var(--ckr-terra-deep);
}

.ckr-site-footer {
    margin-top: 0;
    padding: 0;
    border-top: 0;
    color: var(--ckr-dark-text);
    background: var(--ckr-ink-forest);
}

.ckr-footer-main {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(10rem, 1fr) minmax(10rem, 1fr);
    gap: 2.5rem;
    padding: 4.5rem 0 3rem;
}

.ckr-site-brand--footer,
.ckr-site-brand--footer:hover,
.ckr-site-brand--footer:visited {
    color: var(--ckr-white);
}

.ckr-site-brand--footer .ckr-site-brand__name {
    color: var(--ckr-white);
}

.ckr-site-brand--footer .ckr-site-brand__tagline {
    color: #9db3a4;
}

.ckr-footer-brand p {
    max-width: 19rem;
    margin: 0.875rem 0 0;
    color: var(--ckr-dark-text-soft);
    font-size: 0.9rem;
}

.ckr-footer-nav h2 {
    margin: 0 0 1.125rem;
    color: var(--ckr-white);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ckr-footer-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ckr-footer-nav li {
    margin: 0 0 0.625rem;
}

.ckr-footer-nav a,
.ckr-footer-nav a:visited {
    color: var(--ckr-dark-text-soft);
    font-size: 0.9rem;
    text-decoration: none;
}

.ckr-footer-nav a:hover {
    color: var(--ckr-white);
}

.ckr-footer-disclaimer {
    max-width: 53rem;
    margin: 0;
    padding-bottom: 0.5rem;
    color: #afc0b4;
    font-size: 0.78rem;
}

.ckr-footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    color: #afc0b4;
    font-size: 0.8rem;
}

body.single-sc_product .dp-single-meta {
    display: none;
}

.ckr-product-content {
    padding-block: clamp(var(--ckr-space-8), 7vw, var(--ckr-space-10));
}

.ckr-product-content__inner {
    width: min(640px, calc(100% - 48px));
    margin-inline: auto;
}

.ckr-product-content__inner > .wp-block-surecart-product-page,
.ckr-product-content__inner > .wp-block-surecart-product-list-related {
    width: 100%;
    max-width: 100%;
}

.ckr-product-guide-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(1rem, 3vw, 1.5rem);
    margin-top: var(--ckr-space-6);
}

.ckr-product-guide-card {
    display: flex;
    min-height: 100%;
    flex-direction: column;
    gap: 0.9rem;
    border: 1px solid rgba(94, 127, 106, 0.22);
    border-radius: var(--ckr-radius-md);
    padding: clamp(1.25rem, 3vw, 1.75rem);
    color: inherit;
    background: var(--ckr-card);
    box-shadow: var(--ckr-shadow-md);
    text-decoration: none;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.ckr-product-guide-card:hover {
    transform: translateY(-2px);
    border-color: rgba(204, 90, 59, 0.35);
    box-shadow: var(--ckr-shadow-lg);
}

.ckr-product-guide-card__tag {
    width: fit-content;
    border-radius: var(--ckr-radius-pill);
    padding: 0.42rem 0.78rem;
    color: var(--ckr-sage-dark);
    background: var(--ckr-sage-soft);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1.15;
    text-transform: uppercase;
}

.ckr-product-guide-card h3 {
    margin: 0;
    font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.ckr-product-guide-card p {
    margin: 0;
}

.ckr-product-guide-card__meta {
    margin-top: auto;
    color: var(--ckr-muted);
    font-size: 0.92rem;
    font-weight: 700;
}

/* ==========================================================================
   8. Responsive and reduced-motion safeguards
   ========================================================================== */

@media (max-width: 1020px) {
    .ckr-footer-main {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .ckr-product-guide-grid {
        grid-template-columns: 1fr;
    }

    .ckr-product-content__inner {
        width: min(100% - 32px, 640px);
    }

    .ckr-site-header {
        min-height: 64px !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        gap: 0 !important;
        padding: 10px 18px !important;
    }

    .ckr-site-header .dp-desktop-nav,
    .ckr-site-header .dp-header-cta {
        display: none !important;
    }

    .ckr-site-header .dp-menu-toggle {
        display: grid !important;
        border: 0 !important;
        background: transparent !important;
    }

    body .ckr-site-header .dp-menu-toggle span:not(.screen-reader-text) {
        background: var(--ckr-ink) !important;
    }

    .ckr-site-brand__mark {
        width: 38px;
        height: 38px;
    }

    .ckr-site-brand__name {
        font-size: 1rem;
    }

    .ckr-site-brand__tagline {
        display: none;
    }

    body.nav-open {
        overflow: auto;
    }

    body.nav-open::before {
        display: none;
    }

    .ckr-mobile-nav {
        top: 64px;
        height: auto;
        max-height: calc(100vh - 64px);
        padding: 0.75rem 1.5rem 1.5rem;
        border-bottom: 1px solid var(--ckr-line);
        color: var(--ckr-ink);
        background: var(--ckr-white);
        box-shadow: var(--ckr-shadow-md);
    }

    .ckr-mobile-nav .dp-mobile-nav-header {
        display: none;
    }

    .ckr-mobile-nav .dp-mobile-menu {
        display: flex;
        flex-direction: column;
        gap: 0;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .ckr-mobile-nav .dp-mobile-menu li {
        margin: 0;
        border-bottom: 1px solid var(--ckr-cream-soft);
    }

    .ckr-mobile-nav .dp-mobile-menu a,
    .ckr-mobile-nav .dp-mobile-menu a:visited {
        display: block;
        padding: 0.875rem 0;
        color: var(--ckr-muted) !important;
        font-weight: 600;
        text-decoration: none;
    }

    .ckr-mobile-nav .dp-mobile-menu .current-menu-item > a,
    .ckr-mobile-nav .dp-mobile-menu .current_page_item > a,
    .ckr-mobile-nav .dp-mobile-menu a:hover {
        color: var(--ckr-terra) !important;
    }
}

@media (max-width: 780px) {
    .dp-shell,
    .dp-narrow {
        width: min(100% - 32px, var(--dp-max));
    }

    .dp-section {
        padding-block: var(--ckr-space-9);
    }

    .dp-button,
    .wp-block-button__link,
    .ckr-button,
    .dp-site input[type="submit"] {
        min-height: 50px;
        padding-inline: 1.5rem;
    }

    .ckr-footer-main {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding-block: 3.5rem 2.5rem;
    }

    .ckr-footer-bottom {
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
