/* ===================================================================
   home.css — Interactive homepage
   Warm Claude aesthetic. Coral #D97757 / cream #F6F4EE.
   Reuses tokens from tokens.css + base from app.css.
   =================================================================== */

:root {
    --home-coral: #D97757;
    --home-coral-hover: #c96546;
    --home-coral-ink: #9a4424;
    --home-cream: #F6F4EE;
    --home-coral-tint: color-mix(in srgb, var(--home-coral) 12%, transparent);
    --home-coral-tint-strong: color-mix(in srgb, var(--home-coral) 20%, var(--home-cream));
    --home-coral-soft: color-mix(in srgb, var(--home-coral) 22%, transparent);

    /* Golden-ratio scale (φ = 1.618). Drives section rhythm + element proportions. */
    --phi: 1.618;
    --phi-inv: 0.618;
    --home-gutter: clamp(16px, 5vw, 32px);
    --home-touch: 48px;
}
.dark {
    --home-cream: #1c1a16;
    --home-coral-tint: color-mix(in srgb, var(--home-coral) 18%, transparent);
    --home-coral-tint-strong: color-mix(in srgb, var(--home-coral) 28%, var(--home-cream));
    --home-coral-ink: #f0a285;
}

.home-section { padding: clamp(56px, 8vw, 96px) 0; }

/* ===== 1. Hero ===== */
.home-hero {
    position: relative;
    min-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        radial-gradient(60% 60% at 50% 38.2%, var(--home-coral-tint), transparent 70%),
        radial-gradient(40% 50% at 85% 90%, color-mix(in srgb, var(--home-coral) 8%, transparent), transparent 70%),
        var(--home-cream);
    padding: clamp(48px, 8vw, 96px) var(--home-gutter);
}
.home-hero__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}
.home-hero__inner {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 820px;
    margin: 0 auto;
}
.home-hero__badge {
    display: inline-block;
    padding: 6px 14px;
    margin-bottom: 22px;
    border-radius: var(--radius-pill);
    background: var(--home-coral-tint-strong);
    color: var(--home-coral-ink);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-kicker);
}
.home-hero__title {
    font-family: var(--font-serif);
    font-size: clamp(2.4rem, 6vw, 4.5rem);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: var(--tracking-tight);
    margin: 0 0 0.4em;
}
.home-hero__rotate {
    display: inline-block;
    min-width: 4ch;
    color: var(--home-coral);
}
.home-hero__sub {
    color: var(--muted-foreground);
    font-size: clamp(1.05rem, 2.4vw, 1.28rem);
    max-width: 620px;
    margin: 0 auto 30px;
}
.home-hero__cta {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* ===== 2. Stats ===== */
.home-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}
.home-stat { text-align: center; }
.home-stat__num {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--home-coral);
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.1;
}
.home-stat__label {
    color: var(--muted-foreground);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-kicker);
    margin-top: 6px;
}

/* ===== 3. Reveal on scroll ===== */
.reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity .7s var(--ease), transform .7s var(--ease);
}
.reveal.is-in {
    opacity: 1;
    transform: none;
}
.reveal[style*="--d"] { transition-delay: var(--d); }

/* ===== 4. Playground ===== */
.home-play {
    max-width: 880px;
    margin: 0 auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(20px, 3vw, 32px);
    box-shadow: var(--shadow-md);
}
.home-play__bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.home-play__select {
    min-height: 44px;
    padding: 10px 14px;
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: var(--radius-xs);
    color: var(--foreground);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.home-play__select:focus {
    outline: none;
    border-color: var(--home-coral);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--home-coral) 28%, transparent);
}
.home-play__run {
    min-height: 44px;
    padding: 0 24px;
    border: none;
    background: var(--home-coral);
    color: #ffffff;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 0.96rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.home-play__run:hover {
    background: var(--home-coral-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.home-play__run:active { transform: translateY(0); }
.home-play__run:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.home-play__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.home-play__pane-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-kicker);
    color: var(--muted-foreground);
    margin-bottom: 8px;
}
.home-play__pane {
    background: #161823;
    color: #f5f5f7;
    border-radius: var(--radius-sm);
    padding: 18px 20px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    overflow: auto;
    min-height: 210px;
    white-space: pre-wrap;
    word-break: break-word;
}
.home-play__cursor {
    display: inline-block;
    width: 1ch;
    height: 1.05em;
    vertical-align: text-bottom;
    background: var(--home-coral);
    animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.home-play__hint {
    text-align: center;
    color: var(--muted-foreground);
    font-size: 0.82rem;
    margin-top: 16px;
}
.home-play__hint a { color: var(--home-coral-ink); text-decoration: none; font-weight: 600; }
.home-play__hint a:hover { text-decoration: underline; }

.home-play__remaining {
    font-size: 0.8rem;
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}
.home-play__compose {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.home-play__input {
    flex: 1 1 260px;
    min-width: 0;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--background);
    color: var(--foreground);
    font: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.home-play__input:focus {
    outline: none;
    border-color: var(--home-coral);
    box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.15);
}
.home-play__captcha {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}
.brand-ico {
    display: inline-block;
    width: 18px;
    height: 18px;
    vertical-align: -3px;
    margin-right: 7px;
    flex: none;
    color: var(--foreground);
}

/* ===== 5. Pricing wall ===== */
.price-wall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}
.price-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    overflow: hidden;
    transform-style: preserve-3d;
    will-change: transform;
    transition: transform 0.2s var(--ease);
}
.price-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, color-mix(in srgb, var(--home-coral) 10%, transparent), transparent 55%);
    opacity: 0;
    transition: opacity 0.2s var(--ease);
}
.price-card:hover::after { opacity: 1; }
.price-card__name {
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 4px;
}
.price-card__channel {
    display: inline-block;
    padding: 2px 10px;
    margin-bottom: 14px;
    border-radius: var(--radius-pill);
    background: var(--home-coral-tint-strong);
    color: var(--home-coral-ink);
    font-size: 0.74rem;
    font-weight: 600;
}
.price-card__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    font-size: 0.9rem;
}
.price-card__row > span:first-child { color: var(--muted-foreground); }
.price-card__row > span:last-child {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--home-coral-ink);
}

/* ===== 7. Responsive — mobile-first golden-ratio upgrade ===== */

/* Tablet / large phone landscape */
@media (max-width: 860px) {
    .home-stats { gap: 18px; }
    .home-play { padding: clamp(18px, 4vw, 28px); }
}

/* ---- Phone (portrait) : the core mobile experience ---- */
@media (max-width: 720px) {
    /* Hero: anchored on the golden line (≈38.2% from top) instead of dead-center,
       which reads as more dynamic + leaves the fold for CTAs */
    .home-hero {
        min-height: 100svh;
        align-items: flex-start;
        padding-top: calc(64px + env(safe-area-inset-top));
        padding-bottom: clamp(32px, 12vw, 64px);
    }
    .home-hero__inner {
        margin-top: max(6vh, calc((100svh - 64px) * (1 - var(--phi-inv)) * 0.5));
        max-width: 100%;
    }
    .home-hero__badge { margin-bottom: 16px; font-size: 0.68rem; }
    .home-hero__title {
        font-size: clamp(2.1rem, 9vw, 3.2rem);
        line-height: 1.08;
        text-wrap: balance;
    }
    .home-hero__rotate { min-width: auto; }
    .home-hero__sub {
        font-size: clamp(1rem, 4.2vw, 1.18rem);
        max-width: 38ch;
        text-wrap: pretty;
    }
    /* Stacked, full-width CTAs sized for thumbs */
    .home-hero__cta {
        flex-direction: column;
        gap: 12px;
        width: min(100%, 360px);
        margin-inline: auto;
    }
    .home-hero__cta .btn { width: 100%; min-height: var(--home-touch); }

    /* Stats: 2-up keeps numbers legible; φ-driven gap */
    .home-stats { grid-template-columns: repeat(2, 1fr); gap: clamp(14px, 4vw, 24px); }
    .home-stat__num { font-size: clamp(1.8rem, 8vw, 2.6rem); }

    /* Playground: single column, comfortable padding, edge-to-edge feel */
    .home-play {
        border-radius: var(--radius);
        padding: clamp(16px, 4.5vw, 24px);
    }
    .home-play__grid { grid-template-columns: 1fr; gap: 14px; }
    .home-play__bar { gap: 10px; }
    .home-play__select { width: 100%; min-height: var(--home-touch); }
    .home-play__remaining { margin-left: 0; }
    .home-play__compose { flex-direction: column; gap: 10px; }
    .home-play__input { width: 100%; flex: 1 1 auto; min-height: var(--home-touch); }
    .home-play__run { width: 100%; min-height: var(--home-touch); }
    /* Response pane gets golden-ratio height (req:res ≈ 1:φ) so the result is the focus */
    .home-play__pane { min-height: clamp(132px, 38vw, 200px); padding: 14px 16px; }

    /* Pricing wall: 2-up auto, then stack on the smallest screens */
    .price-wall { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .price-card { padding: 18px; }
    .price-card__name { font-size: 1rem; }
    .price-card__row { font-size: 0.86rem; }
}

/* ---- Small phones ---- */
@media (max-width: 480px) {
    .home-hero__title { font-size: clamp(1.95rem, 10vw, 2.6rem); }
    .home-stats { gap: 12px; }
    .price-wall { grid-template-columns: 1fr; }
}

/* ---- Very small / dense ---- */
@media (max-width: 360px) {
    .home-stats { grid-template-columns: 1fr; }
}

/* Larger tap targets + remove hover-only affordances on touch devices */
@media (hover: none) and (pointer: coarse) {
    .home-play__run,
    .home-play__select,
    .home-play__input { min-height: var(--home-touch); }
    .price-card { transform: none !important; }
    .price-card::after { display: none; }
}

/* Short landscape phones: don't force a full-height hero */
@media (max-width: 860px) and (max-height: 520px) and (orientation: landscape) {
    .home-hero { min-height: auto; align-items: center; padding-block: 56px; }
    .home-hero__inner { margin-top: 0; }
}

/* ===== 8. Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .reveal[style*="--d"] { transition-delay: 0s; }
    .home-play__cursor { animation: none; }
    .home-play__run,
    .price-card,
    .price-card::after { transition: none; }
}

/* ===== 9. Scroll progress (dwell-rate aid) =====
   A thin coral bar under the sticky header that fills as the visitor scrolls.
   Gives a sense of progress/completion which improves read-through + retention. */
.home-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    transform: scaleX(0);
    transform-origin: 0 50%;
    background: linear-gradient(90deg, var(--home-coral), color-mix(in srgb, var(--home-coral) 55%, #ffd9c9));
    z-index: 60;
    pointer-events: none;
    will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
    .home-progress { transition: none; }
}
