/* Certificates Page Styles */

/* FIXED: Smooth scrolling for all modes */
html {
    scroll-behavior: smooth !important;
}

body {
    scroll-behavior: smooth !important;
}

.certificates-hero {
    position: relative;
    overflow: hidden;
    padding: 8rem 0 4rem;
    text-align: center;
}

/* Page title uses the same .sec-title font as every section title, just larger */
.certificates-hero .sec-title.page-title {
    justify-content: center;
    font-size: clamp(2.4rem, 6.4vw, 4.8rem) !important;
    margin-bottom: 1rem;
}

.certificates-hero p {
    color: var(--paper-dim);
    font-size: 1.4rem;
    max-width: 46rem;
    margin: 0 auto;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .certificates-hero p {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .certificates-hero .sec-title.page-title {
        font-size: clamp(2rem, 9.4vw, 2.6rem) !important;
    }

    .certificates-hero p {
        font-size: 0.95rem;
        padding: 0 0.5rem;
    }
}

.certificates-showcase {
    padding: 4rem 0;
}

/* Certificate Section Styles */
.certificate-section {
    margin-bottom: 6rem;
}

/* Section titles: same .sec-title font as the page title, centered, smaller */
.certificate-section .sec-title {
    justify-content: center;
    text-align: center;
    font-size: clamp(1.6rem, 3.4vw, 2.6rem) !important;
    margin: 0 auto 1.6rem;
}

@media (max-width: 768px) {
    .certificate-section .sec-title {
        font-size: clamp(1.35rem, 6.2vw, 1.9rem) !important;
        margin-bottom: 1.2rem;
    }
}

.view-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
    gap: 1rem;
}

.view-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(221, 154, 59, 0.3);
    color: #ccc;
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-btn.active,
.view-btn:hover {
    background: rgba(221, 154, 59, 0.2);
    color: #dd9a3b;
    border-color: #dd9a3b;
}

.microsoft-section .view-btn.active,
.microsoft-section .view-btn:hover {
    background: rgba(95, 179, 163, 0.2);
    color: #5fb3a3;
    border-color: #5fb3a3;
}

.training-section .view-btn.active,
.training-section .view-btn:hover {
    background: rgba(221, 154, 59, 0.2);
    color: #dd9a3b;
    border-color: #dd9a3b;
}

.carousel-container {
    --card-w: 300px;
    --card-h: 400px;
    position: relative;
    perspective: 1500px;
    height: calc(var(--card-h) + 100px);
    margin-top: 110px;
    margin-bottom: 110px;
    border-radius: 15px;
}

.carousel {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.certificate-item {
    position: absolute;
    width: var(--card-w);
    height: var(--card-h);
    left: 50%;
    top: 50%;
    margin-left: calc(var(--card-w) / -2);
    margin-top: calc(var(--card-h) / -2);
    transition: transform 0.5s ease, opacity 0.5s ease;
    transform-style: preserve-3d;
    cursor: pointer;
}

.certificate-item:hover {
    transform: translateZ(50px) scale(1.05);
}

.certificate-front,
.certificate-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: blur(var(--glass-blur));
    backdrop-filter: blur(var(--glass-blur));
    transition: transform 0.6s ease;
}

.certificate-front {
    background: linear-gradient(135deg, rgba(221, 154, 59, 0.1) 0%, rgba(240, 178, 90, 0.3) 100%) !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
    transform: rotateY(0deg);
    z-index: 2;
}

.certificate-front img {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.certificate-front h3 {
    color: #dd9a3b;
    font-size: 1.2rem;
    margin: 0;
    line-height: 1.3;
    flex: 0 0 auto;
    max-width: 100%;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.certificate-back {
    background: var(--glass-2);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    transform: rotateY(180deg);
    z-index: 1;
}

.certificate-back h3 {
    color: #dd9a3b;
    margin-bottom: 1rem;
    margin-top: 0;
    font-size: 1.1rem;
    line-height: 1.3;
}

.certificate-back p {
    overflow-y: auto;
    min-height: 0;
    color: var(--paper-dim);
    margin-bottom: 1.5rem;
    line-height: 1.4;
    margin-top: 0;
    font-size: 0.9rem;
}

.view-full-btn {
    background: rgba(221, 154, 59, 0.2);
    border: 1px solid #dd9a3b;
    color: #dd9a3b;
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: center;
    font-weight: 500;
    margin-top: auto;
    font-size: 0.85rem;
}

.view-full-btn:hover {
    background: #dd9a3b;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(221, 154, 59, 0.3);
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    -webkit-backdrop-filter: blur(var(--glass-blur));
    backdrop-filter: blur(var(--glass-blur));
    color: var(--paper);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 10;
    transition: all 0.3s ease;
}

.carousel-nav:hover {
    background: rgba(221, 154, 59, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.carousel-nav.prev {
    left: 20px;
}

.carousel-nav.next {
    right: 20px;
}

/* Grid View Styles */
.grid-container {
    display: none;
    margin-top: 50px;
    margin-bottom: 50px;
}

.grid-container:not(.hidden) {
    display: block;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.grid-item {
    height: 380px;
    min-width: 0;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.grid-item .certificate-front,
.grid-item .certificate-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.6s ease;
}

.grid-item .certificate-front {
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
    transform: rotateY(0deg);
    z-index: 2;
}

.grid-item .certificate-front img {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.grid-item .certificate-back h3,
.grid-item .certificate-front h3 {
    overflow-wrap: anywhere;
}

.grid-item .certificate-back {
    background: rgba(11, 11, 13, 0.9);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    transform: rotateY(180deg);
    z-index: 1;
}

/* Grid item flip - using transform on the item itself */
.grid-item.flipped {
    transform: rotateY(180deg);
}

/* Desktop hover effect - only on non-touch devices */
@media (hover: hover) and (pointer: fine) {
    .grid-item:hover {
        transform: rotateY(180deg);
    }
}

/* Carousel flip effect */
.certificate-item.flipped .certificate-front {
    transform: rotateY(180deg);
}

.certificate-item.flipped .certificate-back {
    transform: rotateY(0deg);
}

/* Section-specific styles */


/* Microsoft Section Styles */
.microsoft-section .certificate-front {
    background: linear-gradient(135deg, rgba(95, 179, 163, 0.1) 0%, rgba(60, 140, 128, 0.3) 100%) !important;
}

.microsoft-section .certificate-front h3 {
    color: #5fb3a3 !important;
}

.microsoft-section .certificate-back {
    background: rgba(95, 179, 163, 0.12) !important;
}

.microsoft-section .certificate-back h3 {
    color: #5fb3a3 !important;
}

.microsoft-section .view-full-btn {
    background: rgba(95, 179, 163, 0.2);
    border: 1px solid #5fb3a3;
    color: #5fb3a3;
}

.microsoft-section .view-full-btn:hover {
    background: #5fb3a3;
    color: white;
    box-shadow: 0 5px 15px rgba(95, 179, 163, 0.3);
}

.microsoft-section .carousel-nav:hover {
    background: rgba(95, 179, 163, 0.3);
}

/* Training Section Styles */
.training-section .certificate-front {
    background: linear-gradient(135deg, rgba(243, 85, 37, 0.1) 0%, rgba(219, 73, 29, 0.3) 100%) !important;
}

.training-section .certificate-front h3 {
    color: #dd9a3b !important;
}

.training-section .certificate-back {
    background: rgba(221, 154, 59, 0.12);
}

.training-section .certificate-back h3 {
    color: #dd9a3b !important;
}

.training-section .view-full-btn {
    background: rgba(221, 154, 59, 0.2);
    border: 1px solid #dd9a3b;
    color: #dd9a3b;
}

.training-section .view-full-btn:hover {
    background: #dd9a3b;
    color: white;
    box-shadow: 0 5px 15px rgba(221, 154, 59, 0.3);
}

.training-section .carousel-nav:hover {
    background: rgba(221, 154, 59, 0.3);
}

.hidden {
    display: none !important;
}

/* Full View Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    position: relative;
    background-color: rgba(11, 11, 13, 0.95);
    margin: 5% auto;
    padding: 0;
    width: 90%;
    max-width: 900px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #aaa;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: #dd9a3b;
}

.modal-body {
    display: flex;
    flex-direction: column;
    height: 80vh;
    overflow: hidden;
    margin-bottom: 1rem;
}

.modal-body img {
    width: 100%;
    height: 68%;
    object-fit: contain;
    background: #000;
}

.modal-info {
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.modal-info h3 {
    color: #dd9a3b;
    font-size: 1.5rem;
}

.modal-info p {
    color: #ccc;
    margin-top: 0.1rem;
    margin-bottom: 0.8rem;
    line-height: 1.5;
    justify-content: center !important;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(221, 154, 59, 0.2);
    border: 1px solid #dd9a3b;
    color: #dd9a3b;
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    text-decoration: none;
    transition: all 0.3s ease;
    align-self: flex-start;
    justify-content: center !important;
    align-items: center !important;
}

.download-btn:hover {
    background: #dd9a3b;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(221, 154, 59, 0.3);
}

/* Light mode adjustments */

.light-mode body {
    scroll-behavior: smooth !important;
}

.light-mode html {
    scroll-behavior: smooth !important;
}

.light-mode * {
    scroll-behavior: smooth !important;
}

.light-mode .certificate-front {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.light-mode .view-btn {
    background: rgba(20, 18, 14, 0.05);
    color: var(--paper-dim, #4a4458);
}

.light-mode .carousel-nav {
    background: rgba(0, 0, 0, 0.1);
    color: #edeadf;
}

.light-mode .carousel-nav:hover {
    background: rgba(95, 179, 163, 0.2);
}


.light-mode .microsoft-section .view-full-btn {
    background: rgba(95, 179, 163, 0.1);
    border-color: #5fb3a3;
    color: #5fb3a3;
}

.light-mode .microsoft-section .view-full-btn:hover {
    background: #5fb3a3;
    color: white;
}

/* Training section light mode */
.light-mode .training-section .certificate-front h3 {
    color: #dd9a3b !important;
}

.light-mode .training-section .certificate-back h3 {
    color: #dd9a3b !important;
}

.light-mode .training-section .view-full-btn {
    background: rgba(221, 154, 59, 0.1);
    border-color: #dd9a3b;
    color: #dd9a3b;
}

.light-mode .training-section .view-full-btn:hover {
    background: #dd9a3b;
    color: white;
}

.light-mode .modal-content {
    background-color: rgba(245, 241, 232, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.light-mode .modal-info h3 {
    color: #5fb3a3;
}

.light-mode .modal-info p {
    color: #555;
}

.light-mode .download-btn {
    background: rgba(95, 179, 163, 0.1);
    border-color: #5fb3a3;
    color: #5fb3a3;
}

.light-mode .download-btn:hover {
    background: #5fb3a3;
    color: white;
}

.light-mode .close-modal {
    color: #666;
}

.light-mode .close-modal:hover {
    color: #5fb3a3;
}

/* Mobile Responsiveness
   Carousel card size comes from --card-w/--card-h; certificates.js derives the
   ring radius from the card width + number of cards, so any count works. */
@media (max-width: 768px) {
    .carousel-container {
        --card-w: 240px;
        --card-h: 360px;
        perspective: 1100px;
        height: calc(var(--card-h) + 50px);
        margin-top: 20px;
        margin-bottom: 30px;
        max-width: 100%;
        overflow: hidden;
    }

    /* only the front card and its neighbours are drawn: no clutter behind */
    .certificate-item {
        opacity: 0;
        pointer-events: none;
    }

    .certificate-item.is-near {
        opacity: 0.35;
    }

    .certificate-item.is-active {
        opacity: 1;
        pointer-events: auto;
    }

    .certificate-item:hover {
        transform: none;
    }

    .certificate-front,
    .certificate-back {
        padding: 0.9rem;
    }

    .certificate-front h3 {
        font-size: 0.98rem;
        min-height: 2.6em;
        display: -webkit-box;
    }

    .certificate-front img {
        margin-bottom: 0.7rem;
    }

    .certificate-back {
        padding: 1rem;
        gap: 0.6rem;
    }

    .certificate-back h3 {
        font-size: 0.95rem;
        margin: 0;
        flex: 0 0 auto;
    }

    .certificate-back p {
        font-size: 0.8rem;
        margin: 0;
        flex: 1 1 auto;
    }

    .view-full-btn {
        padding: 0.5rem 1.1rem;
        font-size: 0.78rem;
        margin-top: 0.2rem;
        flex: 0 0 auto;
    }

    .carousel-nav {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }

    .carousel-nav.prev {
        left: 6px;
    }

    .carousel-nav.next {
        right: 6px;
    }

    .view-controls {
        flex-direction: row;
        margin-bottom: 1.2rem;
    }

    .view-btn {
        padding: 0.65rem 1.2rem;
        font-size: 0.9rem;
        justify-content: center;
    }

    .grid-container {
        margin-top: 20px;
        margin-bottom: 20px;
    }

    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.9rem;
    }

    .grid-item {
        height: 290px;
    }

    .grid-item .certificate-front,
    .grid-item .certificate-back {
        padding: 0.75rem;
    }

    .grid-item .certificate-front h3 {
        font-size: 0.85rem;
        min-height: 2.6em;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }

    .grid-item .certificate-back {
        gap: 0.4rem;
    }

    .grid-item .certificate-back h3 {
        font-size: 0.82rem;
        margin: 0;
    }

    .grid-item .certificate-back p {
        font-size: 0.7rem;
        margin: 0;
        line-height: 1.35;
        flex: 1 1 auto;
    }

    .grid-item .view-full-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.7rem;
        margin: 0;
    }

    .certificate-section {
        margin-bottom: 3.5rem;
    }
}

@media (max-width: 480px) {
    .carousel-container {
        --card-w: 220px;
        --card-h: 340px;
    }

    .grid {
        gap: 0.7rem;
    }

    .grid-item {
        height: 270px;
    }
}

@media (max-width: 360px) {
    .carousel-container {
        --card-w: 200px;
        --card-h: 320px;
    }

    .grid-item {
        height: 255px;
    }

    .grid-item .certificate-front h3 {
        font-size: 0.78rem;
    }
}

/* Reduce hover effects on touch devices */
@media (hover: none) {
    .certificate-item:hover {
        transform: none;
    }

    .certificate-item:active {
        transform: translateZ(20px) scale(1.02);
    }
}
