:root {
    --bg-light: #eef2ef;
    --text-light: #0b0b0b;
    --muted-light: #6b6f6d;
    --accent: #111827;
    --bg-dark: #0b0b0b;
    --text-dark: #f3f4f6;
    --muted-dark: #9aa0a6;
    --sidebar-w: 200px;
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: 'Space Mono', monospace;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color .35s, color .35s;
    overflow-x: hidden;
    position: relative;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0b0b0b;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
}

.loading-logo {
    font-size: 48px;
    font-weight: 700;
    color: #f3f4f6;
    margin-bottom: 30px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.loading-bar-container {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.loading-bar {
    height: 100%;
    background: #f3f4f6;
    width: 0%;
    animation: loadProgress 2s ease-in-out forwards;
}

@keyframes loadProgress {
    0% {
        width: 0%;
    }

    100% {
        width: 100%;
    }
}

.loading-text {
    margin-top: 20px;
    font-size: 12px;
    color: #9aa0a6;
    letter-spacing: 2px;
}

.loading-dots {
    display: inline-block;
    width: 20px;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '';
    }

    40% {
        content: '.';
    }

    60% {
        content: '..';
    }

    80%,
    100% {
        content: '...';
    }
}

body.theme-light {
    background: var(--bg-light);
    color: var(--text-light)
}

body.theme-light a {
    color: var(--accent)
}

body.theme-light .muted {
    color: var(--muted-light)
}

body.theme-dark {
    background: var(--bg-dark);
    color: var(--text-dark)
}

body.theme-dark a {
    color: var(--text-dark)
}

body.theme-dark .muted {
    color: var(--muted-dark)
}

/* Sinhala Background Animation */
.sinhala-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
}

body.theme-dark .sinhala-bg {
    opacity: 1;
}

.sinhala-letter {
    position: absolute;
    font-family: 'Space Mono', monospace;
    color: rgba(243, 244, 246, 0.08);
    font-size: 18px;
    animation: fall linear infinite;
    user-select: none;
}

@keyframes fall {
    0% {
        transform: translateY(-100%) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.8;
    }

    90% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    position: relative;
    z-index: 1;
}

/* Sidebar */
.sidebar {
    padding: 28px 18px;
    border-right: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column
}

body.theme-dark .sidebar {
    border-right: 1px solid rgba(255, 255, 255, 0.1)
}

.brand h1 {
    margin: 0;
    font-size: 16px
}

.brand p {
    margin: 6px 0 0 0;
    font-size: 12px
}

nav {
    margin-top: 18px
}

nav a {
    display: block;
    text-decoration: none;
    padding: 6px 0;
    font-size: 13px;
    color: inherit;
    opacity: .95
}

nav a.active {
    font-weight: 700
}

.socials {
    margin-top: auto
}

.socials a {
    display: block;
    margin-bottom: 8px;
    text-decoration: none;
    font-size: 13px;
}

.theme-toggle {
    margin-top: 12px;
    padding: 8px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    font-family: inherit;
    font-size: 12px
}

body.theme-dark .theme-toggle {
    border: 1px solid rgba(255, 255, 255, 0.1)
}

.theme-toggle:focus {
    outline: 2px solid rgba(0, 0, 0, 0.08)
}

main {
    padding: 28px 30px;
    overflow-x: hidden;
}

section {
    display: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .45s, transform .45s
}

section.active {
    display: block;
    opacity: 1;
    transform: none
}

/* Hacker-style grid for home */
.hacker-grid-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 70vh;
    padding: 20px;
    position: relative;
}

.hacker-grid {
    width: 100%;
    max-width: 900px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
    gap: 4px;
    padding: 20px;
    font-family: 'Courier New', monospace;
}

.hacker-cell {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.3s;
    opacity: 0.4;
    cursor: default;
}

body.theme-light .hacker-cell {
    color: #444
}

body.theme-dark .hacker-cell {
    color: #888
}

.hacker-cell:hover {
    transform: scale(1.4);
    opacity: 1;
}

body.theme-light .hacker-cell:hover {
    color: #000
}

body.theme-dark .hacker-cell:hover {
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5)
}

.hacker-cell.flash {
    animation: flashAnim 0.5s ease;
}

@keyframes flashAnim {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* --- PROJECT SECTION STYLES --- */
.project-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    max-width: 900px;
}

.project-tab {
    padding: 8px 14px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    transition: all 0.2s;
    color: inherit;
    opacity: 0.7;
}

body.theme-dark .project-tab {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.project-tab:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.03);
}

body.theme-dark .project-tab:hover {
    background: rgba(255, 255, 255, 0.05);
}

.project-tab.active {
    opacity: 1;
    font-weight: 700;
    background: var(--accent);
    color: var(--text-dark);
}

body.theme-light .project-tab.active {
    color: var(--text-dark);
    background: var(--accent);
}

body.theme-dark .project-tab.active {
    color: var(--bg-dark);
    background: var(--text-dark);
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    max-width: 900px;
}

.project-card {
    padding: 0 0 16px 0;
    /* Padding adjustments for banner image */
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 14px;
    overflow: hidden;
    /* Important for border-radius on image */
}

body.theme-dark .project-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.theme-dark .project-card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.08);
}

/* New styles for image banner */
.project-card-image {
    width: 100%;
    height: 150px;
    overflow: hidden;
    margin-bottom: 12px;
    background-color: var(--bg-dark);
    /* Placeholder color */
}

.project-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Ensures image covers the area without distortion */
    transition: transform 0.3s;
}

.project-card:hover .project-card-image img {
    transform: scale(1.05);
}

.project-card-content {
    padding: 0 16px;
    /* Restore padding to content */
}

.project-card-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 16px;
}

.project-card-date {
    font-size: 12px;
    margin-bottom: 10px;
}

.project-card-desc {
    margin-bottom: 12px;
    line-height: 1.5;
}

.project-card-link a {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid;
}

.design-link {
    cursor: pointer;
    /* Indicate it's clickable */
}

.video-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    max-width: 1000px;
    margin-top: 20px;
}

.video-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body.theme-dark .video-embed {
    box-shadow: 0 2px 10px rgba(255, 255, 255, 0.05);
}

.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- END PROJECT SECTION STYLES --- */


.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    max-width: 900px;
    margin-top: 20px;
}

.card {
    padding: 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
    font-size: 14px;
}

body.theme-dark .card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.04)
}

.contact {
    max-width: 600px;
    animation: fadeIn .6s ease both
}

.contact p {
    margin: 12px 0;
    line-height: 1.6;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px)
    }

    to {
        opacity: 1;
        transform: none
    }
}

.mobile-header {
    display: none;
    text-align: center;
    padding: 20px 20px 10px 20px;
}

.mobile-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.mobile-header p {
    margin: 8px 0 0 0;
    font-size: 14px;
}

.mobile-tabs {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-light);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding: 8px 0;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

body.theme-dark .mobile-tabs {
    background: var(--bg-dark);
    border-top-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.mobile-tabs-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
    opacity: 0.5;
    transition: opacity 0.2s;
    padding: 6px 12px;
    font-size: 11px;
    flex: 1;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}

.mobile-tab.active {
    opacity: 1;
    font-weight: 700;
}

.mobile-tab-icon {
    font-size: 18px;
    margin-bottom: 4px;
}

@media (max-width:768px) {
    :root {
        --sidebar-w: 0px;
    }

    .app {
        grid-template-columns: 1fr;
        position: relative;
    }

    .sidebar {
        display: none;
    }

    .mobile-header {
        display: block;
    }

    .mobile-tabs {
        display: block;
    }

    main {
        padding: 20px 16px 80px 16px;
    }

    .hacker-grid-wrap {
        min-height: calc(100vh - 260px);
        padding: 10px;
    }

    .hacker-grid {
        grid-template-columns: repeat(auto-fill, minmax(20px, 1fr));
        gap: 3px;
        padding: 10px;
    }

    .hacker-cell {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }

    .project-tab {
        font-size: 12px;
        padding: 6px 10px;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }

    .project-card {
        font-size: 13px;
    }

    .project-card-image {
        height: 120px;
        /* Slightly shorter on mobile */
    }

    .project-card-content {
        padding: 0 14px;
    }

    .video-container {
        grid-template-columns: 1fr;
    }

    .about-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
    }

    .card {
        padding: 12px;
        font-size: 13px;
    }

    .contact p {
        font-size: 14px;
    }

    /* Mobile modal adjustments */
    .modal-content {
        max-width: 90%;
        max-height: 90%;
    }

    .modal-image {
        max-width: 100%;
        max-height: 100%;
    }

    .modal-close {
        font-size: 30px;
        top: 5px;
        right: 15px;
    }

    .modal-nav {
        display: none;
        /* Hide nav arrows on very small screens if they overlap too much */
    }
}

@media (max-width:420px) {
    .hacker-grid {
        grid-template-columns: repeat(auto-fill, minmax(18px, 1fr));
        gap: 2px;
    }

    .hacker-cell {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }

    .mobile-tab {
        font-size: 10px;
        padding: 4px 8px;
    }

    .mobile-tab-icon {
        font-size: 16px;
    }
}

.muted {
    opacity: .7
}

/* --- NEW MODAL/LIGHTBOX STYLES --- */
.modal {
    display: none;
    position: fixed;
    z-index: 9998;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(2px);
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    position: relative;
    max-width: 900px;
    max-height: 90vh;
    width: auto;
    height: auto;
    animation-name: zoom;
    animation-duration: 0.3s;
    display: flex;
    /* Added for centering image within content */
    justify-content: center;
    align-items: center;
}

.modal-image {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 9999;
}

.modal-close:hover,
.modal-close:focus {
    color: #bbb;
    text-decoration: none;
}

/* Gallery Navigation Arrows */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: 16px;
    font-size: 20px;
    font-weight: 700;
    color: #f1f1f1;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    user-select: none;
    transition: background 0.3s;
    border-radius: 4px;
    line-height: 1;
    /* Keep it centered */
    z-index: 9990;
}

.modal-nav:hover {
    background: rgba(0, 0, 0, 0.6);
}

#prevBtn {
    left: 15px;
}

#nextBtn {
    right: 15px;
}


@keyframes zoom {
    from {
        transform: scale(0.8);
    }

    to {
        transform: scale(1);
    }
}

/* --- END NEW MODAL/LIGHTBOX STYLES --- */
