body {
    margin: 0;
    padding: 0;
    background: #ffffff;
    color: #cdcdcd;
    font-family: "Avenir Next", "Avenir", sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

header {
    position: relative;
    background-color: #f8f8f8;
    height: 4.5rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 1.5rem;
    box-sizing: border-box;
}

html.theme-ready,
html.theme-ready body,
html.theme-ready header,
html.theme-ready .copyright {
    transition: background-color 0.25s ease, color 0.25s ease;
}

nav {
    display: flex;
    align-items: center;
    justify-self: start;
    z-index: 20;
    height: auto;
}

.hero-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 1.5rem;
}

.text {
    font-family: Arial, sans-serif;
    font-weight: 700;
    letter-spacing: 3px;
    text-align: center;
    font-size: clamp(1.75rem, 3.5vw, 2.75rem);
    color: #18181b;
    margin: 0 0 0.75rem 0;
    transition: color 0.25s ease;
}

.text1 {
    font-family: Arial, sans-serif;
    font-weight: 300;
    letter-spacing: 3px;
    text-align: center;
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    color: #666f7e;
    margin: 0;
    transition: color 0.25s ease;
}

.logo {
    font-size: 110%;
    font-family: Arial, sans-serif;
    letter-spacing: 8px;
    text-indent: 8px;
    color: #666f7e;
    text-align: center;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    line-height: 1;
    white-space: nowrap;
    transition: color 0.25s ease;
}

.logo h1 {
    margin: 0;
    padding: 0;
    font-size: inherit;
    font-weight: normal;
    line-height: 1;
}

a {
    text-decoration: none;
    font-family: Arial;
    font-weight: lighter;
    letter-spacing: 3px;
    text-align: center;
    color: #666f7e; /* Default link color */
}

main {
    text-align: center;
    padding-bottom: 50px;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    box-sizing: border-box;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    flex-grow: 1;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2.5rem;
    max-width: 1280px;
    margin: 0 auto;
    align-items: start;
}

.project-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.project-card--centered {
    grid-column: 1 / -1;
    max-width: calc(50% - 1.25rem);
    margin: 0 auto;
}

.project-card > a,
.preview-link {
    display: block;
    width: 100%;
}

.preview-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 1280 / 820;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transition: opacity 0.2s ease, box-shadow 0.25s ease, border-color 0.25s ease, transform 1.5s ease-out;
}

.preview-link:hover .preview-frame {
    opacity: 0.94;
}

.preview-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

.preview-dark {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

html.theme-ready .preview-dark {
    transition: opacity 0.25s ease;
}

html.dark-mode .preview-dark {
    opacity: 1;
}

.caption-wrap {
    margin-top: 1rem;
}

.caption-wrap .text1 {
    margin-top: 0.5rem;
}

.caption, .caption1 {
    display: inline-block;
    font-family: Arial;
    font-weight: 200;
    letter-spacing: 3px;
    font-size: clamp(1.25rem, 2.2vw, 2.1rem);
    color: #0f0f0f;
    padding-bottom: 0.2rem;
    margin-top: 0.75rem;
    text-align: center;
    transition: color 0.25s ease, opacity 1.5s ease-out, transform 1.5s ease-out;
}

.caption:hover, .caption1:hover {
    color: #2563eb;
}

.copyright {
    font-family: Arial;
    font-weight: lighter;
    letter-spacing: 5px;
    font-size: 80%;
    bottom: 0;
    width: 100%;
    color: #666f7e;
    background-color: #f8f8f8;
    padding: 10px 0;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.main-content {
    opacity: 0;
    transform: translateY(20px);
    transition: color 0.25s ease, opacity 1.5s ease-out, transform 1.5s ease-out;
}

.main-content.show {
    opacity: 1;
    transform: translateY(0);
}

.space {
    margin: 30px 0;
}

.space1 {
    margin: 20px 0;
}

/* Hamburger Menu Styles */
#menuToggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    align-self: center;
    position: relative;
    z-index: 21;
    -webkit-user-select: none;
    user-select: none;
}

#menuToggle a {
    text-decoration: none;
    color: #232323; /* Overrides global a color for menu links */
    transition: color 0.3s ease;
}

#menuToggle a:hover {
    color: rgb(144, 103, 95);
}

#menuToggle input {
    display: block;
    width: 40px;
    height: 32px;
    position: absolute;
    top: -5px;
    left: -4px;
    cursor: pointer;
    opacity: 0; /* hide this */
    z-index: 26; /* and place it over the hamburger */
    -webkit-touch-callout: none;
}

#menuToggle span {
    display: block;
    width: 30px;
    height: 1.5px;
    margin-bottom: 6.5px;
    position: relative;
    background: #666f7e;
    border-radius: 2px;
    z-index: 25;
    transform-origin: 4px 0px;
    transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
                background 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
                opacity 0.55s ease;
}

#menuToggle span:first-of-type {
    transform-origin: 0% 0%;
}

#menuToggle span:nth-of-type(3) {
    transform-origin: 0% 100%;
    margin-bottom: 0;
}

#menuToggle input:checked ~ span {
    opacity: 1;
    transform: rotate(45deg) translate(-1.5px, -1.5px);
    background: #232323;
}

#menuToggle input:checked ~ span:nth-last-child(3) {
    opacity: 0;
    transform: rotate(0deg) scale(0.2, 0.2);
}

#menuToggle input:checked ~ span:nth-last-child(2) {
    transform: rotate(-45deg) translate(-1.5px, 1.5px);
}

#menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100vh;
    margin: 0;
    padding: 50px 40px;
    padding-top: 100px;
    background: #ededed;
    list-style-type: none;
    -webkit-font-smoothing: antialiased;
    transform-origin: 0% 0%;
    transform: translate(-100%, 0);
    visibility: hidden;
    pointer-events: none;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    z-index: 20;
    box-sizing: border-box;
}

html.theme-ready #menu {
    transition: transform 0.4s cubic-bezier(0.77, 0.2, 0.05, 1.0),
                background-color 0.25s ease,
                visibility 0.4s;
}

#menu li {
    padding: 10px 0;
    font-size: 20px;
}

#menuToggle input:checked ~ ul {
    transform: none;
    visibility: visible;
    pointer-events: auto;
}

@media (max-width: 768px) {
    header {
        padding: max(env(safe-area-inset-top, 0px), 0.75rem) 1rem 0 1rem;
        height: calc(3.5rem + max(env(safe-area-inset-top, 0px), 0.75rem));
    }

    #menu {
        padding-top: calc(100px + env(safe-area-inset-top, 0px));
    }

    .logo {
        font-size: 75%;
        letter-spacing: 3px;
        text-indent: 3px;
    }

    .logo h1 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    main {
        padding-left: 1rem;
        padding-right: 1rem;
        padding-bottom: 60px;
    }

    .projects-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }

    .project-card--centered {
        max-width: 100%;
    }

    img {
        max-width: 100%;
        border-radius: 6px;
    }

    .caption, .caption1 {
        font-size: 140%;
        letter-spacing: 2px;
        border-bottom-width: 3px;
        display: inline-block;
        text-align: center;
        box-sizing: border-box;
    }

    .space {
        margin: 40px 0;
    }

    .copyright {
        font-size: 70%;
        letter-spacing: 3px;
        text-align: center;
        padding: 8px 1rem;
    }

    footer {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

@media (max-width: 430px) {
    .logo {
        font-size: 68%;
        letter-spacing: 2.5px;
        text-indent: 2.5px;
    }

    .caption, .caption1 {
        font-size: 130%;
        letter-spacing: 1px;
    }
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin-right: -0.375rem;
    padding: 0;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: #666f7e;
    cursor: pointer;
    z-index: 15;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: #18181b;
}

.theme-toggle:focus-visible {
    outline: 2px solid #666f7e;
    outline-offset: 2px;
}

.theme-toggle svg {
    width: 1.75rem;
    height: 1.75rem;
}

.theme-toggle .icon-sun {
    display: block;
}

.theme-toggle .icon-moon {
    display: none;
}

/* Dark Mode (Comfortable Off-Black) */
html.dark-mode,
html.dark-mode body {
    background-color: #141416;
    color: #a1a1aa;
}

html.dark-mode header {
    background-color: #1c1c1f;
}

html.dark-mode .theme-toggle {
    color: #a1a1aa;
}

html.dark-mode .theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #f0f0f2;
}

html.dark-mode .theme-toggle:focus-visible {
    outline-color: #a1a1aa;
}

html.dark-mode .theme-toggle .icon-sun {
    display: none;
}

html.dark-mode .theme-toggle .icon-moon {
    display: block;
}

html.dark-mode .logo {
    color: #a1a1aa;
}

html.dark-mode .text {
    color: #f0f0f2;
}

html.dark-mode .text1 {
    color: #a1a1aa;
}

html.dark-mode .caption,
html.dark-mode .caption1 {
    color: #a1a1aa;
    border-bottom-color: #a1a1aa;
}

html.dark-mode .caption:hover,
html.dark-mode .caption1:hover {
    color: #e4e4e7;
    border-bottom-color: #e4e4e7;
}

html.dark-mode .preview-frame {
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.6), 0 4px 10px -2px rgba(0, 0, 0, 0.45);
}

html.dark-mode .copyright {
    background-color: #1c1c1f;
    color: #a1a1aa;
}

html.dark-mode #menuToggle span {
    background: #a1a1aa;
}

html.dark-mode #menuToggle input:checked ~ span {
    background: #f0f0f2;
}

html.dark-mode #menu {
    background: #1c1c1f;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.55);
}

html.dark-mode #menuToggle a {
    color: #e4e4e7;
}

html.dark-mode #menuToggle a:hover {
    color: #93c5fd;
}
