/* ==========================================================================
   App Download Landing — /app
   Scope: every rule is prefixed with .app-download-page so it cannot leak
   into other pages even when registered globally.
   ========================================================================== */

.app-download-page {
    /* Page-scoped tokens — defaults equal current dark literals so dark mode
       remains pixel-identical. Light theme rebinds these at the bottom. */
    --app-bg: #0b162a;
    --app-text: #ffffff;
    --app-text-muted: rgba(255, 255, 255, 0.8);
    --app-card: rgba(255, 255, 255, 0.04);
    --app-line: rgba(255, 255, 255, 0.10);
    --app-mockup-fallback: #112240;
    --app-glow-teal: rgba(79, 209, 197, 0.15);
    --app-glow-violet: rgba(139, 92, 246, 0.15);

    color: rgba(255, 255, 255, 0.85);
    background: var(--app-bg);
}

/* ---------- Hero ---------- */
.app-download-page .hero {
    position: relative;
    padding: 120px 0 80px;
    background:
        radial-gradient(circle at 20% 20%, var(--app-glow-teal), transparent 55%),
        radial-gradient(circle at 80% 60%, var(--app-glow-violet), transparent 55%),
        var(--app-bg);
    overflow: hidden;
}

.app-download-page .hero-eyebrow {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #fce08b;
    background: rgba(252, 224, 139, 0.15);
    padding: 6px 14px;
    border-radius: 999px;
    margin-bottom: 18px;
}

.app-download-page .hero-title {
    font-size: clamp(2rem, 4vw, 3.25rem);
    font-weight: 800;
    line-height: 1.15;
    color: var(--app-text);
    margin-bottom: 16px;
}

.app-download-page .hero-tagline {
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    color: var(--app-text-muted);
    line-height: 1.55;
    max-width: 560px;
    margin-bottom: 32px;
}

/* ---------- iOS-style logo squircle ---------- */
.app-download-page .app-logo {
    width: 132px;
    height: 132px;
    border-radius: 22.37%;
    object-fit: cover;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    /* Fixed light chip surface so the squircle still reads as a tile
       even if the logo PNG fails to load — works in both themes. */
    background: #f1f3f8;
    display: block;
}

.app-download-page .hero-logo-row {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 28px;
}

.app-download-page .hero-logo-row .brand-name {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--app-text);
    letter-spacing: -0.01em;
}

.app-download-page .hero-logo-row .brand-tag {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

/* ---------- Download CTA buttons ---------- */
.app-download-page .download-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 28px;
}

.app-download-page .dl-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 14px 22px;
    border-radius: 14px;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
    min-width: 200px;
}

.app-download-page .dl-btn:hover:not(.is-disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(139, 92, 246, 0.4);
    background: linear-gradient(135deg, #4fd1c5 0%, #8b5cf6 100%);
    color: #fff;
    border-color: transparent;
}

.app-download-page .dl-btn.is-highlight {
    background: linear-gradient(135deg, #4d6cf3 0%, #021a42 100%);
}

.app-download-page .dl-btn.is-disabled,
.app-download-page button.dl-btn[disabled] {
    background: rgba(255, 255, 255, 0.02);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.85;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.app-download-page button.dl-btn { font: inherit; }

.app-download-page .dl-btn .dl-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.app-download-page .dl-btn .dl-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.app-download-page .dl-btn .dl-meta .dl-sub {
    font-size: 0.72rem;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.app-download-page .dl-btn .dl-meta .dl-main {
    font-size: 1rem;
    font-weight: 700;
}

/* ---------- QR block (desktop only by default) ---------- */
.app-download-page .qr-block {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    background: var(--app-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--app-line);
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.85rem;
    color: var(--app-text-muted);
}

.app-download-page .qr-block .qr-img {
    width: 84px;
    height: 84px;
    border-radius: 8px;
    /* Fixed light plate in BOTH themes: QR codes need a light surround so
       transparent PNG margins remain scannable. Intentionally not theme-aware. */
    background: #f1f3f8;
    object-fit: cover;
}

.app-download-page .qr-block.is-hidden {
    display: none;
}

/* ---------- Hero mockups (right column) ---------- */
.app-download-page .mockup-stack {
    position: relative;
    height: 540px;
    perspective: 1200px;
}

.app-download-page .mockup-frame {
    position: absolute;
    width: 240px;
    height: 500px;
    border-radius: 38px;
    background: transparent;
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.5),
        0 6px 14px rgba(0, 0, 0, 0.3);
    outline: 1px solid rgba(255, 255, 255, 0.15);
    outline-offset: -1px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    padding: 0;
}

.app-download-page .mockup-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.app-download-page .mockup-frame:not(:has(img)) {
    background: var(--app-mockup-fallback);
    padding: 16px;
}

.app-download-page .mockup-frame.m1 { left: 0;     top: 40px; transform: rotate(-6deg); z-index: 1; }
.app-download-page .mockup-frame.m2 { left: 140px; top: 0;    transform: rotate(0deg);  z-index: 3; }
.app-download-page .mockup-frame.m3 { left: 280px; top: 40px; transform: rotate(6deg);  z-index: 2; }

/* ---------- Generic section ---------- */
.app-download-page .section {
    padding: 72px 0;
}

.app-download-page .section-heading {
    font-size: clamp(1.6rem, 2.4vw, 2.2rem);
    font-weight: 800;
    color: var(--app-text);
    text-align: center;
    margin-bottom: 12px;
}

.app-download-page .section-sub {
    text-align: center;
    color: var(--app-text-muted);
    max-width: 640px;
    margin: 0 auto 44px;
}

/* ---------- Features (2 cards) ---------- */
.app-download-page .feature-card {
    height: 100%;
    background: var(--app-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--app-line);
    border-radius: 20px;
    padding: 32px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-download-page .feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

.app-download-page .feature-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    background: linear-gradient(135deg, #4d6cf3 0%, #021a42 100%);
    margin-bottom: 18px;
}

.app-download-page .feature-card.alt .feature-icon {
    background: linear-gradient(135deg, #ffb347 0%, #ff8a3d 100%);
}

.app-download-page .feature-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--app-text);
    margin-bottom: 8px;
}

.app-download-page .feature-desc {
    color: var(--app-text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
}

.app-download-page .feature-cta {
    color: #fce08b;
    font-weight: 600;
    text-decoration: none;
}

.app-download-page .feature-cta:hover { text-decoration: underline; }

/* ---------- Screenshots row ---------- */
.app-download-page .screenshot-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 36px;
    align-items: end;
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
}

.app-download-page .screenshot-row .screenshot-frame:nth-child(2) {
    transform: translateY(-24px);
}

.app-download-page .screenshot-frame {
    border-radius: 36px;
    background: transparent;
    overflow: hidden;
    aspect-ratio: 9 / 19.5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    text-align: center;
    padding: 0;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.4),
        0 6px 14px rgba(0, 0, 0, 0.2);
    outline: 1px solid rgba(255, 255, 255, 0.15);
    outline-offset: -1px;
}

.app-download-page .screenshot-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.app-download-page .screenshot-frame:not(:has(img)) {
    background: var(--app-mockup-fallback);
    padding: 16px;
}

/* ---------- Why FlipEarth ---------- */
.app-download-page .why-card {
    text-align: center;
    padding: 18px;
}

.app-download-page .why-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #4d6cf3;
    background: rgba(77, 108, 243, 0.10);
    margin-bottom: 14px;
    font-size: 1.3rem;
}

.app-download-page .why-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--app-text);
    margin-bottom: 6px;
}

.app-download-page .why-desc {
    font-size: 0.95rem;
    color: var(--app-text-muted);
    line-height: 1.55;
}

/* ---------- FAQ ---------- */
.app-download-page .faq-section {
    background: transparent;
}

.app-download-page .faq-list {
    max-width: 760px;
    margin: 0 auto;
}

.app-download-page .faq-item {
    background: var(--app-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--app-line);
    border-radius: 14px;
    margin-bottom: 12px;
    overflow: hidden;
}

.app-download-page .faq-q {
    width: 100%;
    background: transparent;
    border: 0;
    text-align: left;
    padding: 18px 22px;
    font-weight: 600;
    color: var(--app-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.app-download-page .faq-q[aria-expanded="true"] .faq-chevron {
    transform: rotate(180deg);
}

.app-download-page .faq-chevron {
    transition: transform 0.2s ease;
    color: rgba(255, 255, 255, 0.5);
}

.app-download-page .faq-a {
    padding: 0 22px 20px;
    color: var(--app-text-muted);
    line-height: 1.6;
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-download-page .hero { padding: 100px 0 60px; text-align: center; }
    .app-download-page .hero-tagline { margin-left: auto; margin-right: auto; }
    .app-download-page .download-row { justify-content: center; }
    .app-download-page .hero-logo-row { justify-content: center; }
    .app-download-page .mockup-stack { height: 480px; margin-top: 40px; transform: scale(0.8); transform-origin: top center; }
    .app-download-page .qr-block.is-hidden-mobile { display: none; }
}

@media (max-width: 767.98px) {
    .app-download-page .screenshot-row { grid-template-columns: 1fr; gap: 24px; max-width: 320px; margin: 0 auto; }
    .app-download-page .dl-btn { min-width: 0; flex: 1 1 100%; justify-content: center; }
}

/* ============================================================
   Light-theme overrides (Phase 2)
   Rebinds the .app-download-page palette and patches selectors
   that don't flow through a var. Dark-mode rules above are
   untouched; this block only fires when html[data-theme="light"].
   ============================================================ */

html[data-theme="light"] .app-download-page {
    --app-bg: #f7f9fc;
    --app-text: #0f172a;
    --app-text-muted: #475569;
    --app-card: rgba(15, 23, 42, 0.04);
    --app-line: rgba(15, 23, 42, 0.08);
    --app-mockup-fallback: #eef2f7;
    --app-glow-teal: rgba(20, 184, 166, 0.10);
    --app-glow-violet: rgba(139, 92, 246, 0.08);

    color: var(--app-text);
}

/* Body-text muted helpers that hard-code rgba(255,255,255,*) outside the
   tokenized set above — restate against the ink palette for legibility. */
html[data-theme="light"] .app-download-page .hero-logo-row .brand-tag,
html[data-theme="light"] .app-download-page .mockup-frame,
html[data-theme="light"] .app-download-page .screenshot-frame,
html[data-theme="light"] .app-download-page .faq-chevron {
    color: var(--app-text-muted);
}

/* dl-btn base chip is a glass surface in dark; on white it needs an ink-tinted
   surface (Apple/Google brand badges live on top via inline imagery and are
   unaffected). */
html[data-theme="light"] .app-download-page .dl-btn {
    background: var(--app-card);
    border-color: var(--app-line);
    color: var(--app-text);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

/* Disabled CTA: switch the white-on-white wash to an ink-tinted muted chip. */
html[data-theme="light"] .app-download-page .dl-btn.is-disabled,
html[data-theme="light"] .app-download-page button.dl-btn[disabled] {
    background: rgba(15, 23, 42, 0.04);
    color: rgba(15, 23, 42, 0.45);
    border-color: rgba(15, 23, 42, 0.06);
}

/* Re-tint the blue feature-icon gradient to the central teal accent so it
   doesn't read as a navy slab on white. The orange .alt gradient is left
   alone — warm chip works in both themes. */
html[data-theme="light"] .app-download-page .feature-icon {
    background: linear-gradient(135deg, var(--accent, #14b8a6) 0%, var(--accent-strong, #0f9488) 100%);
}

/* Accent text links (eyebrow + feature CTA) use a warm gold that fails AA on
   white — restate to the central accent palette. */
html[data-theme="light"] .app-download-page .hero-eyebrow {
    color: var(--accent-strong, #0f9488);
    background: var(--accent-soft, rgba(20, 184, 166, 0.12));
}

html[data-theme="light"] .app-download-page .feature-cta {
    color: var(--accent, #14b8a6);
}

/* Why-icon swatch: ink-blue tint reads weak on white; promote to the accent
   tone used elsewhere on the page. */
html[data-theme="light"] .app-download-page .why-icon {
    color: var(--accent, #14b8a6);
    background: rgba(20, 184, 166, 0.10);
}

/* Mockup / screenshot outlines: the white outline disappears on white bg. */
html[data-theme="light"] .app-download-page .mockup-frame,
html[data-theme="light"] .app-download-page .screenshot-frame {
    outline-color: rgba(15, 23, 42, 0.10);
    box-shadow:
        0 24px 48px rgba(15, 23, 42, 0.12),
        0 6px 14px rgba(15, 23, 42, 0.06);
}

/* Feature-card hover shadow is tuned for dark; soften for light. */
html[data-theme="light"] .app-download-page .feature-card:hover {
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.10);
}

/* dl-btn hover + highlight: dark base uses neon teal→violet / blue→navy
   gradients that read as muddy navy slabs on white. Retint to the central
   accent palette so the active states stay on-brand. */
html[data-theme="light"] .app-download-page .dl-btn:hover:not(.is-disabled) {
    background: linear-gradient(135deg, var(--accent, #14b8a6) 0%, #8b5cf6 100%);
    color: #ffffff;
    border-color: transparent;
}
html[data-theme="light"] .app-download-page .dl-btn.is-highlight {
    background: linear-gradient(135deg, var(--accent, #14b8a6) 0%, var(--accent-strong, #0f9488) 100%);
    color: #ffffff;
}
