/* PROFILE.CSS - THE FINAL TWO-PAGE SCROLLING LAYOUT V4 */

:root {
    --frame-border-width: 15px;
}

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* Prevent default scrollbars */
    background-color: var(--background-dark);
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.profile-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory; /* The magic for the one-pager scroll */
}

.profile-section {
    height: 100vh;
    width: 100%;
    scroll-snap-align: start; /* Each section is a snap point */
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* --- SECTION 1: SHOWCASE FRAME --- */
.profile-frame {
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 4px;
    border: var(--frame-border-width) solid;
    border-image-slice: 1;
    border-image-source: var(--theme-gradient);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

.collage-container {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.certificate-grid-public {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 15px;
    height: 100%;
}

.cert-card-public {
    position: relative;
    overflow: hidden;
    background-color: var(--background-light);
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* aspect-ratio removed from here to fix desktop */
}
.cert-card-public:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.5);
}

.cert-card-overlay {
    position: absolute; inset: 0; display: flex;
    justify-content: space-between; align-items: flex-end;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 80%);
    padding: 12px; color: #fff; opacity: 0; transition: opacity 0.3s ease;
}
.cert-card-public:hover .cert-card-overlay { opacity: 1; }
.cert-card-overlay p { margin: 0; font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.link-indicator-public {
    background: rgba(255,255,255,0.15); width: 28px; height: 28px;
    border-radius: 50%; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0;
}
.link-indicator-public img { width: 16px; height: 16px; object-fit: contain; }
.no-certs-message, .no-results-message-search {
    grid-column: 1 / -1; display: flex; align-items: center; justify-content: center;
    min-height: 50vh; color: var(--text-secondary); font-size: 1.2rem;
}

/* --- REFINED UTILITY FOOTER --- */
.profile-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    flex-shrink: 0;
}
.footer-user-title { flex: 1; text-align: left; min-width: 0; }
.footer-user-title h3 {
    font-size: 0.9rem; color: var(--text-secondary);
    font-weight: 500; margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.footer-center-controls {
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}
.public-search-bar { position: relative; }
.public-search-bar .fa-search {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%); color: var(--text-secondary);
    font-size: 0.8rem;
}
#public-cert-search {
    background-color: rgba(0,0,0,0.2); border: 1px solid var(--border-color);
    border-radius: 6px; padding: 6px 12px 6px 30px;
    color: var(--text-primary); font-size: 0.8rem; width: 200px;
    transition: all 0.2s ease;
}
#public-cert-search:focus {
    outline: none; border-color: var(--text-primary);
    background-color: var(--background-dark);
}
.pagination-dots { text-align: center; }
.dot {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; background-color: var(--border-color);
    margin: 0 4px; transition: all 0.3s ease; transform: scale(0.8);
}
.dot.active, .dot:hover { background: var(--theme-gradient); transform: scale(1); }
.footer-powered-by {
    flex: 1; display: flex; justify-content: flex-end;
    align-items: center; gap: 8px; color: var(--text-secondary);
    font-size: 0.8rem; opacity: 0.7;
}
.footer-powered-by a {
    display: flex; align-items: center; gap: 6px;
    text-decoration: none; color: var(--text-secondary);
    font-weight: 600; font-size: 0.9rem; transition: color 0.2s ease;
}
.footer-powered-by a:hover { color: var(--text-primary); }
.footer-powered-by img { height: 22px; }

/* --- SECTION 2: DETAILS FRAME --- */
.profile-details-frame {
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 15px;
    border: var(--frame-border-width) solid;
    border-image-slice: 1;
    border-image-source: var(--theme-gradient);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    position: relative;
}

.details-content {
    max-width: 1280px;
    width: 100%;
    margin: auto;
    display: flex;
    flex-direction: column;
    padding: 30px 40px;
    height: 100%;
    box-sizing: border-box;
}

.details-header {
    display: flex;
    align-items: center;
    gap: 40px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.pfp-container {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    padding: 3px;
    background: var(--theme-gradient);
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.pfp-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.info-stack {
    text-align: left;
    flex-grow: 1;
    min-width: 0; /* Prevents flex items from overflowing */
}

.profile-name {
    display: flex;
    align-items: center;
    gap: 15px;
}
.info-stack h1 { font-size: 2.6rem; margin: 0; }
.verified-badge {
    height: 28px;
    width: auto;
}

.occupation-location-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 5px;
}
.occupation-location-line h2 {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
}
.location-display {
    font-size: 1rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.location-display i {
    color: var(--theme-color);
}

.profile-sub-details {
    margin-top: 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.profile-sub-details span {
    display: flex;
    align-items: center;
}
.profile-sub-details span::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--theme-gradient);
    margin-right: 12px;
}
.theme-color-text {
    color: var(--theme-color);
    font-weight: 600;
}

.stats-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 20px;
}
.stat-item { text-align: right; }
.stat-number { font-size: 2rem; font-weight: 700; display: block; }
.stat-label { font-size: 0.9rem; color: var(--text-secondary); }
.social-links-profile {
    display: flex;
    align-items: center;
    gap: 20px;
}
.social-links-profile a {
    color: var(--text-secondary);
    transition: color 0.2s ease, transform 0.2s ease;
}
.social-links-profile a i {
    font-size: 1.8rem;
}
.social-links-profile a:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}
#share-profile-btn i.fa-check {
    color: var(--theme-color);
}
.social-links-profile a:hover .fa-youtube { color: #FF0000; }

.profile-main-content {
    display: grid;
    grid-template-columns: 1fr 320px; /* Description | Sidebar */
    gap: 40px;
    flex-grow: 1;
    margin-top: 30px;
    overflow: hidden;
}

.profile-description {
    text-align: left;
    line-height: 1.7;
    color: var(--text-secondary);
    overflow-y: auto; 
    padding-right: 10px;
}
.profile-description h3 { font-size: 1.4rem; color: var(--text-primary); margin-top: 0; margin-bottom: 15px; }
.profile-description p { 
    white-space: pre-wrap; 
    margin: 0; 
    font-size: 1rem;
}

.profile-side-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-height: 0;
}
.side-widget {
    background-color: rgba(0,0,0,0.15);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}
.skills-widget {
    flex: 1 1 auto;
    min-height: 0;
}
.side-widget h3 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    flex-shrink: 0;
}
.skills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: flex-start;
    overflow-y: auto;
    padding-right: 8px;
}
.skills-container::-webkit-scrollbar,
.profile-description::-webkit-scrollbar {
  width: 6px;
}
.skills-container::-webkit-scrollbar-track,
.profile-description::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}
.skills-container::-webkit-scrollbar-thumb,
.profile-description::-webkit-scrollbar-thumb {
  background-color: var(--theme-color);
  border-radius: 3px;
}
.skill-tag {
    background: var(--theme-gradient);
    color: var(--theme-button-text-color);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
}
.links-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.external-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
    font-size: 0.9rem;
}
.external-link:hover {
    color: var(--text-primary);
}
.external-link i {
    color: var(--theme-color);
}

.details-footer {
    position: absolute;
    bottom: 30px;
    right: 40px;
}
.powered-by-footer {
    opacity: 0.6; display: flex; align-items: center;
    gap: 8px; font-size: 0.9rem;
}
.powered-by-footer span { color: var(--text-secondary); }
.powered-by-footer a {
    color: var(--text-primary); text-decoration: none; display: flex;
    align-items: center; gap: 6px; font-weight: 600;
    transition: opacity 0.2s ease;
}
.powered-by-footer a:hover { opacity: 0.8; }
.powered-by-footer img { height: 22px; }

/* --- VIEWER MODAL --- */
.btn { padding: 10px 20px; border-radius: 8px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; transition: all 0.2s ease; border: none; cursor: pointer; }
.btn-theme { background: var(--theme-gradient); color: var(--theme-button-text-color); }
.btn-theme:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.8); backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; box-sizing: border-box;}
.viewer-content { background-color: var(--background-light); border-radius: 16px; width: 100%; max-width: 80vw; max-height: 85vh; display: flex; position: relative; border: 1px solid var(--border-color); box-shadow: 0 20px 50px rgba(0,0,0,0.5); animation: zoomIn 0.3s ease-out; }
@keyframes zoomIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.viewer-preview { flex-basis: 75%; background-color: var(--background-dark); border-radius: 16px 0 0 16px; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: hidden; position: relative; }
.viewer-preview img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.viewer-details { flex-basis: 25%; padding: 30px; display: flex; flex-direction: column; overflow-y: auto; }
.viewer-details h2 { color: var(--text-primary); font-size: 1.5rem; margin: 0 0 20px 0; line-height: 1.3; }
.viewer-details p { color: var(--text-secondary); margin-bottom: 15px; font-size: 0.9rem; }
.viewer-details strong { color: var(--text-primary); display: block; margin-bottom: 3px; }
#viewer-link-container { margin-top: auto; border-top: 1px solid var(--border-color); padding-top: 20px; }
#viewer-link-container .btn { width: 100%; justify-content: center; }
.gallery-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; background: rgba(0,0,0,0.4); color: #fff; border: none; border-radius: 50%; cursor: pointer; font-size: 1.2rem; z-index: 1011; transition: background-color 0.2s ease; }
.gallery-nav:hover { background: rgba(0,0,0,0.7); }
#prev-cert-btn { left: 15px; }
#next-cert-btn { right: 15px; }
.loader { border: 5px solid var(--border-color); border-top: 5px solid var(--text-primary); border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.modal-close { position: absolute; top: 15px; right: 15px; background: none; border: none; color: var(--text-secondary); font-size: 1.5rem; cursor: pointer; z-index: 10;}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 1200px) {
    .certificate-grid-public {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    /* --- General Mobile Layout --- */
    html, body {
        overflow: auto; /* Enable normal scrolling */
    }
    .profile-container {
        height: auto;
        overflow-y: visible;
        scroll-snap-type: none; /* Disable scroll snapping */
    }
    .profile-section, .profile-frame, .profile-details-frame {
        height: auto; /* Let sections grow with content */
        min-height: 100vh; /* Ensure they at least fill the screen */
    }

    /* --- Showcase Section --- */
    .certificate-grid-public {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
        height: auto;
    }
    /* --- FINAL FIX IS HERE --- */
    .certificate-grid-public .cert-card-public {
        aspect-ratio: 4 / 3; /* Apply aspect ratio ONLY on smaller screens */
    }
    .profile-frame, .profile-details-frame {
        padding: 10px;
        border-width: 10px;
    }
    
    .collage-container { 
        padding: 10px; 
        overflow: visible; 
    }
    /* --- END OF FINAL FIX --- */

    /* --- Details Section --- */
    .details-content { padding: 20px; }
    .details-header {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }
    .info-stack { text-align: center; }
    .profile-name { justify-content: center; }
    .occupation-location-line { justify-content: center; }
    .profile-sub-details { justify-content: center; }
    .stats-stack {
        align-items: center;
        flex-direction: row;
        gap: 30px;
    }
    .profile-main-content {
        grid-template-columns: 1fr;
    }
    .profile-description, .profile-side-content {
        overflow-y: visible;
    }
    .details-footer {
        position: static;
        margin-top: 40px;
        display: flex;
        justify-content: center;
    }

    /* --- Modal Viewer --- */
    .viewer-content {
        flex-direction: column;
        max-width: 95vw;
        max-height: 90vh;
    }
    .viewer-preview {
        flex-basis: 60%;
        border-radius: 16px 16px 0 0;
    }
    .viewer-details {
        flex-basis: 40%;
    }
}

@media (max-width: 768px) {
    /* --- Showcase Section --- */
    .profile-footer {
        flex-direction: column;
        gap: 20px;
        padding: 15px;
    }
    .footer-user-title { order: 1; text-align: center; }
    .footer-powered-by { order: 2; }
    .footer-center-controls {
        order: 3;
        flex-direction: column;
        gap: 15px;
        width: 100%;
    }
    #public-cert-search { width: 100%; box-sizing: border-box; }
    
    /* --- Details Section --- */
    .info-stack h1 { font-size: 2rem; }
    .occupation-location-line h2 { font-size: 1.1rem; }
    .pfp-container { width: 120px; height: 120px; }
    
    /* --- Modal Viewer --- */
    .gallery-nav { display: none; } /* Nav buttons are hard to use on mobile */
}

@media (max-width: 480px) {
    .certificate-grid-public {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .profile-frame, .profile-details-frame {
        border-width: 8px;
    }
    .info-stack h1 { font-size: 1.8rem; }
    .profile-sub-details {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}