/* Screen reader only */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Dark mode variables + global background */
:root {
    --color-bg: #0b1014;
    --color-bg-alt: #11181f;
    --color-surface: #182229;
    --color-surface-hover: #1f2c35;
    --color-border: #22323d;
    --color-text: #e6f1f3;
    --color-text-dim: #9badb9;
    --color-accent-cyan: #18ccff;
    --color-accent-green: #32ff7e;
    --color-link: #32ff7e;
    --color-link-hover: #18ccff;
    --shadow-elev: 0 4px 18px -4px rgba(0,0,0,.55), 0 2px 4px -1px rgba(0,0,0,.4);
    --focus-ring: 0 0 0 2px rgba(24,204,255,.55), 0 0 0 4px rgba(24,204,255,.18);
}

body {
    background:
        radial-gradient(at 85% 12%, rgba(24,204,255,.18), rgba(11,16,20,0) 60%),
        radial-gradient(at 12% 88%, rgba(50,255,126,.15), rgba(11,16,20,0) 55%),
        linear-gradient(135deg,#0b1014,#0e1419 55%, #101a21);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    background-color: var(--color-bg); /* Fallback solid */
    background-attachment: fixed;
}

/* Keep global link accent but allow override */
a { color: var(--color-link); }
a:hover, a:focus { color: var(--color-link-hover); }

/* Nav-specific links revert to neutral text */
.nav-link {
    color: var(--color-text) !important;
    transition: color .25s ease;
}


/* Improved navbar link hover contrast */
.nav-link {
    /* add padding & shape without causing layout shift */
    padding: .35rem .65rem;
    border-radius: 6px;
    border: 1px solid transparent;
    line-height: 1.1;
    position: relative;
}

/* Nav link underline on hover/focus */
.nav-link:hover{
    text-decoration: underline;
    color: #ffffff;
    text-decoration-thickness: 3px;
    text-underline-offset: 4px;
}

/* High-contrast focus ring */
a:focus-visible,
button:focus-visible,
.menu-toggle:focus-visible,
.main-menu a:focus-visible,
.projects .project-card:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    position: relative;
    z-index: 2;
    border-radius: 4px;
}

/* Button styling */

.menu-toggle {
    display: inline-block;
    padding: .20em 1px;
    line-height: 1em;
    color: var(--color-text);
}

a#main-menu-toggle {
    color: var(--color-text) !important;
}

.menu-toggle:hover,
.menu-toggle:focus {
    color: var(--color-accent-cyan);
}

/*
 Default styles + Mobile first
 Offscreen menu style
*/

.main-menu {
    position: absolute;
    display: none;
    left: -200px;
    top: 0;
    height: 100%;
    overflow-y: scroll;
    overflow-x: visible;
    transition: right 0.3s ease, box-shadow 0.3s ease;
    z-index: 999;
    background: transparent;
}

.main-menu ul {
    list-style: none;
    margin: 0;
    padding: 2.5em 0 0;
    /* Hide shadow w/ -8px while 'closed' */
    min-height: 100%;
    width: 200px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
}

.main-menu a {
    display: block;
    padding: .75em 15px;
    line-height: 1em;
    font-size: 1em;
    color: var(--color-text);
    text-decoration: none;
    transition: color .18s ease, background .25s ease;
}

.main-menu a:hover,
.main-menu a:focus {
    text-decoration: none;
    color: var(--color-accent-cyan);
    background: rgba(255,255,255,0.04);
}

.main-menu .menu-close {
    position: absolute;
    right: 0;
    top: 0;
    color: var(--color-text);
}

/*
 Demo purposes only
*/

*,
*:before,
*:after {
    box-sizing: border-box;
}

/*
 On small devices, allow it to toggle...
*/

/*
 :target for non-JavaScript
 [aria-expanded] will be used if/when JavaScript is added to improve interaction, though it's completely optional.
*/

.main-menu:target,
.main-menu[aria-expanded="true"] {
    display: block;
    left: 0;
    outline: none;
    box-shadow: 6px 0 24px -8px rgba(0,0,0,.65);
    will-change: transform;
}

/* Open state shadow refinement */
.main-menu:target,
.main-menu[aria-expanded="true"] {
    box-shadow: 6px 0 24px -8px rgba(0,0,0,.65);
}

.main-menu:target .menu-close,
.main-menu[aria-expanded="true"] .menu-close {
    z-index: 1001;
}

.main-menu:target ul,
.main-menu[aria-expanded="true"] ul {
    position: relative;
    z-index: 1000;
}

/* 
 We could us `.main-menu:target:after`, but
 it wouldn't be clickable.
*/

.main-menu:target+.backdrop,
.main-menu[aria-expanded="true"]+.backdrop {
    position: absolute;
    display: block;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 998;
    background: rgba(0,0,0,.82);
    cursor: default;
}

@supports (position: fixed) {

    .main-menu,
    .main-menu:target+.backdrop,
    .main-menu[aria-expanded="true"]+.backdrop {
        position: fixed;
    }
}

/* Project cards (override any existing light styles) */
.projects {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem; /* tighter gap so 5 fit */
    align-items: stretch;
    justify-content: flex-start;
    margin-top: 0.75rem;
}
.projects .project-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    flex: 1 1 260px;
    max-width: 320px;
    min-width: 240px;
    overflow: hidden;
    box-shadow: var(--shadow-elev);
    transition: transform .3s ease, background .35s ease, border-color .35s ease;
    outline: none;
}
.projects .project-card:hover {
    transform: translateY(-4px);
    background: var(--color-surface-hover);
    border-color: var(--color-accent-cyan);
    box-shadow: 0 6px 26px -6px rgba(0,0,0,.65), 0 2px 6px -1px rgba(0,0,0,.4);
}
.projects .project-img {
    filter: saturate(.9) brightness(.9);
    transition: filter .1s ease, transform 1s ease;
    will-change: filter, transform;
}
.projects .project-card:hover .project-img,
.projects .project-card:focus-visible .project-img {
    transition: filter .1s ease, transform .75s cubic-bezier(.4,0,.2,1);
    transform: scale(1.3);
}
.projects .project-content {
    flex: 1 1 auto;
    padding: 0.75rem 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: var(--color-text-dim);
}
.projects .project-title {
    color: var(--color-text);
    margin: 0;
}
.projects .project-desc {
    flex: 1 1 auto;
    color: var(--color-text-dim);
    line-height: 1.35em;
}

/* Prevent unexpected horizontal scrollbar */
html, body {
    overflow-x: hidden;
}

/* Safety: ensure project area and absolute wrapper don't create overflow */
.projects,
.mt-16.absolute {
    max-width: 100%;
    overflow-x: hidden;
}

/* Constrain decorative fixed corner images (avoid oversize intrinsic widths causing scroll) */
#right-shape,
#left-shape {
    max-width: 40vw;
    height: auto;
    pointer-events: none;
    user-select: none;
    /* Ensure no layout width contribution beyond viewport */
    display: block;
}

/* If image scale on hover still pushes (rare in some browsers), isolate it */
.projects .project-card .overflow-hidden {
    overflow: hidden;
}

/* Ensure absolute project wrapper can span full width */
.mt-16.absolute {
    width: 100%;
    left: 0;
    /* optional containment */
    padding-right: 1.25rem;
}

/* Wider screens: center with max width */
@media (min-width: 1280px) {
    .projects {
        max-width: 1400px;
    }
}

/* Narrow screens: allow tighter cards */
@media (max-width: 520px) {
    .projects {
        gap: 1rem;
    }
    .projects .project-card {
        max-width: 100%;
        min-width: 100%;
    }
}

/* Projects layout adjustments for 5-across fit */
.projects {
    gap: 1rem; /* tighter gap so 5 fit */
}

/* Base card padding tightened */
.projects .project-card .project-content {
    padding: 0.75rem 0.85rem 1rem;
    gap: 0.5rem;
}

/* Force exactly 5 columns on standard / large monitors */
@media (min-width: 1200px) {
    .projects {
        gap: 0.75rem;
    }
    .projects .project-card {
        flex: 0 0 calc((100% - (0.75rem * 4)) / 5);
        max-width: calc((100% - (0.75rem * 4)) / 5);
        min-width: 0; /* allow calc to govern */
    }
}

/* Slightly denser layout on mid-large screens (fit 5 on ~1366px) */
@media (min-width: 1100px) and (max-width: 1199.98px) {
    .projects {
        gap: 0.6rem;
    }
    .projects .project-card {
        flex: 0 0 calc((100% - (0.6rem * 4)) / 5);
        max-width: calc((100% - (0.6rem * 4)) / 5);
    }
    .projects .project-card .project-content {
        padding: 0.65rem 0.75rem 0.9rem;
    }
}

/* Below ~1100px allow natural wrap (no change to previous responsive behavior) */

/* Typed text + headings refinement */
h1, h2, h3, h4, h5 {
    color: var(--color-text);
}
#typed { color: var(--color-accent-green); }
#typed span { color: var(--color-accent-cyan); }

/* Force headings + typed text pure white */
#typed,
#typed span {
    color: #ffffff !important;
}

/* Selection */
::selection {
    background: rgba(24,204,255,.35);
    color: var(--color-text);
}
::-moz-selection {
    background: rgba(24,204,255,.35);
    color: var(--color-text);
}

/* Scrollbar theming (non-intrusive) */
@media (pointer: fine) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--color-border) transparent;
    }
    *::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }
    *::-webkit-scrollbar-track {
        background: transparent;
    }
    *::-webkit-scrollbar-thumb {
        background: linear-gradient(var(--color-border), var(--color-surface-hover));
        border-radius: 20px;
        border: 2px solid transparent;
        background-clip: padding-box;
    }
    *::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(var(--color-accent-cyan), var(--color-accent-green));
        border: 0;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* Full-width projects row and unrestricted cards */
.projects {
    max-width: none !important;
    width: 100%;
}

.projects .project-card {
    max-width: none !important;
}

/* If you want equal 5-column stretch across any large width without per-card max constraints */
@media (min-width: 1100px) {
    .projects .project-card {
        flex: 0 0 calc((100% - (0.75rem * 4)) / 5);
        width: calc((100% - (0.75rem * 4)) / 5);
    }
}

/* Ensure earlier breakpoint (1200px) rules do not reintroduce a max-width */
@media (min-width: 1200px) {
    .projects {
        max-width: none !important;
    }
    .projects .project-card {
        max-width: none !important;
    }
}

/* Five-across layout using grid on wider screens */
@media (min-width: 1000px) {
    .projects {
        /* Use centered fixed-ish column widths; still exactly 5 columns */
        display: grid;
        grid-template-columns: repeat(5, minmax(0, clamp(200px, 19vw, 250px)));
        justify-content: center;
        gap: 1rem;
        width: 100%;
    }
    .projects .project-card {
        max-width: clamp(200px, 19vw, 250px);
        width: 100%;
        min-height: 400px; /* taller overall */
    }
    .projects .project-card > .overflow-hidden {
        max-height: 140px; /* slightly taller image zone */
    }
    .projects .project-card .project-content {
        padding: 0.85rem 0.9rem 1.15rem;
    }
    .projects .project-card .project-desc {
        line-height: 1.4;
    }
}

/* Ultra-wide: allow a bit more height so vertical balance remains */
@media (min-width: 1600px) {
    .projects .project-card {
        min-height: 430px;
    }
    .projects .project-card > .overflow-hidden {
        max-height: 155px;
    }
}

/* Slight squeeze for narrower large screens (still 5 across) */
@media (min-width: 1000px) and (max-width: 1180px) {
    .projects {
        gap: 0.75rem;
        grid-template-columns: repeat(5, minmax(0, clamp(188px, 20vw, 225px)));
    }
    .projects .project-card {
        max-width: clamp(188px, 20vw, 225px);
        min-height: 385px;
    }
}

/* Wider cards override (second widening) */
@media (min-width: 1000px) {
    .projects {
        grid-template-columns: repeat(5, minmax(0, clamp(215px, 20vw, 270px)));
        gap: 1rem;
    }
    .projects .project-card {
        max-width: clamp(215px, 20vw, 270px);
        min-height: 420px;
    }
    .projects .project-card > .overflow-hidden {
        max-height: 160px;
    }
}

/* Narrow large screens (ensure still 5 across without wrapping) */
@media (min-width: 1000px) and (max-width: 1180px) {
    .projects {
        grid-template-columns: repeat(5, minmax(0, clamp(200px, 21vw, 240px)));
        gap: 0.75rem;
    }
    .projects .project-card {
        max-width: clamp(200px, 21vw, 240px);
        min-height: 405px;
    }
    .projects .project-card > .overflow-hidden {
        max-height: 150px;
    }
}

/* Third widening: only apply on roomier screens */
@media (min-width: 1300px) {
    .projects {
        /* Slightly wider columns while keeping exactly 5 */
        grid-template-columns: repeat(5, minmax(0, clamp(225px, 18.5vw, 300px)));
        gap: 1rem;
    }
    .projects .project-card {
        max-width: clamp(225px, 18.5vw, 300px);
        min-height: 450px;
    }
    .projects .project-card > .overflow-hidden {
        max-height: 175px;
    }
}

/* Extra-wide refinement */
@media (min-width: 1800px) {
    .projects .project-card {
        min-height: 470px;
    }
    .projects .project-card > .overflow-hidden {
        max-height: 190px;
    }
}

/* Align "My Projects" heading with first card (only when 5-column grid active) */
@media (min-width: 1000px) {
    :root {
        --proj-col: clamp(215px, 20vw, 270px); /* matches current grid (second widening) */
        --proj-gap: 1rem;
    }
    .projects {
        /* Ensure gap variable stays consistent with heading math */
        --proj-gap: 1rem;
    }
    .mt-16.absolute > h3 {
        padding-left: 0 !important;
        margin-left: max(0px, calc((100% - (5 * var(--proj-col) + 4 * var(--proj-gap))) / 2));
        transition: margin-left .3s ease;
    }
}

/* Narrow large screens variant (override column width + gap math) */
@media (min-width:1000px) and (max-width:1180px) {
    :root {
        --proj-col: clamp(200px, 21vw, 240px);
        --proj-gap: 0.75rem;
    }
    .mt-16.absolute > h3 {
        margin-left: max(0px, calc((100% - (5 * var(--proj-col) + 4 * var(--proj-gap))) / 2));
    }
}

/* Roomier screens (third widening) */
@media (min-width:1300px) {
    :root {
        --proj-col: clamp(225px, 18.5vw, 300px);
        --proj-gap: 1rem;
    }
    .mt-16.absolute > h3 {
        margin-left: max(0px, calc((100% - (5 * var(--proj-col) + 4 * var(--proj-gap))) / 2));
    }
}

/* Extra-wide refinement keeps same column clamp; heading auto-updates */
@media (min-width:1800px) {
    /* (Column clamp already defined above; no change needed) */
    .mt-16.absolute > h3 {
        margin-left: max(0px, calc((100% - (5 * var(--proj-col) + 4 * var(--proj-gap))) / 2));
    }
}