/* ══════════════════════════════════════════════════════
   modals.css
   All modal styles (project + about/skills/contact/tools)
   ══════════════════════════════════════════════════════ */

/* === MODALS — ABOUT / SKILLS / CONTACT / TOOLS === */
.about-text p {
    color: #c0c0c0;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    font-size: 0.81rem;
    font-weight: 300;
    letter-spacing: 0;
}

/* Skills and Contact modals should also match project modal text */
.skills-grid,
.contact-info {
    color: #c0c0c0;
    line-height: 1.6;
    font-size: 0.81rem;
    font-weight: 300;
    letter-spacing: 0;
}

/* About Stats Section - Compact Version */
.about-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.stat {
    text-align: center;
    padding: 0.6rem 0.4rem;
    background: rgba(245, 245, 245, 0.03);
    border-radius: 6px;
    border: 1px solid rgba(245, 245, 245, 0.08);
    transition: all 0.3s ease;
}

.stat:hover {
    background: rgba(245, 245, 245, 0.06);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.stat-number {
    display: block;
    font-size: 1.4rem;
    font-weight: 600;
    color: #f5f5f5;
    margin-bottom: 0.3rem;
    font-family: 'Space Grotesk', sans-serif;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: #c0c0c0;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
}

.skills-section {
    margin: 2rem 0;
}

.skills-section h3 {
    color: #f5f5f5;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.skill-category h4 {
    font-family: 'Space Grotesk', sans-serif;
    color: #f5f5f5;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.skill-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.skill-item {
    background: rgba(212, 212, 212, 0.1);
    color: #d4d4d4;
    padding: 0.4rem 0.8rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(200, 216, 228, 0.4);
}

.contact-intro {
    color: #c0c0c0;
    line-height: 1.6;
    font-size: 0.81rem;
    font-weight: 300;
    margin-bottom: 1.25rem;
}

.contact-form .form-field {
    margin-bottom: 1rem;
}

.contact-form .form-field label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a0a0a0;
    margin-bottom: 0.35rem;
    font-family: 'Space Grotesk', sans-serif;
}

.contact-form .form-field input,
.contact-form .form-field select,
.contact-form .form-field textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(245, 245, 245, 0.15);
    background: rgba(26, 26, 26, 0.85);
    color: #f5f5f5;
    font-family: 'Work Sans', sans-serif;
    font-size: 0.9rem;
}

.contact-form .form-field textarea {
    resize: vertical;
    min-height: 6rem;
}

.contact-form .contact-btn {
    margin-top: 0.5rem;
    width: 100%;
}

.form-success {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid rgba(200, 216, 228, 0.35);
    border-radius: 8px;
    background: rgba(200, 216, 228, 0.06);
}

.form-success p {
    margin: 0;
    color: #e0e0e0;
    font-size: 0.85rem;
}

.modal-meta-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.meta-year,
.meta-cat,
.meta-sw {
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-colour);
    font-weight: 500;
}

.meta-sep {
    color: rgba(245, 245, 245, 0.35);
    font-weight: 400;
}

/* === MODALS — PROJECT === */
.modal {
    display: none;
    position: fixed;
    /* Render below fixed white header */
    top: 82px;
    left: 0;
    width: 100%;
    height: calc(100vh - 82px);
    /* Keep header in foreground (header is z-index: 4000) */
    z-index: 3000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: fixed;
    top: 82px;
    left: 0;
    width: 100vw;
    height: calc(100vh - 82px);
    background: rgba(26, 26, 26, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    touch-action: none;
}

.modal-content {
    position: relative;
    background: transparent;
    border-radius: 8px;
    width: 500px;
    /* Use dynamic viewport so mobile browser chrome + 100% zoom don’t clip the bottom */
    /* Use modal viewport (already offset below header) to avoid top clipping under navbar */
    max-height: calc(100% - 24px);
    max-height: calc(100vh - 82px - 24px);
    max-height: calc(100dvh - 82px - 24px);
    margin-top: 16px;
    margin-bottom: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: none;
    border: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.modal#about-modal .modal-content,
.modal#skills-modal .modal-content,
.modal#contact-modal .modal-content,
.modal#modal .modal-content {
    width: min(625px, 92vw);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: #f5f5f5;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.modal-close:hover {
    color: #f5f5f5;
    background: rgba(0, 0, 0, 0.9);
}

.modal-title {
    font-size: 1.45rem;
    color: #f5f5f5;
    font-weight: 300;
    margin: 0 0 1rem 0;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.modal-scrollable-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(26, 26, 26, 0.8);
    backdrop-filter: blur(15px);
    border-radius: 0 0 8px 8px;
    /* min-height:0 lets this region shrink inside flex so gallery / iframe aren’t clipped */
    min-height: 0;
    width: 100%;
       /* FIX FOR ANDROID: Stops scroll chaining to the body */
    overscroll-behavior: contain;
}

.modal-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 0;
    width: 100%;
    flex-shrink: 0;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    backdrop-filter: blur(15px);
    height: auto;
    min-height: 140px;
    max-height: 400px;
}

.modal-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 8px 8px 0 0;
    transition: opacity 0.75s ease, transform 0.75s ease;
}

.modal-info {
    padding: 1rem 2rem 1rem 2rem;
    background: transparent;
    /* flex-shrink: 0 — if this block can shrink (0 1 auto + min-height:0), the gallery row
       lays out too high while description still paints → thumbnails overlap text */
    flex: 0 0 auto;
    overflow-y: visible;
    backdrop-filter: none;
    border-radius: 0;
    scroll-behavior: smooth;
}

.modal-gallery-container {
    position: relative;
    margin: 0;
    padding: 1rem 2rem 1rem 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    background: transparent;
    backdrop-filter: none;
    border-radius: 0 0 8px 8px;
    min-height: 60px;
    width: 100%;
}

.modal-gallery {
    display: flex;
    gap: 0.8rem;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    padding: 0;
    min-height: 50px;
    align-items: center;
}

.modal-gallery::-webkit-scrollbar {
    display: none;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 1px solid rgba(245, 245, 245, 0.3);
    color: #d4d4d4;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    border-radius: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    font-weight: 300;
    letter-spacing: 0.5px;
}

.gallery-nav:hover {
    border-color: #f5f5f5;
    color: #f5f5f5;
    background: rgba(245, 245, 245, 0.05);
}

.gallery-nav-left {
    left: 0.5rem;
}

.gallery-nav-right {
    right: 0.5rem;
}

.gallery-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.modal-description {
    color: #c0c0c0;
    line-height: 1.6;
    margin-bottom: 2rem;
    font-size: 0.81rem;
    font-weight: 300;
    letter-spacing: 0;
}

.modal-description p {
    margin-bottom: 1rem;
}

.modal-description p:last-child {
    margin-bottom: 0;
}

.modal-gallery img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.75s ease;
    border: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.modal-gallery img:hover {
    transform: scale(1.03);
    border-color: #d4d4d4;
}

/* Hide scrollbars on modals for cleaner look */
.modal-content::-webkit-scrollbar {
    display: none;
}

.modal-info::-webkit-scrollbar {
    display: none;
}

/* Contact Section */
.contact-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(212, 212, 212, 0.1);
}

.contact-section h3 {
    font-size: 1.5rem;
    font-weight: 300;
    color: #f5f5f5;
    margin-bottom: 1.5rem;
    text-align: center;
    letter-spacing: 0.05em;
}

.contact-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem;
    background: rgba(212, 212, 212, 0.05);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.contact-item:hover {
    background: rgba(212, 212, 212, 0.1);
    transform: translateY(-2px);
}

.contact-icon {
    font-size: 1.2rem;
    opacity: 0.8;
}

.contact-text {
    color: #d4d4d4;
    font-size: 0.95rem;
    font-weight: 400;
}

.contact-cta {
    text-align: center;
    margin-top: 2rem;
}

.contact-cta p {
    color: #e0e0e0;
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.contact-btn {
    padding: 0.8rem 2rem;
    background: rgba(212, 212, 212, 0.1);
    border: 1px solid #d4d4d4;
    color: #d4d4d4;
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.contact-btn:hover {
    background: #d4d4d4;
    color: #1a1a1a;
    transform: translateY(-2px);
}

/* === MODALS — BASE === */
.modal-logo {
    width: clamp(56px, 4.2vmin, 72px);
    height: clamp(56px, 4.2vmin, 72px);
    margin-bottom: clamp(0.45rem, 0.8vmin, 0.65rem);
    opacity: 0.9;
    filter: brightness(1.1);
    transition: all 0.3s ease;
}

.modal-logo:hover {
        opacity: 1;
    transform: scale(1.05);
    filter: brightness(1.2);
}

/* Modal Hero Sections - Unified with Project Modals */
.skills-hero,
.contact-hero,
.about-hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: clamp(0.9rem, 1.4vmin, 1.15rem) clamp(1rem, 2.4vmin, 1.6rem) clamp(1rem, 1.8vmin, 1.35rem);
    min-height: 0;
    background: transparent;
}

.skills-hero h2,
.contact-hero h2,
.about-hero h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.2rem, 1.05rem + 0.55vw, 1.45rem);
    font-weight: 300;
    color: #f5f5f5;
    margin-bottom: clamp(0.35rem, 0.75vmin, 0.5rem);
    letter-spacing: 0.02em;
    line-height: 1.25;
}

.skills-hero p,
.contact-hero p,
.about-hero p {
    font-family: 'Work Sans', sans-serif;
    font-size: clamp(0.76rem, 0.72rem + 0.22vw, 0.84rem);
    color: #c0c0c0;
    max-width: 500px;
    line-height: 1.55;
    font-weight: 300;
    letter-spacing: 0;
    margin: 0;
}

/* Prevent hero subtitles from ballooning on smaller desktop/laptop screens */
@media (min-width: 769px) {
    .skills-hero p,
    .contact-hero p,
    .about-hero p {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

.about-hero p + p {
    margin-top: 0.35rem;
}

/* modals.css */

body.modal-open {
    overflow: hidden !important;
    /* Prevents the 'pull-to-refresh' or address bar movement 
       that often triggers background scrolling on Android */
    overscroll-behavior: none; 
}

/* Ensure the modal content CAN still scroll */
.modal-scrollable-content {
    touch-action: pan-y; /* Allows vertical scrolling inside the modal only */
    -webkit-overflow-scrolling: touch;
}


/* --- MOBILE REFINEMENTS --- */
@media (max-width: 768px) {
    /* 1. OVERRIDE THE CENTERING TO STOP TOP CLIPPING */
    .modal.active {
        align-items: flex-start !important; 
        padding-top: 10px !important; /* Small gap below navbar */
    }

    .modal-content {
        width: 94vw !important;
        margin: 0 auto !important;
        /* Absolute hard limit to prevent bottom clipping */
        max-height: calc(100dvh - 82px - 20px) !important; 
        display: flex !important;
        flex-direction: column !important;
    }

    /* 2. THE TELEPORT FIX (Gallery above Text) */
    .modal-scrollable-content {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Gallery jumps to the top of the scrollable area */
    .modal-gallery-container {
        order: 1 !important;
        padding: 1rem !important;
        border-top: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    /* Info (Title + Text) drops below the gallery */
    .modal-info {
        order: 2 !important;
        padding: 1rem 1.2rem !important;
    }

    /* 3. FORMATTING */
    .modal-image-container {
        height: 180px !important;
        min-height: 180px !important;
        touch-action: pan-y;
       
    }

    .modal-image {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    .modal-title {
        font-family: 'Space Grotesk', sans-serif !important;
        font-size: 1.25rem !important;
        text-align: center !important;
        margin-bottom: 1rem !important;
    }

    .modal-description {
        text-align: justify !important;
        text-justify: inter-word !important;
        font-size: 0.81rem !important;
    }
}
