/* theme */
:root {
    color-scheme: light dark;
    --bg-color: light-dark(oklch(92.8% 0 0), oklch(21.78% 0 0));
    --text-color: light-dark(oklch(22.25% 0.0141 274.5), oklch(89.93% 0.0164 262.75));
    --border-color: light-dark(oklch(80% 0 0), oklch(30% 0 0));
    --shadow-color: light-dark(oklch(0% 0 0 / 0.3), oklch(100% 0 0 / 0.3));
    --overlay-color: light-dark(oklch(100% 0 0 / 0.9), oklch(20% 0 0 / 0.9));
    --link-color: light-dark(oklch(42.54% 0.1269 299.1), oklch(72.36% 0.0454 298.54));
    --code-color: light-dark(oklch(39.07% 0.0915 253.74), oklch(72.04% 0.0912 253.56));
    --emphasis-color: light-dark(oklch(40% 0.1359 19.2), oklch(75.38% 0.1015 17.52));
    --abbr-color: light-dark(oklch(38.35% 0.0678 207.03), oklch(71.95% 0.0684 206.76));
    --bg-opacity: 0.2;
    --nav-height: 3rem;
}

@media (max-width: 31.25rem) {
    :root {
        --nav-height: 7.25rem;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'SF Mono', 'IBM Plex Mono', 'Courier', monospace;
    letter-spacing: -0.031rem;
    text-underline-offset: 0.188rem;
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(
        circle at center,
        var(--text-color) 0.0625rem,
        transparent 0.03125rem
    );
    background-size: 1.25rem 1.25rem;
    background-position: 0 0;
    color: var(--text-color);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow: hidden;
}

/* additional font styling */
.html5 {
    color: light-dark(oklch(40.37% 0.1544 60.71), oklch(76.85% 0.1926 60.71));
}

.css3 {
    color: light-dark(oklch(37.87% 0.1454 255.71), oklch(73.7% 0.1548 241.47));
}

.es6 {
    color: light-dark(oklch(40.56% 0.1322 93.37), oklch(87.09% 0.1817 93.37));
}

:is(h1, h2, h3, h4, h5, h6) {
    text-wrap: pretty;
}

.terminal-header h2 {
    font-size: 90%;
    letter-spacing: -0.04rem;
}

.terminal-content h3 {
    font-size: 120%;
}

abbr {
    color: var(--abbr-color);
}

p {
    display: inline-block;
    margin-top: 0;
    text-wrap: pretty;
}

a {
    display: inline-block;
    color: var(--link-color);
    text-decoration: none;
    padding: 0 0.125rem;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a:hover {
    background-color: var(--link-color);
    color: var(--bg-color);
}

abbr code {
    text-decoration: inherit;
}

code,
pre {
    display: inline-block;
    color: var(--code-color);
}

code a {
    color: var(--code-color);
    text-decoration: underline;
}

code a:hover {
    background-color: var(--code-color);
    color: var(--bg-color);
    text-decoration: none;
}

strong {
    display: inline-block;
    color: var(--emphasis-color);
}

:is(a, button, summary):focus-visible {
    outline: 0.125rem dashed currentColor;
    outline-offset: 0.25rem;
}

[hidden] {
    display: none !important;
}

/* semantic HTML layout */
section {
    display: flex;
    flex-direction: column;
    padding: 1.25rem 2rem 2rem 2rem;
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-line;
    color: var(--text-color);
    cursor: default;
    align-content: center;
}

section ul {
    margin: 0 -1rem;
}

section ul li {
    position: relative;
    list-style-type: "* ";
    list-style-position: inside;
    margin-top: -0.4rem;
    margin-bottom: -0.4rem;
}

section ul * {
    font-size: 105%;
}

details {
    padding: 0;
}

details[open] > summary {
    margin: 0 0 -1.5rem;
    padding: 0;
}

details > ul {
    margin: 0 0 -2rem;
    padding-left: 1rem;
    line-height: 1.2;
}

details li {
    margin: 0.2rem 0;
}

aside {
    display: flex;
    flex-direction: column;
}

@media screen and (min-width: 31.25rem) {
    abbr[title]:hover::after,
    abbr[title]:focus::after {
        content: attr(title);
        position: absolute;
        left: 50%;
        top: 100%;
        transform: translateX(-40%);
        margin-top: 0.3125rem;
        width: auto;
        white-space: preserve nowrap;
        z-index: 100;
        background-color: var(--text-color);
        color: var(--bg-color);
        border-radius: 0.25rem;
        box-shadow: 0.0625rem 0.0625rem 0.3125rem 0rem var(--shadow-color);
        font-size: 0.75rem;
        padding: 0.125rem 0.25rem 0.125rem 0.25rem;
    }
}

abbr[title] {
    position: relative;
    text-decoration: underline dotted;
}
/* content layout */

#about-container {
    display: flex;
    gap: 1rem;
    position: relative;
    align-items: stretch;
}

#about-icon-container {
    flex: 0 0 30%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-right: 1.25rem;
}

#about-container::after {
    content: '';
    position: absolute;
    left: calc(30%);
    top: 0;
    bottom: 0;
    width: 0.125rem;
    background-color: var(--border-color);
}

#about-icon {
    max-width: 100%;
    height: auto;
    margin-bottom: 0.5rem;
    filter: grayscale(100%);
    transition: filter 0.3s ease;
    border: 0.0625rem solid var(--text-color);
}

#about-icon:hover {
    filter: grayscale(0%);
}

#about-text {
    flex: 1;
    padding: 0rem 0rem 0rem 0.5rem;
}

/* nav bar style */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: var(--text-color);
    z-index: 1000;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

nav ul {
    display: flex;
    list-style: none;
    margin: 0;
}

nav ul li {
    margin: 0 0.5rem;
}

nav ul li a {
    color: var(--bg-color);
    font-size: 1rem;
    padding: 0.25rem 0.75rem;
}

nav ul li a:hover,
nav ul li a.active-link,
nav ul li a[aria-current="page"] {
    background-color: var(--bg-color);
    color: var(--text-color);
}

nav ul li a:hover {
    opacity: 0.9;
}

nav ul li a.active-link:hover {
    opacity: 0.8;
}

/* toggle theme button */
#toggle-theme {
    background: none;
    border: none;
    color: var(--bg-color);
    font-size: 0.813rem;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

#toggle-theme:hover {
    background-color: var(--bg-color);
    color: var(--text-color);
    opacity: 0.9;
}

/* panel layout */
.panels-container {
    margin-top: var(--nav-height);
    position: relative;
    height: calc(100vh - var(--nav-height));
    height: calc(100dvh - var(--nav-height));
    overflow: hidden;
    padding: 1.25rem;
    box-sizing: border-box;
}

/* panel container background */
.panels-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--bg-color);
    opacity: calc(1 - var(--bg-opacity));
    z-index: -1;
    pointer-events: none;
}

.panel {
    position: absolute;
    width: 45%;
    max-width: 37.5rem;
    transition: width 0.3s ease, transform 0.3s ease;
    transform: translate3d(0, 0, 0);
    will-change: transform;
    height: auto;
}

.panel.dragging {
    will-change: transform;
}

/* panel styling */
.terminal-window {
    border: 0.125rem solid var(--border-color);
    background-color: var(--bg-color);
    width: 100%;
    position: relative;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    user-select: none;
    display: flex;
    flex-direction: column;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--text-color);
    color: var(--bg-color);
    padding: 0.4rem 0.8rem;
    cursor: default;
}

.terminal-tabs {
    margin: -0.4rem 0rem;
}

.terminal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 1.25rem;
}

.terminal-tab {
    display: none;
    height: 100%;
    width: 100%;
}

.terminal-tab.tab-active {
    display: flex;
    flex-direction: column;
}

/* children should use the full space, since terminal-tab is merely an organizational container */
.terminal-tab > * {
    flex: 1;
    width: 100%;
    height: 100%;
}

.tab-button {
    background: none;
    border: none;
    color: var(--bg-color);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.tab-button:hover {
    text-decoration: underline;
}

.tab-button.tab-active {
    opacity: 1;
    text-decoration: underline;
}

/* panel focus state */
.panel.active:not(#preview) .terminal-header {
    cursor: move;
    touch-action: none;
}

.panel.active .terminal-content {
    user-select: text;
}

.panel:not(.active) .cursor {
    display: none;
}

.active .terminal-window {
    border: 0.125rem solid var(--text-color);
    box-shadow: 0.5rem 0.5rem 0 var(--shadow-color);
}

.panel.dragging {
    transition: none !important;

    .terminal-window {
        user-select: none;
    }
}

/* panel inactive overlay */
.terminal-window::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--overlay-color);
    transition: opacity 0.3s ease;
    opacity: 1;
}

.panel:not(.active):hover .terminal-window::after {
    opacity: 0.7;
}

.active .terminal-window::after {
    opacity: 0;
    pointer-events: none;
}

/* panel placements */
#welcome {
    top: calc(40vh - 5.688rem);
    left: 25vw;
    max-width: 50rem;
    width: 100%;
    z-index: 5;
}

#about {
    top: calc(15vh - 5.688rem);
    left: 1.5vw;
    max-width: 37.5rem;
    z-index: 3;

    .terminal-content {
        min-height: 20rem;
        justify-content: space-between;
    }
}

#projects {
    top: calc(12vh - 5.688rem);
    right: 1.5vw;
    max-width: fit-content;
    z-index: 2;
}

#skills {
    top: calc(45vh - 5.688rem);
    left: 5vw;
    max-width: fit-content;
    z-index: 4;
}

#refs {
    top: calc(86vh - 5.688rem);
    right: 2vw;
    max-width: fit-content;
    z-index: 1;
}

/* ref links */
sup {
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

sup a,
sup a:hover {
    background-color: transparent;
    color: inherit;
    padding: 0;
}

sup.highlight {
    background-color: var(--text-color);
    color: var(--bg-color);
    padding: 0 0.25rem;
    border-radius: 0.125rem;
}

#refs sup {
    margin-right: 0.5rem;
}

/* links */
.terminal-content a.highlight {
    background-color: var(--link-color);
    color: var(--bg-color);
    padding: 0 0.25rem;
    border-radius: 0.125rem;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.terminal-content a.highlight:hover {
    color: var(--bg-color);
    opacity: 0.9;
}

/* image preview styles */
#preview {
    position: fixed;
    top: calc(50% + var(--nav-height) / 2);
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 75rem;
    height: 80vh;
    height: 80dvh;
    background: var(--bg-color);
}

#preview::backdrop {
    background-color: var(--shadow-color);
    backdrop-filter: blur(0.1875rem);
}

#preview .terminal-window {
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
}

#preview .terminal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: hidden;
}

#preview .preview-container {
    flex: 1;
    width: 100%;
    height: 100%;
    max-width: 100rem;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    overflow: hidden;
}

#preview iframe {
    flex: 1 1 auto;
    width: inherit;
    height: inherit;
    min-height: 0;
    border: none;
    background: var(--bg-color);
}

#preview .preview-external-link {
    flex: 0 0 auto;
}

#preview img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
    object-position: center;
}

/* Image previews follow the image's natural size until they reach the viewport limits. */
#preview.image-preview {
    width: fit-content;
    max-width: min(90vw, 75rem);
    height: fit-content;
    max-height: 80vh;
    max-height: 80dvh;
}

#preview.image-preview .terminal-window {
    width: fit-content;
    max-width: 100%;
    height: auto;
}

#preview.image-preview .terminal-content,
#preview.image-preview .preview-container {
    flex: 0 1 auto;
    width: fit-content;
    height: fit-content;
    max-width: 100%;
}

#preview.image-preview .terminal-content {
    max-height: calc(80vh - 2rem);
    max-height: calc(80dvh - 2rem);
    overflow: auto;
}

#preview.image-preview img {
    max-width: calc(90vw - 2rem);
    max-height: calc(80vh - 5rem);
    max-height: calc(80dvh - 5rem);
}

/* desktop */
@media (max-width: 75rem) {
    .panel.active {
        width: 75%;
    }
}

/* tablets */
@media (max-width: 48rem) {
    .panel.active {
        width: 90%;
    }
}

/* mobile */
@media (max-width: 31.25rem) {
    /* font size adjustments */

    * {
        font-size: 95%;
    }

    body {
        overflow-y: auto;
    }

    section {
        padding: 1rem 1.5rem 1.5rem 1.5rem;
    }

    section h4 {
        padding-bottom: 1.25rem;
    }

    section p {
        font-size: 100%;
        line-height: 1.6rem;
    }

    section ul * {
        font-size: 96%;
    }

    nav {
        padding: 0.5rem;
        flex-direction: column;
    }

    nav ul {
        flex-wrap: wrap;
        justify-content: center;
        padding: 0.5rem 0;
    }

    nav ul li {
        margin: 0.25rem;
    }

    nav ul li a {
        padding: 0.25rem 0.5rem;
    }

    #toggle-theme {
        padding: 0.2rem;
    }

    .panels-container {
        min-height: calc(100vh - var(--nav-height));
        min-height: calc(100dvh - var(--nav-height));
        height: auto;
        overflow-y: auto;
        padding: 1rem;
        position: relative;
    }

    .panels-container::before {
        position: fixed;
        top: var(--nav-height);
        height: calc(100vh - var(--nav-height));
        height: calc(100dvh - var(--nav-height));
        width: 100%;
    }

    .panel:not(#preview) {
        position: relative !important;
        height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 2rem;
        inset: 0 !important;
        transform: none !important;
    }

    .terminal-window {
        box-shadow: none;
    }

    .terminal-content {
        min-height: 25rem;
    }

    .panel.active .terminal-header {
        cursor: default;
    }

    .terminal-header {
        flex-direction: row;
        padding: 0.4rem 0.8rem;
        justify-content: space-between;
    }

    .terminal-header h2 {
        font-size: 110%;
    }

    .terminal-tabs {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }

    .tab-button {
        display: block;
        padding: 0rem 0.5rem 0rem 0.5rem;
        margin: 0rem;
        opacity: 0.7;
        transition: opacity 0.3s ease;
    }

    .tab-button:hover {
        opacity: 1;
    }

    .tab-button.tab-active {
        opacity: 1;
        text-decoration: underline;
    }

    #preview {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        margin-top: var(--nav-height);
        height: calc(100vh - var(--nav-height));
        height: calc(100dvh - var(--nav-height));
        transform: none;
    }

    #preview.image-preview {
        top: calc(50% + var(--nav-height) / 2);
        left: 50%;
        right: auto;
        bottom: auto;
        width: fit-content !important;
        max-width: calc(100vw - 2rem) !important;
        height: fit-content;
        max-height: calc(100dvh - var(--nav-height) - 2rem);
        margin-top: 0;
        transform: translate(-50%, -50%) !important;
    }

    #preview.image-preview img {
        max-width: calc(100vw - 4rem);
        max-height: calc(100dvh - var(--nav-height) - 6rem);
    }

    #preview.image-preview .terminal-content {
        min-height: 0;
    }

    #preview::backdrop {
        background-color: var(--shadow-color);
        backdrop-filter: blur(0.125rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
