/* ============================================================================
   TFG de MaHerMo - Hoja de estilos principal
   Web del Trabajo Fin de Grado.
   - Modo oscuro por defecto, claro como alternativa.
   - Variables CSS para tema, tipografía Inter (system fallback).
   - Layout fluido + grid responsive (3 / 2 / 1 columnas).
   - Efectos hover en cajitas: lift + sombra + brillo de borde.
   ============================================================================ */

/* ---------- Reset minimalista ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--c-text);
    background: var(--c-bg);
    transition: background-color 0.25s ease, color 0.25s ease;
    display: flex;
    flex-direction: column;
}

img, svg, video {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: var(--c-accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--c-accent-strong);
}

h1, h2, h3, h4 {
    margin: 0 0 0.6em;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--c-heading);
}

p {
    margin: 0 0 1em;
}

code {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    background: var(--c-code-bg);
    color: var(--c-code-fg);
    padding: 0.12em 0.4em;
    border-radius: 4px;
}

button {
    font: inherit;
    cursor: pointer;
}

/* ---------- Variables de tema ---------- */
:root {
    /* Paleta MaHerMo */
    --c-mahermo-blue: #0a3d7a;
    --c-mahermo-blue-light: #1b6dc7;
    --c-mahermo-cyan: #4fb3e5;

    /* Geometría */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --container: 1180px;
    --container-narrow: 920px;

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.18);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.28);
}

/* Modo oscuro (por defecto) */
:root,
[data-theme="dark"] {
    --c-bg: #0a0f1a;
    --c-bg-elevated: #111827;
    --c-bg-alt: #0f1623;
    --c-surface: rgba(255, 255, 255, 0.03);
    --c-surface-hover: rgba(255, 255, 255, 0.06);
    --c-border: rgba(255, 255, 255, 0.08);
    --c-border-strong: rgba(79, 179, 229, 0.4);
    --c-text: #d6dde8;
    --c-text-muted: #8b94a6;
    --c-heading: #f1f5fb;
    --c-accent: #4fb3e5;
    --c-accent-strong: #7cc8ee;
    --c-accent-bg: rgba(79, 179, 229, 0.12);
    --c-code-bg: rgba(255, 255, 255, 0.06);
    --c-code-fg: #a8d8f0;
    --c-header-bg: rgba(10, 15, 26, 0.78);
    --c-glow: rgba(79, 179, 229, 0.22);
    --c-gradient: radial-gradient(ellipse at top, rgba(79, 179, 229, 0.10), transparent 55%);
}

/* Modo claro */
[data-theme="light"] {
    --c-bg: #f6f8fb;
    --c-bg-elevated: #ffffff;
    --c-bg-alt: #eef2f8;
    --c-surface: #ffffff;
    --c-surface-hover: #f2f6fc;
    --c-border: rgba(10, 61, 122, 0.12);
    --c-border-strong: rgba(10, 61, 122, 0.45);
    --c-text: #2a3447;
    --c-text-muted: #5d6b82;
    --c-heading: #0a3d7a;
    --c-accent: #0a3d7a;
    --c-accent-strong: #1b6dc7;
    --c-accent-bg: rgba(10, 61, 122, 0.08);
    --c-code-bg: rgba(10, 61, 122, 0.06);
    --c-code-fg: #0a3d7a;
    --c-header-bg: rgba(246, 248, 251, 0.85);
    --c-glow: rgba(10, 61, 122, 0.14);
    --c-gradient: radial-gradient(ellipse at top, rgba(10, 61, 122, 0.08), transparent 55%);
}

/* ---------- Layout: contenedor y skip-link ---------- */
.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
}

.container-narrow {
    max-width: var(--container-narrow);
}

main {
    flex: 1 0 auto;
    background: var(--c-gradient), var(--c-bg);
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--c-accent);
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    z-index: 1000;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 16px;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--c-header-bg);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--c-border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 68px;
}

.brand {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.brand-logo {
    height: 36px;
    width: auto;
    transition: opacity 0.2s ease;
}

[data-theme="dark"] .brand-logo-light { display: none; }
[data-theme="light"] .brand-logo-dark { display: none; }

.site-nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--c-text-muted);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.94rem;
    transition: color 0.2s, background-color 0.2s;
}

.nav-link:hover {
    color: var(--c-heading);
    background: var(--c-surface-hover);
}

.nav-link.is-active {
    color: var(--c-accent);
    background: var(--c-accent-bg);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    background: var(--c-surface);
    color: var(--c-text);
    transition: border-color 0.2s, background-color 0.2s, color 0.2s, transform 0.15s;
}

.theme-toggle:hover {
    border-color: var(--c-border-strong);
    color: var(--c-accent);
    transform: translateY(-1px);
}

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ---------- Hero ---------- */
.hero {
    padding: clamp(48px, 8vw, 96px) 0 clamp(40px, 6vw, 72px);
    position: relative;
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 22px;
}

.eyebrow-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c-accent);
    box-shadow: 0 0 0 4px var(--c-accent-bg);
    animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.9); }
}

.hero-title {
    font-size: clamp(2rem, 4.6vw, 3.4rem);
    line-height: 1.12;
    max-width: 22ch;
    margin-bottom: 22px;
    letter-spacing: -0.02em;
}

.hero-accent {
    background: linear-gradient(135deg, var(--c-accent) 0%, var(--c-mahermo-blue-light) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-lead {
    font-size: clamp(1rem, 1.4vw, 1.18rem);
    max-width: 64ch;
    color: var(--c-text-muted);
    margin-bottom: 36px;
}

.hero-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    padding: 24px 28px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    margin-bottom: 32px;
}

.hero-meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hero-meta-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-text-muted);
}

.hero-meta-value {
    font-weight: 600;
    color: var(--c-heading);
    font-size: 0.98rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

/* ---------- Botones ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.96rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease,
                background-color 0.2s ease, border-color 0.2s ease, color 0.2s;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--c-mahermo-blue-light), var(--c-accent));
    color: #fff;
    box-shadow: 0 6px 18px var(--c-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px var(--c-glow);
    color: #fff;
}

.btn-ghost {
    background: var(--c-surface);
    color: var(--c-text);
    border-color: var(--c-border);
}

.btn-ghost:hover {
    background: var(--c-surface-hover);
    border-color: var(--c-border-strong);
    color: var(--c-accent);
    transform: translateY(-2px);
}

/* ---------- Secciones ---------- */
.section {
    padding: clamp(48px, 6vw, 80px) 0;
}

.section-alt {
    background: var(--c-bg-alt);
    border-top: 1px solid var(--c-border);
    border-bottom: 1px solid var(--c-border);
}

.section-header {
    text-align: center;
    max-width: 720px;
    margin: 0 auto 48px;
}

.section-title {
    font-size: clamp(1.6rem, 2.4vw, 2.1rem);
}

.section-subtitle {
    color: var(--c-text-muted);
    font-size: 1.04rem;
    margin: 0;
}

/* ---------- Grids de tarjetas ---------- */
.card-grid {
    display: grid;
    gap: 22px;
}

.card-grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* ---------- Card base + hover effect ---------- */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 28px 26px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    color: var(--c-text);
    text-decoration: none;
    overflow: hidden;
    transition: transform 0.25s ease,
                border-color 0.25s ease,
                background-color 0.25s ease,
                box-shadow 0.3s ease;
}

/* Línea luminosa superior que aparece al hover */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--c-accent), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Glow radial detrás de la cajita */
.card::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-lg);
    background: radial-gradient(circle at 50% 0%, var(--c-glow), transparent 70%);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.card:hover {
    transform: translateY(-6px);
    border-color: var(--c-border-strong);
    background: var(--c-surface-hover);
    box-shadow: var(--shadow-lg);
    color: var(--c-text);
}

.card:hover::before { opacity: 1; }
.card:hover::after { opacity: 1; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--c-accent-bg);
    color: var(--c-accent);
    transition: transform 0.3s ease;
}

.card:hover .card-icon {
    transform: scale(1.06) rotate(-2deg);
}

.card-sigla {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 10px;
    border: 1px solid var(--c-border);
    border-radius: 999px;
    color: var(--c-text-muted);
    background: var(--c-bg-elevated);
    letter-spacing: 0.04em;
}

.card-title {
    font-size: 1.18rem;
    margin: 0 0 6px;
}

.card-subtitle {
    color: var(--c-accent);
    font-size: 0.88rem;
    font-weight: 500;
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card-desc {
    color: var(--c-text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
    margin: 0 0 18px;
    flex-grow: 1;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 14px;
    border-top: 1px dashed var(--c-border);
    margin-bottom: 18px;
    color: var(--c-text-muted);
    font-size: 0.84rem;
}

.card-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.card-meta-item svg {
    width: 16px;
    height: 16px;
}

.card-meta-file {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.78rem;
    opacity: 0.8;
}

.card-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    background: var(--c-accent-bg);
    color: var(--c-accent);
    font-weight: 600;
    font-size: 0.92rem;
    align-self: flex-start;
    transition: background-color 0.2s, color 0.2s, transform 0.2s;
}

.card-action svg {
    width: 16px;
    height: 16px;
}

.card-action svg:last-child {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.card:hover .card-action {
    background: var(--c-accent);
    color: #fff;
}

.card-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--c-accent);
    font-weight: 600;
    font-size: 0.94rem;
    margin-top: auto;
    transition: gap 0.2s ease;
}

.card-cta svg {
    width: 16px;
    height: 16px;
    transition: transform 0.25s ease;
}

.card:hover .card-cta { gap: 12px; }
.card:hover .card-cta svg { transform: translateX(3px); }

/* Card destacado (manuales más usados) */
.card-manual.is-featured {
    border-color: var(--c-border-strong);
}

.card-manual.is-featured::before {
    opacity: 0.5;
}

/* ---------- Stats ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 18px;
}

.stat {
    padding: 28px 22px;
    text-align: center;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat:hover {
    transform: translateY(-3px);
    border-color: var(--c-border-strong);
}

.stat-value {
    display: block;
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    font-weight: 700;
    color: var(--c-accent);
    line-height: 1.1;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.stat-label {
    display: block;
    font-size: 0.88rem;
    color: var(--c-text-muted);
}

/* ---------- Tech pills ---------- */
.tech-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.tech-pill {
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: transform 0.2s, border-color 0.2s, color 0.2s, background-color 0.2s;
}

.tech-pill:hover {
    border-color: var(--c-border-strong);
    color: var(--c-accent);
    transform: translateY(-2px);
}

/* ---------- Page header (subpáginas) ---------- */
.page-header {
    padding: clamp(40px, 5vw, 72px) 0 clamp(24px, 3vw, 36px);
    background: var(--c-gradient), var(--c-bg);
    border-bottom: 1px solid var(--c-border);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--c-text-muted);
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 20px;
    transition: color 0.2s, transform 0.2s;
}

.back-link:hover {
    color: var(--c-accent);
    transform: translateX(-3px);
}

.page-title {
    font-size: clamp(1.9rem, 3.6vw, 2.6rem);
    margin: 0 0 14px;
}

.page-lead {
    color: var(--c-text-muted);
    font-size: 1.04rem;
    max-width: 70ch;
    margin: 0;
}

/* ---------- Cite examples (manuales) ---------- */
.cite-examples {
    display: grid;
    gap: 14px;
    max-width: 900px;
    margin: 0 auto;
}

.cite-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
}

.cite-short {
    font-size: 0.9rem;
}

.cite-arrow {
    color: var(--c-accent);
    display: inline-flex;
    opacity: 0.7;
}

.cite-arrow svg {
    width: 18px;
    height: 18px;
}

.cite-long {
    font-size: 0.92rem;
    color: var(--c-text-muted);
}

/* ---------- Video ---------- */
.video-frame {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--c-border);
    background: #000;
    box-shadow: var(--shadow-lg);
    aspect-ratio: 16 / 9;
}

.video-player {
    width: 100%;
    height: 100%;
    background: #000;
    display: block;
}

.video-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
    margin-top: 24px;
}

.video-meta {
    margin-top: 48px;
}

.video-meta-block {
    padding: 28px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
}

.video-meta-title {
    font-size: 1.18rem;
    margin: 0 0 14px;
}

.video-meta-list {
    margin: 0;
    padding-left: 22px;
    color: var(--c-text-muted);
}

.video-meta-list li {
    margin-bottom: 8px;
    line-height: 1.55;
}

/* ---------- Footer ---------- */
.site-footer {
    margin-top: auto;
    padding: 36px 0;
    background: var(--c-bg-alt);
    border-top: 1px solid var(--c-border);
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
    align-items: flex-start;
}

.footer-block {
    flex: 1 1 280px;
}

.footer-block-right {
    text-align: right;
}

.footer-line {
    margin: 0 0 4px;
    color: var(--c-text);
    font-size: 0.92rem;
}

.footer-meta {
    color: var(--c-text-muted);
    font-size: 0.86rem;
}

.footer-link {
    color: var(--c-accent);
    font-weight: 500;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .header-inner {
        gap: 8px;
    }

    .brand-logo {
        height: 30px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 0.88rem;
    }

    .theme-toggle {
        width: 38px;
        height: 38px;
    }

    .hero-meta {
        padding: 18px 20px;
    }

    .footer-inner {
        flex-direction: column;
    }

    .footer-block-right {
        text-align: left;
    }

    .cite-row {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .cite-arrow {
        display: none;
    }
}

@media (max-width: 500px) {
    .site-nav { gap: 0; }
    .nav-link { padding: 6px 8px; font-size: 0.84rem; }

    .container { padding: 0 16px; }
    .hero-title { font-size: 1.85rem; }
    .hero-actions { flex-direction: column; align-items: stretch; }
    .btn { justify-content: center; }
}

/* ---------- Animaciones de entrada ---------- */
@media (prefers-reduced-motion: no-preference) {
    .hero > .container > * {
        animation: fade-up 0.6s ease backwards;
    }

    .hero-eyebrow { animation-delay: 0.05s; }
    .hero-title { animation-delay: 0.15s; }
    .hero-lead { animation-delay: 0.25s; }
    .hero-meta { animation-delay: 0.35s; }
    .hero-actions { animation-delay: 0.45s; }

    @keyframes fade-up {
        from { opacity: 0; transform: translateY(14px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}
