/* ==========================================================================
   Estilos generales de vista de página (Layout General)
   ========================================================================== */

/* Fuentes propias: el sitio no llama a Google Fonts */
@font-face {
    font-family: 'Arimo';
    src: url('/assets/fonts/arimo-latin-400-normal.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Arimo';
    src: url('/assets/fonts/arimo-latin-700-normal.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Oswald';
    src: url('/assets/fonts/oswald-latin-500-normal.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Oswald';
    src: url('/assets/fonts/oswald-latin-600-normal.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Oswald';
    src: url('/assets/fonts/oswald-latin-700-normal.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Fuente de títulos, declarada una sola vez para todas las páginas */
@font-face {
    font-family: 'MiFuentePersonalizada';
    src: url('/assets/fonts/extension-regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Arimo', Arial, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-page);
}

img {
    max-width: 100%;
}

/* Header siempre presente (las reglas de ocultar/compactar están en header.css).
   Solo el del sitio: el <header class="h-head"> de la hoja Harvard no debe quedarse pegado. */
header[data-layout="header"] {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    min-height: 60px;
    flex-shrink: 0;
}

/* Espacio reservado para el contenido principal (Main / Body del layout) */
main,
.main {
    flex: 1 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Espacio reservado para Footer */
footer,
footer[data-layout="footer"] {
    width: 100%;
    min-height: 120px;
    flex-shrink: 0;
    margin-top: auto;
}

/* Botones/enlaces de acción compartidos */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 22px;
    border: 1px solid rgba(243, 244, 246, 0.35);
    border-radius: 999px;
    color: var(--text-primary);
    background: transparent;
    font-family: 'Arimo', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.btn:hover,
.btn:focus-visible {
    color: var(--brand-accent);
    border-color: var(--brand-accent);
}

.btn-primary {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
    color: var(--bg-page);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background-color: transparent;
}

.reveal-ready .scroll-reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.65s ease, transform 0.65s ease;
}

.reveal-ready .scroll-reveal[data-reveal-direction="up"] {
    transform: translateY(-24px);
}

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

@media (prefers-reduced-motion: reduce) {
    .reveal-ready .scroll-reveal,
    .reveal-ready .scroll-reveal[data-reveal-direction="up"],
    .reveal-ready .scroll-reveal.is-visible {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .btn {
        transition: none;
    }
}

@media (max-width: 768px) {
    footer,
    footer[data-layout="footer"] {
        min-height: 100px;
    }
}

/* ==========================================================================
   Accesibilidad: saltar al contenido
   ========================================================================== */
.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 200;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--brand-accent);
    color: var(--bg-page);
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus {
    top: 12px;
}

/* ==========================================================================
   Skeletons
   - Todo contenedor de medios tiene aspect-ratio fijo: el skeleton ocupa
     exactamente el lugar final y no hay saltos de layout.
   - .skel = contenedor que muestra el brillo hasta que su <img>/<iframe>
     carga (layout.js agrega .is-loaded o .is-error).
   ========================================================================== */
:root {
    --skel-base: #1A2333;
    --skel-shine: #253147;

    /* Tokens de diseño (los usan el cotizador y el botón flotante) */
    --bg-page: #0D0E15;
    --bg-surface: #1D2D44;
    --text-primary: #F3F4F6;
    --text-secondary: #D1D5DB;
    --text-muted: #9CA3AF;
    --text-on-accent: #0D0E15;
    --brand-accent: #10B981;
    --brand-accent-soft: #A7F3D0;
    --brand-accent-tint: rgba(16, 185, 129, 0.1);
    --border-subtle: rgba(243, 244, 246, 0.16);
    --border-card: rgba(255, 255, 255, 0.14);
    --font-body: 'Arimo', Arial, sans-serif;
    --font-heading: 'Oswald', sans-serif;
    --font-display: 'MiFuentePersonalizada', 'Oswald', sans-serif;

    /* Tracking de títulos: H1 en la fuente display, H2 en Oswald */
    --tracking-display: 1px;
    --tracking-heading: 2px;

    /* Radios: botones en píldora; tarjetas, medios y etiquetas con radio propio */
    --radius-card: 16px;
    --radius-inner: 12px;
    --radius-chip: 8px;

    /* Superficie de tarjeta: plana, sin degradado */
    --surface-card: rgba(29, 45, 68, 0.45);
}

h1, h2, h3 {
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

@keyframes skel-shimmer {
    from { background-position: 150% 0; }
    to { background-position: -50% 0; }
}

.skel,
.skel-line {
    background-color: var(--skel-base);
    background-image: linear-gradient(100deg, transparent 30%, var(--skel-shine) 50%, transparent 70%);
    background-size: 200% 100%;
    background-repeat: no-repeat;
    animation: skel-shimmer 1.4s ease-in-out infinite;
}

.skel {
    position: relative;
    overflow: hidden;
}

/* El medio aparece suave encima del skeleton cuando termina de cargar */
.js .skel img,
.js .skel iframe {
    opacity: 0;
    transition: opacity 0.35s ease;
}

.skel.is-loaded {
    animation: none;
    background-image: none;
}

.js .skel.is-loaded img,
.js .skel.is-loaded iframe {
    opacity: 1;
}

/* Si un medio no carga, el skeleton se detiene y deja un aviso discreto */
.skel.is-error {
    animation: none;
    background-image: none;
}

.skel.is-error::after {
    content: attr(data-error);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 16px;
    color: #9CA3AF;
    font-size: 0.9rem;
    text-align: center;
}

/* ==========================================================================
   Piezas compartidas: lámpara de disponibilidad, chips e iconos
   ========================================================================== */
/* La lámpara del "escritorio de noche" se enciende una vez al cargar: abierto a ofertas */
.availability {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 700;
}

.lamp {
    flex: none;
    width: 40px;
    height: 40px;
    color: var(--brand-accent-soft);
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.lamp-light {
    fill: var(--brand-accent);
    fill-opacity: 0.3;
    stroke: none;
}

@media (prefers-reduced-motion: no-preference) {
    .lamp-light {
        animation: lamp-on 1.2s steps(1, end) 0.5s both;
    }
}

@keyframes lamp-on {
    0% { opacity: 0; }
    12% { opacity: 1; }
    22% { opacity: 0.15; }
    34% { opacity: 1; }
    42% { opacity: 0.5; }
    54%, 100% { opacity: 1; }
}

/* Filete de acento bajo los títulos de sección (Sobre mí, Perfil, casos de estudio); "Mis proyectos" va centrado y sin filete */
.about h2::after,
.profile-section h2::after,
.case-body h2::after {
    content: "";
    display: block;
    width: 48px;
    height: 4px;
    margin-top: 16px;
    border-radius: 2px;
    background: var(--brand-accent);
}

/* Párrafos cortos sin palabras sueltas en la última línea */
.hero-copy,
.contact-intro,
.contact-option-description,
.projects-hero p,
.profile-hero p {
    text-wrap: balance;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.chips li {
    padding: 5px 12px;
    border: 1px solid rgba(243, 244, 246, 0.16);
    border-radius: var(--radius-chip);
    color: #D1D5DB;
    font-size: 0.85rem;
}

/* Iconos monocromos: el SVG funciona como máscara y toma el color del texto */
.icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask: var(--icon) center / contain no-repeat;
    mask: var(--icon) center / contain no-repeat;
}

.icon-mail { --icon: url('/assets/ui/mail.svg'); }
.icon-phone { --icon: url('/assets/ui/phone.svg'); }
.icon-whatsapp { --icon: url('/assets/ui/whatsapp.svg'); }
.icon-github { --icon: url('/assets/ui/github.svg'); }
.icon-linkedin { --icon: url('/assets/ui/linkedin.svg'); }
.icon-copy { --icon: url('/assets/ui/copy.svg'); }
.icon-web { --icon: url('/assets/ui/web.svg'); }
.icon-arrow { --icon: url('/assets/ui/arrow.svg'); }

.icon-links {
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.icon-links a {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(243, 244, 246, 0.2);
    border-radius: 50%;
    color: var(--text-primary);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.icon-links a:hover,
.icon-links a:focus-visible {
    color: var(--brand-accent);
    border-color: var(--brand-accent);
}

.btn .icon {
    width: 18px;
    height: 18px;
    margin-right: 8px;
}

/* ==========================================================================
   Video de YouTube que solo se carga al tocarlo (miniatura + botón play)
   ========================================================================== */
.yt-facade {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    padding: 0;
    border: 0;
    background: transparent;
    border-radius: inherit;
    cursor: pointer;
    overflow: hidden;
}

.yt-facade img,
.yt-facade iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    object-fit: cover;
}

.yt-facade .yt-play {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 72px;
    height: 72px;
    margin: -36px 0 0 -36px;
    border-radius: 50%;
    background: rgba(13, 14, 21, 0.75);
    border: 2px solid rgba(243, 244, 246, 0.85);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.yt-facade .yt-play::after {
    content: '';
    position: absolute;
    left: 28px;
    top: 21px;
    border-style: solid;
    border-width: 14px 0 14px 22px;
    border-color: transparent transparent transparent var(--text-primary);
}

.yt-facade:hover .yt-play,
.yt-facade:focus-visible .yt-play {
    transform: scale(1.08);
    background: var(--brand-accent);
}

@media (prefers-reduced-motion: reduce) {
    .skel,
    .skel-line,
    header[data-layout="header"]:empty::after,
    footer[data-layout="footer"]:empty::after {
        animation: none;
    }

    .js .skel img,
    .js .skel iframe,
    .icon-links a,
    .yt-facade .yt-play {
        transition: none;
    }
}

/* Confirmación al copiar: el botón se pone verde mientras dice "Copiado" */
.btn.is-copied {
    color: var(--brand-accent);
    border-color: var(--brand-accent);
}

/* Sin recuadro azul al tocar o dar clic. El anillo de foco sigue apareciendo al navegar con teclado (:focus-visible) */
* {
    -webkit-tap-highlight-color: transparent;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ==========================================================================
   Respuesta al toque: todo lo que se puede presionar se hunde un poco y
   cambia de color mientras está presionado. Se usa la propiedad scale (no
   transform) para no pisar los transform que ya tienen algunos elementos.
   ========================================================================== */

/* Elementos compactos: botones, flechas, puntos, logo */
.btn:active,
.navbar button:active,
.hamburger-menu:active,
.quote-fab:active,
.slider-arrow:active,
.slider-dots button:active,
.case-back:active,
.segmented button:active,
.icon-links a:active,
.logo-section:active {
    color: var(--brand-accent);
}

.btn-primary:active {
    background-color: #0E9F6E;
    border-color: #0E9F6E;
    color: var(--bg-page);
}

/* Enlaces de texto: solo color (un enlace en línea no se puede escalar) */
.navbar ul li a:active,
.copyright a:active,
.contact-info a:active,
.case-body a:active {
    color: var(--brand-accent);
}

/* Solo para lectores de pantalla */
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px !important;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Secciones de texto desplegables (proyectos y preguntas frecuentes) */
.case-body summary:active,
.quote-faq summary:active {
    color: var(--brand-accent);
    background-color: rgba(16, 185, 129, 0.1);
}

/* Tarjetas que son enlace o control completo */
.contact-link:active,
.case-project-link:active,
.choice:active,
.extra:active {
    border-color: var(--brand-accent);
    background-color: rgba(16, 185, 129, 0.1);
}

.yt-facade:active .yt-play {
    filter: brightness(0.85);
}

@media (prefers-reduced-motion: no-preference) {
    .btn:active,
    .navbar button:active,
    .hamburger-menu:active,
    .quote-fab:active,
    .slider-arrow:active,
    .slider-dots button:active,
    .case-back:active,
    .segmented button:active,
    .icon-links a:active,
    .logo-section:active {
        scale: 0.94;
    }

    .contact-link:active,
    .case-project-link:active,
    .choice:active,
    .extra:active {
        scale: 0.98;
    }

    .yt-facade:active .yt-play {
        scale: 0.92;
    }
}
