/* Vondi's Meal Finder - Crystal Aesthetic Design System */

:root {
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    --blur-amount: 20px;

    --primary: #c49d11;
    --primary: #c49d11;
    /* Vondi's Mustard Gold */
    --primary-dark: #a6840d;
    --text-dark: #2c3e50;
    --text-muted: #5d6d7e;
    --bg-fallback: #f8f4e6;

    /* Universal Safe Zones */
    --safe-top: 15px;
    --safe-bottom: 50px;
    /* Disclaimer + Gap */
    --safe-side: 15px;
    /* Symmetric Framing */

    /* Optical correction to lower center gravity */
    --optical-shift: 0px;
}

/* Mobile Overrides for Variables */
@media (max-width: 768px) {
    :root {
        --safe-top: 10px;
        --safe-bottom: 85px;
        /* Tightened Gap */
        --safe-side: 10px;
        /* Symmetric Framing */

        /* Mobile needs to push center down 20px */
        --optical-shift: 40px;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-fallback);
    color: var(--text-dark);
    line-height: 1.6;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    /* Prevent body scroll, cards handle internal overflow */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s ease;
}

body.results-mode {
    align-items: flex-start;
    overflow: hidden;
}

/* Background Wrapper: Handles Layout & Zoom */
#app-background-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-color: var(--bg-fallback);
    transition: transform 1.5s ease-out;
}

/* Background Layers: Handle Image & Opacity */
.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-image: linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05)),
        url('images/app-background.png');
    /* Default/Fallback */
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

/* Active Layer is Visible */
.bg-layer.active {
    opacity: 1;
}

/* Zoom Effect Applies to Wrapper Only */
body.results-mode #app-background-wrapper {
    transform: scale(1.05);
}

/* Main Container (Centered Viewport) with Safe Zones */
#vondis-app {
    width: 100%;
    height: 100dvh;
    /* Dynamic Height */
    display: flex;
    align-items: center;
    /* Vertically center small cards */
    justify-content: center;

    /* The Constraint Box */
    padding-top: calc(var(--safe-top) + var(--optical-shift));
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-side);
    padding-right: var(--safe-side);
    box-sizing: border-box;
}

/* --- THE CRYSTAL CARD --- */
.crystal-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 20px;
    width: 100%;
    max-width: 600px;

    /* Universal Layout Adaptation */
    max-height: 100%;
    /* Never exceed safe zone */
    height: auto;
    /* Shrink if content is small */

    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    animation: cardEntry 0.6s cubic-bezier(0.23, 1, 0.320, 1) both;
}

/* Wide view for results - DEPRECATED in favor of viewport-pane but keeping for compatibility until JS updated */
.crystal-card.results-wide {
    max-width: 1200px;
    width: 98%;
}

/* --- THE VIEWPORT PANE (Full Screen Results Layout) --- */
.viewport-pane {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 20px;
    width: 100%;
    /* Fill the padded safe zone */

    /* Universal Layout Adaptation */
    height: 100%;
    /* Fill the safe zone completely */
    margin: 0 auto;
    /* Centered horizontally, vertical handled by container */

    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cardEntry 0.6s cubic-bezier(0.23, 1, 0.320, 1) both;
}

.pane-header {
    padding: 10px 40px;
    background: rgba(255, 255, 255, 0.3);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.pane-header h2 {
    font-size: 1.4rem;
    color: var(--primary);
    margin: 0;
    font-style: italic;
}

.pane-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    padding-bottom: 140px;
    /* Space for fixed footer buttons + disclaimer */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.pane-content::-webkit-scrollbar {
    width: 8px;
}

.pane-content::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 10px;
}

.pane-footer {
    padding: 10px 40px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    z-index: 100;
}

@keyframes cardEntry {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-header {
    padding: 30px 40px 0;
    text-align: center;
}

.card-header h1,
.card-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Branding Integrations --- */
.landing-logo {
    height: 170px;
    width: auto;
    margin-bottom: 0;
    vertical-align: middle;
}

.card-content {
    padding: 20px 40px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
    text-align: center;
    /* Center text and blocks */
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center alignment for content */
}

.card-content::-webkit-scrollbar {
    width: 6px;
}

.card-content::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 10px;
}

.card-footer {
    padding: 20px 40px 20px;
    display: flex;
    gap: 15px;
    justify-content: center;
    /* Center buttons as a unit */
    flex-wrap: wrap;
    /* Safety for mobile */
    background: rgba(255, 255, 255, 0.2);
    border-top: 1px solid var(--glass-border);
}

/* --- BUTTONS --- */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    min-width: 140px;
    /* Symmetrical weight */
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(196, 157, 17, 0.3);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-dark);
    min-width: 140px;
    /* Symmetrical weight */
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
}

.btn-home {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 10px 15px;
}

/* --- LISTS & INPUTS --- */
.selection-list {
    list-style: none;
    width: 100%;
    max-width: 450px;
    /* Prevent labels from stretching too wide */
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.selection-item {
    margin-bottom: 12px;
    width: 100%;
}

.selection-item label {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
    min-height: 52px;
    /* Enhanced Touch Target */
}

/* --- STEP INDICATOR --- */
.step-indicator {
    font-size: 0.85rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    font-weight: 600;
    opacity: 0.8;
}

.selection-item label:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--primary);
}

.selection-item input[type="checkbox"],
.selection-item input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 15px;
    accent-color: var(--primary);
}

/* Intro Text */
.intro-para {
    margin-top: 20px;
    margin-bottom: 20px;
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 90%;
    /* Optical readability */
    margin-left: auto;
    margin-right: auto;
}

/* --- RESULTS GRID --- */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0;
}

/* Force 3 columns on large screens */
@media (min-width: 1100px) {
    .results-grid {
        grid-template-columns: repeat(3, 320px);
    }
}

.category-group {
    width: 100%;
    margin-bottom: 40px;
}

.category-header {
    font-size: 1.4rem;
    color: var(--primary);
    border-bottom: 2px solid var(--glass-border);
    padding-bottom: 10px;
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* --- PRODUCT CARD --- */
.product-card {
    position: relative;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    overflow: hidden;
    width: 100%;
    max-width: 320px;
    /* Rule of 3 on desktop-wide */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.product-link-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.82);
}

.product-img-frame {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #eee;
}

.product-img-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.product-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.product-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Forensic Audit Styling Integration */
.forensic-audit {
    background: rgba(0, 0, 0, 0.03) !important;
    border-radius: 10px;
    margin-bottom: 30px !important;
    padding: 20px !important;
    text-align: left;
}

/* --- MOBILE OPTIMIZATION (max-width: 768px) --- */
@media (max-width: 768px) {

    /* Stack the Header elements */
    .pane-header {
        flex-direction: column;
        text-align: center;
        padding: 15px;
        gap: 15px;
    }

    .pane-header h2 {
        font-size: 1.2rem;
        line-height: 1.4;
    }

    /* Center the nav buttons when stacked */
    .pane-header-nav {
        width: 100%;
        justify-content: center;
    }

    .viewport-pane {
        width: 98vw;
        /* Safe Zone handled by Container Padding now */
        height: 100%;
        margin: 0 auto;
    }

    .pane-content {
        padding: 15px;
        /* Recover internal space */
    }

    /* Scale down category titles */
    .category-header {
        font-size: 1.1rem;
        margin-bottom: 20px;
    }

    /* Force single column grid */
    .results-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Allow cards to fill the mobile width naturally */
    .product-card {
        max-width: 100%;
    }

    /* Stack footer buttons for easier tapping */
    .pane-footer {
        flex-direction: column;
        padding: 20px;
        gap: 15px;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* --- MOBILE FOOTER COMPACTION (2x2 Grid) --- */
@media (max-width: 768px) {
    .card-footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        padding: 15px;
    }

    .card-footer .btn {
        width: 100%;
        height: 100%;
        /* Match height of neighbour */
        margin: 0;
        min-width: auto;
        padding: 10px 5px;
        /* Tight side padding */
        font-size: 0.85rem;
        /* readable but small */
        white-space: normal;
        /* Allow text wrap */
        line-height: 1.2;
    }

    /* Slot 1: Back */
    .card-footer .btn:nth-child(1) {
        grid-row: 1;
        grid-column: 1 / 2;
    }

    /* Slot 2: Home */
    .card-footer .btn:nth-child(2) {
        grid-row: 1;
        grid-column: 2 / 3;
    }

    /* Slot 3: None (if present) */
    .card-footer .btn:nth-child(3) {
        grid-row: 2;
        grid-column: 1 / 2;
    }

    /* Slot 4: Continue (Last) */
    .card-footer .btn:last-child:not(:nth-child(1)):not(:nth-child(2)) {
        grid-row: 2;
        grid-column: 2 / 3;
    }

    /* Fix for Landing Page (Only 1 button) */
    .card-footer .btn:only-child {
        grid-row: 1;
        grid-column: 1 / -1;
    }
}

/* --- DISCLAIMER SYSTEM --- */

/* Persistent Footer */
/* Persistent Footer */
#disclaimer-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 8px 10px;
    z-index: 900;
    /* Above content, below modal */
    border-top: 1px solid var(--glass-border);
}

/* Modal Overlay */
#welcome-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

.modal-card {
    max-width: 500px;
    max-height: 80vh;
    /* Safety for small screens */
    width: 90%;
    /* Mobile safe */
    animation: cardEntry 0.4s ease-out;
}

.hidden {
    display: none !important;
}

/* Mobile Tweaks for Disclaimer */
@media (max-width: 768px) {
    #disclaimer-footer {
        font-size: 0.65rem;
        padding: 6px;
    }
}

/* --- RECOVERY ACTIONS (Zero Result) --- */
.recovery-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .recovery-actions {
        flex-direction: column;
        width: 100%;
    }

    .recovery-actions .btn {
        width: 100%;
        margin-bottom: 10px;
    }
}

/* --- MOBILE FOOTER REDESIGN (Side-by-Side) --- */
@media (max-width: 768px) {
    .pane-footer {
        flex-direction: row !important;
        align-items: stretch;
        /* Twin Tower Effect */
        gap: 10px;
        padding: 12px;
    }

    .pane-footer .btn {
        flex: 1;
        width: auto;
        min-width: 0;
        min-height: 50px;
        /* Taller target */
        height: auto;
        font-size: 0.8rem;
        padding: 0 5px;
        white-space: normal;
        text-align: center;
        line-height: 1.2;
    }
}

/* Clinical Exception Note (Trust Logic) */
.clinical-note {
    background: #fff9e6;
    /* Very light gold */
    border-left: 4px solid var(--primary);
    color: var(--text-dark);
    padding: 10px;
    margin-top: 10px;
    margin-bottom: 5px;
    font-size: 0.9em;
    border-radius: 4px;
    line-height: 1.4;
}

/* --- PROFILE SELECTOR (Life Stage) --- */
.profile-grid {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
    /* Mobile Safety */
    margin: 20px 0;
    width: 100%;
}

.profile-btn {
    /* STRICT RESET */
    background: transparent;
    border: none;
    padding: 0;
    appearance: none;
    /* Layout */
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
}

.profile-btn:hover {
    transform: scale(1.05);
    opacity: 1.0;
}

.profile-btn img {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 4px solid var(--primary);
    object-fit: cover;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
    background-color: #fff;
    /* Fallback for transparency */
    transition: border-color 0.3s ease;
}

.profile-btn:hover img {
    border-color: var(--primary-dark);
}

.profile-btn span {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 15px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}