@font-face {
    font-family: 'SaolDisplay';
    src: url('Fonts/SaolDisplayTrial-Medium.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'AkzidenzGrotesk';
    src: url('Fonts/AkzidenzGrotesk-Regular.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
}


/* =========================
   BASE STYLES & VARIABLES
========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --twilight-indigo: #273469;
    --space-indigo: #1e2749;
    --jet-black: #30343f;
    --ghost-white: #fafaff;
    --periwinkle: #e4d9ff;
    /* Consistent gap between all grid items (projects and gallery images) */
    --gallery-gap: 1rem;
}

body {
    font-family: 'AkzidenzGrotesk', sans-serif;
    font-weight: 100;
    background-color: var(--ghost-white);
    color: var(--jet-black);
    overflow-x: hidden;
    cursor: none;
}

h1, h2, h3, h4, h5, h6,
.subsection-title,
#mg-logo {
    font-family: 'SaolDisplay', serif !important;
    font-weight: 400;
}

strong, b {
    font-family: 'SaolDisplay', serif;
    font-weight: 400;
}

/* =========================
   CUSTOM CURSOR
========================= */
.cursor {
    width: 20px;
    height: 20px;
    border: 2px solid var(--twilight-indigo);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transition: transform 0.1s ease;
}

/* =========================
   NAVIGATION
========================= */
nav {
    position: fixed;
    width: 100%;
    padding: 2rem 5%;
    background: rgba(250, 250, 255, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid rgba(39, 52, 105, 0.1);
}

nav.scrolled {
    padding: 1rem 5%;
    background: rgba(250, 250, 255, 0.95);
    box-shadow: 0 2px 10px rgba(39, 52, 105, 0.1);
}

#mg-logo {
    position: absolute;
    left: 5%;
    font-size: 1.5rem;
    color: var(--space-indigo);
    font-weight: 300;
    letter-spacing: 0.2em;
    opacity: 0;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex: 1;
}

nav a {
    color: var(--space-indigo);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
    font-size: 1.1rem;
    cursor: none;
}

nav a:hover {
    color: var(--twilight-indigo);
}

nav a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--twilight-indigo);
    transition: width 0.3s ease;
}

nav a:hover::after {
    width: 100%;
}

/* Hamburger Menu */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    position: absolute;
    right: 5%;
    z-index: 1001;
}

.hamburger span {
    width: 25px;
    height: 2px;
    background: var(--twilight-indigo);
    transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* =========================
   SECTIONS
========================= */
.hero {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

#p5-container {
    position: relative;
    width: 100%;
    height: 80vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#p5-container canvas {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
}

.hero p {
    font-size: 1.5rem;
    color: #666;
    opacity: 0;
    animation: fadeInUp 1s ease 0.3s forwards;
    text-align: center;
    margin-top: 2rem;
}

section {
    min-height: 100vh;
    padding: 5rem 5%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#contact {
    min-height: auto;
}

/* =========================
   TYPOGRAPHY
========================= */
h2 {
    font-size: 3rem;
    color: var(--space-indigo);
    margin-bottom: 3rem;
    position: relative;
    display: inline-block;
    opacity: 0;
    transform: translateX(-100px);
    text-align: center;
    width: 100%;
    font-weight: 700;
}

h2.visible {
    animation: popInLeft 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#projects h2.visible {
    animation: popInRight 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.subsection-title {
    font-size: 1.5rem;
    color: var(--space-indigo);
    margin: 2rem 0 3rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 600;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--periwinkle);
}

/* =========================
   ABOUT SECTION
========================= */
.about-content {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.2rem;
    line-height: 1.8;
    color: #555;
}

/* =========================
   PROJECTS
========================= */
.project-subsection {
    margin-bottom: 3rem;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: var(--gallery-gap);
    margin-top: 2rem;
}

.project-card {
    aspect-ratio: 1 / 1;
    position: relative;
    cursor: none;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.5s ease;
}

.project-card.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.project-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
    animation: clipReveal 0.8s ease forwards;
    transition: all 0.4s ease;
}

.project-card:hover img {
    transform: scale(1.1) rotate(1deg);
    filter: brightness(0.8);
}

.project-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1rem;
    background: linear-gradient(to top, rgba(30, 39, 73, 0.95), transparent);
    transform: translateY(100%);
    transition: all 0.4s ease;
}

.project-card:hover .project-overlay {
    transform: translateY(0);
}

.project-overlay h3 {
    color: var(--periwinkle);
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.project-overlay p {
    color: #ddd;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

/* =========================
   MODALS
========================= */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--ghost-white);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active,
.lightbox.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 100%;
    height: 100%;
    padding: clamp(2rem, 5vw, 4rem);
    animation: modalFadeIn 0.4s ease;
    overflow-y: auto;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(2rem, 4vw, 4rem);
    align-items: start;
    max-width: min(95%, 1600px);
    margin: 0 auto;
}

.modal-images {
    width: 100%;
    margin: 0;
    padding: 0;
}

/* 
 * MASONRY GRID SYSTEM
 * Uses CSS Grid with 10px row heights for optimal performance
 * JavaScript calculates row spans: span = ceil(imageHeight / 10)
 * Column gap: 1rem, Row gap: 1rem + 5px for extra vertical breathing room
 */
.image-gallery {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    column-gap: 8.1px;
    row-gap: 8.1px;
    grid-auto-rows: 2px;
    align-items: start;
    margin: 0;
    padding: 0;
}

.gallery-item {
    border-radius: 8px;
    background: transparent;
    overflow: visible;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.gallery-item img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
    cursor: none;
    transition: all 0.3s ease;
    border: none;
    display: block;
    margin: 0;
    padding: 0;
}

.gallery-item iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    cursor: none;
    transition: all 0.3s ease;
    border: none;
    display: block;
    margin: 0;
    padding: 0;
}

.gallery-item:hover {
    transform: scale(1.02);
    z-index: 10;
}

.modal-info {
    padding-top: 2rem;
}

.modal-info h3 {
    color: var(--space-indigo);
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.modal-info p {
    color: #555;
    line-height: 1.8;
    margin-bottom: 2rem;
    font-size: clamp(1rem, 1.5vw, 1.1rem);
}

.modal-info p a {
    color: var(--twilight-indigo);
    text-decoration: underline;
    transition: all 0.3s ease;
    cursor: none;
}

.modal-info p a:hover {
    color: var(--space-indigo);
    text-decoration: none;
}

.project-details {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--periwinkle);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-label {
    color: var(--twilight-indigo);
    font-size: clamp(0.8rem, 1.2vw, 0.9rem);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.detail-value {
    color: var(--jet-black);
    font-size: clamp(1rem, 1.5vw, 1.1rem);
}

.close-modal {
    position: fixed;
    top: clamp(1.5rem, 3vw, 3rem);
    right: clamp(1.5rem, 3vw, 3rem);
    font-size: clamp(2rem, 3vw, 3rem);
    color: var(--twilight-indigo);
    cursor: none;
    transition: all 0.3s ease;
    z-index: 2001;
}

.close-modal:hover {
    transform: rotate(90deg);
    color: var(--space-indigo);
}

.lightbox-close {
    position: fixed;
    top: clamp(1rem, 2vw, 2rem);
    right: clamp(1rem, 2vw, 2rem);
    font-size: 3.5rem;
    color: var(--periwinkle);
    cursor: none;
    transition: all 0.3s ease;
    z-index: 2002;
    background: rgba(30, 39, 73, 0.8);
    width: clamp(50px, 8vw, 60px);
    height: clamp(50px, 8vw, 60px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-weight: 300;
}

.lightbox-close:hover {
    transform: rotate(90deg) scale(1.1);
    background: rgba(30, 39, 73, 0.95);
}

/* =========================
   LIGHTBOX
========================= */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(30, 39, 73, 0.95);
    z-index: 2001;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox img {
    max-width: 70%;
    max-height: 80vh;
    object-fit: contain;
    animation: lightboxZoomIn 0.3s ease;
}

.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--periwinkle);
    font-size: clamp(3rem, 5vw, 4rem);
    width: clamp(50px, 8vw, 60px);
    height: clamp(50px, 8vw, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: none;
    z-index: 2003;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.lightbox-nav:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.2);
}

.lightbox-prev { left: clamp(1rem, 2vw, 2rem); }
.lightbox-next { right: clamp(1rem, 2vw, 2rem); }

.lightbox-counter {
    position: fixed;
    bottom: clamp(1.5rem, 3vw, 3rem);
    left: 50%;
    transform: translateX(-50%);
    color: var(--periwinkle);
    font-size: clamp(1rem, 2vw, 1.2rem);
    z-index: 2003;
    background: rgba(30, 39, 73, 0.7);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
}

/* =========================
   CONTACT
========================= */
.contact-links {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 3rem;
    margin: 0 auto;
}

.contact-link {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-decoration: none;
    align-items: center;
}

.contact-label {
    color: var(--twilight-indigo);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: bold;
}

.contact-value {
    color: var(--jet-black);
    font-size: 1rem;
    transition: color 0.3s ease;
}

.contact-link:hover .contact-value {
    color: var(--twilight-indigo);
}

/* =========================
   ANIMATIONS
========================= */
@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popInLeft {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes popInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes clipReveal {
    from {
        clip-path: polygon(50% 0%, 50% 0%, 50% 100%, 50% 100%);
    }
    to {
        clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
    }
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes lightboxZoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* =========================
   MOBILE RESPONSIVE
========================= */
@media (max-width: 1200px) {
    .modal-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .modal-content {
        padding: 3rem 2rem;
    }
    
    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 1024px) {
    .modal-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .modal-content {
        padding: 2rem;
    }

    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    }
    
    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 900px) {
    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 768px) {
    /* Disable custom cursor on mobile */
    .cursor { display: none; }
    body { cursor: auto; }
    * { cursor: auto !important; }
    
    /* Mobile navigation */
    .hamburger { display: flex; }
    
    nav {
        flex-direction: row;
        justify-content: space-between;
        padding: 1rem 5%;
    }
    
    #mg-logo {
        position: static;
        opacity: 1;
        font-size: 1.2rem;
    }
    
    nav ul {
        position: fixed;
        top: 0;
        right: -100%;
        height: 100vh;
        width: 70%;
        background: rgba(250, 250, 255, 0.98);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 2rem;
        transition: right 0.3s ease;
        z-index: 1000;
    }
    
    nav ul.active { right: 0; }
    nav a { font-size: 1.5rem; }
    
    /* Hero adjustments */
    #p5-container { height: 50vh; }
    #p5-container canvas { max-width: 90vw !important; }
    .hero p { font-size: 1rem; padding: 0 1rem; }
    
    /* Modal adjustments */
    .modal-grid { 
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .modal-content { 
        padding: 1.5rem 1rem; 
    }
    
    /* Gallery adjustments for mobile */
    .image-gallery {
        grid-template-columns: 1fr;
        column-gap: var(--gallery-gap);
        row-gap: calc(var(--gallery-gap) + 5px);
        grid-auto-rows: 10px;
    }
    
    /* Projects grid on mobile */
    .projects-grid {
        grid-template-columns: 1fr;
        gap: var(--gallery-gap);
    }
    
    /* Contact */
    .contact-links { flex-direction: column; gap: 2rem; }
    .contact-link { width: 100%; max-width: 300px; }
    
    /* Lightbox */
    .lightbox img {
        max-width: 90%;
        max-height: 80vh;
    }
    
    /* General */
    h2 { font-size: 2rem; }
    .subsection-title { font-size: 1.2rem; }
    section { padding: 3rem 5%; }
}