/* ═══════════════════════════════════════════════════════════
   ORTEGON & ASOCIADOS — PREMIUM STYLES (CORREGIDO)
   ═══════════════════════════════════════════════════════════ */

/* ── BASE ── */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 6rem;
    /* IMPORTANTE: que el html pueda hacer scroll */
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    background-color: #050505;
    /* QUITAMOS overflow hidden - esto bloqueaba el scroll */
    overflow-x: hidden;
    overflow-y: auto;
    cursor: none;
    -webkit-tap-highlight-color: transparent;
}

body * { cursor: none; }

img {
    max-width: 100%;
    height: auto;
}

main {
    overflow-x: clip;
    /* Asegurar que main no bloquee scroll vertical */
    overflow-y: visible;
}

@media (max-width: 1023px) {
    body, body * { cursor: auto; }
}

/* ── SCROLLBAR ── */
* {
    scrollbar-width: thin;
    scrollbar-color: #C8A24E #050505;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #050505; }
::-webkit-scrollbar-thumb { background: #C8A24E; border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: #E2C36B; }

/* ── SELECTION ── */
::selection {
    background: rgba(200, 162, 78, 0.3);
    color: #fff;
}

/* ── FOCUS ── */
*:focus-visible {
    outline: 1px solid rgba(200, 162, 78, 0.5);
    outline-offset: 2px;
}

/* ══════════════════════════════════════
   LOADER - CORREGIDO (era el problema principal)
   ══════════════════════════════════════ */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at center, rgba(200, 162, 78, 0.05) 0%, transparent 35%),
        #050505;
    transition: opacity 0.7s ease, visibility 0.7s ease;
    /* Asegurar que empieza visible */
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* CUANDO SE CARGA - desaparece Y deja de bloquear */
#page-loader.loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* CLAVE: después de la animación, lo sacamos del flujo */
    z-index: -1;
}

@keyframes loaderLogoPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(200, 162, 78, 0.08));
    }
    50% {
        transform: scale(1.04);
        filter: drop-shadow(0 0 30px rgba(200, 162, 78, 0.2));
    }
}

@keyframes loaderHalo {
    0%, 100% {
        box-shadow:
            0 0 0 0 rgba(200, 162, 78, 0.05),
            0 0 40px rgba(200, 162, 78, 0.04) inset;
    }
    50% {
        box-shadow:
            0 0 0 18px rgba(200, 162, 78, 0),
            0 0 70px rgba(200, 162, 78, 0.08) inset;
    }
}

#page-loader .loader-logo {
    animation: loaderLogoPulse 2.5s ease-in-out infinite;
}

#page-loader .loader-mark {
    animation: loaderHalo 2.8s ease-in-out infinite;
}

/* ── PROGRESS BAR ── */
#progress-bar {
    will-change: width;
}

/* ── NAVBAR ── */
#navbar {
    background: transparent;
    /* Asegurar que navbar no bloquee clicks innecesariamente */
    pointer-events: auto;
}
#navbar.scrolled {
    background: rgba(5, 5, 5, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-bottom: 1px solid rgba(200, 162, 78, 0.05);
}

/* ── HERO LOGO PREMIUM ── */
@keyframes heroLogoFloat {
    0%, 100% {
        transform: translateY(0);
        filter: drop-shadow(0 0 12px rgba(200, 162, 78, 0.08));
    }
    50% {
        transform: translateY(-8px);
        filter: drop-shadow(0 0 32px rgba(200, 162, 78, 0.18));
    }
}

#inicio img[alt="Logo Ortegon y Asociados"] {
    animation: heroLogoFloat 6s ease-in-out infinite;
}

/* ── HAMBURGER ANIMATION ── */
#hamburger.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
#hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(10px);
}
#hamburger.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* ══════════════════════════════════════
   MOBILE MENU - CORREGIDO
   ══════════════════════════════════════ */
#mobile-menu {
    /* Empieza invisible y sin poder clickear */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    background: linear-gradient(180deg, rgba(5, 5, 5, 0.98) 0%, rgba(10, 10, 10, 0.99) 100%);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
}

#mobile-menu.active {
    opacity: 1;
    pointer-events: auto;
}

#mobile-menu.active .mobile-link {
    opacity: 1;
    transform: translateY(0);
}

.mobile-link {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease, color 0.3s ease;
}

.mobile-link:nth-child(1) { transition-delay: 0.1s; }
.mobile-link:nth-child(2) { transition-delay: 0.2s; }
.mobile-link:nth-child(3) { transition-delay: 0.3s; }
.mobile-link:nth-child(4) { transition-delay: 0.4s; }
.mobile-link:nth-child(5) { transition-delay: 0.5s; }

/* Mobile menu decorative elements */
#mobile-menu::before {
    content: '';
    position: absolute;
    top: 20%;
    left: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(200, 162, 78, 0.03) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

#mobile-menu::after {
    content: '';
    position: absolute;
    bottom: 10%;
    right: -10%;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(200, 162, 78, 0.02) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

#mobile-menu .mobile-link {
    position: relative;
    display: inline-block;
}

#mobile-menu .mobile-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #C8A24E, transparent);
    transition: width 0.5s ease;
}

#mobile-menu .mobile-link:hover::after {
    width: 100%;
}

/* ── HERO GRADIENT ── */
.hero-gradient {
    background: radial-gradient(ellipse 60% 50% at 50% 50%, rgba(200, 162, 78, 0.04) 0%, transparent 70%);
}

/* ── HERO TEXT REVEAL ── */
@keyframes textReveal {
    from { transform: translateY(110%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.hero-text-reveal {
    animation: textReveal 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.8s;
    opacity: 0;
}

/* ── HERO STAGGER ── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-stagger {
    animation: fadeUp 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hero-stagger:nth-child(1) { animation-delay: 0.5s; }
.hero-stagger:nth-child(2) { animation-delay: 0.3s; }
.hero-stagger:nth-child(3) { animation-delay: 1.4s; }
.hero-stagger:nth-child(4) { animation-delay: 1.7s; }
.hero-stagger:nth-child(5) { animation-delay: 2.2s; }

/* ── SCROLL INDICATOR ── */
@keyframes scrollLine {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(200%); }
}

.animate-scroll-line {
    animation: scrollLine 1.5s ease-in-out infinite;
}

/* ── FLOAT ANIMATIONS ── */
@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(15px, -20px); }
    66% { transform: translate(-10px, 15px); }
}

@keyframes floatDelayed {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(-20px, 15px); }
    66% { transform: translate(10px, -20px); }
}

.animate-float { animation: float 8s ease-in-out infinite; }
.animate-float-delayed { animation: floatDelayed 10s ease-in-out infinite; }

/* ── PARALLAX LINES ── */
@keyframes lineFlow {
    0% { opacity: 0; transform: translateY(-100%); }
    50% { opacity: 1; }
    100% { opacity: 0; transform: translateY(100%); }
}

.parallax-line {
    animation: lineFlow 6s ease-in-out infinite;
}

/* ── MARQUEE ── */
.marquee-container {
    overflow: hidden;
    white-space: nowrap;
}

.marquee-content {
    display: inline-flex;
    animation: marquee 30s linear infinite;
}

.marquee-item {
    color: rgba(200, 162, 78, 0.15);
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.25em;
    padding: 0 2rem;
}

.marquee-dot {
    color: rgba(200, 162, 78, 0.1);
    font-size: 0.5rem;
    display: inline-flex;
    align-items: center;
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ── SCROLL REVEAL ── */
.scroll-reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1),
                transform 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-reveal:nth-child(2) { transition-delay: 0.15s; }
.scroll-reveal:nth-child(3) { transition-delay: 0.3s; }
.scroll-reveal:nth-child(4) { transition-delay: 0.45s; }

/* ══════════════════════════════════════
   BOTONES FLOTANTES - CORREGIDO
   ══════════════════════════════════════ */
#btn-top {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#btn-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#btn-whatsapp {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#btn-whatsapp.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

@keyframes waPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.3); }
    50% { box-shadow: 0 0 0 15px rgba(37, 211, 102, 0); }
}

#btn-whatsapp.visible {
    animation: waPulse 2.5s ease-in-out infinite;
}

/* ── FORM ── */
input:focus, textarea:focus {
    box-shadow: 0 1px 0 0 rgba(200, 162, 78, 0.3);
}

/* ── MAGNETIC EFFECT ── */
.magnetic {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── TEAM / ABOGADOS ── */
@keyframes teamGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(200, 162, 78, 0); }
    50% { box-shadow: 0 0 30px rgba(200, 162, 78, 0.06); }
}

#nosotros .group:hover {
    animation: teamGlow 2.5s ease-in-out infinite;
}

#nosotros img[alt="Abogado de Ortegon y Asociados"] {
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), filter 0.8s ease;
    filter: saturate(0.95) contrast(1.02);
}

#nosotros .group:hover img[alt="Abogado de Ortegon y Asociados"] {
    filter: saturate(1.02) contrast(1.06);
}

/* ── PERFORMANCE ── */
.scroll-reveal,
#navbar,
#btn-top,
#btn-whatsapp,
#cursor,
#cursor-dot {
    will-change: transform, opacity;
}

/* ═══════════════════════════════════════════════════════════
   HEALTH / MEDICAL CARD
   ═══════════════════════════════════════════════════════════ */

@keyframes pingSlow {
    0% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.15); opacity: 0; }
    100% { transform: scale(1); opacity: 0.3; }
}

.animate-ping-slow {
    animation: pingSlow 3s ease-in-out infinite;
}

@keyframes ecgConstant {
    0% { stroke-dashoffset: 1600; }
    40% { stroke-dashoffset: 0; }
    60% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -1600; }
}

.ecg-line-constant {
    stroke-dasharray: 1600;
    stroke-dashoffset: 1600;
    animation: ecgConstant 4s ease-in-out infinite;
    opacity: 0.4;
}

@keyframes ecgScan {
    0% { left: -20%; }
    100% { left: 120%; }
}

.ecg-scanner {
    position: absolute;
    top: 0;
    width: 20%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(74, 144, 217, 0.3), transparent);
    animation: ecgScan 3s ease-in-out infinite;
}

@keyframes glowLine {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.health-glow-line {
    animation: glowLine 3s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════
   ECG HEARTBEAT
   ═══════════════════════════════════════════════════════════ */

@keyframes ecgHeartbeat {
    0% { stroke-dashoffset: 1000; }
    50% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -1000; }
}

.ecg-heartbeat {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: ecgHeartbeat 3s ease-in-out infinite;
}

@keyframes ecgGlow {
    0%, 100% { filter: drop-shadow(0 0 2px rgba(74, 144, 217, 0.3)); }
    50% { filter: drop-shadow(0 0 8px rgba(74, 144, 217, 0.6)); }
}

.ecg-container {
    animation: ecgGlow 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════
   SERVICE TABS
   ═══════════════════════════════════════════════════════════ */

.service-tab {
    color: #6B7280;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    /* ASEGURAR QUE SE PUEDE CLICKEAR */
    cursor: pointer;
    pointer-events: auto;
}

.service-tab::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(200, 162, 78, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.service-tab:hover {
    color: #C8A24E;
    border-color: rgba(200, 162, 78, 0.2);
}

.service-tab:hover::before {
    opacity: 1;
}

.service-tab.active {
    color: #000;
    background: #C8A24E;
    border-color: #C8A24E;
}

.service-tab.active::before {
    opacity: 0;
}

.service-tab.active svg {
    color: #000;
}

.service-tab[data-tab="medicos"].active {
    color: #000;
    background: #4A90D9;
    border-color: #4A90D9;
}

.service-tab[data-tab="medicos"]:not(.active):hover {
    color: #4A90D9;
    border-color: rgba(74, 144, 217, 0.3);
}

.service-tab[data-tab="medicos"]:not(.active):hover::before {
    background: linear-gradient(135deg, rgba(74, 144, 217, 0.1) 0%, transparent 100%);
}

.tab-indicator {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: #C8A24E;
    transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.service-tab:hover .tab-indicator {
    width: 60%;
}

.service-tab.active .tab-indicator {
    width: 0;
}

.service-tab[data-tab="medicos"] .tab-indicator {
    background: #4A90D9;
}

.service-panels-container {
    position: relative;
    min-height: 200px;
    transition: height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.service-panel {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(20px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.6s;
}

.service-panel.active {
    opacity: 1;
    visibility: visible;
    position: relative;
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════════
   TEAM CARDS
   ═══════════════════════════════════════════════════════════ */

#nosotros .group img {
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                filter 0.8s ease;
    filter: saturate(0.95) contrast(1.02);
}

#nosotros .group:hover img {
    filter: saturate(1.05) contrast(1.08);
}

/* ═══════════════════════════════════════════════════════════
   LEGAL HEALTH CHECK
   ═══════════════════════════════════════════════════════════ */

#legal-health-check .group {
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.5s ease;
}

#legal-health-check .group:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(200, 162, 78, 0.08);
}

/* ═══════════════════════════════════════════════════════════
   EXPANDABLE CARDS
   ═══════════════════════════════════════════════════════════ */

.card-expandable .card-content-hidden {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.4s ease,
                margin 0.4s ease;
    margin-top: 0;
}

.card-expandable.expanded .card-content-hidden {
    max-height: 500px;
    opacity: 1;
    margin-top: 0.75rem;
}

.card-expandable .btn-expand {
    transition: all 0.3s ease;
    cursor: pointer;
    pointer-events: auto;
}

.card-expandable .btn-expand svg {
    transition: transform 0.3s ease;
}

.card-expandable.expanded .btn-expand svg {
    transform: rotate(180deg);
}

.card-expandable .btn-expand:hover {
    color: #C8A24E;
}

@media (min-width: 640px) {
    .card-expandable .btn-expand {
        display: none;
    }

    .card-expandable .card-content-hidden {
        max-height: none;
        opacity: 1;
        margin-top: 0.75rem;
    }
}

/* ═══════════════════════════════════════════════════════════
   FORM IMPROVEMENTS
   ═══════════════════════════════════════════════════════════ */

#contact-form input:focus,
#contact-form textarea:focus {
    border-color: rgba(200, 162, 78, 0.5);
    box-shadow: 0 0 0 3px rgba(200, 162, 78, 0.1);
}

#contact-form input.error,
#contact-form textarea.error {
    border-color: rgba(239, 68, 68, 0.5);
}

#contact-form input.success,
#contact-form textarea.success {
    border-color: rgba(34, 197, 94, 0.5);
}

.form-error-message {
    color: #ef4444;
    font-size: 0.7rem;
    margin-top: 0.25rem;
    display: none;
}

.form-error-message.show {
    display: block;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 1023px) {
    .marquee-item {
        font-size: 0.75rem;
        padding: 0 1.25rem;
    }

    #mobile-menu {
        background: rgba(5, 5, 5, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    .mobile-link {
        font-size: 1.5rem;
        padding: 0.75rem 0;
    }
}

@media (max-width: 767px) {
    html {
        scroll-padding-top: 5rem;
    }

    .hero-gradient {
        background: radial-gradient(ellipse 75% 55% at 50% 35%, rgba(200, 162, 78, 0.05) 0%, transparent 75%);
    }

    .marquee-item {
        font-size: 0.66rem;
        padding: 0 1rem;
        letter-spacing: 0.18em;
    }

    .marquee-dot {
        font-size: 0.38rem;
    }

    #inicio img[alt="Logo Ortegon y Asociados"] {
        animation-duration: 5s;
        filter: drop-shadow(0 0 8px rgba(200, 162, 78, 0.1));
    }

    #btn-whatsapp,
    #btn-top {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    input,
    textarea,
    select {
        font-size: 16px !important;
    }

    #mobile-menu {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 639px) {
    .service-tab {
        width: 100%;
        justify-content: center;
        min-height: 56px;
        font-size: 0.75rem;
    }

    .service-tab span:not(.tab-indicator) {
        white-space: nowrap;
    }

    .service-panels-container {
        min-height: auto;
    }

    .service-panel {
        position: relative;
    }

    .service-panel:not(.active) {
        display: none;
    }

    #inicio {
        min-height: 100svh;
    }

    .mobile-link {
        font-size: 1.35rem;
    }

    .card-expandable {
        padding: 1rem !important;
    }

    .card-expandable h3 {
        font-size: 0.9rem;
    }
}

@media (max-width: 374px) {
    .mobile-link {
        font-size: 1.2rem;
    }
}

/* iOS Safari fix */
@supports (-webkit-touch-callout: none) {
    #inicio {
        min-height: -webkit-fill-available;
    }
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .scroll-reveal { opacity: 1; transform: none; }
    html { scroll-behavior: auto; }
    body, body * { cursor: auto; }
    #cursor, #cursor-dot { display: none !important; }
    .marquee-content { animation: none; }
}