/**
 * Flipbook Widget — Annual Reports
 *
 * @package TAMUK_Foundation
 */

/* -------------------------------------------------------
 * Wrapper & Header
 * ----------------------------------------------------- */
.tamuk-fb {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.tamuk-fb-header {
    text-align: center;
    margin-bottom: 1rem;
}

.tamuk-fb-heading {
    font-size: 1.75rem;
    font-weight: 700;
    color: #003399;
    margin: 0;
    display: inline-block;
}

.tamuk-fb-heading::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: #FCC10F;
    margin: 0.5rem auto 0;
    border-radius: 2px;
}

.tamuk-fb-intro {
    text-align: center;
    color: #555;
    max-width: 700px;
    margin: 0 auto 2rem;
    font-size: 1rem;
}

/* -------------------------------------------------------
 * Card Grid
 * ----------------------------------------------------- */
.tamuk-fb-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

.tamuk-fb-card {
    cursor: pointer;
    text-align: center;
    outline: none;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}

.tamuk-fb-card-cover-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Divider between featured and past reports */
.tamuk-fb-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.25rem 0 0.5rem;
}

.tamuk-fb-divider::before,
.tamuk-fb-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.tamuk-fb-divider span {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9ca3af;
    white-space: nowrap;
}

/* Featured (first) card spans full width */
.tamuk-fb-card:first-child {
    grid-column: 1 / -1;
    max-width: 100%;
    margin: 0 auto 1.5rem;
}

.tamuk-fb-card:first-child .tamuk-fb-card-cover-wrap {
    position: relative;
}

.tamuk-fb-card:first-child .tamuk-fb-card-cover {
    position: relative;
    z-index: 3;
    max-width: 320px;
    margin: 0 auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* -------------------------------------------------------
 * Featured Stack — symmetric angled fan
 * Desktop only. 4 internal pages fan out from behind the
 * cover — 2 left, 2 right — angled inward toward center
 * to draw the eye to the cover.
 * ----------------------------------------------------- */
.tamuk-fb-featured-stack {
    display: none;
}

@media (min-width: 769px) {
    .tamuk-fb-card:first-child .tamuk-fb-card-cover-wrap {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 440px;
        padding: 1.5rem 0;
    }

    .tamuk-fb-featured-stack {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 1;
        pointer-events: none;
    }

    .tamuk-fb-stack-page {
        position: absolute;
        top: 50%;
        left: 50%;
        border-radius: 6px;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 3px 8px rgba(0, 0, 0, 0.15);
        object-fit: cover;
        height: 78%;
        width: auto;
        margin-left: -160px;
        transform-origin: center center;
        transition: transform 0.4s ease-out, opacity 0.4s ease-out;
    }

    /* --- Entrance: pages start hidden behind cover --- */
    .tamuk-fb-animating .tamuk-fb-stack-page {
        transform: perspective(800px) rotateY(0deg) translateX(0) translateY(-50%) scale(0.85) !important;
        opacity: 0 !important;
    }

    /* Entrance: slow, staggered fan-out when .tamuk-fb-animating is removed */
    .tamuk-fb-entering .tamuk-fb-stack-page {
        transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.8s ease-out;
    }
    .tamuk-fb-entering .tamuk-fb-stack-left   { transition-delay: 0.1s; }
    .tamuk-fb-entering .tamuk-fb-stack-right  { transition-delay: 0.15s; }
    .tamuk-fb-entering .tamuk-fb-stack-far-left  { transition-delay: 0.3s; }
    .tamuk-fb-entering .tamuk-fb-stack-far-right { transition-delay: 0.35s; }

    /* --- Resting states --- */

    /* Inner left */
    .tamuk-fb-stack-left {
        z-index: 2;
        transform: perspective(800px) rotateY(8deg) translateX(-100px) translateY(-50%) scale(0.88);
        opacity: 0.7;
    }

    /* Inner right */
    .tamuk-fb-stack-right {
        z-index: 2;
        transform: perspective(800px) rotateY(-8deg) translateX(100px) translateY(-50%) scale(0.88);
        opacity: 0.7;
    }

    /* Outer left */
    .tamuk-fb-stack-far-left {
        z-index: 1;
        box-shadow: 0 10px 35px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.2);
        transform: perspective(800px) rotateY(14deg) translateX(-190px) translateY(-47%) scale(0.75);
        opacity: 0.18;
    }

    /* Outer right */
    .tamuk-fb-stack-far-right {
        z-index: 1;
        box-shadow: 0 10px 35px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.2);
        transform: perspective(800px) rotateY(-14deg) translateX(190px) translateY(-47%) scale(0.75);
        opacity: 0.18;
    }

    /* Hover: fan out wider, bring opacity up */
    .tamuk-fb-card:first-child:hover .tamuk-fb-stack-left {
        transform: perspective(800px) rotateY(16deg) translateX(-220px) translateY(-50%) scale(0.85);
        opacity: 0.92;
    }
    .tamuk-fb-card:first-child:hover .tamuk-fb-stack-right {
        transform: perspective(800px) rotateY(-16deg) translateX(220px) translateY(-50%) scale(0.85);
        opacity: 0.92;
    }
    .tamuk-fb-card:first-child:hover .tamuk-fb-stack-far-left {
        transform: perspective(800px) rotateY(24deg) translateX(-400px) translateY(-47%) scale(0.72);
        opacity: 0.55;
    }
    .tamuk-fb-card:first-child:hover .tamuk-fb-stack-far-right {
        transform: perspective(800px) rotateY(-24deg) translateX(400px) translateY(-47%) scale(0.72);
        opacity: 0.55;
    }

    .tamuk-fb-stack-page {
        transition: transform 0.4s ease, opacity 0.4s ease;
    }
}

.tamuk-fb-card:first-child .tamuk-fb-card-year {
    font-size: 1.5rem;
}

.tamuk-fb-card:first-child .tamuk-fb-card-title {
    font-size: 1rem;
}

.tamuk-fb-card:hover,
.tamuk-fb-card:focus-visible {
    transform: translateY(-6px);
}

.tamuk-fb-card--empty {
    cursor: default;
    opacity: 0.6;
}

.tamuk-fb-card--empty:hover,
.tamuk-fb-card--empty:focus-visible {
    transform: none;
}

/* -------------------------------------------------------
 * Card Cover
 * ----------------------------------------------------- */
.tamuk-fb-card-cover {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    background: #f0f0f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s;
}

.tamuk-fb-card:hover .tamuk-fb-card-cover,
.tamuk-fb-card:focus-visible .tamuk-fb-card-cover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.tamuk-fb-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.tamuk-fb-card-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.tamuk-fb-card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(0, 51, 153, 0.75);
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.25s, background 0.2s;
    z-index: 4;
}

.tamuk-fb-card:hover .tamuk-fb-card-overlay,
.tamuk-fb-card:focus-visible .tamuk-fb-card-overlay {
    opacity: 1;
}

/* Featured card: delay overlay so fan-out is the first visual response */
.tamuk-fb-card:first-child .tamuk-fb-card-overlay {
    transition: opacity 0.3s 0.15s, background 0.2s;
}

.tamuk-fb-card-overlay:hover {
    background: rgba(0, 51, 153, 0.88);
}

.tamuk-fb-card-overlay span {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    transition: background 0.2s, border-color 0.2s;
}

.tamuk-fb-card-overlay:hover span {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
}

/* -------------------------------------------------------
 * Card Text
 * ----------------------------------------------------- */
.tamuk-fb-card-year {
    font-size: 1.25rem;
    font-weight: 700;
    color: #003399;
    margin: 0.75rem 0 0.125rem;
}

.tamuk-fb-card-title {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

/* -------------------------------------------------------
 * Modal
 * ----------------------------------------------------- */
.tamuk-fb-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}

.tamuk-fb-modal[aria-hidden="false"] {
    display: flex;
}

@keyframes tamuk-fb-modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes tamuk-fb-modal-rise {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tamuk-fb-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: tamuk-fb-modal-fade 0.3s ease-out;
}

.tamuk-fb-modal-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 95vw;
    height: 95vh;
    max-width: 1200px;
    background: transparent;
    animation: tamuk-fb-modal-rise 0.35s ease-out;
}

.tamuk-fb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    color: #fff;
}

.tamuk-fb-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: #fff;
}

.tamuk-fb-modal-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.15s;
}

.tamuk-fb-modal-close:hover,
.tamuk-fb-modal-close:focus {
    background: rgba(255, 255, 255, 0.15);
}

/* -------------------------------------------------------
 * Toolbar (Zoom, Print, Download)
 * ----------------------------------------------------- */
.tamuk-fb-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
    margin-right: 1rem;
}

.tamuk-fb-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}

.tamuk-fb-toolbar-btn:hover,
.tamuk-fb-toolbar-btn:focus {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    text-decoration: none;
}

.tamuk-fb-toolbar-sep {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 0.375rem;
}

.tamuk-fb-zoom-reset {
    display: none;
}

.tamuk-fb-zoom-reset.tamuk-fb-zoom-active {
    display: inline-flex;
}

/* Hide toolbar on mobile — buttons are too small for touch */
@media (max-width: 768px) {
    .tamuk-fb-toolbar {
        display: none;
    }
}

/* -------------------------------------------------------
 * Zoom
 * ----------------------------------------------------- */
.tamuk-fb-modal-body {
    position: relative;
}

.tamuk-fb-flipbook {
    transition: transform 0.2s ease;
    transform-origin: center center;
}

/* -------------------------------------------------------
 * Modal Body (Flipbook)
 * ----------------------------------------------------- */
.tamuk-fb-modal-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0 1rem;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.tamuk-fb-flipbook {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tamuk-fb-pages {
    max-width: 100%;
    max-height: 100%;
}

.tamuk-fb-page {
    background: #fff;
}

.tamuk-fb-page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tamuk-fb-loading {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    text-align: center;
    padding: 2rem;
}

.tamuk-fb-error {
    color: #f87171;
    font-size: 1rem;
    text-align: center;
    padding: 2rem;
}

/* -------------------------------------------------------
 * Modal Footer (Page Navigation)
 * ----------------------------------------------------- */
.tamuk-fb-modal-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    color: #fff;
}

.tamuk-fb-modal-prev,
.tamuk-fb-modal-next {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.15s;
    display: flex;
    align-items: center;
}

.tamuk-fb-modal-prev:hover,
.tamuk-fb-modal-next:hover,
.tamuk-fb-modal-prev:focus,
.tamuk-fb-modal-next:focus {
    background: rgba(255, 255, 255, 0.25);
}

.tamuk-fb-modal-page-info {
    font-size: 0.875rem;
    min-width: 120px;
    text-align: center;
}

/* -------------------------------------------------------
 * Responsive
 * ----------------------------------------------------- */
@media (max-width: 768px) {
    .tamuk-fb-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .tamuk-fb-card:first-child {
        max-width: 320px;
    }

    .tamuk-fb-modal-container {
        width: 100vw;
        height: 100vh;
    }

    .tamuk-fb-modal-body {
        padding: 0;
    }

    .tamuk-fb-flipbook {
        touch-action: none;
    }
}

@media (max-width: 480px) {
    .tamuk-fb-grid {
        grid-template-columns: 1fr;
        max-width: 280px;
        margin: 0 auto;
    }
}

/* -------------------------------------------------------
 * Load-in Animations — Pure CSS, no JS dependency.
 * Staggered @keyframes entrance for header and cards.
 * animation-fill-mode: both ensures elements stay visible after animating.
 * ----------------------------------------------------- */
@keyframes tamuk-fb-slide-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .tamuk-fb-header,
    .tamuk-fb-intro {
        animation: tamuk-fb-slide-up 0.6s ease-out both;
    }

    .tamuk-fb-card {
        animation: tamuk-fb-slide-up 0.5s ease-out both;
    }

    /* Featured card gets a slightly longer entrance */
    .tamuk-fb-card:nth-child(1) { animation: tamuk-fb-slide-up 0.7s ease-out both; animation-delay: 0.1s; }
    .tamuk-fb-card:nth-child(2) { animation-delay: 0.35s; }
    .tamuk-fb-card:nth-child(3) { animation-delay: 0.45s; }
    .tamuk-fb-card:nth-child(4) { animation-delay: 0.55s; }
    .tamuk-fb-card:nth-child(5) { animation-delay: 0.65s; }
    .tamuk-fb-card:nth-child(6) { animation-delay: 0.75s; }
}
