/* Layout and interaction styles for index.html and se.html.
   Loaded after the inline <style> block, so these rules win on equal specificity. */

html {
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}

html.modal-open {
    overflow: hidden;
}

body {
    padding-top: 0;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #111;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.light ::-webkit-scrollbar-track {
    background: #f1f3f5;
}

.light ::-webkit-scrollbar-thumb {
    background: #ced4da;
}

/* ---------- Navigation ---------- */

#navbar {
    background: rgba(0, 0, 0, 0.35) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    transition: transform 0.3s ease, background-color 0.3s ease !important;
}

#navbar.nav-hidden {
    transform: translateY(-100%);
}

.light #navbar {
    background: rgba(255, 255, 255, 0.7) !important;
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

#navbar .nav-link {
    color: #9ca3af;
}

#navbar .nav-link:hover,
#navbar .nav-link.nav-active {
    color: #ffffff;
}

.light #navbar .nav-link.nav-active {
    color: #000000 !important;
}

#navbar:has(#mobile-menu.open) {
    background: rgba(0, 0, 0, 0.9) !important;
}

.light #navbar:has(#mobile-menu.open) {
    background: rgba(255, 255, 255, 0.95) !important;
}

#mobile-menu {
    display: none;
}

#mobile-menu.open {
    display: block;
}

@media (min-width: 768px) {
    #mobile-menu.open {
        display: none;
    }
}

/* Light-mode hover fixes (the inline rules for these never matched) */
.light .hover\:bg-gray-800:hover {
    background-color: #f1f3f5 !important;
}

.light .hover\:text-white:hover,
.light .hover\:text-gray-300:hover {
    color: #000000 !important;
}

.light .hover\:border-white:hover {
    border-color: #000000 !important;
}

/* ---------- Sections ---------- */

section[id] {
    scroll-margin-top: 72px;
}

section[id].py-20 {
    padding-top: 4.5rem;
    padding-bottom: 4.5rem;
}

.section-divider {
    margin: 0;
}

.minimal-card {
    backdrop-filter: none;
}

#experience li,
.modal-content li {
    padding-left: 0.9rem;
    text-indent: -0.9rem;
}

/* ---------- Hero ---------- */

.hero-overlay {
    background: rgba(0, 0, 0, 0.3);
}

.light .hero-overlay {
    background: rgba(255, 255, 255, 0.55);
}

.light #hero a[download] {
    background-color: rgba(0, 0, 0, 0.85) !important;
    color: #ffffff !important;
}

.light #hero a[download]:hover {
    background-color: #000000 !important;
}

.light #hero a[href="#projects"] {
    border-color: #000000 !important;
}

/* ---------- Skills accordion ---------- */

.skills-grid {
    align-items: start;
}

.skill-header {
    display: block;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.skill-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease;
}

.skill-category.open .skill-content {
    grid-template-rows: 1fr;
}

.skill-content-inner {
    min-height: 0;
    overflow: hidden;
    visibility: hidden;
    transition: visibility 0.3s;
}

.skill-category.open .skill-content-inner {
    visibility: visible;
}

.skill-arrow {
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.skill-category.open .skill-arrow {
    transform: rotate(180deg);
}

/* ---------- Project cards ---------- */

.project-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 1.5rem;
}

.project-card {
    display: flex;
    flex-direction: column;
}

.project-card > .flex {
    margin-top: auto;
}

.project-card.visible {
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, opacity 0.6s ease;
}

.project-card.visible:hover,
.project-card.visible:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.25);
}

.project-card:focus-visible,
.skill-header:focus-visible {
    outline: 2px solid #9ca3af;
    outline-offset: 2px;
}

.light .project-card.visible:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12) !important;
}

/* ---------- Project modals ---------- */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    z-index: 100000;
    padding: 24px;
    overflow-y: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal.open {
    display: flex;
    animation: modal-fade 0.2s ease;
}

.modal-content {
    margin: auto;
    width: 100%;
    max-width: 960px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    padding: 2rem 2.25rem 2.25rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.modal.open .modal-content {
    animation: modal-pop 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal-content:focus {
    outline: none;
}

.modal-content > .close {
    position: sticky;
    top: 0;
    right: auto;
    float: right;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: -0.5rem -0.75rem 0 1rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1;
    color: #d1d5db;
}

.modal-content > .close:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.light .modal-content > .close {
    background: rgba(0, 0, 0, 0.06);
}

.project-gallery {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin: 0 0 1.5rem;
    clear: both;
}

.project-gallery img {
    height: 280px;
    border-radius: 8px;
    background: #0a0a0a;
    cursor: zoom-in;
    transition: opacity 0.2s ease;
}

.project-gallery img:only-child {
    height: auto;
    max-height: min(56vh, 520px);
    object-fit: contain;
}

.project-gallery img.contain {
    object-fit: contain;
}

.project-gallery img:hover {
    transform: none;
    opacity: 0.85;
}

.light .project-gallery img {
    background: #f1f3f5;
}

.video-container,
.project-gallery video {
    clear: both;
}

.video-container:hover {
    transform: none;
}

.video-container video,
.video-container iframe,
.project-gallery video {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    background: #000;
}

#imageModal .modal-content {
    width: auto;
    max-width: min(94vw, 1500px);
    padding: 0;
    border: 0;
    overflow: visible;
    background: transparent !important;
}

#imageModal .modal-content > .close {
    position: fixed;
    top: 16px;
    right: 16px;
    float: none;
    margin: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff !important;
}

#modalImage {
    display: block;
    width: auto !important;
    max-width: 100%;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    margin: 0 auto;
    object-fit: contain;
}

@keyframes modal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 640px) {
    .modal {
        padding: 12px;
    }

    .modal-content {
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        padding: 1.25rem 1.25rem 1.5rem;
    }

    .project-gallery {
        grid-template-columns: repeat(2, 1fr);
    }

    .project-gallery > :first-child,
    .project-gallery > :only-child {
        grid-column: 1 / -1;
    }

    .project-gallery img {
        height: 220px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .fade-in {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .modal.open,
    .modal.open .modal-content {
        animation: none;
    }

    .skill-content,
    .skill-arrow,
    #navbar {
        transition: none !important;
    }
}

/* ---------- Project filters ---------- */

.project-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2.5rem;
}

.filter-chip {
    padding: 0.4rem 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 9999px;
    font-size: 0.875rem;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.filter-chip:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.4);
}

.filter-chip.active {
    background: #ffffff;
    border-color: #ffffff;
    color: #000000;
}

.filter-chip:focus-visible {
    outline: 2px solid #9ca3af;
    outline-offset: 2px;
}

.filter-chip .count {
    margin-left: 0.35rem;
    opacity: 0.6;
}

.light .filter-chip {
    border-color: rgba(0, 0, 0, 0.15);
    color: #666666;
}

.light .filter-chip:hover {
    color: #000000;
    border-color: rgba(0, 0, 0, 0.4);
}

.light .filter-chip.active {
    background: #000000;
    border-color: #000000;
    color: #ffffff;
}

.project-card.filtered-out {
    display: none;
}

.project-grid.filtering .project-card.visible {
    animation: card-in 0.3s ease;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .project-grid.filtering .project-card.visible {
        animation: none;
    }
}

/* ---------- Experience logos ---------- */

.company-logo {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    object-fit: cover;
}

.light .company-logo {
    border-color: rgba(0, 0, 0, 0.1);
}
