/* ==========================================================================
   UI Components: Matte Panels, 3D Globe, Navigation & Dialog Modal
   ========================================================================== */

/* 3D Globe Container — Centered symmetrically with layout */
#globeViz,
#globeViz * {
    pointer-events: none !important;
    user-select: none;
}

#globeViz {
    position: absolute;
    top: 0;
    right: max(0px, calc((100% - 80rem) / 2 - 5rem));
    width: min(60%, 54rem);
    height: 100dvh;
    z-index: 0;
}

@media (max-width: 1024px) {
    #globeViz {
        right: 0;
        width: 100%;
        height: 100dvh;
        opacity: 0.35;
    }
}

@media (max-width: 640px) {
    #globeViz {
        height: 70dvh;
        opacity: 0.22;
    }
}

/* Mobile Navigation Dropdown Menu */
#mobileMenu {
    transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

#mobileMenu.is-open {
    max-height: 320px;
    opacity: 1;
}

/* Touch Targets for Mobile Usability */
.touch-target {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Matte Surface Panels */
.matte-panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.matte-panel-interactive:hover {
    border-color: var(--border-hover);
    background-color: var(--bg-elevated);
}

/* Native <dialog> Modal */
dialog#downloadModal {
    background: transparent;
    border: none;
    padding: 0;
    max-width: 34rem;
    width: calc(100% - 2rem);
    max-height: 90dvh;
    color: var(--text-primary);
    margin: auto;
    overscroll-behavior: contain;
}

.modal-content-scroller {
    max-height: calc(90dvh - 2rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

dialog#downloadModal::backdrop {
    background: rgba(7, 8, 10, 0.82);
    backdrop-filter: blur(4px);
}

dialog#downloadModal[open] {
    animation: modal-fade-in 0.18s ease-out;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Form Controls & Real-time Validation */
.form-input {
    width: 100%;
    min-height: 44px;
    background-color: #0e1014;
    border: 1px solid var(--border-subtle);
    border-radius: 0.375rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.9375rem;
    color: var(--text-primary);
    transition: border-color 0.15s ease;
    outline: none;
}

@media (max-width: 640px) {
    .form-input {
        font-size: 16px; /* Prevents auto-zoom in mobile Safari */
    }
}

.form-input:focus {
    border-color: #525b6d;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.field-error-msg {
    display: none;
    font-size: 0.75rem;
    color: #e05252;
    margin-top: 0.35rem;
}

/* Interaction-driven validation (:user-invalid) */
.form-input:user-invalid,
.form-input.user-invalid-fallback {
    border-color: var(--status-error);
    background-color: rgba(200, 30, 30, 0.05);
}

.form-input:user-invalid + .field-error-msg,
.form-input.user-invalid-fallback + .field-error-msg {
    display: block;
}

.form-input:user-valid,
.form-input.user-valid-fallback {
    border-color: #2f4f3e;
}
