:root {
    --sidebar-width: 260px;
    --sidebar-rail-width: 58px;
    --sidebar-toggle-size: 42px;
    --wallpaper-landscape: url("/static/media/wallpaper.jpeg");
    --wallpaper-portrait: url("/static/media/wallpaper.jpeg");
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    overflow-x: hidden;
    background-color: #000 !important;
    background-image: var(--wallpaper-landscape);
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    background-attachment: fixed;
}

@media (orientation: portrait) {
    body {
        background-image: var(--wallpaper-portrait);
    }
}

img {
    max-width: 100%;
    height: auto;
}

.app-shell {
    min-height: 100vh;
}

/* fixed left sidebar */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    overflow-y: auto;
    background-color: #212529;
    z-index: 1000;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.12);
}

.sidebar-brand {
    display: block;
    min-height: var(--sidebar-toggle-size);
    margin-bottom: 1rem;
    padding-right: 3rem;
}

.sidebar-brand img {
    display: block;
    width: min(100%, 220px);
    height: auto;
}

.sidebar-toggle {
    position: fixed;
    top: 14px;
    left: calc(var(--sidebar-width) - var(--sidebar-toggle-size) - 12px);
    width: var(--sidebar-toggle-size);
    height: var(--sidebar-toggle-size);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: #2b3035;
    color: #fff;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
    transition: left 0.22s ease, background 0.2s ease, border-color 0.2s ease;
}

.sidebar-toggle::before {
    content: "<";
    display: block;
    font-size: 1.8rem;
    line-height: 1;
    transform: translateY(-1px);
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    background: #343a40;
    border-color: rgba(255, 255, 255, 0.36);
}

.sidebar-toggle:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.35);
    outline-offset: 2px;
}

body.sidebar-collapsed #sidebar {
    overflow: hidden;
    transform: translateX(calc(-1 * (var(--sidebar-width) - var(--sidebar-rail-width))));
    box-shadow: 4px 0 14px rgba(15, 23, 42, 0.14);
}

body.sidebar-collapsed #sidebar > * {
    opacity: 0;
    pointer-events: none;
}

body.sidebar-collapsed .sidebar-toggle {
    left: calc((var(--sidebar-rail-width) - var(--sidebar-toggle-size)) / 2);
    background: #2b3035;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

body.sidebar-collapsed .sidebar-toggle::before {
    content: ">";
    font-size: 1.2rem;
    transform: none;
}

/* right content area */
#page-content {
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.22s ease, width 0.22s ease;
}

body.sidebar-collapsed #page-content {
    width: calc(100% - var(--sidebar-rail-width));
    margin-left: var(--sidebar-rail-width);
}

/* keep footer at bottom */
main {
    flex: 1;
}

#page-content main {
    padding-top: 4.5rem;
    min-width: 0;
    color: #1e1c1cff;
}

#page-content main h1,
#page-content main h2,
#page-content main h3,
#page-content main h4,
#page-content main h5,
#page-content main h6,
#page-content main p,
#page-content main li,
#page-content main label,
#page-content main small {
    color: #1e1c1cff;
}

#page-content main a:not(.btn):not(.contact-link) {
    color: #e9f2ff;
}

#page-content footer {
    flex-shrink: 0;
}

/* sidebar links */
#sidebar .nav-link {
    border-radius: 6px;
    transition: background 0.2s ease;
}

#sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.18);
    box-shadow: inset 3px 0 0 #fff;
    color: #fff !important;
}

#sidebarMenu.sidebar-menu-open {
    display: block;
}

.hero {
    display: grid;
    gap: 1.25rem;
}

.hero h1 {
    max-width: 780px;
}

.hero-media {
    width: 100%;
    max-height: 68vh;
    overflow: hidden;
    border-radius: 8px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-media img {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(68vh, 620px);
    object-fit: contain;
    object-position: center;
}

.profile-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(240px, 0.8fr);
    gap: 2rem;
    align-items: center;
}

.profile-layout p {
    max-width: 42rem;
    color: #495057;
    font-size: 1.05rem;
}

.profile-photo {
    justify-self: center;
    width: min(100%, 360px);
}

.profile-img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    border-radius: 8px;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 1.5rem;
    width: 100%;
}

.portfolio-cell {
    min-width: 0;
}

.portfolio-frame {
    appearance: none;
    aspect-ratio: 4 / 3;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.portfolio-frame:hover {
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.portfolio-frame:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.35);
    outline-offset: 3px;
}

.portfolio-item {
    width: 100%;
    height: 100%;
    padding: 0.5rem;
    object-fit: contain;
    cursor: pointer;
}

#imageModal {
    display: none;
    background: rgba(0, 0, 0, 0.72);
}

#imageModal.show {
    display: block;
}

body.lightbox-open {
    overflow: hidden;
}

#imageModal .modal-dialog {
    min-height: 100vh;
    margin-top: 0;
    margin-bottom: 0;
}

#imageModal .modal-content {
    max-height: 94vh;
}

#imageModal .modal-body {
    position: relative;
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#modalImage {
    max-height: 90vh;
    max-width: 100%;
    object-fit: contain;
}

.gallery-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    color: #212529;
    font-size: 1.8rem;
    line-height: 1;
    z-index: 3;
}

.gallery-close:hover,
.gallery-close:focus-visible {
    background: #fff;
}

.gallery-control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 56px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    color: #212529;
    font-size: 1.8rem;
    line-height: 1;
    z-index: 2;
}

.gallery-control:hover,
.gallery-control:focus-visible {
    background: #fff;
}

.gallery-control:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.45);
    outline-offset: 2px;
}

.gallery-control-prev {
    left: 1rem;
}

.gallery-control-next {
    right: 1rem;
}

.contact-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
    gap: 2rem;
    align-items: start;
    background: transparent;
}

.contact-intro {
    max-width: 42rem;
    color: #1e1c1cff;
    font-size: 1.05rem;
}

.contact-links {
    display: grid;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.contact-link {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 0.875rem;
    align-items: center;
    padding: 1rem;
    border-radius: 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #1e1c1cff;
    text-decoration: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.contact-link:hover,
.contact-link:focus-visible {
    border-color: rgba(255, 255, 255, 0.6);
    color: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
    transform: translateY(-1px);
}

.contact-link:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.35);
    outline-offset: 3px;
}

.contact-link-label {
    display: block;
    font-weight: 700;
}

.contact-link-value {
    display: block;
    color: #1e1c1cff;
    overflow-wrap: anywhere;
}

.contact-link-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    color: #1e1c1cff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.contact-link-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.contact-layout .form-control {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.35);
    color: #1e1c1cff;
}

.contact-layout .form-control::placeholder {
    color: rgba(248, 249, 250, 0.7);
}

.list-group {
    background: transparent;
}

.list-group-item {
    background: transparent !important;
    border-color: rgba(255, 255, 255, 0.35);
    color: #1e1c1cff;
}

/* mobile */
@media (max-width: 992px) {
    :root {
        --sidebar-width: min(280px, calc(100vw - 56px));
        --sidebar-rail-width: 52px;
    }

    #sidebar {
        width: var(--sidebar-width);
        max-width: calc(100vw - 64px);
    }

    #page-content {
        width: calc(100% - var(--sidebar-rail-width));
        margin-left: var(--sidebar-rail-width);
    }

    body.sidebar-collapsed #page-content {
        width: calc(100% - var(--sidebar-rail-width));
        margin-left: var(--sidebar-rail-width);
    }

    #page-content main {
        padding: 4.25rem 1rem 1.5rem !important;
    }

    .portfolio-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
        gap: 1rem;
    }

    .portfolio-frame {
        aspect-ratio: 4 / 3;
    }

    .contact-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .profile-layout {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .profile-photo {
        justify-self: start;
        width: min(100%, 320px);
    }
}

@media (max-width: 576px) {
    :root {
        --sidebar-rail-width: 46px;
        --sidebar-toggle-size: 38px;
    }

    #page-content main {
        padding: 4rem 0.75rem 1rem !important;
    }

    main h1 {
        font-size: 1.75rem;
        margin-bottom: 1rem !important;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }

    .portfolio-item {
        padding: 0.375rem;
    }

    .hero-media img {
        width: 100%;
        height: auto;
        max-height: 52vh;
        object-fit: contain;
    }

    .gallery-control {
        width: 38px;
        height: 48px;
        font-size: 1.4rem;
    }

    .gallery-control-prev {
        left: 0.5rem;
    }

    .gallery-control-next {
        right: 0.5rem;
    }

    .gallery-close {
        top: 0.5rem;
        right: 0.5rem;
        width: 38px;
        height: 38px;
        font-size: 1.5rem;
    }

    .contact-link {
        grid-template-columns: 40px minmax(0, 1fr);
        gap: 0.75rem;
        padding: 0.875rem;
    }

    .contact-link-icon {
        width: 40px;
        height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #sidebar,
    #page-content,
    .sidebar-toggle,
    .portfolio-frame {
        transition: none;
    }
}
