/* ================= PUBLICATIONS & CERTIFICATIONS ================= */
.publications-section {
    position: relative;
    padding: 14rem 5% 0;
    overflow: hidden;
    background: radial-gradient(circle at top left, #1a1a1a 0%, #050505 100%);
}

/* Seamless fade from achievements into publications section */
.publications-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 140px;
    background: linear-gradient(to bottom, #050505 0%, transparent 100%);
    pointer-events: none;
    z-index: 5;
}

/* Seamless fade into contact section */
.publications-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 160px;
    background: linear-gradient(to bottom, transparent 0%, #0a0a0a 100%);
    pointer-events: none;
    z-index: 5;
}

.pub-layout-container {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 40px;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

/* ================================================================
   LEFT SIDE — 3D REAL BOOK
   ================================================================ */
.pub-main-book {
    flex: 0 0 40%;
    max-width: 40%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-top: 2rem;
    padding-bottom: 1rem;
    position: relative;
    overflow: visible;
}

/* Scene: provides perspective depth for the whole book */
.book-scene {
    perspective: 1200px;
    perspective-origin: 60% 50%;
    width: 280px;
    height: 380px;
    position: relative;
}

/* Float wrapper: JS animates this for idle float + parallax tilt */
.book-float {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform: rotateX(15deg) rotateY(-25deg) rotateZ(5deg);
    will-change: transform;
    cursor: pointer;
    transition: transform 0.1s ease-out;
}

/* Book body: the actual physical book in 3D space */
.book-body {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

/* ── COVER ────────────────────────────────────────────────────────
   The cover sits on top and rotates open along the LEFT spine.
   transform-origin: left center = the spine hinge.
   ---------------------------------------------------------------- */
.book-cover {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transform-origin: left center;
    transform: rotateY(0deg);
    /* 1000ms matches JS FLIP_DURATION */
    transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1);
    cursor: pointer;
    z-index: 3;
}

/* When JS adds .open, the cover swings to -160deg (book opens) */
.book-cover.open {
    transform: rotateY(-160deg);
}

/* Front face of the cover: the cover image */
.book-cover-front {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 3px 6px 6px 3px;
    overflow: hidden;
    background: #1a1a2e;
    box-shadow:
        2px 0 6px rgba(0,0,0,0.5),
        inset -2px 0 8px rgba(0,0,0,0.3);
}

.page-front .cover-img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    border-radius: 3px 6px 6px 3px;
}

/* Lighting overlay: darkens during the flip past 90° */
.book-cover-front::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background 1s cubic-bezier(0.645, 0.045, 0.355, 1);
    border-radius: 3px 6px 6px 3px;
    pointer-events: none;
}

.book-cover.open .book-cover-front::after {
    background: rgba(0,0,0,0.6);
}

/* Spine-edge shimmer: hints the book is interactive */
.spine-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 8px;
    height: 100%;
    background: linear-gradient(to right,
        rgba(255,255,255,0.5) 0%,
        rgba(255,255,255,0.0) 100%);
    border-radius: 3px 0 0 3px;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.book-float:hover .spine-glow {
    opacity: 1;
}

/* Back face of the cover: inside cover (cream paper) — LEFT page when open */
.book-cover-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: rotateY(180deg);
    background: linear-gradient(160deg, #faf8f2 0%, #f0ebe0 100%);
    border-radius: 6px 3px 3px 6px;
    box-shadow: inset 2px 0 10px rgba(0,0,0,0.12);
    overflow: hidden;
}

/* Left page content (title page) */
.left-page-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.2rem 1rem;
    text-align: center;
    box-sizing: border-box;
}

.left-page-journal {
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #8a6030;
    margin-bottom: 0.7rem;
    font-family: 'Georgia', serif;
    opacity: 0.7;
}

.left-page-logo {
    margin-bottom: 0.6rem;
    opacity: 0.7;
}

.left-page-title {
    font-size: 1.1rem;
    font-weight: 900;
    color: #1a1008;
    font-family: 'Georgia', serif;
    letter-spacing: 0.04em;
    margin: 0 0 0.2rem 0;
}

.left-page-subtitle {
    font-size: 0.58rem;
    color: #5a4a35;
    font-family: 'Georgia', serif;
    line-height: 1.5;
    margin: 0 0 0.6rem 0;
    font-style: italic;
}

.left-page-rule,
.left-page-bottom-rule {
    width: 60%;
    height: 1px;
    background: linear-gradient(to right, transparent, #c8a870, transparent);
    margin: 0.4rem auto;
}

.left-page-meta {
    font-size: 0.55rem;
    color: #7a6545;
    font-family: 'Georgia', serif;
    line-height: 1.6;
    margin: 0;
}

.left-page-footer {
    font-size: 0.5rem;
    color: #8a6030;
    font-family: 'Georgia', serif;
    letter-spacing: 0.06em;
    opacity: 0.6;
    margin: 0;
}

/* Center gutter shadow — appears between pages when open */
.book-inside::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 14px;
    height: 100%;
    background: linear-gradient(to right,
        rgba(80,50,20,0.2) 0%,
        rgba(80,50,20,0) 100%);
    pointer-events: none;
    z-index: 5;
}

/* ── INSIDE PAGE ──────────────────────────────────────────────────
   Sits behind the cover; revealed when cover swings open.
   ---------------------------------------------------------------- */
.book-inside {
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, #faf8f2 0%, #f0ebe0 100%);
    border-radius: 3px 6px 6px 3px;
    overflow: hidden;
    cursor: pointer;
    z-index: 1;
    box-shadow: inset -4px 0 12px rgba(0,0,0,0.08);
}

/* Hover close affordance: subtle brightening edge */
.book-inside::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid rgba(100,80,40,0);
    border-radius: 3px 6px 6px 3px;
    transition: border-color 0.3s ease;
    pointer-events: none;
}

.book-float.book-is-open .book-inside:hover::after {
    border-color: rgba(100,80,40,0.3);
}

.book-inside-content {
    padding: 1.5rem;
    height: 100%;
    overflow: hidden;
}

.page-heading {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #2a1f0e;
    margin: 0 0 0.4rem 0;
    font-family: 'Georgia', serif;
}

.book-inside-content p {
    font-size: 0.65rem;
    color: #4a3f2e;
    line-height: 1.7;
    margin-bottom: 0.9rem;
    font-family: 'Georgia', serif;
}

.close-hint {
    font-size: 0.6rem !important;
    color: rgba(100,80,40,0.5) !important;
    font-style: italic;
    margin-top: 0.5rem !important;
    margin-bottom: 0 !important;
    letter-spacing: 0.04em;
}

/* ── Paper summary styles (inside page content) ─────────────────── */
.paper-journal {
    font-size: 0.55rem !important;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8a7060 !important;
    margin: 0 0 0.4rem 0 !important;
    font-family: 'Georgia', serif;
}

.page-heading {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: #1a1008;
    margin: 0 0 0.3rem 0;
    font-family: 'Georgia', serif;
    line-height: 1.3;
}

.paper-authors {
    font-size: 0.58rem !important;
    color: #6a5a45 !important;
    margin: 0 0 0.5rem 0 !important;
    font-style: italic;
    font-family: 'Georgia', serif;
}

.paper-college {
    font-style: normal;
    font-weight: 600;
}

.paper-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, #c8b898, transparent);
    margin: 0.5rem 0;
}

.paper-abstract {
    font-size: 0.6rem !important;
    color: #3a2e1e !important;
    line-height: 1.65;
    margin: 0 0 0.6rem 0 !important;
    font-family: 'Georgia', serif;
}

.paper-sections {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.paper-section-item {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.58rem;
    color: #3a2e1e;
    font-family: 'Georgia', serif;
    line-height: 1.4;
}

.paper-section-item strong {
    color: #1a1008;
}

.section-dot {
    flex: 0 0 5px;
    height: 5px;
    width: 5px;
    border-radius: 50%;
    background: #8a6030;
    margin-top: 0.3rem;
}



/* Spine: left side thickness */
.book-spine {
    position: absolute;
    top: 2px;
    left: -14px;
    width: 14px;
    height: calc(100% - 4px);
    text-shadow: 0 0 14px rgba(255, 248, 220, 0.55), 0 0 28px rgba(255, 248, 220, 0.28);
    color: rgba(255, 255, 255, 0.18);
    transform: rotateY(-90deg);
    border-radius: 3px 0 0 3px;
    box-shadow: inset -3px 0 8px rgba(0,0,0,0.4);
}

/* Bottom edge */
.book-bottom-edge {
    position: absolute;
    bottom: -10px;
    left: 2px;
    width: calc(100% - 4px);
    height: 10px;
    background: linear-gradient(to bottom, #d5cfc0, #b8b0a0);
    transform-origin: top center;
    transform: rotateX(-90deg);
    border-radius: 0 0 3px 3px;
}

/* Drop shadow blob under the book */
.book-drop-shadow {
    position: absolute;
    bottom: -40px;
    left: 5%;
    width: 90%;
    height: 30px;
    background: radial-gradient(ellipse at center,
        rgba(0,0,0,0.5) 0%,
        rgba(0,0,0,0.0) 75%);
    filter: blur(10px);
    transform-origin: center top;
    transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1),
                opacity   1s ease;
    pointer-events: none;
}

.book-float.book-is-open .book-drop-shadow {
    transform: translateX(10%) scaleX(0.7);
    opacity: 0.65;
}


/* ================================================================
   RIGHT SIDE — CERTIFICATIONS PANEL
   ================================================================ */
.pub-cert-side {
    flex: 0 0 55%;
    max-width: 55%;
    position: relative;
    background: #18181b; /* Solid dark background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 3.5rem 2rem 2rem 2rem; /* Reduced padding */
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Mac OS Top Bar */
.pub-cert-side::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2.5rem;
    background: #27272a; /* Lighter top bar */
    border-bottom: 1px solid rgba(255,255,255,0.05);
    z-index: 1;
}

/* Mac OS Dots */
.pub-cert-side::after {
    content: '';
    position: absolute;
    top: 0.9rem;
    left: 1.2rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff5f56;
    box-shadow: 20px 0 0 #ffbd2e, 40px 0 0 #27c93f;
    z-index: 2;
}

.pub-cert-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: #fff;
    letter-spacing: 1px;
    z-index: 2;
    position: relative;
}

/* Scroll Viewport and Track */
.cert-scroll-viewport {
    width: 100%;
    overflow: hidden;
    cursor: grab;
}

.cert-scroll-viewport:active {
    cursor: grabbing;
}

.cert-scroll-track {
    display: flex;
    gap: 1.2rem;
    width: max-content;
}

.cert-item {
    appearance: none;
    border: none;
    padding: 0;
    position: relative;
    flex: 0 0 160px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    background: #000;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
}

.cert-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.7;
    filter: grayscale(80%);
    transition: all 0.3s ease;
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .cert-item:hover {
        transform: translateY(-5px) scale(1.05);
        box-shadow: 0 10px 25px rgba(255, 255, 255, 0.2);
        z-index: 10;
    }

    .cert-item:hover img {
        opacity: 1;
        filter: grayscale(0%);
    }
}


/* ================================================================
   LIGHTBOX MODAL
   ================================================================ */
.cert-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.cert-lightbox.active {
    opacity: 1;
    pointer-events: all;
    visibility: visible;
}

.cert-lightbox-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: none;
        color: rgba(255, 255, 255, 0.26);
        text-shadow: 0 0 10px rgba(255, 248, 220, 0.6), 0 0 20px rgba(255, 248, 220, 0.35);
    border: none;
    color: white;
    font-size: 3rem;
    line-height: 1;
    cursor: pointer;
    z-index: 10000;
    transition: transform 0.2s ease;
}

.cert-lightbox-close:hover {
    transform: scale(1.2);
}

.cert-lightbox-content {
    position: relative;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cert-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    will-change: transform, opacity;
}


/* ================================================================
/* ================================================================
   INSIDE BOOK PAGES (3D Flip)
   ================================================================ */
.book-page {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transform-origin: left center;
    transform: rotateY(0deg);
    transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1);
    cursor: pointer;
}

.book-page.flipped {
    transform: rotateY(-160deg);
}

.page-front, .page-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
    background: linear-gradient(160deg, #faf8f2 0%, #f0ebe0 100%);
    box-shadow: inset 2px 0 10px rgba(0,0,0,0.12);
}

.page-front {
    border-radius: 3px 6px 6px 3px;
    box-shadow: inset -4px 0 12px rgba(0,0,0,0.08);
}

.page-back {
    transform: rotateY(180deg);
    border-radius: 6px 3px 3px 6px;
}

/* Hard back cover */
.book-back-cover {
    position: absolute;
    inset: 0;
    background: #1a1a2e;
    border-radius: 3px 6px 6px 3px;
    box-shadow: 2px 0 6px rgba(0,0,0,0.5);
    z-index: 0;
}

.book-back-cover-inside {
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, #faf8f2 0%, #f0ebe0 100%);
    border-radius: 3px 6px 6px 3px;
    box-shadow: inset -4px 0 12px rgba(0,0,0,0.08);
}

.bp-page-inner {
    padding: 1.5rem;
    height: 100%;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.bp-page-tag {
    position: absolute;
    top: 0.8rem;
    right: 1.5rem;
    font-size: 0.5rem;
    color: #8a6030;
    font-weight: 700;
    font-family: 'Georgia', serif;
}

.page-back .bp-page-tag {
    left: 1.5rem;
    right: auto;
}

.bp-heading {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: #1a1008;
    margin: 0 0 0.3rem 0;
    font-family: 'Georgia', serif;
    line-height: 1.3;
}

.bp-text {
    font-size: 0.6rem;
    color: #3a2e1e;
    line-height: 1.65;
    margin: 0 0 0.6rem 0;
    font-family: 'Georgia', serif;
}

.bp-rule {
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, #c8b898, transparent);
    margin: 0.5rem 0;
}

.bp-ref {
    font-size: 0.5rem;
    color: #8a6030;
    font-family: 'Georgia', serif;
    font-style: italic;
    margin-top: auto;
    text-align: center;
}

.bp-pub-btn {
    display: block;
    margin: 0.6rem auto 0;
    padding: 0.35rem 0.9rem;
    font-size: 0.55rem;
    font-family: 'Georgia', serif;
    font-style: italic;
    color: #fff;
    background: linear-gradient(135deg, #c0392b, #922b21);
    border: none;
    border-radius: 3px;
    text-decoration: none;
    text-align: center;
    letter-spacing: 0.04em;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    cursor: pointer;
    width: fit-content;
}
.bp-pub-btn:hover {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}

/* Page Navigation Arrows */
.bp-nav-arrows {
    position: absolute;
    bottom: 0.5rem;
    right: 1rem;
    display: flex;
    gap: 10px;
    z-index: 20;
}
.page-back .bp-nav-arrows {
    left: 1rem;
    right: auto;
}

.bp-arrow {
    background: rgba(255,255,255,0.7);
    border: 1px solid rgba(138,96,48,0.3);
    color: #8a6030;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s ease;
}

.bp-arrow:hover {
    background: #fff;
    color: #1a1008;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1024px) {
    .pub-main-book {
        flex: 0 0 45%;
        max-width: 45%;
    }
    .pub-cert-side {
        flex: 1;
        max-width: unset;
    }
}

@media (max-width: 800px) {
    .pub-layout-container {
        flex-direction: column;
    }

    .pub-main-book {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        margin-bottom: 4rem;
    }

    .pub-cert-side {
        flex: 1 1 auto;
        width: 100%;
    }

    .book-scene {
        width: 220px;
        height: 300px;
    }

    .publications-section {
        padding: 10rem 5% 0;
        background: radial-gradient(circle at top left, #1a1a1a 0%, #050505 100%);
    }

    .publications-section::before {
        background: linear-gradient(to bottom, #050505 0%, transparent 100%);
    }

    .publications-section::after {
        background: linear-gradient(to bottom, transparent 0%, #0a0a0a 100%);
    }

    .pub-cert-side {
        background: #232327;
        border-color: rgba(255, 255, 255, 0.16);
        box-shadow: 0 20px 40px rgba(0,0,0,0.45), 0 0 24px rgba(255,255,255,0.05);
    }

    .pub-cert-title {
        color: #fff7ef;
        text-shadow: 0 0 12px rgba(255,255,255,0.08);
    }

    .cert-item img {
        opacity: 0.95;
        filter: grayscale(20%);
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .book-cover,
    .book-cover-front::after,
    .book-drop-shadow {
        transition: none;
    }
    .cert-item {
        transition: none;
    }
    .cert-lightbox {
        transition: none;
    }
}

/* ── Tap to open label — below the book ── */
.tap-to-open-below {
    position: static;
    margin-top: 1.5rem;
    text-align: center;
    font-family: 'Caveat', cursive, sans-serif;
    font-size: 2rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    pointer-events: none;
    transition: opacity 0.4s ease;
    white-space: nowrap;
    transform: rotate(-3deg);
    display: block;
    animation: tap-pulse 2.2s ease-in-out infinite;
}

/* Hide label when book is open — overrides animation-driven opacity */
#book-scene:has(.book-is-open) ~ #tap-to-open-text {
    opacity: 0 !important;
    animation: none !important;
}

@keyframes tap-pulse {
    0%, 100% { opacity: 0.85; transform: rotate(-3deg) translateY(0); }
    50%       { opacity: 1;    transform: rotate(-3deg) translateY(-5px); }
}
