/*
 * The stylesheet for every page the server renders: the landing page at /, the
 * share page at /s/{shareId}, and the Terms and Privacy pages.
 *
 * A bedtime app should look like the sky it is read under, so every page is a
 * pastel day-sky blue in light mode and a soft night blue, with stars, in dark
 * mode. Coral stays the brand colour (shared/ui/theme/Theme.kt) and sunny doubles
 * as moonlight. `--coral-ink` is coral for *text*: the brand coral is too light to
 * read on pale blue and too loud on navy, so each theme gets its own shade.
 *
 * No fonts are fetched — a system stack renders instantly and cannot be the
 * reason the page is slow. The landing page asks for the rounded system face
 * where one exists (Apple platforms) and falls back to the ordinary one.
 */

:root {
    --coral: #FF6B5A;
    --sunny: #FFC94D;
    --bg: #DDEBFA;
    --surface: #FFFFFF;
    --surface-2: #EEF5FE;
    --ink: #1E2A4C;
    --ink-soft: #55628A;
    --line: rgba(70, 95, 160, 0.14);
    --shadow: 0 14px 40px rgba(50, 80, 150, 0.12);
    --accent: #4F5EC4;
    --coral-ink: #D94C40;
    --glow: rgba(160, 140, 255, 0.45);
    --mark: rgba(255, 201, 77, 0.55);
    --tint-blue: rgba(124, 140, 240, 0.18);
    --sky:
        radial-gradient(circle at 15% 10%, rgba(200, 185, 255, 0.55), transparent 45%),
        radial-gradient(circle at 85% 90%, rgba(165, 225, 235, 0.55), transparent 45%);
    --sky-size: auto;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #222E52;
        --surface: #2B3862;
        --surface-2: #26325A;
        --ink: #EEF1FF;
        --ink-soft: #B7C0E0;
        --line: rgba(190, 200, 255, 0.14);
        --shadow: 0 14px 40px rgba(6, 10, 28, 0.4);
        --accent: #A9B6FF;
        --coral-ink: #FF9E90;
        --glow: rgba(255, 214, 120, 0.25);
        --mark: rgba(169, 182, 255, 0.3);
        --tint-blue: rgba(169, 182, 255, 0.16);
        /* Four tiled layers of stars at different sizes, so the repeat is not
           visible, over a lavender wash and a moonlit corner. */
        --sky:
            radial-gradient(circle at 40px 60px, rgba(255, 255, 255, 0.85) 0 1.2px, transparent 1.8px),
            radial-gradient(circle at 130px 20px, rgba(255, 255, 255, 0.6) 0 0.8px, transparent 1.4px),
            radial-gradient(circle at 200px 150px, rgba(255, 240, 200, 0.75) 0 1px, transparent 1.6px),
            radial-gradient(circle at 70px 210px, rgba(255, 255, 255, 0.5) 0 0.8px, transparent 1.4px),
            radial-gradient(circle at 85% 12%, rgba(255, 220, 150, 0.14), transparent 35%),
            radial-gradient(circle at 15% 10%, rgba(150, 130, 240, 0.25), transparent 45%),
            radial-gradient(circle at 85% 90%, rgba(90, 170, 210, 0.16), transparent 45%);
        --sky-size: 230px 230px, 170px 170px, 310px 310px, 260px 260px, auto, auto, auto;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);

    /* Fixed so the washes and the stars do not slide around when a small screen
       scrolls. */
    background-color: var(--bg);
    background-image: var(--sky);
    background-size: var(--sky-size);
    background-attachment: fixed;
}

.footer {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--ink-soft);
}

.footer p {
    margin: 0;
}

/*
 * The landing page at /.
 *
 * Scoped under `body.landing` so none of it leaks into the share or legal pages,
 * which share only the palette and the footer.
 */

body.landing {
    font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow-x: hidden;
}

.landing .wrap {
    width: min(72rem, 100% - 32px);
    margin-inline: auto;
}

.landing h2,
.landing h3 {
    letter-spacing: -0.02em;
}

/* ── Hero ── */

.hero {
    position: relative;
    padding: 28px 0 64px;
}

.float-emoji {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.float-emoji span {
    position: absolute;
    left: var(--x);
    top: var(--y);
    font-size: clamp(1.75rem, 4vw, 3rem);
    opacity: 0.45;
    animation: bob 7s ease-in-out infinite;
    animation-delay: var(--d);
}

@keyframes bob {
    0%, 100% { transform: translateY(0) rotate(-8deg); }
    50% { transform: translateY(-16px) rotate(8deg); }
}

.hero-grid {
    position: relative;
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 48px;
    align-items: center;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--coral-ink);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.brand img {
    /* The source icon is a square with white corners — the app platforms mask it
       themselves. Clipping it here is what keeps those corners off the page. */
    border-radius: 24%;
    box-shadow: 0 6px 18px rgba(255, 107, 90, 0.35);
}

.hero h1 {
    margin: 32px 0 0;
    font-size: clamp(2.4rem, 6vw, 4.25rem);
    font-weight: 800;
    line-height: 1.04;
    letter-spacing: -0.035em;
    text-wrap: balance;
}

.hero h1 em {
    font-style: normal;
    color: var(--coral-ink);
    background: linear-gradient(transparent 64%, var(--mark) 64%);
    padding: 0 0.06em;
}

.lede {
    margin: 20px 0 0;
    max-width: 34rem;
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    line-height: 1.6;
    color: var(--ink-soft);
}

/* A miniature of the reader: each word lights up in turn, the way the app does it
   against the narration. Nine words at 0.6 s, plus a beat of rest before it loops,
   is 6.6 s; each word's window is 0.6 / 6.6 of that. */
.read-along {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25em;
    width: fit-content;
    max-width: 100%;
    margin: 24px 0 0;
    padding: 14px 18px;

    font-size: 1.15rem;
    font-weight: 600;

    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.read-along span {
    padding: 0 0.18em;
    border-radius: 6px;
    animation: word 6.6s infinite;
    animation-delay: calc(var(--i) * 0.6s);
}

@keyframes word {
    0%, 8.4% { background: var(--sunny); color: #1E2A4C; }
    9.1%, 100% { background: transparent; color: var(--ink); }
}

.stores {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
}

.store-badge {
    display: inline-block;
    border-radius: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Both badges are drawn at the same 54 px height, which also makes them the same
   width: Apple's is 135x40 and Google's 180x53.3. */
.store-badge img {
    display: block;
    width: auto;
    height: 54px;
}

.store-badge:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(30, 42, 76, 0.25);
}

.hero-note {
    margin: 14px 0 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.hero-phone {
    position: relative;
    display: flex;
    justify-content: center;
    isolation: isolate;
}

.hero-phone::before {
    content: "";
    position: absolute;
    inset: 10% -6%;
    z-index: -1;
    background: radial-gradient(circle, var(--glow), transparent 65%);
    filter: blur(24px);
}

.hero-phone .phone {
    width: min(300px, 72vw);
    transform: rotate(3deg);
}

.phone {
    padding: 9px;
    background: #161D36;
    border-radius: 38px;
    box-shadow: 0 30px 60px rgba(20, 30, 70, 0.28);
}

.phone img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 30px;
}

/* ── Desktop & web ── */

.platforms {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}

.panel {
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.panel-head h2 {
    margin: 0;
    font-size: 1.5rem;
}

.panel-head p {
    margin: 6px 0 0;
    color: var(--ink-soft);
}

.os-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 22px;
}

.os-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;

    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;

    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 18px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.os-btn small {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.os-btn:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.os-more {
    margin: 14px 0 0;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.os-more a {
    color: var(--accent);
    font-weight: 600;
}

/* The icons are single-colour SVGs used as a mask, so they take the text colour
   in either theme instead of being baked black. */
.os-icon {
    flex: none;
    width: 26px;
    height: 26px;
    background: currentColor;
    -webkit-mask: var(--icon) center / contain no-repeat;
    mask: var(--icon) center / contain no-repeat;
}

.os-icon.big {
    width: 44px;
    height: 44px;
}

.web-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 28px;

    color: #FFFFFF;
    text-decoration: none;

    background: linear-gradient(135deg, #6A78E2, #4B58C2);
    border-radius: 28px;
    box-shadow: 0 18px 40px rgba(75, 88, 194, 0.35);
    transition: transform 0.2s ease;
}

.web-copy strong {
    display: block;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

.web-copy span {
    display: block;
    margin-top: 4px;
    opacity: 0.9;
}

.web-card .arrow {
    margin-left: auto;
    font-size: 1.8rem;
    transition: transform 0.2s ease;
}

.web-card:hover {
    transform: translateY(-2px);
}

.web-card:hover .arrow {
    transform: translateX(6px);
}

/* ── Sections ── */

.section {
    padding-top: 88px;
}

.eyebrow {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}

.section-title {
    max-width: 42rem;
    margin: 10px 0 0;
    font-size: clamp(1.75rem, 4vw, 2.6rem);
    line-height: 1.12;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 36px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.steps li,
.features article,
.plan {
    position: relative;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.steps li {
    counter-increment: step;
}

.steps li::after {
    content: counter(step);
    position: absolute;
    top: 22px;
    right: 24px;
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--line);
}

.step-emoji,
.features article > span {
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    font-size: 2rem;
    background: var(--tint, rgba(255, 107, 90, 0.14));
    border-radius: 18px;
}

.steps li:nth-child(2) { --tint: rgba(255, 201, 77, 0.24); }
.steps li:nth-child(3) { --tint: var(--tint-blue); }

.steps h3,
.features h3 {
    margin: 18px 0 6px;
    font-size: 1.2rem;
}

.steps p,
.features p {
    margin: 0;
    line-height: 1.6;
    color: var(--ink-soft);
}

/* ── Screenshots ── */

.shots {
    padding-top: 72px;
}

/* Scrolls sideways when the phones do not fit and centres them when they do; auto
   margins collapse to zero in an overflowing flex row, so nothing is clipped. */
.shots-track {
    display: flex;
    gap: 28px;
    padding: 8px 16px 32px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.shots-track::-webkit-scrollbar {
    display: none;
}

.shots figure {
    flex: 0 0 min(230px, 62vw);
    margin: 0;
    text-align: center;
    scroll-snap-align: center;
}

.shots figure:first-child { margin-left: auto; }
.shots figure:last-child { margin-right: auto; }

.shots figure:nth-child(odd) .phone { transform: rotate(-2deg); }
.shots figure:nth-child(even) .phone { transform: rotate(2deg) translateY(18px); }

.shots figcaption {
    margin-top: 30px;
    font-weight: 700;
    color: var(--ink-soft);
}

/* ── Features ── */

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 36px;
}

.features article:nth-child(3n + 2) { --tint: rgba(255, 201, 77, 0.24); }
.features article:nth-child(3n) { --tint: var(--tint-blue); }

/* ── Why ── */

.why {
    position: relative;
    margin: 0;
    padding: clamp(32px, 6vw, 64px);
    /* Room for the quotation mark, which would otherwise sit on the first line. */
    padding-top: 72px;
    background: linear-gradient(135deg, rgba(190, 175, 255, 0.45), rgba(255, 200, 180, 0.35));
    border-radius: 32px;
}

.why::before {
    content: "“";
    position: absolute;
    top: -0.1em;
    left: 0.25em;
    font-size: 7rem;
    font-weight: 800;
    color: var(--coral-ink);
    opacity: 0.5;
}

.why p {
    position: relative;
    max-width: 46rem;
    margin: 0 auto;
    font-size: clamp(1.25rem, 2.6vw, 1.75rem);
    font-weight: 700;
    line-height: 1.5;
    letter-spacing: -0.01em;
    text-wrap: pretty;
}

.why em {
    font-style: normal;
    color: var(--coral-ink);
}

/* ── Everywhere ── */

.everywhere {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 40px;
    align-items: center;
}

.everywhere p:not(.eyebrow) {
    margin: 16px 0 0;
    max-width: 36rem;
    line-height: 1.7;
    color: var(--ink-soft);
}

.device-chips {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.device-chips li {
    padding: 22px 18px;
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

/* ── Plans ── */

.plans {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 54rem;
    margin-top: 36px;
}

.plan h3 {
    margin: 0 0 14px;
    font-size: 1.4rem;
}

.plan ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.plan li {
    position: relative;
    margin-top: 10px;
    padding-left: 28px;
    line-height: 1.5;
}

.plan li::before {
    content: "✓";
    position: absolute;
    left: 0;
    font-weight: 800;
    color: var(--accent);
}

.plan.pro {
    border: 2px solid transparent;
    background:
        linear-gradient(var(--surface), var(--surface)) padding-box,
        linear-gradient(135deg, var(--coral), var(--sunny)) border-box;
}

.plan.pro h3 {
    color: var(--coral-ink);
}

/* ── Closing call to action ── */

.cta-band {
    margin-top: 96px;
    padding: 56px 24px;
    text-align: center;
    color: #FFFFFF;
    background: linear-gradient(135deg, var(--coral), #FF8E5E);
    border-radius: 32px;
    box-shadow: 0 24px 50px rgba(255, 107, 90, 0.3);
}

.cta-band h2 {
    margin: 0;
    font-size: clamp(1.75rem, 4vw, 2.6rem);
}

.cta-band .stores {
    justify-content: center;
}

.cta-band p {
    margin: 22px 0 0;
}

.cta-band p a {
    color: #FFFFFF;
    font-weight: 700;
}

body.landing .footer {
    padding: 48px 16px;
    text-align: center;
}

/* ── Small screens ── */

@media (max-width: 860px) {
    .hero-grid,
    .platforms,
    .everywhere {
        grid-template-columns: 1fr;
    }

    .hero-copy {
        text-align: center;
    }

    .hero .lede,
    .read-along {
        margin-inline: auto;
    }

    .hero .stores {
        justify-content: center;
    }

    .steps,
    .features {
        grid-template-columns: repeat(2, 1fr);
    }

    .float-emoji span {
        opacity: 0.25;
    }
}

@media (max-width: 600px) {
    .steps,
    .features,
    .plans,
    .os-buttons {
        grid-template-columns: 1fr;
    }

    .section {
        padding-top: 64px;
    }

    .web-card,
    .panel {
        padding: 22px;
    }

    .read-along {
        font-size: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .float-emoji span,
    .read-along span {
        animation: none;
    }

    .store-badge,
    .os-btn,
    .web-card,
    .web-card .arrow {
        transition: none;
    }
}

/*
 * The share page at /s/{shareId}.
 *
 * Shares the palette above, but not the layout: this is a document someone
 * reads top to bottom.
 */

body.reader {
    padding: 24px 16px 48px;
}

.story {
    max-width: 44rem;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 20px;
    padding: clamp(20px, 5vw, 40px);
    box-shadow: var(--shadow);
}

.story-title {
    margin: 0 0 24px;
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    line-height: 1.2;
    color: var(--coral-ink);
    text-align: center;
}

/* 16:9, matching what the illustrator generates (768x432), so the page does not
   reflow as each beat's artwork loads in. */
/* Sized by the picture itself rather than forced to 16:9. Family art is painted
   portrait now, and a forced landscape box with object-fit: cover chopped it to a
   band through the middle; a landscape beat still fills the width. */
.beat {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 80vh;
    border-radius: 14px;
    margin: 28px auto 18px;
    background: var(--surface-2);
}

.page p {
    margin: 0 0 18px;
    font-size: clamp(1.05rem, 2.6vw, 1.25rem);
    line-height: 1.7;
    color: var(--ink);
}

.narration {
    width: 100%;
    margin-bottom: 26px;
}

.share-footer {
    max-width: 44rem;
    margin: 32px auto 0;
    text-align: center;
    color: var(--ink-soft);
}

.share-footer .cta {
    display: inline-block;
    padding: 12px 26px;
    border-radius: 999px;
    background: linear-gradient(135deg, #6A78E2, #4B58C2);
    color: #FFFFFF;
    font-weight: 600;
    text-decoration: none;
}

.share-footer p {
    margin: 12px 0 0;
    font-size: 0.95rem;
}

/*
 * The Terms and Privacy pages.
 *
 * Same palette as the rest, and a document layout like the share page's.
 */

body.legal {
    padding: 0 16px 56px;
}

.legal-head {
    display: flex;
    justify-content: center;
    padding: 24px 0 8px;
}

.legal-home {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 800;
    font-size: 1.15rem;
}

.legal-home img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.legal-body {
    max-width: 46rem;
    margin: 12px auto 0;
    background: var(--surface);
    border-radius: 20px;
    padding: clamp(24px, 5vw, 44px);
    box-shadow: var(--shadow);
}

.legal-body h1 {
    margin: 0 0 4px;
    color: var(--coral-ink);
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    line-height: 1.2;
}

.legal-updated {
    margin: 0 0 24px;
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.legal-body h2 {
    margin: 30px 0 8px;
    color: var(--accent);
    font-size: 1.2rem;
}

.legal-body p,
.legal-body li {
    line-height: 1.7;
    color: var(--ink);
}

.legal-body ul {
    padding-left: 1.25rem;
}

.legal-body li {
    margin-bottom: 8px;
}

.legal-body a {
    color: var(--coral-ink);
}

.legal-note {
    background: var(--tint-blue);
    border-radius: 12px;
    padding: 14px 18px;
}

.legal-cross {
    margin-top: 34px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    font-weight: 600;
}

/* Footer links on the landing page. */
.footer-links {
    margin-top: 6px;
}

.footer-links a {
    color: var(--ink-soft);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}
