/* 
  Perco-Frank Digital Instrument 
  Preset A - CSS System Design
*/

:root {
    --color-paper: #E8E4DD;
    --color-red-perco: #9c031c;
    --color-off-white: #F5F3EE;
    --color-black: #111111;
    --font-main: 'Inter', sans-serif;
    --radius-pill: 100px;
    --radius-large: 2.5rem;
    --transition-smooth: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--color-paper);
    color: var(--color-black);
    font-family: var(--font-main);
    overflow-x: hidden;
    line-height: 1.6;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-main);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -0.02em;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- Layout Components --- */

/* Header: Fixed but with its own space */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 7rem;
    background: #ffffff;
    /* Solid white to match logo */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: var(--transition-smooth);
    padding: 0 5%;
}

.header-pill {
    width: 100%;
    max-width: 1200px;
    height: 4.5rem;
    background: #ffffff;
    /* Consistent white background */
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border: 1px solid rgba(17, 17, 17, 0.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    transition: var(--transition-smooth);
}

header.scrolled {
    height: 5rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
}

header.scrolled .header-pill {
    height: 3.5rem;
    background: #ffffff;
}

/* Adjust main content starting position */
main {
    padding-top: 0;
}

/* Hero overlaps behind the fixed header */
.hero {
    margin-top: 0;
}

.logo img {
    height: 2.5rem;
    transition: var(--transition-smooth);
}

nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
}

nav a {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    position: relative;
    padding: 0.5rem 0;
}

nav a.active::after,
nav a:focus-visible::after {
    width: 100%;
}

nav a:focus-visible {
    outline: none;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-red-perco);
    transition: var(--transition-smooth);
}

nav a:hover::after {
    width: 100%;
}

.email-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    background: var(--color-black);
    color: var(--color-off-white);
    border-radius: 50%;
    transition: var(--transition-smooth);
}

.email-icon:hover {
    transform: scale(1.05);
    background: var(--color-red-perco);
}

/* Mobile nav hidden on desktop */
.mobile-nav {
    display: none;
}

/* Sections */
section {
    padding: 6rem 5%;
    position: relative;
}

.hero {
    height: 70dvh;
    padding: 0;
    margin-top: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding-top: 7rem;
    padding-bottom: 7rem;
}

.hero-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(17, 17, 17, 0.4), rgba(17, 17, 17, 0.9));
}

.hero-content {
    position: relative;
    text-align: center;
    color: var(--color-off-white);
    max-width: 900px;
    margin: 0 auto;
}

.hero-content h1 {
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.hero-content .italic-serif {
    font-family: serif;
    font-style: italic;
    text-transform: lowercase;
    display: block;
    font-weight: 400;
    font-size: 0.6em;
    margin-top: 0.4em;
}

/* Cards & UI Elements */
.card {
    background: var(--color-off-white);
    border-radius: 0;
    padding: 2.5rem;
    overflow: hidden;
    transition: var(--transition-smooth);
    text-align: center;
    min-height: 420px;
    border: 1px solid rgba(17, 17, 17, 0.06);
}

a.card,
.card[onclick] {
    cursor: pointer;
}

a.card:hover,
.card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 48px rgba(17, 17, 17, 0.1);
    border-color: rgba(17, 17, 17, 0.12);
}

a.card:focus-visible {
    outline: 3px solid var(--color-red-perco);
    outline-offset: 2px;
}

.service-item .card {
    background: transparent;
    padding: 0;
    min-height: auto;
    max-width: 100%;
}

.magnetic-btn {
    display: inline-block;
    padding: 1rem 2.5rem;
    background: var(--color-red-perco);
    color: var(--color-off-white);
    border-radius: var(--radius-pill);
    font-weight: 700;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
    border: none;
    cursor: pointer;
}

.magnetic-btn span {
    position: relative;
    z-index: 2;
}

.magnetic-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: #7a0215;
    transition: var(--transition-smooth);
    z-index: 1;
}

.magnetic-btn:hover::before {
    left: 0;
}

.magnetic-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 24px rgba(156, 3, 28, 0.4);
}

.magnetic-btn:focus-visible {
    outline: 3px solid var(--color-red-perco);
    outline-offset: 3px;
}

/* Protocol / Feature sections */
.protocol-stack {
    position: relative;
    height: auto;
}

/* Footer: Deep dark, rounded-t */
footer {
    background: #0a0a0a;
    color: var(--color-off-white);
    padding: 6rem 5% 2rem;
    border-radius: 0;
    margin-top: 4rem;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(245, 243, 238, 0.1);
}

.os-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(245, 243, 238, 0.5);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 10px #4ade80;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(1.2);
    }

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

/* =========================================================
   COOKIE CONSENT BANNER
   ========================================================= */

.cookie-overlay { display: none; }

.cookie-modal {
    position: fixed;
    bottom: 8rem;
    right: 1.5rem;
    transform: translateY(12px) scale(.97);
    width: min(400px, calc(100vw - 2rem));
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 8px 48px rgba(17,17,17,.18);
    z-index: 9999;
    opacity: 0;
    transition: opacity .3s ease, transform .3s ease;
    pointer-events: none;
    overflow: hidden;
}
.cookie-modal.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.cookie-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 0;
}
.cookie-modal-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-black);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.cookie-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: rgba(17,17,17,0.5);
    font-size: 1.1rem;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.cookie-close:hover { background: rgba(17,17,17,0.06); color: var(--color-black); }

.cookie-modal-body {
    padding: 1rem 1.5rem 1.25rem;
}
.cookie-modal-body p {
    font-size: .88rem;
    color: rgba(17,17,17,0.7);
    line-height: 1.6;
}
.cookie-modal-body a {
    color: var(--color-red-perco);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.cookie-modal-body a:hover { color: #7a0215; }

.cookie-modal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    padding: 0 1.5rem 1.5rem;
}
.cookie-btn {
    flex: 1 1 auto;
    min-width: 110px;
    padding: .65rem 1rem;
    border-radius: var(--radius-pill);
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    border: 1.5px solid transparent;
}
.cookie-btn-accept {
    background: var(--color-red-perco);
    color: #ffffff;
    border-color: var(--color-red-perco);
}
.cookie-btn-accept:hover {
    background: #7a0215;
    border-color: #7a0215;
    box-shadow: 0 2px 12px rgba(156,3,28,.35);
}
.cookie-btn-deny {
    background: #ffffff;
    color: var(--color-black);
    border-color: rgba(17,17,17,0.15);
}
.cookie-btn-deny:hover {
    border-color: rgba(17,17,17,0.35);
    background: rgba(17,17,17,0.04);
}
.cookie-btn-prefs {
    background: #ffffff;
    color: var(--color-black);
    border-color: rgba(17,17,17,0.15);
}
.cookie-btn-prefs:hover {
    border-color: rgba(17,17,17,0.35);
    background: rgba(17,17,17,0.04);
}

/* Preferences panel */
.cookie-category {
    border: 1px solid rgba(17,17,17,0.1);
    border-radius: 0.5rem;
    margin-bottom: .65rem;
    overflow: hidden;
}
.cookie-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1rem;
    background: var(--color-off-white);
    cursor: pointer;
    gap: .75rem;
}
.cookie-category-header:hover { background: rgba(17,17,17,0.05); }
.cookie-category-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-black);
    flex: 1;
}
.cookie-required-badge {
    font-size: .7rem;
    font-weight: 500;
    color: rgba(17,17,17,0.5);
    background: rgba(17,17,17,0.1);
    padding: .15rem .5rem;
    border-radius: 99px;
    text-transform: none;
}
.cookie-category-desc {
    font-size: .82rem;
    color: rgba(17,17,17,0.65);
    padding: .65rem 1rem;
    border-top: 1px solid rgba(17,17,17,0.08);
    background: #ffffff;
    display: none;
}
.cookie-category.expanded .cookie-category-desc { display: block; }
.cookie-category-toggle-icon {
    font-size: .75rem;
    color: rgba(17,17,17,0.4);
    transition: transform .2s ease;
    flex-shrink: 0;
}
.cookie-category.expanded .cookie-category-toggle-icon { transform: rotate(180deg); }

/* Toggle switch */
.cookie-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.cookie-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.cookie-toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(17,17,17,0.15);
    border-radius: 99px;
    transition: background .2s ease;
    cursor: pointer;
}
.cookie-toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform .2s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.cookie-toggle input:checked + .cookie-toggle-slider { background: var(--color-red-perco); }
.cookie-toggle input:checked + .cookie-toggle-slider::before { transform: translateX(18px); }
.cookie-toggle input:disabled + .cookie-toggle-slider { background: #ccc; cursor: not-allowed; }
.cookie-toggle input:disabled + .cookie-toggle-slider::before { transform: translateX(18px); }
.cookie-toggle input:focus-visible + .cookie-toggle-slider {
    outline: 2px solid var(--color-red-perco);
    outline-offset: 2px;
}

.cookie-prefs-footer {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    padding: 0 1.5rem 1.5rem;
}

/* Floating re-open button */
.cookie-manage-btn {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    z-index: 9990;
    background: #ffffff;
    border: 1.5px solid rgba(17,17,17,0.12);
    border-radius: var(--radius-pill);
    padding: .5rem .85rem;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(17,17,17,0.6);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(17,17,17,0.08);
    display: flex;
    align-items: center;
    gap: .4rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.cookie-manage-btn.visible { opacity: 1; pointer-events: auto; }
.cookie-manage-btn:hover {
    border-color: var(--color-red-perco);
    color: var(--color-red-perco);
    box-shadow: 0 8px 32px rgba(17,17,17,0.14);
}

@media (max-width: 520px) {
    .cookie-modal {
        right: .75rem;
        left: .75rem;
        width: auto;
        bottom: 4rem;
    }
    .cookie-modal-footer,
    .cookie-prefs-footer { flex-direction: column; }
    .cookie-btn { min-width: 100%; text-align: center; }
}

/* Stats trust strip */
.stats-strip {
    padding: 4rem 5%;
    background: var(--color-black);
    color: var(--color-off-white);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 2rem;
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.stat-number {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 900;
    font-family: var(--font-main);
    color: var(--color-off-white);
    line-height: 1;
    letter-spacing: -0.03em;
}

.stat-accent {
    color: var(--color-red-perco);
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.6;
}

/* Focus visible global */
:focus-visible {
    outline: 3px solid var(--color-red-perco);
    outline-offset: 3px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0 1rem;
    }

    nav {
        display: none;
    }

    .hamburger {
        display: flex;
        flex-direction: column;
        gap: 5px;
        cursor: pointer;
        z-index: 1100;
        width: 30px;
        padding: 10px;
        box-sizing: content-box;
    }

    .hamburger span {
        display: block;
        width: 30px;
        height: 2px;
        background: var(--color-black);
        transition: var(--transition-smooth);
        transform-origin: center;
    }

    /* Hamburger Animation */
    .header-pill.menu-open .hamburger span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .header-pill.menu-open .hamburger span:nth-child(2) {
        opacity: 0;
    }

    .header-pill.menu-open .hamburger span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* Mobile Nav Overlay */
    .mobile-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100dvh;
        background: var(--color-off-white);
        z-index: 1050;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        clip-path: circle(0% at 90% 5%);
        transition: clip-path 0.8s cubic-bezier(0.77, 0, 0.175, 1);
        pointer-events: none;
    }

    .mobile-nav.active {
        clip-path: circle(150% at 90% 5%);
        pointer-events: all;
    }

    .mobile-nav-close {
        position: absolute;
        top: 1.5rem;
        right: 1.5rem;
        background: none;
        border: none;
        cursor: pointer;
        font-size: 2rem;
        line-height: 1;
        color: var(--color-black);
        padding: 0.5rem;
        transition: var(--transition-smooth);
    }

    .mobile-nav-close:hover {
        color: var(--color-red-perco);
        transform: scale(1.1);
    }

    .mobile-nav ul {
        list-style: none;
        text-align: center;
    }

    .mobile-nav li {
        margin: 1.5rem 0;
        opacity: 0;
        transform: translateY(20px);
        transition: all 0.4s ease;
    }

    .mobile-nav.active li {
        opacity: 1;
        transform: translateY(0);
    }

    .mobile-nav.active li:nth-child(1) {
        transition-delay: 0.2s;
    }

    .mobile-nav.active li:nth-child(2) {
        transition-delay: 0.3s;
    }

    .mobile-nav.active li:nth-child(3) {
        transition-delay: 0.4s;
    }

    .mobile-nav.active li:nth-child(4) {
        transition-delay: 0.5s;
    }

    .mobile-nav a {
        font-size: 2.5rem;
        font-weight: 900;
        text-transform: uppercase;
        color: var(--color-black);
    }

    .mobile-nav a:hover {
        color: var(--color-red-perco);
    }

    /* Hero responsive */
    .hero {
        padding-top: 7rem;
        padding-bottom: 1.5rem;
    }

    .hero-content {
        padding: 0 1.5rem;
    }

    .hero-content h1 {
        font-size: clamp(2rem, 8vw, 2.8rem);
        margin-bottom: 0.8rem;
        line-height: 1.2;
    }

    .hero-content .italic-serif {
        font-size: 0.7em;
        margin-top: 0.3em;
    }

    /* Servicios responsive */
    .service-item {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        text-align: center;
    }

    .service-item h2 {
        font-size: 2rem !important;
        margin-bottom: 1.5rem !important;
    }

    .service-item p {
        font-size: 1rem !important;
    }

    .service-item .card {
        max-width: 400px;
        margin: 0 auto;
    }

    /* Contacto responsive */
    #contacto h2 {
        font-size: 2.5rem !important;
    }

    #contacto p {
        font-size: 1rem !important;
    }
}