/* ==========================================================================
   Math Katas — Web theme
   Mirrors the Math Katas iOS/iPadOS app:
   - Warm cream "tatami" base (#F3F0E8)
   - Deep dojo blue accent (#265D80)
   - Amber→orange gradient on primary actions (#F6C453 → #E98A2E)
   - Rounded SF Pro typography, soft 8/12/14 px corners, gentle shadows
   ========================================================================== */

:root {
    /* Surfaces & text — light mode */
    --c-app-bg:            #F3F0E8;
    --c-surface:           #FFFFFF;
    --c-text-primary:      #2B2B2B;
    --c-text-secondary:    #555555;

    /* Brand */
    --c-accent:            #265D80;  /* dojo blue */
    --c-accent-strong:     #1F4E6D;
    --c-success:           #339066;  /* belt-green / charts */
    --c-warning:           #C45A4A;  /* repeated-rule chart color, also used for warnings */

    /* Help-button gradient — used for primary CTAs */
    --c-cta-grad-start:    #F6C453;
    --c-cta-grad-end:      #E98A2E;
    --c-cta-text:          #FFFFFF;

    /* Help / panel surfaces */
    --c-panel-fill:        #FFFDF7;
    --c-panel-stroke:      #1E232B;
    --c-panel-text:        #2A2E34;
    --c-highlight-fill:    #FFE9A8;        /* soft gold highlight */
    --c-commutative-fill:  #F2C27A;        /* peach-gold */
    --c-factors-fill:      #7B7F88;
    --c-factors-stroke:    #2C2F35;
    --c-table-fill:        #E7E9EE;
    --c-table-stroke:      #D7DDE5;

    /* Annotation pill (used on hero / callouts) */
    --c-annotation-bg:     #FAF7F2;
    --c-annotation-text:   rgba(58, 58, 58, 0.6);

    /* Belt palette (for accents and backgrounds) */
    --c-belt-white:        #F3F1EB;
    --c-belt-yellow:       #F6C453;
    --c-belt-orange:       #E98A2E;
    --c-belt-green:        #339066;
    --c-belt-blue:         #265D80;
    --c-belt-brown:        #6E4F2A;
    --c-belt-black:        #1F1F1F;
    --c-belt-red:          #C45A4A;

    /* Typography */
    --font-rounded:
        "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
        "Segoe UI", "Helvetica Neue", "Nunito", system-ui, sans-serif;
    --font-display: var(--font-rounded);
    --font-body:    var(--font-rounded);

    --fs-display:    clamp(2.4rem, 5vw, 3.6rem);   /* hero h1 */
    --fs-h2:         clamp(1.6rem, 3vw, 2.1rem);
    --fs-h3:         1.25rem;
    --fs-body:       1.0625rem;
    --fs-small:      0.9375rem;

    --lh-tight:      1.15;
    --lh-body:       1.55;

    /* Radii */
    --r-sm:  8px;     /* HelpButtonStyle */
    --r-md:  12px;    /* keypad keys, inline cards */
    --r-lg:  14px;    /* popup cards */
    --r-xl:  20px;    /* hero / large panels */
    --r-pill: 999px;

    /* Shadows */
    --shadow-soft:
        0 1px 2px rgba(20, 24, 30, 0.04),
        0 6px 16px rgba(20, 24, 30, 0.06);
    --shadow-card:
        0 2px 4px rgba(20, 24, 30, 0.05),
        0 12px 28px rgba(20, 24, 30, 0.08);
    --shadow-text-on-image:
        0 4px 8px rgba(0, 0, 0, 0.18);

    /* Spacing scale (8-pt grid) */
    --sp-1:  4px;
    --sp-2:  8px;
    --sp-3:  12px;
    --sp-4:  16px;
    --sp-5:  20px;
    --sp-6:  24px;
    --sp-7:  32px;
    --sp-8:  48px;
    --sp-9:  64px;
    --sp-10: 96px;

    /* Layout */
    --content-max:  1080px;
    --content-narrow: 720px;

    /* Motion */
    --ease-spring: cubic-bezier(0.4, 0.0, 0.2, 1);
    --t-fast: 0.12s;
    --t-med:  0.25s;
}

/* Dark mode mirrors the asset-catalog "Dark" variants */
@media (prefers-color-scheme: dark) {
    :root {
        --c-app-bg:           #1D1F2A;
        --c-surface:          #2A2B36;
        --c-text-primary:     #ECECEC;
        --c-text-secondary:   #B8B8B8;

        --c-accent:           #6EA3DC;
        --c-accent-strong:    #8FB8E5;
        --c-success:          #4EC185;
        --c-warning:          #EF7264;

        --c-cta-grad-start:   #9C6B1F;
        --c-cta-grad-end:     #6F3F12;

        --c-panel-fill:       #171A1F;
        --c-panel-stroke:     #AAB2BD;
        --c-panel-text:       #C9CED6;
        --c-highlight-fill:   #8A6A1F;
        --c-commutative-fill: #6E4F1D;
        --c-factors-fill:     #3A3F46;
        --c-factors-stroke:   #0E1116;
        --c-table-fill:       #232833;
        --c-table-stroke:     #3A4150;

        --c-annotation-bg:    #29362B;
        --c-annotation-text:  #E2E2E2;

        --shadow-soft:
            0 1px 2px rgba(0, 0, 0, 0.4),
            0 6px 16px rgba(0, 0, 0, 0.45);
        --shadow-card:
            0 2px 4px rgba(0, 0, 0, 0.45),
            0 12px 28px rgba(0, 0, 0, 0.55);
    }
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background-color: var(--c-app-bg);
    color: var(--c-text-primary);
    font-family: var(--font-body);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

a {
    color: var(--c-accent);
    text-decoration-color: rgba(38, 93, 128, 0.35);
    text-underline-offset: 0.18em;
    transition: color var(--t-fast) var(--ease-spring),
                text-decoration-color var(--t-fast) var(--ease-spring);
}
a:hover { color: var(--c-accent-strong); text-decoration-color: currentColor; }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--c-text-primary);
    line-height: var(--lh-tight);
    margin: 0 0 var(--sp-4);
    letter-spacing: -0.01em;
    font-weight: 800;
}
h1 { font-size: var(--fs-display); }
h2 { font-size: var(--fs-h2); font-weight: 800; }
h3 { font-size: var(--fs-h3); font-weight: 700; }

p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

::selection { background: var(--c-highlight-fill); color: var(--c-text-primary); }

/* ==========================================================================
   Layout
   ========================================================================== */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--sp-5);
}
.container--narrow { max-width: var(--content-narrow); }

.section { padding: var(--sp-9) 0; }
.section--tight { padding: var(--sp-7) 0; }

/* ==========================================================================
   Site header
   ========================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--c-app-bg) 88%, transparent);
    backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-bottom: 1px solid color-mix(in srgb, var(--c-text-primary) 8%, transparent);
}
.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-5);
    padding: var(--sp-3) var(--sp-5);
    max-width: var(--content-max);
    margin: 0 auto;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-3);
    text-decoration: none;
    color: var(--c-text-primary);
    font-weight: 800;
    font-size: 1.1rem;
}
.brand__icon {
    width: 38px; height: 38px;
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-soft);
}
.nav { display: flex; gap: var(--sp-5); align-items: center; }
.nav a {
    color: var(--c-text-secondary);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}
.nav a:hover { color: var(--c-text-primary); }

/* Tablet portrait & smaller: stack the brand above the nav, allow nav to wrap.
   Without this, the 4 links + "Get the app" button + brand cannot fit on one
   line on iPhone widths and individual link text wraps mid-link. */
@media (max-width: 760px) {
    .site-header__inner {
        flex-direction: column;
        gap: var(--sp-3);
        padding: var(--sp-3) var(--sp-4);
    }
    .nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--sp-3) var(--sp-4);
        font-size: 0.95rem;
        width: 100%;
    }
    .brand { font-size: 1rem; }
    .brand__icon { width: 32px; height: 32px; }
    /* Tighten the in-nav CTA button so it doesn't dominate the wrapped row */
    .nav .btn {
        padding: 8px 14px;
        min-height: 0;
        font-size: 0.95rem;
    }
}

/* Very narrow iPhones (SE, Mini): tighten nav further so all 5 items still
   fit one line where possible. */
@media (max-width: 380px) {
    .nav { gap: var(--sp-2) var(--sp-3); font-size: 0.9rem; }
    .nav .btn { padding: 7px 12px; font-size: 0.9rem; }
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
    position: relative;
    overflow: hidden;
    padding: var(--sp-10) 0 var(--sp-9);
    isolation: isolate;
}
.hero__bg {
    position: absolute;
    inset: 0;
    z-index: -2;
    background-image:
        linear-gradient(180deg,
            color-mix(in srgb, var(--c-app-bg) 60%, transparent) 0%,
            color-mix(in srgb, var(--c-app-bg) 88%, transparent) 60%,
            var(--c-app-bg) 100%),
        url("../images/garden.jpg");
    background-size: cover;
    background-position: center;
    filter: blur(2px);
    opacity: 0.65;
    transform: scale(1.05);
}
@media (prefers-color-scheme: dark) {
    .hero__bg { background-image:
        linear-gradient(180deg,
            color-mix(in srgb, var(--c-app-bg) 60%, transparent) 0%,
            color-mix(in srgb, var(--c-app-bg) 88%, transparent) 60%,
            var(--c-app-bg) 100%),
        url("../images/garden-dark.jpg");
        opacity: 0.55;
    }
}

.hero__inner {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: var(--sp-9);
    align-items: center;
}
.hero__eyebrow {
    display: inline-block;
    padding: 6px 12px;
    background: var(--c-annotation-bg);
    color: var(--c-text-secondary);
    border-radius: var(--r-pill);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: var(--sp-4);
}
.hero__title {
    font-size: var(--fs-display);
    background: linear-gradient(135deg,
        var(--c-text-primary) 0%,
        var(--c-accent) 60%,
        var(--c-belt-blue) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: var(--sp-5);
}
.hero__lede {
    font-size: 1.2rem;
    color: var(--c-text-secondary);
    max-width: 36ch;
    margin-bottom: var(--sp-6);
}
.hero__art {
    display: flex;
    justify-content: center;
}
.hero__icon {
    width: clamp(180px, 30vw, 260px);
    height: auto;
    border-radius: 28%;
    box-shadow: var(--shadow-card);
}

@media (max-width: 760px) {
    .hero__inner { grid-template-columns: 1fr; gap: var(--sp-6); }
    .hero { padding: var(--sp-8) 0 var(--sp-7); }
    .hero__art { order: -1; }
    .hero__icon { width: 140px; }
}

/* ==========================================================================
   Buttons (mirrors HelpButtonStyle.swift)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 12px 22px;
    min-height: 46px;
    border-radius: var(--r-sm);
    font-family: var(--font-rounded);
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    border: 0;
    cursor: pointer;
    transition: transform var(--t-med) var(--ease-spring),
                box-shadow var(--t-med) var(--ease-spring),
                opacity var(--t-fast) var(--ease-spring);
    box-shadow: var(--shadow-soft);
}
.btn:active { transform: scale(0.97); opacity: 0.92; }

.btn--primary {
    background: linear-gradient(90deg,
        var(--c-cta-grad-start) 0%,
        var(--c-cta-grad-end) 100%);
    color: var(--c-cta-text);
}
.btn--primary:hover { transform: scale(1.03); box-shadow: var(--shadow-card); }

.btn--secondary {
    background: var(--c-surface);
    color: var(--c-text-primary);
    border: 1px solid color-mix(in srgb, var(--c-text-primary) 12%, transparent);
}
.btn--secondary:hover { transform: scale(1.02); }

.btn--ghost {
    background: transparent;
    color: var(--c-accent);
    box-shadow: none;
}
.btn--ghost:hover { background: color-mix(in srgb, var(--c-accent) 8%, transparent); }

/* App Store badge (text-only fallback when no SVG provided) */
.app-store-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: #000;
    color: #fff;
    border-radius: var(--r-md);
    font-weight: 600;
    text-decoration: none;
    line-height: 1.1;
    transition: transform var(--t-fast) var(--ease-spring);
}
.app-store-badge small { display: block; font-size: 0.7rem; opacity: 0.8; font-weight: 500; }
.app-store-badge:hover { transform: translateY(-1px); }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
    box-shadow: var(--shadow-soft);
    border: 1px solid color-mix(in srgb, var(--c-text-primary) 6%, transparent);
}
.card--highlight {
    background: var(--c-highlight-fill);
    border-color: color-mix(in srgb, var(--c-warning) 35%, transparent);
}

/* Daily-vs-weekly callout — earns prominence (per brief §4) */
.callout {
    background: var(--c-highlight-fill);
    border-left: 6px solid var(--c-warning);
    border-radius: var(--r-md);
    padding: var(--sp-5) var(--sp-6);
    box-shadow: var(--shadow-soft);
}
.callout strong { color: var(--c-warning); }

/* ==========================================================================
   Feature grid (BloomGarden-style three columns)
   ========================================================================== */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-5);
}
.feature {
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
    box-shadow: var(--shadow-soft);
    border: 1px solid color-mix(in srgb, var(--c-text-primary) 6%, transparent);
    transition: transform var(--t-med) var(--ease-spring),
                box-shadow var(--t-med) var(--ease-spring);
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }
.feature__icon {
    width: 56px; height: 56px;
    margin-bottom: var(--sp-4);
    border-radius: 22%;
}
.feature__title { margin-bottom: var(--sp-2); }
.feature p { color: var(--c-text-secondary); font-size: var(--fs-small); }

@media (max-width: 760px) {
    .feature-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Belt strip
   ========================================================================== */
.belt-strip {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: var(--sp-3);
    align-items: end;
    padding: var(--sp-5);
    background: var(--c-surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-soft);
}
.belt-strip img {
    width: 100%;
    height: auto;
    transition: transform var(--t-med) var(--ease-spring);
}
.belt-strip img:hover { transform: translateY(-4px) scale(1.04); }
@media (max-width: 760px) {
    .belt-strip { grid-template-columns: repeat(4, 1fr); }
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
    margin-top: var(--sp-9);
    padding: var(--sp-7) 0 var(--sp-8);
    border-top: 1px solid color-mix(in srgb, var(--c-text-primary) 10%, transparent);
    color: var(--c-text-secondary);
    font-size: var(--fs-small);
}
.site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-5);
    align-items: center;
    justify-content: space-between;
}
.site-footer a { color: var(--c-text-secondary); }
.site-footer a:hover { color: var(--c-text-primary); }

/* ==========================================================================
   Utilities
   ========================================================================== */
.text-center { text-align: center; }
.muted { color: var(--c-text-secondary); }
.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-6); }
.cluster {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    align-items: center;
}
