/* Research notebooks and publication reader
   -------------------------------------------------------------------------- */

.notebooks-page-header {
    min-height: clamp(360px, 48vh, 520px);
}

.notebooks-page-header h1 {
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(3.4rem, 9vw, 7rem) !important;
    font-weight: 400;
    letter-spacing: -0.055em;
    line-height: 0.92;
    margin-bottom: 1.25rem;
}

.notebooks-page-header .hero-subtitle {
    color: var(--color-text-secondary);
    font-size: clamp(0.72rem, 1.6vw, 0.9rem);
    font-weight: 600;
    letter-spacing: 0.28em;
    margin: 0;
}

.research-view[hidden],
.research-empty-state[hidden],
.research-status[hidden],
.publication-card[hidden] {
    display: none !important;
}

.notebooks-section {
    padding-top: clamp(2.5rem, 6vw, 5rem);
}

.notebooks-intro {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(280px, 1.2fr);
    gap: clamp(2rem, 6vw, 6rem);
    align-items: end;
    margin-bottom: clamp(2.5rem, 6vw, 4.5rem);
}

.notebooks-eyebrow,
.notebook-kicker,
.publication-kicker {
    color: var(--color-accent);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.notebooks-intro h2,
.notebook-detail-title {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 400;
    letter-spacing: -0.035em;
}

.notebooks-intro h2 {
    font-size: clamp(2rem, 4vw, 3.5rem);
    margin: 0;
}

.notebooks-intro > p {
    font-size: clamp(1rem, 1.7vw, 1.18rem);
    line-height: 1.8;
    margin: 0;
    max-width: 660px;
}

.notebook-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(1.2rem, 2.5vw, 2rem);
}

.notebook-card {
    --notebook-accent: #2997ff;
    --notebook-accent-soft: rgba(41, 151, 255, 0.22);
    display: flex;
    min-height: 470px;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    color: inherit;
    text-decoration: none;
    background: linear-gradient(155deg, rgba(14, 29, 55, 0.92), rgba(3, 8, 22, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 28px;
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.25);
    isolation: isolate;
    transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
        border-color 0.35s ease,
        box-shadow 0.45s ease;
}

.notebook-card:nth-child(3n + 2) {
    --notebook-accent: #a688ff;
    --notebook-accent-soft: rgba(166, 136, 255, 0.22);
}

.notebook-card:nth-child(3n + 3) {
    --notebook-accent: #45d4b4;
    --notebook-accent-soft: rgba(69, 212, 180, 0.2);
}

.notebook-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -2;
    background-image: linear-gradient(180deg, rgba(2, 4, 16, 0.06), rgba(2, 4, 16, 0.95)),
        var(--notebook-cover, linear-gradient(140deg, var(--notebook-accent-soft), transparent 65%));
    background-position: center;
    background-size: cover;
    transition: transform 0.65s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.notebook-card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: radial-gradient(circle at 80% 10%, var(--notebook-accent-soft), transparent 42%);
    pointer-events: none;
}

.notebook-card:hover,
.notebook-card:focus-visible {
    transform: translateY(-9px);
    border-color: color-mix(in srgb, var(--notebook-accent) 58%, white 15%);
    box-shadow: 0 28px 75px rgba(0, 0, 0, 0.4), 0 0 36px var(--notebook-accent-soft);
}

.notebook-card:hover::before,
.notebook-card:focus-visible::before {
    transform: scale(1.035);
}

.notebook-card:focus-visible,
.publication-card:focus-visible,
.back-link:focus-visible,
.pdf-download-button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 4px;
}

.notebook-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.6rem 1.6rem 0;
}

.notebook-index {
    font-family: "Playfair Display", Georgia, serif;
    font-size: 3.2rem;
    line-height: 1;
    color: rgba(255, 255, 255, 0.18);
}

.notebook-status {
    padding: 0.38rem 0.7rem;
    color: rgba(255, 255, 255, 0.76);
    background: rgba(2, 4, 16, 0.38);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-pill);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.notebook-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: flex-end;
    padding: 6rem 1.6rem 1.6rem;
}

.notebook-card h3 {
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(1.75rem, 3vw, 2.35rem);
    font-weight: 400;
    line-height: 1.08;
    letter-spacing: -0.035em;
    margin-bottom: 1rem;
}

.notebook-card-description {
    color: rgba(225, 225, 229, 0.72);
    font-size: 0.94rem;
    line-height: 1.7;
    margin-bottom: 1.6rem;
}

.notebook-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1.2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.78rem;
}

.notebook-card-arrow,
.publication-card-arrow {
    color: var(--notebook-accent, var(--color-accent));
    font-size: 1.25rem;
    transition: transform 0.25s ease;
}

.notebook-card:hover .notebook-card-arrow,
.notebook-card:focus-visible .notebook-card-arrow,
.publication-card:hover .publication-card-arrow,
.publication-card:focus-visible .publication-card-arrow {
    transform: translateX(5px);
}

.research-status {
    margin: 1.5rem 0 0;
    color: var(--color-text-secondary);
    font-size: 0.82rem;
    text-align: center;
}

.notebook-publications-section {
    background: linear-gradient(180deg, rgba(5, 16, 37, 0.76), rgba(2, 4, 16, 0.28));
    min-height: 55vh;
}

.notebook-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    color: var(--color-text-secondary);
    font-size: 0.86rem;
}

.notebook-breadcrumb a {
    color: inherit;
    text-decoration: none;
}

.notebook-breadcrumb a:hover {
    color: var(--color-text-primary);
}

.notebook-breadcrumb-separator {
    opacity: 0.35;
}

.notebook-detail-header {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(230px, 0.7fr);
    align-items: end;
    gap: 2.5rem;
    padding-bottom: 2.5rem;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--color-border);
}

.notebook-detail-title {
    font-size: clamp(2.4rem, 6vw, 4.7rem);
    line-height: 1;
    margin: 0.55rem 0 0;
}

.notebook-detail-description {
    margin: 0;
    font-size: 1rem;
    line-height: 1.75;
}

.publications-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1.5rem;
    margin-bottom: 1.6rem;
}

.publications-heading h3 {
    font-size: clamp(1.4rem, 3vw, 2rem);
    margin: 0;
}

.publications-count {
    color: var(--color-text-secondary);
    font-size: 0.82rem;
    margin: 0;
}

.publication-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.4rem;
}

.publication-card {
    --notebook-accent: var(--color-accent);
    display: flex;
    min-height: 340px;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(1.5rem, 3vw, 2rem);
    position: relative;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    background: linear-gradient(145deg, rgba(15, 30, 58, 0.78), rgba(4, 9, 23, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    transition: transform 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

.publication-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: linear-gradient(180deg, rgba(2, 4, 16, 0.22), rgba(2, 4, 16, 0.92)),
        var(--publication-cover, radial-gradient(circle at 90% 5%, rgba(41, 151, 255, 0.22), transparent 44%));
    background-position: center;
    background-size: cover;
    pointer-events: none;
}

.publication-card > * {
    position: relative;
    z-index: 1;
}

.publication-card:hover,
.publication-card:focus-visible {
    transform: translateY(-6px);
    border-color: rgba(41, 151, 255, 0.48);
    box-shadow: 0 22px 50px rgba(0, 0, 0, 0.3);
}

.publication-card h4 {
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(1.45rem, 3vw, 2rem);
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -0.025em;
    margin: 0.8rem 0 1rem;
}

.publication-excerpt {
    color: rgba(225, 225, 229, 0.66);
    font-size: 0.9rem;
    line-height: 1.65;
    margin-bottom: 1.8rem;
}

.publication-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.76rem;
}

.research-empty-state {
    padding: clamp(2.5rem, 7vw, 5rem) 1.5rem;
    border: 1px dashed rgba(255, 255, 255, 0.16);
    border-radius: 24px;
    text-align: center;
    background: rgba(255, 255, 255, 0.025);
}

.research-empty-symbol {
    display: block;
    margin-bottom: 1rem;
    color: var(--color-accent);
    font-family: "Playfair Display", Georgia, serif;
    font-size: 3rem;
    opacity: 0.75;
}

.research-empty-state h3 {
    font-size: 1.35rem;
}

.research-empty-state p {
    max-width: 520px;
    margin: 0 auto;
}

/* Full publication reader */

.paper-container {
    max-width: 860px;
    margin: 0 auto;
    padding: calc(var(--header-height) + clamp(2rem, 5vw, 4rem)) 2rem 6rem;
}

.paper-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2.2rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: inherit;
    font-size: 0.85rem;
    opacity: 0.58;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.back-link:hover {
    opacity: 1;
}

.pdf-download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 42px;
    padding: 0.65rem 1rem;
    color: #07101f;
    background: linear-gradient(135deg, #f5f7fa, #cfd5df);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: var(--radius-pill);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font: 600 0.8rem/1 var(--font-body);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pdf-download-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(41, 151, 255, 0.2);
}

.pdf-download-button svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.paper-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 2.5rem;
}

.paper-badge {
    padding: 0.3rem 0.8rem;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: 2rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.paper-badge.secondary {
    color: rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.paper-title {
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(2rem, 5vw, 3.15rem);
    font-weight: 700;
    line-height: 1.18;
    letter-spacing: -0.025em;
    margin-bottom: 1rem;
}

.paper-authors {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.65;
}

.paper-affiliation {
    margin-bottom: 2.5rem;
    font-size: 0.85rem;
    font-style: italic;
    opacity: 0.48;
}

.paper-divider {
    margin: 2.5rem 0;
    border: 0;
    border-top: 1px solid var(--color-border);
}

.paper-section-label {
    margin-bottom: 0.75rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    opacity: 0.45;
    text-transform: uppercase;
}

.paper-section-title,
.paper-body h2,
.paper-body h3,
.paper-body h4 {
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-weight: 600;
}

.paper-body h1 {
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: 1.65rem;
    font-weight: 650;
}

.paper-section-title {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.paper-body {
    color: rgba(225, 225, 229, 0.85);
    font-size: 1rem;
    line-height: 1.85;
}

.paper-body > * + * {
    margin-top: 1.1rem;
}

.paper-body p,
.paper-body ul,
.paper-body ol,
.paper-body blockquote,
.paper-body pre,
.paper-body figure,
.paper-body table {
    margin-bottom: 1.1rem;
}

.paper-body ul,
.paper-body ol {
    padding-left: 1.5rem;
}

.paper-body li + li {
    margin-top: 0.5rem;
}

.paper-body blockquote,
.rq-block {
    padding: 0.85rem 1.25rem;
    margin: 1rem 0;
    background: rgba(255, 255, 255, 0.025);
    border-left: 2px solid var(--color-accent);
    border-radius: 0 5px 5px 0;
}

.paper-body blockquote p:last-child {
    margin-bottom: 0;
}

.paper-body pre {
    max-width: 100%;
    overflow-x: auto;
    padding: 1.25rem;
    background: #01030a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    font-size: 0.86rem;
    line-height: 1.7;
}

.paper-body :not(pre) > code {
    padding: 0.14rem 0.35rem;
    color: #b9dcff;
    background: rgba(41, 151, 255, 0.12);
    border-radius: 5px;
    font-size: 0.9em;
}

.paper-body a {
    color: #76baff;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.paper-body img {
    height: auto;
    margin: 1.5rem auto;
    border-radius: 16px;
}

.paper-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.paper-body th,
.paper-body td {
    padding: 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-align: left;
    vertical-align: top;
}

.rq-label {
    margin-bottom: 0.3rem;
    color: var(--color-accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.rq-text {
    margin: 0;
    font-size: 0.95rem;
    font-style: italic;
    line-height: 1.65;
    opacity: 0.82;
}

.references-list {
    padding: 0;
    list-style: none;
    counter-reset: research-reference;
}

.references-list li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.7;
    opacity: 0.66;
    counter-increment: research-reference;
}

.references-list li::before {
    content: "[" counter(research-reference) "]";
    position: absolute;
    left: 0;
    color: var(--color-accent);
    font-weight: 600;
}

@media (max-width: 900px) {
    .notebook-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .notebooks-intro,
    .notebook-detail-header {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }
}

@media (max-width: 640px) {
    .notebooks-page-header {
        min-height: 390px;
    }

    .notebook-grid,
    .publication-grid {
        grid-template-columns: 1fr;
    }

    .notebook-card {
        min-height: 420px;
    }

    .notebook-card-body {
        padding-top: 4.5rem;
    }

    .paper-container {
        padding: calc(var(--header-height) + 2rem) 1.25rem 4rem;
    }

    .paper-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .pdf-download-button {
        width: 100%;
    }
}

/* Native print is the PDF renderer. Keeping the article as semantic HTML makes
   headings, lists, quotes, code and tables survive browser PDF export cleanly. */
@page {
    margin: 18mm 17mm 20mm;
}

@media print {
    html,
    body {
        overflow: visible !important;
        background: #fff !important;
        color: #111827 !important;
        font-size: 10.5pt;
    }

    body::before,
    body::after,
    .navbar,
    footer,
    #elysium-preloader,
    .paper-toolbar,
    .parallax-lambda {
        display: none !important;
    }

    main,
    .paper-container {
        width: auto !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .paper-title,
    .paper-section-title,
    .paper-body h1,
    .paper-body h2,
    .paper-body h3,
    .paper-body h4 {
        color: #111827 !important;
        text-shadow: none !important;
        break-after: avoid;
        break-inside: avoid;
    }

    .paper-title {
        font-size: 24pt;
    }

    .paper-authors,
    .paper-affiliation,
    .paper-section-label,
    .paper-body,
    .references-list li,
    .rq-text {
        color: #1f2937 !important;
        opacity: 1 !important;
    }

    /* Un párrafo o un punto de lista no se parte dejando una línea suelta. */
    .paper-body p,
    .paper-body li,
    .references-list li {
        orphans: 3;
        widows: 3;
    }

    .paper-badge {
        color: #1d4ed8 !important;
        border-color: #93c5fd !important;
    }

    .paper-badge.secondary {
        color: #4b5563 !important;
        border-color: #d1d5db !important;
    }

    .paper-divider {
        border-color: #d1d5db !important;
    }

    .paper-body blockquote,
    .rq-block {
        color: #1f2937 !important;
        background: #f8fafc !important;
        border-color: #2563eb !important;
        break-inside: avoid;
    }

    .paper-body pre {
        color: #111827 !important;
        background: #f3f4f6 !important;
        border-color: #d1d5db !important;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    .paper-body :not(pre) > code {
        color: #111827 !important;
        background: #eef2ff !important;
    }

    .paper-body a {
        color: #1d4ed8 !important;
        overflow-wrap: anywhere;
    }

    .paper-body img {
        max-height: 220mm;
        object-fit: contain;
        break-inside: avoid;
    }

    .paper-body table,
    .paper-body figure,
    .references-list li {
        break-inside: avoid;
    }

    .paper-body th,
    .paper-body td {
        border-color: #9ca3af !important;
    }
}
