/* HelioScript - Custom styles, glassmorphism, and animations */
/* Tailwind CDN handles utility classes; this file handles bespoke effects */

:root {
    --solar: #FFBF00;
    --solar-dim: rgba(255, 191, 0, 0.12);
    --solar-glow: rgba(255, 191, 0, 0.18);
    --slate-deep: #0F172A;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.07);
    --radius-card: 16px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--slate-deep);
    color: #F1F5F9;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Ambient dot-grid background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(rgba(255, 191, 0, 0.035) 1px, transparent 1px);
    background-size: 36px 36px;
    pointer-events: none;
    z-index: 0;
}

/* Ambient glow blobs */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 55% at 15% 5%, rgba(255, 191, 0, 0.07) 0%, transparent 70%),
        radial-gradient(ellipse 55% 45% at 85% 95%, rgba(255, 191, 0, 0.045) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* All page content must sit above background layers */
header, main, footer, section, nav, div.z-layer {
    position: relative;
    z-index: 1;
}

/* ================================================
   GLASSMORPHISM COMPONENTS
   ================================================ */

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-card);
}

.glass-strong {
    background: rgba(255, 255, 255, 0.065);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 20px;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.glass-card:hover {
    background: var(--glass-hover);
    border-color: rgba(255, 255, 255, 0.13);
    transform: translateY(-2px);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.28);
}

/* ================================================
   SOLAR AMBER UTILITIES
   ================================================ */

.text-solar { color: var(--solar); }
.bg-solar    { background-color: var(--solar); }
.border-solar { border-color: var(--solar); }

.gradient-text {
    background: linear-gradient(135deg, #FFBF00 0%, #FF9A00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-solar {
    box-shadow: 0 0 28px rgba(255, 191, 0, 0.22);
}

/* ================================================
   BUTTONS
   ================================================ */

.btn-primary {
    display: inline-flex;
    align-items: center;
    background: var(--solar);
    color: #0F172A;
    font-weight: 700;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

.btn-primary:hover {
    background: #E6AB00;
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(255, 191, 0, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    background: transparent;
    color: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    text-decoration: none;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.28);
    color: #fff;
}

.btn-danger-ghost {
    display: inline-flex;
    align-items: center;
    background: rgba(239, 68, 68, 0.08);
    color: #F87171;
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    text-decoration: none;
}

.btn-danger-ghost:hover {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(248, 113, 113, 0.35);
}

/* ================================================
   UPLOAD ZONE
   ================================================ */

.upload-zone {
    border: 2px dashed rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: border-color 0.3s ease, background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    user-select: none;
}

.upload-zone:hover {
    border-color: rgba(255, 191, 0, 0.38);
    background: rgba(255, 191, 0, 0.025);
}

.upload-zone.drag-over {
    border-color: var(--solar);
    background: rgba(255, 191, 0, 0.055);
    transform: scale(1.008);
    box-shadow: 0 0 0 4px rgba(255, 191, 0, 0.1), inset 0 0 60px rgba(255, 191, 0, 0.04);
}

.upload-zone.processing {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* ================================================
   SENSITIVITY BADGES
   ================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 11px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-normal {
    background: rgba(74, 222, 128, 0.1);
    color: #4ADE80;
    border: 1px solid rgba(74, 222, 128, 0.22);
}

.badge-reduced {
    background: rgba(251, 146, 60, 0.1);
    color: #FB923C;
    border: 1px solid rgba(251, 146, 60, 0.22);
}

.badge-impaired {
    background: rgba(248, 113, 113, 0.1);
    color: #F87171;
    border: 1px solid rgba(248, 113, 113, 0.22);
}

.badge-not-detected {
    background: rgba(148, 163, 184, 0.1);
    color: #94A3B8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

/* ================================================
   COFACTOR PRIORITY BADGES
   ================================================ */

.priority-high {
    background: rgba(248, 113, 113, 0.1);
    color: #F87171;
    border: 1px solid rgba(248, 113, 113, 0.22);
}

.priority-moderate {
    background: rgba(251, 146, 60, 0.1);
    color: #FB923C;
    border: 1px solid rgba(251, 146, 60, 0.22);
}

.priority-standard {
    background: rgba(74, 222, 128, 0.1);
    color: #4ADE80;
    border: 1px solid rgba(74, 222, 128, 0.22);
}

/* ================================================
   HEALTH GAUGE (SVG)
   r=76, circumference=477.52, 270deg arc=358.14
   ================================================ */

.gauge-track {
    stroke: rgba(255, 255, 255, 0.07);
    stroke-dasharray: 358.14 119.38;
    fill: none;
}

.gauge-progress {
    stroke: var(--solar);
    stroke-dasharray: 0 477.52;
    fill: none;
    transition: stroke 0.5s ease;
}

/* ================================================
   PROGRESS / COFACTOR BARS
   ================================================ */

.score-bar-track {
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 1.4s cubic-bezier(0.22, 1, 0.36, 1);
    width: 0;
}

/* ================================================
   TOGGLE SWITCH
   ================================================ */

.toggle-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.toggle-track {
    position: relative;
    width: 46px;
    height: 25px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 13px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    transition: background 0.3s ease, border-color 0.3s ease;
    flex-shrink: 0;
}

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 17px;
    height: 17px;
    background: #64748B;
    border-radius: 50%;
    transition: transform 0.3s ease, background 0.3s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.toggle-input:checked + .toggle-track {
    background: var(--solar);
    border-color: rgba(255, 191, 0, 0.5);
}

.toggle-input:checked + .toggle-track .toggle-thumb {
    transform: translateX(21px);
    background: #0F172A;
}

/* ================================================
   ANIMATIONS
   ================================================ */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(22px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes spinCW {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes pulseSolar {
    0%,100% { box-shadow: 0 0 0 0 rgba(255, 191, 0, 0.4); }
    50%      { box-shadow: 0 0 0 10px rgba(255, 191, 0, 0); }
}

@keyframes floatY {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

.anim-fade-in-up {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.anim-fade-in {
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
}

.anim-spin {
    animation: spinCW 0.9s linear infinite;
}

.anim-float {
    animation: floatY 3.5s ease-in-out infinite;
}

/* Staggered delays for card grids */
.delay-1 { animation-delay: 0.08s; }
.delay-2 { animation-delay: 0.16s; }
.delay-3 { animation-delay: 0.24s; }
.delay-4 { animation-delay: 0.32s; }
.delay-5 { animation-delay: 0.40s; }
.delay-6 { animation-delay: 0.48s; }

/* ================================================
   TOAST NOTIFICATIONS
   ================================================ */

.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 9999;
    animation: fadeInUp 0.3s ease forwards;
    max-width: 360px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    line-height: 1.4;
}

.toast-success {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(74, 222, 128, 0.28);
    color: #4ADE80;
}

.toast-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.28);
    color: #F87171;
}

.toast-info {
    background: rgba(255, 191, 0, 0.1);
    border: 1px solid rgba(255, 191, 0, 0.28);
    color: var(--solar);
}

/* ================================================
   DATA VOLATILITY PROTOCOL BADGE
   ================================================ */

.dvp-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 16px;
    border: 1px solid transparent;
    margin-bottom: 28px;
}

.dvp-badge--verified {
    background: rgba(74, 222, 128, 0.07);
    border-color: rgba(74, 222, 128, 0.22);
}

.dvp-badge--local {
    background: rgba(74, 222, 128, 0.05);
    border-color: rgba(74, 222, 128, 0.16);
}

.dvp-badge--warning {
    background: rgba(251, 191, 36, 0.07);
    border-color: rgba(251, 191, 36, 0.22);
}

/* ================================================
   DIVIDER
   ================================================ */

.divider {
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.07), transparent);
    border: none;
}

/* ================================================
   SCROLLBAR
   ================================================ */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.02); }
::-webkit-scrollbar-thumb { background: rgba(255, 191, 0, 0.32); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 191, 0, 0.52); }

/* ================================================
   FEATURE ICON WRAPPERS
   ================================================ */

.icon-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--solar-dim);
    border: 1px solid rgba(255, 191, 0, 0.18);
    color: var(--solar);
}

/* ================================================
   STEP CONNECTORS (How It Works)
   ================================================ */

.step-connector {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, rgba(255, 191, 0, 0.25), rgba(255, 191, 0, 0.05));
}

/* ================================================
   DISCLAIMER BOX
   ================================================ */

.disclaimer {
    background: rgba(248, 113, 113, 0.06);
    border: 1px solid rgba(248, 113, 113, 0.18);
    border-radius: 12px;
    padding: 16px 20px;
    font-size: 0.8rem;
    color: #94A3B8;
    line-height: 1.6;
}

.disclaimer strong {
    color: #F87171;
    font-weight: 600;
}

/* ================================================
   PRINT / PDF EXPORT OVERRIDES

   Triggered by the Export PDF button (window.print()). The browser
   renders the live DOM with these rules, producing a clean white-on-
   white PDF with selectable text and native page breaks.

   Strategy: force colour-scheme to light, then explicitly reset every
   dark background source (body class, glass vars, Tailwind utilities,
   pseudo-elements). Selectively restore amber/colour only where needed.
   ================================================ */

@media print {
    @page {
        size: A4 portrait;
        margin: 16mm 14mm 18mm 14mm;

        @bottom-right {
            content: "Page " counter(page);
            font-family: 'Inter', system-ui, sans-serif;
            font-size: 8pt;
            color: #64748B;
        }
    }

    /* ── 1. Force light colour scheme at root level ── */
    :root {
        color-scheme: light !important;
    }

    /* ── 2. White page, dark text, exact colour rendering ── */
    html, body {
        background: #ffffff !important;
        background-color: #ffffff !important;
        color: #0F172A !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* ── 3. Kill decorative fixed-position layers ── */
    body::before,
    body::after {
        display: none !important;
    }

    /* ── 4. Wipe dark backgrounds on ALL Tailwind bg-slate-* / bg-zinc-* /
              bg-gray-* classes and every custom glass variant ── */
    [class*="bg-slate-"],
    [class*="bg-zinc-"],
    [class*="bg-gray-"],
    .glass,
    .glass-card,
    .glass-strong {
        background: #ffffff !important;
        background-color: #ffffff !important;
        background-image: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        box-shadow: none !important;
    }

    /* ── 5. Card styling: clean white panel with a visible border ── */
    .glass,
    .glass-card,
    .glass-strong {
        border: 1.5px solid #94A3B8 !important;
        border-radius: 10px !important;
        padding: 16px 18px !important;
        margin-bottom: 14px !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* ── 6. Hide all chrome / page furniture ── */
    nav, footer, #upload-section, #hero, #features, #how-it-works,
    #loading-overlay, #toast, #consent-card, #unlock-card,
    #save-now-banner, #security-badge, #new-analysis-btn,
    #export-pdf-btn,
    .no-print, .hs-preview-only {
        display: none !important;
    }

    /* ── 6b. Toast is dynamically created with class .toast (no #id) ── */
    .toast { display: none !important; }

    /* ── 7. Force results section + pdf content visible ── */
    #results-section { display: block !important; padding: 0 !important; }
    #pdf-content     { display: block !important; }

    /* ── 8. Force technical-detail expander fully open ── */
    details#technical-detail              { display: block !important; }
    details#technical-detail > summary    { display: none !important; }
    details#technical-detail[open] > div,
    details#technical-detail        > div { display: block !important; }

    /* ── 9. Text colour overrides — bumped dark for print legibility ── */
    .text-white                 { color: #0F172A !important; }
    h1, h2, h3, h4, h5, h6     { color: #0F172A !important; }
    p, li, span                 { color: inherit; }
    .text-slate-200             { color: #0F172A !important; }
    .text-slate-300             { color: #1E293B !important; }
    .text-slate-400             { color: #1E293B !important; }
    .text-slate-500             { color: #334155 !important; }
    .text-slate-600             { color: #475569 !important; }
    .text-amber-200,
    .text-amber-400             { color: #92400E !important; }
    /* Mono / code text */
    .font-mono                  { color: #334155 !important; }

    /* ── 10. Solar / gradient accent text → deep amber on white ── */
    .gradient-text,
    .text-solar {
        -webkit-text-fill-color: #B38700 !important;
        background: none !important;
        color: #B38700 !important;
    }

    /* ── 11. Beat medallions: amber fill, dark digit ── */
    [style*="background:#FFBF00"],
    [style*="background: #FFBF00"] {
        background: #FFBF00 !important;
        background-color: #FFBF00 !important;
        color: #0F172A !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* ── 12. Per-locus call badges keep their inline rgba colours ── */
    #snp-results [style*="background"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* ── 13. SNP name chip: was bg-white/8 (near-invisible on white) ── */
    #snp-results span[class*="bg-white"] {
        background: #F1F5F9 !important;
        background-color: #F1F5F9 !important;
        color: #0F172A !important;
        border: 1px solid #CBD5E1 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* ── 14. Locus grid → single column for print readability ── */
    #snp-results {
        display: block !important;
        grid-template-columns: none !important;
    }
    #snp-results > div {
        margin-bottom: 10px !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* ── 15. Disclaimer: light amber callout ── */
    .disclaimer {
        background: #FFF7ED !important;
        background-color: #FFF7ED !important;
        border: 1px solid #FED7AA !important;
        color: #78350F !important;
        padding: 12px 16px !important;
        border-radius: 8px !important;
        page-break-inside: avoid;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* ── 16. Page-break hints: keep heading + body together ── */
    #parse-summary-card,
    #beat1-card,
    #beat2-card,
    #beat3-card,
    .disclaimer,
    #technical-detail {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* ── 17. Hide outbound links and divider decorations ── */
    #beat3-card a { display: none !important; }
    .divider { background: #E2E8F0 !important; background-color: #E2E8F0 !important; }

    /* ── 18. No URL expansion after links ── */
    a[href]:after { content: "" !important; }

    /* ── 19. SVG icons: neutral dark stroke ── */
    svg { color: #475569 !important; }

    /* ── 19b. PDF header: larger logo, visible subtitle, prominent wordmark ── */
    #pdf-content > .glass:first-child {
        border-bottom: 2px solid #FFBF00 !important;
        padding: 14px 18px !important;
        margin-bottom: 18px !important;
    }
    #pdf-content > .glass:first-child svg {
        width: 34px !important;
        height: 34px !important;
    }
    #pdf-content > .glass:first-child .font-extrabold {
        font-size: 1.2rem !important;
        letter-spacing: -0.02em !important;
    }
    /* Show the hidden | separator and subtitle in print */
    #pdf-content > .glass:first-child .hidden {
        display: inline !important;
    }
    /* Subtitle text colour */
    #pdf-content > .glass:first-child span.text-slate-400 {
        color: #475569 !important;
        font-size: 0.75rem !important;
    }

    /* ── 20. Suppress animations / transitions ── */
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }

    /* ── 21. Animation classes start at opacity:0 — force visible in print ── */
    .anim-fade-in,
    .anim-fade-in-up {
        opacity: 1 !important;
        transform: none !important;
    }

    /* ── 22. Print footer: fixed bar on every page with clickable URL ── */
    #pdf-footer {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 5px 14mm;
        align-items: center;
        justify-content: space-between;
        background: #ffffff;
        border-top: 1px solid #CBD5E1;
        font-size: 8pt;
        color: #94A3B8;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    #pdf-footer a {
        color: #B38700 !important;
        text-decoration: none !important;
        font-weight: 600 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Bottom padding so content doesn't slide under the fixed footer */
    #pdf-content {
        padding-bottom: 14mm !important;
    }
}
