/* =========================================
   VARIABLES & BASE STYLES
   ========================================= */
:root {
    --primary-color: #ffffff;
    --secondary-color: #f4f4f4;
    --font-color: #333;
    --accent-color: #007bff;
    --background-color: #fff;
    --overlay-color: rgba(0, 0, 0, 0.7);
}

body, html {
    height: 100%;
    margin: 0;
    font-family: "Noto Sans Mono", monospace;
    background-color: var(--background-color);
    text-rendering: optimizeLegibility;
    color: var(--font-color);
    transition: background-color 0.5s, color 0.5s;
    overflow-x: hidden;
}

/* =========================================
   ICONS
   ========================================= */
.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    background-color: currentColor;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    flex-shrink: 0;
}

svg.icon {
    background-color: transparent !important;
    -webkit-mask-image: none !important;
    mask-image: none !important;
    fill: currentColor;
    width: 24px;
    height: 24px;
    color: #F3F3F3;
}

/* =========================================
   NAVIGATION BAR
   ========================================= */
.sticky-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    transition: transform 0.24s cubic-bezier(0.2,0,0,1);
    padding: 10px 0;
    opacity: 1;
    pointer-events: none;
    will-change: transform;
    transform: translate3d(0, -130%, 0);
}

.sticky-nav.visible {
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
}

.bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.5rem;
    margin: 20px auto;
    max-width: 900px;
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    will-change: backdrop-filter;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.bar:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.nav-links {
    display: flex;
    align-items: center;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    border-radius: 9999px;
    transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-item.button {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    margin: 0 5px;
    border-radius: 20px;
    transition: background-color 0.3s, color 0.3s;
    cursor: pointer;
}

.bar-item.button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Language Selector specifics */
.language-selector {
    display: flex;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    padding: 2px;
}

.language-selector .bar-item.button {
    margin: 0;
    padding: 6px 12px;
}

.language-selector .bar-item.button.active {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Dark Mode Toggle */
#dark-mode-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
    margin-left: 10px;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Dark/light icon crossfade + motion */
#dark-mode-toggle {
    position: relative;
    overflow: visible;
}

#dark-mode-toggle .icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: opacity 220ms cubic-bezier(0.2,0,0,1), transform 220ms cubic-bezier(0.2,0,0,1);
    will-change: opacity, transform;
    opacity: 0;
    pointer-events: none;
}

#dark-mode-toggle .icon-dark-mode {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(0) scale(1);
}

body.dark-mode #dark-mode-toggle .icon-dark-mode {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(-6px) scale(0.95);
}

body.dark-mode #dark-mode-toggle .icon-light-mode {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(0) scale(1);
}

#dark-mode-toggle .icon-light-mode {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(6px) scale(0.95);
}

/* =========================================
   HEADER (HERO SECTION)
   ========================================= */
.bgimg-header {
    position: relative;
    height: 100vh;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    overflow: hidden;
}

.smallImg-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    filter: blur(20px);
    transform: scale(1.1);
    z-index: -1;
}

.display-middle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 20px;
    width: 50%;
}

.display-middle h1 {
    font-family: "Noto Sans Display", sans-serif;
    font-size: 3em;
    font-weight: 400;
    margin-bottom: 0.5em;
    text-shadow: none;
}

.display-middle p {
    font-family: "Noto Sans Mono", monospace;
    font-size: 1.2em;
    font-weight: 300;
}

/* Glass Panel Styling */
.glass-panel {
    border-radius: 1.5em;
    padding: 40px 40px;
    overflow: hidden;
    z-index: 10;
    position: relative;
    max-width: 700px;
    background-image: linear-gradient(to right, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
    transform: translateZ(0);
    will-change: backdrop-filter;
    box-shadow: 
        0 2.8px 2.2px rgba(0, 0, 0, 0.034),
        0 6.7px 5.3px rgba(0, 0, 0, 0.048),
        0 12.5px 10px rgba(0, 0, 0, 0.06),
        0 22.3px 17.9px rgba(0, 0, 0, 0.072),
        0 41.8px 33.4px rgba(0, 0, 0, 0.086),
        0 100px 80px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-panel::before {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    border-radius: 1.5em;
    border: 1px solid rgba(255, 255, 255, 0.5);
    -webkit-mask-image: linear-gradient(135deg, white, transparent 50%);
    mask-image: linear-gradient(135deg, white, transparent 50%);
    pointer-events: none;
    z-index: 1;
}

.glass-panel::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    border-radius: 1.5em;
    border: 1px solid rgba(139, 92, 246, 0.5);
    -webkit-mask-image: linear-gradient(135deg, transparent 50%, white);
    mask-image: linear-gradient(135deg, transparent 50%, white);
    pointer-events: none;
    z-index: 1;
}

/* =========================================
   MAIN CONTENT & GALLERY
   ========================================= */
.main.content {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 5;
    background-color: var(--background-color);
    transition: background-color 0.5s;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    padding: 30px 0;
    max-width: 1200px;
    margin: 0 auto;
}

.portfolio-item {
    position: relative;
    content-visibility: auto;  /* Improve rendering performance for off-screen items */
    contain-intrinsic-size: 384px 216px; /* Approximation based on small image size */
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s, background-color 0.5s;
    transform: translateZ(0);
    background-size: cover;
    background-position: center;
    padding-top: 66.66%;
    background-color: var(--secondary-color);
}

.portfolio-item:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 12px 24px rgba(0,0,0,0.2);
}

.portfolio-item .description {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 40px 20px 20px;
    transform: translateY(100%);
    transition: transform 0.4s ease-in-out;
}

.portfolio-item:hover .description {
    transform: translateY(0);
}

.portfolio-item .description p {
    margin: 0;
    font-size: 0.9em;
}

/* =========================================
   SIDEBAR
   ========================================= */
.sidebar {
    height: 100%;
    width: 250px;
    position: fixed;
    z-index: 2001;
    top: 0;
    left: -250px; /* Start off-screen */
    background-color: var(--secondary-color);
    overflow-x: hidden;
    transition: 0.5s;
    padding-top: 15px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar .bar-item.button {
    color: var(--font-color);
}

.sidebar a {
    padding: 10px 15px;
    text-decoration: none;
    font-size: 1.1em;
    color: var(--font-color);
    display: block;
    transition: 0.3s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    outline: none;
}

.sidebar a:hover {
    background-color: rgba(0,0,0,0.1);
}

/* =========================================
   LIGHTBOX & OVERLAYS
   ========================================= */
.overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: var(--overlay-color);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.overlay.visible {
    opacity: 1;
}

.lightbox {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 2001;
    display: none;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    max-width: 90vw;
    max-height: 90vh;
}

.lightbox.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.lightbox-image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 50vh;
    height: 100%;
}

.lightbox-content {
    max-width: 70vw;
    max-height: 72vh;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    object-fit: contain;
    background-color: rgba(0,0,0,0.2);
    aspect-ratio: 16/9;
    display: block;
    transition: opacity 0.3s ease;
}

.lightbox-content.loading {
    opacity: 0; 
}

.close-lightbox {
    position: absolute;
    top: 15px; right: 15px;
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 2002;
    font-size: 36px;
    color: #F3F3F3;
}

.close-lightbox:hover {
    transform: scale(1.1);
    color: #ccc;
}

.lightbox-caption {
    text-align: center;
    color: white;
    padding: 15px 0;
    font-size: 1.1em;
}

.lightbox-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 10px 0;
}

.control-button {
    background: rgba(0,0,0,0.2);
    border-radius: 50%;
    width: 40px; height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
    border: 1px solid rgba(255,255,255,0.1);
}

.control-button:hover {
    background: rgba(0,0,0,0.4);
}

.resolution-selector {
    display: flex;
    gap: 5px;
    background: rgba(0,0,0,0.2);
    border-radius: 30px;
    padding: 4px;
    border: 1px solid rgba(255,255,255,0.1);
}

.res-button {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 32px; height: 32px;
    transition: background-color 0.3s;
}

.res-button.active {
    background: rgba(255,255,255,0.2);
}

.loading-spinner {
    position: absolute;
    top: 50%; left: 50%;
    width: 50px; height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    z-index: 2002;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#offline-banner {
    position: fixed;
    bottom: 0; left: 0;
    width: 100%;
    background-color: #ff4d4d;
    color: white;
    text-align: center;
    padding: 10px;
    z-index: 3000;
    display: none;
}

/* =========================================
   FOOTER
   ========================================= */
footer {
    background-color: var(--secondary-color);
    color: var(--font-color);
    padding: 40px 20px;
    text-align: center;
    font-size: 0.9em;
    line-height: 1.6;
    transition: background-color 0.5s, color 0.5s;
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    text-decoration: underline;
}

/* =========================================
   MEDIA QUERIES (RESPONSIVE)
   ========================================= */
@media (max-width: 900px) {
    .portfolio-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .bar {
        flex-direction: column;
        border-radius: 0;
        margin: 0;
        max-width: 100%;
    }
    .hide-small {
        display: none;
    }
    .display-middle h1 {
        font-size: 2.5em;
    }
    .display-middle p {
        font-size: 1.2em;
    }
}

@media (max-width: 600px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
}