/* =======================================================
   HabitsFlow mini-site
   Mirrors the app: iOS grouped background, white cards,
   violet accent, tinted habit rows, floating tab bar.
   ======================================================= */

:root {
    --maxw: 1160px;
    --gutter: clamp(16px, 5vw, 36px);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Habit colors, as in the app */
    --h-green: #3dbf5f;
    --h-orange: #f29a3e;
    --h-red: #ee5566;
    --h-magenta: #bb55db;
    --h-violet: #6f5df5;
    --h-blue: #3e8ef7;

    --accent: #6e5cf6;
    --accent-strong: #5a47e8;
    --accent-soft: #ebe8ff;

    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-2: #f6f6f9;
    --seg: #e5e5ec;
    --seg-on: #ffffff;
    --text: #121218;
    --text-2: #5f5f6e;
    --text-3: #9898a8;
    --line: rgba(18, 18, 24, 0.08);
    --shadow: 0 1px 2px rgba(18, 18, 24, 0.04), 0 14px 34px -14px rgba(18, 18, 24, 0.14);
    --tint: 13%;
    --glass: rgba(255, 255, 255, 0.74);
    --glow-a: rgba(111, 93, 245, 0.16);
    --glow-b: rgba(187, 85, 219, 0.12);

    --device-frame: #1c1c22;
    --focus-ring: var(--accent);
    --show-light: block;
    --show-dark: none;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --accent: #7d6cff;
        --accent-strong: #6a58f5;
        --accent-soft: #272342;
        --bg: #0b0b10;
        --surface: #17171f;
        --surface-2: #1f1f29;
        --seg: #1d1d27;
        --seg-on: #35353f;
        --text: #f4f4f8;
        --text-2: #a8a8b9;
        --text-3: #6f6f82;
        --line: rgba(255, 255, 255, 0.08);
        --shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.7);
        --tint: 24%;
        --glass: rgba(30, 30, 40, 0.72);
        --glow-a: rgba(111, 93, 245, 0.28);
        --glow-b: rgba(187, 85, 219, 0.16);
        --device-frame: #2b2b33;
        --show-light: none;
        --show-dark: block;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --accent: #7d6cff;
    --accent-strong: #6a58f5;
    --accent-soft: #272342;
    --bg: #0b0b10;
    --surface: #17171f;
    --surface-2: #1f1f29;
    --seg: #1d1d27;
    --seg-on: #35353f;
    --text: #f4f4f8;
    --text-2: #a8a8b9;
    --text-3: #6f6f82;
    --line: rgba(255, 255, 255, 0.08);
    --shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.7);
    --tint: 24%;
    --glass: rgba(30, 30, 40, 0.72);
    --glow-a: rgba(111, 93, 245, 0.28);
    --glow-b: rgba(187, 85, 219, 0.16);
    --device-frame: #2b2b33;
    --show-light: none;
    --show-dark: block;
    color-scheme: dark;
}

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(60rem 36rem at 85% -8rem, var(--glow-a), transparent 70%),
        radial-gradient(44rem 30rem at -10% 10rem, var(--glow-b), transparent 70%);
    background-repeat: no-repeat;
    transition:
        background-color 0.35s,
        color 0.35s;
}

svg {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
}

.eyebrow,
.label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    min-height: 64px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 750;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    box-shadow: 0 6px 16px -6px rgba(111, 93, 245, 0.7);
}

.tabs {
    display: flex;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--glass);
    box-shadow: var(--shadow);
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-2);
    text-decoration: none;
    transition:
        background-color 0.25s,
        color 0.25s;
}

.tab svg {
    display: none;
}

.tab:hover {
    color: var(--text);
}

.tab.is-active {
    background: var(--accent-soft);
    color: var(--accent);
}

.topbar-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    transition: transform 0.2s;
}

.icon-btn:hover {
    transform: rotate(-12deg);
}

.theme-toggle .when-dark,
.theme-toggle[data-state="dark"] .when-light {
    display: none;
}

.theme-toggle[data-state="dark"] .when-dark {
    display: block;
}

.pill-link {
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.pill-link:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    color: var(--accent);
}

/* ---------- Hero ---------- */
.hero {
    padding-block: clamp(40px, 7vw, 88px) clamp(24px, 4vw, 48px);
    scroll-margin-top: 64px;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.08fr 0.92fr;
    align-items: center;
    gap: clamp(40px, 6vw, 72px);
}

.hero h1 {
    margin: 14px 0 20px;
    font-size: clamp(2.9rem, 7.4vw, 5.4rem);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -0.045em;
}

.flow-word {
    background: linear-gradient(90deg, var(--h-violet), var(--h-magenta), var(--h-orange), var(--h-green), var(--h-violet));
    background-size: 400% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: flow 12s linear infinite;
}

@keyframes flow {
    to {
        background-position: 400% 0;
    }
}

.lead {
    max-width: 34em;
    font-size: clamp(1.05rem, 1.6vw, 1.2rem);
    line-height: 1.6;
    color: var(--text-2);
}

.hero-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 30px;
}

.btn-store {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    padding: 11px 24px 11px 18px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--h-violet), #9168ff);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 14px 30px -12px rgba(111, 93, 245, 0.75);
    transition:
        transform 0.25s,
        box-shadow 0.25s;
}

.btn-store:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px -12px rgba(111, 93, 245, 0.85);
}

.btn-store svg {
    font-size: 26px;
}

.btn-store span {
    font-size: 1.18rem;
    font-weight: 700;
    line-height: 1.1;
}

.btn-store small {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.85;
}

.btn-soft {
    display: inline-flex;
    align-items: center;
    padding: 14px 22px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    font-weight: 650;
    color: var(--text);
    text-decoration: none;
    transition: transform 0.25s;
}

.btn-soft:hover {
    transform: translateY(-2px);
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-top: 30px;
    list-style: none;
    font-size: 0.92rem;
    color: var(--text-2);
}

.hero-meta li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c);
}

.hero-device {
    position: relative;
    display: grid;
    justify-items: center;
}

.hero-device::before {
    content: "";
    position: absolute;
    inset: 8% 4% 14%;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(closest-side, var(--glow-a), transparent);
    filter: blur(20px);
}

.hero-device .device {
    --device-w: 320px;
}

.shot-light {
    display: var(--show-light);
}

.shot-dark {
    display: var(--show-dark);
}

/* ---------- Sections ---------- */
.section {
    padding-block: clamp(56px, 7vw, 96px);
    scroll-margin-top: 40px;
}

.section-head {
    margin-bottom: clamp(28px, 4vw, 44px);
}

.section-head h2 {
    margin-top: 12px;
    font-size: clamp(2rem, 4.6vw, 3.4rem);
    font-weight: 800;
    line-height: 1.07;
    letter-spacing: -0.035em;
}

.narrow {
    max-width: 800px;
}

/* ---------- Bento ---------- */
.bento {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: clamp(22px, 3vw, 32px);
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.tile h3 {
    font-size: 1.42rem;
    font-weight: 750;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.tile p {
    color: var(--text-2);
}

.tile-copy {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tile-week,
.tile-schedule {
    grid-column: span 7;
}

.tile-focus,
.tile-sync {
    grid-column: span 5;
}

.tile-stats,
.tile-widgets,
.tile-themes {
    grid-column: span 4;
}

.tile-sync {
    gap: 24px;
}

/* A screenshot peeking out of the bottom of the tile, like the top of a phone */
.tile:has(.tile-shot) {
    padding-bottom: 0;
}

.tile:has(.tile-shot) .tile-copy {
    margin-bottom: 10px;
}

.tile-shot {
    position: relative;
    display: block;
    width: min(100%, 290px);
    aspect-ratio: 29 / 30;
    align-self: center;
    margin-top: auto;
    overflow: hidden;
    border: 7px solid var(--device-frame);
    border-bottom: 0;
    border-radius: 42px 42px 0 0;
    background: var(--device-frame);
    box-shadow: 0 -12px 40px -26px rgba(0, 0, 0, 0.4);
    transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.tile-shot::after {
    /* Dynamic Island */
    content: "";
    position: absolute;
    top: 9px;
    left: 50%;
    width: 31%;
    height: 22px;
    border-radius: 999px;
    background: #000;
    transform: translateX(-50%);
}

.tile-shot:hover {
    transform: translateY(-6px);
}

.tile-shot img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 35px 35px 0 0;
}

.tile-shot-ipad {
    width: min(100%, 340px);
    aspect-ratio: 34 / 27;
    border-width: 9px;
    border-radius: 26px 26px 0 0;
}

.tile-shot-ipad::after {
    content: none;
}

.tile-shot-ipad img {
    border-radius: 17px 17px 0 0;
}

.tile-schedule .tile-shot-ipad {
    aspect-ratio: 34 / 31;
}

/* Wide tiles: text on the left, screenshot on the right */
.tile-wide {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    column-gap: 28px;
}

.tile-wide .tile-copy {
    align-self: start;
}

.tile-wide .tile-shot {
    width: 290px;
}

.tile-wide .tile-shot-ipad {
    width: 340px;
}

/* Sync demo */
.sync-demo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding: 20px 18px;
    border-radius: 22px;
    background: var(--surface-2);
}

.sync-device {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 650;
    color: var(--text-2);
}

.sync-device svg {
    font-size: 30px;
    color: var(--text);
}

.sync-cloud {
    display: grid;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    place-items: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 24px;
}

.sync-line {
    flex: 1;
    min-width: 10px;
    height: 2px;
    background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 12px);
    background-size: 24px 2px;
    animation: dash 1.4s linear infinite;
    opacity: 0.6;
}

@keyframes dash {
    to {
        background-position: 24px 0;
    }
}

/* ---------- Screens ---------- */
.section-head-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
}

.shots-nav button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.shots-nav button:not(:disabled):hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.shots {
    --shot-w: 250px;
    --shot-radius: 40px;
}

.shot .device {
    --device-w: 100%;
    --device-shadow: 0 30px 50px -30px rgba(0, 0, 0, 0.5);
}

.shot figcaption {
    color: var(--text-2);
}

.shot figcaption b {
    display: block;
    color: var(--text);
}

.ipad-block {
    display: grid;
    grid-template-columns: 0.75fr 1.25fr;
    align-items: center;
    gap: clamp(24px, 4vw, 48px);
    margin-top: clamp(32px, 5vw, 56px);
}

.ipad-copy {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ipad-copy h3 {
    font-size: clamp(1.5rem, 2.6vw, 2rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.025em;
}

.ipad-copy p {
    color: var(--text-2);
}

.ipad-shots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(10px, 1.6vw, 18px);
}

.ipad-shot {
    overflow: hidden;
    border: clamp(4px, 0.6vw, 7px) solid var(--device-frame);
    border-radius: clamp(12px, 1.8vw, 22px);
    box-shadow: var(--shadow);
    transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.ipad-shot:nth-child(2) {
    transform: translateY(-18px);
}

.ipad-shot:hover {
    transform: translateY(-8px);
}

.ipad-shot:nth-child(2):hover {
    transform: translateY(-26px);
}

.ipad-shot img {
    width: 100%;
    height: auto;
}

/* ---------- What's new ---------- */
.changelog {
    display: grid;
    gap: 10px;
    list-style: none;
}

.changelog li {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    background: color-mix(in srgb, var(--c) var(--tint), var(--surface));
}

.changelog li::after {
    content: "";
    width: 26px;
    height: 26px;
    margin-left: auto;
    flex-shrink: 0;
    border-radius: 50%;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 12.5l3.7 3.7 7.3-8' fill='none' stroke='white' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 70% no-repeat,
        var(--c);
}

.ver {
    display: grid;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    place-items: center;
    border-radius: 13px;
    background: var(--c);
    font-size: 0.85rem;
    font-weight: 800;
    color: #fff;
}

.changelog div {
    display: flex;
    flex-direction: column;
}

.changelog b {
    font-weight: 650;
}

.changelog div span {
    font-size: 0.86rem;
    color: var(--text-3);
}

/* ---------- Support ---------- */
.support-grid {
    display: grid;
    grid-template-columns: 1.45fr 0.9fr;
    align-items: start;
    gap: 24px;
}

.faq details {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    transition: box-shadow 0.25s;
}

.faq details[open] {
    box-shadow: var(--shadow);
}

.faq summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    font-weight: 650;
    list-style: none;
    cursor: pointer;
}

.faq summary::-webkit-details-marker {
    display: none;
}

.faq summary::after {
    content: "";
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 50%;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 7v10M7 12h10' fill='none' stroke='%236e5cf6' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / 70% no-repeat,
        var(--accent-soft);
    transition: transform 0.3s;
}

.faq details[open] summary::after {
    transform: rotate(45deg);
}

.faq p {
    padding: 0 20px 18px;
    color: var(--text-2);
}

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

.contact {
    position: sticky;
    top: 88px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 28px;
    border-radius: 28px;
    background: linear-gradient(155deg, var(--h-violet), #8f5cf2 55%, var(--h-magenta));
    color: #fff;
    box-shadow: 0 30px 60px -30px rgba(111, 93, 245, 0.8);
}

.contact-icon {
    display: grid;
    width: 50px;
    height: 50px;
    place-items: center;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.2);
    font-size: 24px;
}

.contact h3 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.contact p {
    opacity: 0.9;
}

.btn-primary {
    margin-top: 6px;
    padding: 14px 20px;
    border-radius: 14px;
    background: #fff;
    font-weight: 700;
    text-align: center;
    color: #3d2bc4;
    text-decoration: none;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.contact .contact-mail {
    font-size: 0.86rem;
    text-align: center;
    opacity: 0.8;
    user-select: all;
    word-break: break-all;
}

/* ---------- Footer ---------- */
.footer {
    padding-block: 32px 44px;
    border-top: 1px solid var(--line);
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 18px 28px;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
}

.footer-links a {
    font-size: 0.92rem;
    color: var(--text-2);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--accent);
}

.copyright {
    font-size: 0.88rem;
    color: var(--text-3);
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }

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

    .lead {
        margin-inline: auto;
    }

    .hero-cta,
    .hero-meta {
        justify-content: center;
    }

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

    .tile-week,
    .tile-schedule,
    .tile-sync {
        grid-column: span 12;
    }

    .tile-focus,
    .tile-stats,
    .tile-widgets,
    .tile-themes {
        grid-column: span 6;
    }

    .support-grid {
        grid-template-columns: 1fr;
    }

    .contact {
        position: static;
    }

    .ipad-block {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    body {
        padding-bottom: 92px;
    }

    /* A backdrop-filter would make the bar the containing block of the fixed tab bar below */
    .topbar {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background: color-mix(in srgb, var(--bg) 94%, transparent);
    }

    .topbar-inner {
        grid-template-columns: 1fr auto;
        min-height: 58px;
    }

    /* Section tabs become the app's floating tab bar */
    .tabs {
        position: fixed;
        z-index: 60;
        bottom: calc(12px + env(safe-area-inset-bottom));
        left: 50%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        width: min(420px, calc(100% - 32px));
        padding: 6px;
        border-radius: 32px;
        transform: translateX(-50%);
        -webkit-backdrop-filter: saturate(180%) blur(18px);
        backdrop-filter: saturate(180%) blur(18px);
        box-shadow: 0 16px 36px -14px rgba(0, 0, 0, 0.35);
    }

    .tab {
        flex-direction: column;
        gap: 3px;
        padding: 7px 0 6px;
        border-radius: 26px;
        font-size: 0.68rem;
    }

    .tab svg {
        display: block;
        font-size: 22px;
    }

    .tab.is-active {
        background: color-mix(in srgb, var(--text) 7%, transparent);
    }

    .section-head-row .shots-nav {
        display: none;
    }

    .shots {
        --shot-w: 212px;
    }
}

@media (max-width: 640px) {
    .tile-focus,
    .tile-stats,
    .tile-widgets,
    .tile-themes {
        grid-column: span 12;
    }

    .tile-wide {
        grid-template-columns: 1fr;
        row-gap: 8px;
    }

    .tile-wide .tile-shot {
        justify-self: center;
        width: min(100%, 290px);
    }

    .tile-wide .tile-shot-ipad {
        width: min(100%, 340px);
    }

    .hero-device .device {
        --device-w: 290px;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }
}
