@import url('https://fonts.googleapis.com/css2?family=Zen+Kaku+Gothic+New:wght@300;400;500;700;900&display=swap');

:root {
    --sidebar-width: 22em;
    --sidebar-padding-top: 3em;
    --logo-width: clamp(6em, 18vw, 10em);
    --profile-max-width: 400px;
    --content-max-width: 50em;
    --content-padding: 6em;
    --scrollbar-width: calc(100vw - 100%);
}

/* Base reset */
html, body {
    font-family: "Zen Kaku Gothic New", sans-serif;
    margin: 0;
    padding: 0;
    color: #111;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}

body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

*, *::before, *::after { 
    box-sizing: inherit; 
}

html {
    overflow-y: scroll;
}

/* Layout */
.page {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100%;
    align-items: center;
    flex: 1 0 auto; /* Make pages take up available space */
}

.header {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header > * {
    width: 100%;
    max-width: none;
    margin: 0;
}

.small-content {
    margin: 3em 0;
    max-width: 800px;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-sizing: border-box;
}

    .large-content {
    margin: 3em 0;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.huge-content {
    margin: 1em auto;
    width: 100%;
    max-width: calc(100% - 2em);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    overflow-x: hidden;
}/* Ensure all direct children of large-content have consistent width */
.large-content > * {
    width: 100%;
}

.large-content img {
    width: 100%;
    height: auto;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #000;
    color: #fff;
    position: fixed;
    left: 0;
    top: 0;
    height: 100dvh; /* dynamic viewport height */
    max-height: 100dvh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: left;
    padding: var(--sidebar-padding-top) 4em;
    text-align: left;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
    overscroll-behavior: contain; /* prevent scroll chain */
}

.sidebarlogo {
    width: var(--logo-width);
    max-width: var(--logo-width);
    height: auto;
    display: block;
    margin-bottom: 0;
    flex: 0 0 auto;
    object-fit: contain;
}

.sidebarlogoname {
    width: var(--logo-width);
    display: block;
    margin-bottom: 1.5em;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 0;
    width: calc(100vw - var(--sidebar-width) - var(--scrollbar-width));
    min-height: 100vh;
    box-sizing: border-box;
    opacity: 0;
    animation: fadeIn 1s ease forwards;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    /* Make sure main content takes up full height and pushes footer to bottom */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 0.5em;
}

h1 {
    font-size: 1.5rem;
    letter-spacing: 0.1em;
    font-weight: 700;
}

h2 {
    font-size: 1rem;
    letter-spacing: 0.1em;
    font-weight: 400;
}

.main-content h2 {
    padding-bottom: 3em;
    margin-bottom: 2em;
    position: relative;
}

.main-content h2::after {
    content: '';
    position: absolute;
    bottom: 0.5em;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background-color: currentColor;
    opacity: 0.3;
}

#about h1, #about h2 {
    padding-bottom: 0;
}

#about h1::after, #about h2::after {
    display: none;
}

p {
    margin: 0 0 1em;
    line-height: 1.5;
}

/* Navigation */
.sidebar nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar nav ul li {
    margin: 0 0 8px;
}

.sidebar nav a {
    display: inline-block;
    padding: 6px 0;
    color: inherit;
    text-decoration: none;
    opacity: .5;
    transition: opacity .18s ease;
}

.sidebar nav a:hover, 
.sidebar nav a.active {
    opacity: 1;
}

/* Subcategories */
.subcategory {
    font-variant: all-small-caps;
    padding-bottom: .5em;
    padding-left: 1em;
    position: relative;
}

.subcategory::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 1px;
    background-color: #fff;
    opacity: 0.5;
    transition: width 160ms ease, opacity 160ms ease;
}

.subcategory:has(a.active)::before {
    width: 2px;
    opacity: 1;
}

.subcategory p {
    font-size: 20px;
    margin: 0 0 .15em;
    line-height: 0.85;
}

.subcategory p:first-of-type {
    font-weight: 200;
}

.subcategory p:nth-of-type(2) {
    font-weight: 700;
}

/* Hamburger Menu */
.hamburger {
    display: none;
    position: fixed;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: #000;
    color: #fff;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: background-color 160ms ease, color 160ms ease, transform 120ms ease;
    z-index: 10000;
}

/* Video Components */
.video-wrapper {
    position: relative;
    width: 100%;
    max-width: none;
    height: 0;
    overflow: hidden;
    margin: 0 auto;
}

.video-wrapper.ultrawide {
    padding-bottom: 42.1875%;
}

.video-wrapper.widescreen {
    padding-bottom: 56.25%;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Ensure video-wrapper inside large-content works properly */
.large-content .video-wrapper {
    width: 90%;
    max-width: 90%;
}

/* Grids */
.banner-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0 auto;
    padding: 0;
}

.banner-grid img {
    flex: 1;
    max-width: 33.333%;
    height: auto;
    object-fit: contain;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    width: 100%;
    margin: 0 auto 1rem;
    padding: 0;
    box-sizing: border-box;
}

@media (max-width: 960px) {
    .video-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

.huge-content .centered-video {
    width: 100%;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
}

.gif-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    width: 100%;
    margin: 3rem 0;
    box-sizing: border-box;
    justify-content: center;
}

.gif-grid img {
    flex: 1 1 200px; /* grow, shrink, basis */
    min-width: 0; /* allows shrinking below basis */
    max-width: calc(250px - 1.5rem); /* prevents growing too large */
    height: auto;
    object-fit: contain;
}

.projects-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    width: 100%;
    margin: 0 auto;
    padding: 0 2rem;
    justify-content: center;
    align-items: center;
    align-content: center;
}

/* Project Components */
.project-link {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    transition: transform 200ms ease;
    width: 166px;
    flex-shrink: 0;
}

.project-link:hover {
    transform: translateY(-4px) rotate(1deg);
}

.project-link video,
.video-grid video,
.centered-video video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

/* Hero Images */
.project-hero-image {
    position: relative;
    width: calc(100vw - var(--scrollbar-width));
    height: 50vh;
    min-height: 600px;
    max-height: 1000px;
    margin: -6em;
    margin-bottom: 3rem;
    background-size: cover;
    background-position: top;
    background-repeat: no-repeat;
    overflow: hidden;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.hero-overlay video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    transform: translate(0, 5em);
}

/* Contact Form */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 30em;
    margin: 2rem auto;
    padding: 0 2rem;
    box-sizing: border-box;
}

.contact-form input,
.contact-form textarea {
    padding: 0.75rem 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 200ms ease;
}

.contact-form input:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: #000;
}

.contact-form textarea {
    resize: vertical;
    min-height: 120px;
}

.contact-form button {
    font-family: inherit;
    font-size: 1rem;
    align-self: center;
    margin-top: 1rem;
    cursor: pointer;
    background-color: #000;
    border-radius: 2rem;
    color: #fff;
    padding: 1rem 2rem;
    font-weight: 600;
    box-shadow: none;
    border: 0px solid #000;
    text-decoration: none;
    transition: transform 200ms ease;
}

.contact-form button:hover {
    transform: translateY(-4px);
}

.button {
    font-family: inherit;
    font-size: 1rem;
    align-self: center;
    cursor: pointer;
    background-color: #000;
    border-radius: 2rem;
    color: #fff;
    padding: 1rem 2rem;
    font-weight: 600;
    box-shadow: none;
    border: 0px solid #000;
    text-decoration: none;
    transition: transform 200ms ease;
    max-width: 300px;
}

.button-margin {
    margin: 3rem auto 4rem auto;
}

.button:hover {
    transform: translateY(-4px);
}

/* Footer */
.site-footer {
    background-color: #000;
    color: #fff;
    padding: 2.5rem;
    width: 100%;
    margin-top: auto; /* Push footer to bottom of flex container */
    flex-shrink: 0; /* Prevent footer from shrinking */
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.footer-link {
    color: #fff;
    text-decoration: none;
    transition: opacity 200ms ease;
    font-weight: 600;
}

.footer-link:hover {
    opacity: 0.7;
}

.footer-text {
    color: #fff;
    font-weight: 200;
}

.footer-separator {
    margin: auto 2rem;
    color: #fff;
    opacity: 0.5;
    font-weight: 200;
}

/* Masonry Gallery */
.gallery-container {
    width: 100%;
    padding: 0 2rem;
    box-sizing: border-box;
}

.masonry-gallery {
    column-count: 4;
    column-gap: 1.5rem;
    width: 100%;
}

.masonry-item {
    break-inside: avoid;
    margin-bottom: 1.5rem;
}

.masonry-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 200ms ease;
}

.masonry-item img:hover {
    transform: translateY(-4px);
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 10001;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
}

.lightbox-close {
    position: fixed;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.lightbox-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    color: #f1f1f1;
    font-size: 60px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.lightbox-prev {
    left: 35px;
}

.lightbox-next {
    right: 35px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================================================
   Responsive Design - Screen size breakpoints in descending order
   ========================================================================== */

@media (max-width: 1440px) {
    .small-content,
        .large-content {
            margin: 2em 0rem;
            padding: 0 8rem;
    }
}

@media (max-width: 1024px) {
    .masonry-gallery {
        column-count: 2;
    }
}

/* Specific styles for tablets in landscape mode */
@media (max-width: 960px) and (orientation: landscape) {
    .sidebar {
        position: fixed;
        height: 100dvh; /* Use dynamic viewport height */
        max-height: 100dvh;
        padding: 0.5em 1em;
        display: flex;
        flex-direction: column;
        overflow-y: auto; /* Auto overflow on container */
    }

    .sidebar.open {
        transform: translateY(0);
        pointer-events: auto;
    }

    /* Compact the header section */
    .sidebar .sidebarlogo {
        width: 80px;
        margin: 0.5em auto 0.25em;
    }

    .sidebar .sidebarlogoname {
        width: 80px;
        margin: 0 auto 0.5em;
    }

    /* Make the navigation section independently scrollable */
    .sidebar nav {
        flex: 1;
        overflow-y: scroll; /* Changed to scroll */
        margin: 0.5em 0;
        -webkit-overflow-scrolling: touch;
        mask-image: linear-gradient(to bottom, transparent 0, black 1rem, black calc(100% - 1rem), transparent 100%);
        -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 1rem, black calc(100% - 1rem), transparent 100%);
        padding: 1rem 0;
    }

    .sidebar nav ul {
        margin: 0;
        padding: 1rem 0 3rem;
    }

    /* Tighter spacing for nav items */
    .category {
        margin-bottom: 0.75em;
    }

    .subcategory {
        margin-bottom: 0.5em;
    }

    /* Make links easier to tap */
    .sidebar nav a {
        padding: 0.5em 0;
        display: inline-block;
    }
}

@media (max-width: 960px) {
    .small-content,
    .large-content {
        margin: 2em 0rem;
        padding: 0 2rem;
    }

    .gif-grid img {
        max-width: calc(250px - 1.5rem);
    }
    
    .banner-grid {
        flex-direction: column;
    }
    
    .banner-grid img {
        max-width: 100%;
    }
    
    .banner-grid img:last-child {
        margin-bottom: 0;
    }
    
    .hamburger { 
        display: inline-flex;
        position: fixed;
        z-index: 2001;
    }
    
    body.sidebar-open {
        position: fixed;
        width: 100%;
        height: var(--window-height, 100%);
        overflow: hidden;
    }
    
    .sidebar {
        position: fixed;
        width: 100%;
        height: 100dvh; /* dynamic viewport height */
        max-height: 100dvh;
        top: 0;
        left: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        transition: transform 320ms ease;
        pointer-events: none;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 1em;
        padding-bottom: calc(1em + env(safe-area-inset-bottom)); /* iOS safe area */
        z-index: 2000;
        transform: translateY(-100%);
        display: flex;
        -webkit-overflow-scrolling: touch;
        background: #000;
    }
    
    .sidebar.open {
        transform: translateY(0);
        pointer-events: auto;
        padding: 1em;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .sidebar.collapsed {
        transform: translateY(-100%);
        pointer-events: none;
        padding: 1em;
    }
    
    .sidebar .sidebarlogo {
        margin: 0 auto .75em;
        width: 80%;
        max-width: 200px;
    }
    
    .sidebar .sidebarlogoname {
        margin: 0 auto 2.5em;
        width: 80%;
        max-width: 200px;
    }
    
    .sidebar nav {
        width: 100%;
        text-align: center;
        flex: 1 1 auto;
        margin-top: 1em;
        position: relative;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        mask-image: linear-gradient(to bottom, 
            transparent 0, 
            black 1rem, 
            black calc(100% - 2rem), 
            transparent 100%
        );
        -webkit-mask-image: linear-gradient(to bottom, 
            transparent 0, 
            black 1rem, 
            black calc(100% - 2rem), 
            transparent 100%
        );
    }
    
    .sidebar nav ul {
        padding: 1rem 0;
        margin: 0;
        padding-bottom: calc(4em + env(safe-area-inset-bottom));
        list-style: none;
        position: relative;
    }

    .sidebar nav a {
        display: inline-block;
        text-align: center;
        width: auto;
        margin: 0 auto;
    }
    
    .subcategory {
        padding-left: 0;
        text-align: center;
    }
    
    .subcategory::before {
        display: none;
    }

    .main-content {
        margin-left: 0;
        width: calc(100vw - var(--scrollbar-width));
    }
    
    .contact-form {
        width: 100%;
        max-width: 100%;
        padding: 0 1rem;
    }
    
    .project-hero-image {
        width: 100vw;
        margin-left: -1rem;
        margin-right: -1rem;
        height: 60vh;
        min-height: 400px;
    }
    
    .hero-overlay video {
        max-height: 40%;
    }
    
    .content {
        padding: 2rem 1rem;
    }
    
    .projects-grid {
        gap: 1rem;
    }
    
    .project-link {
        width: calc(50% - 0.5rem);
        max-width: 200px;
    }


}

@media (max-width: 600px) {
    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
    }

    .footer-separator {
        display: none;
    }

    .masonry-gallery {
        column-count: 1;
    }

    .lightbox-arrow {
        font-size: 40px;
    }

    .lightbox-prev {
        left: 15px;
    }

    .lightbox-next {
        right: 15px;
    }
}



/* Center content vertically on About and Contact pages */
#about,
#contact {
    justify-content: center;
}

#about .small-content,
#contact .large-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
    padding: 0 1rem;
    box-sizing: border-box;
}

@media (max-width: 960px) {
    #about .huge-content {
        margin: 0;
        padding: 1em;
        width: 100%;
    }
    
    #about .small-content {
        margin: 0;
        width: 100%;
    }
    
    #about .small-content img {
        max-width: 100%;
        height: auto;
    }
}

/* Utility Classes */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}