@import url("theme.css");

/* peril.lol's signature serif */
:root {
    --font-body: "EB Garamond", Georgia, "Times New Roman", serif;
    --font-head: "EB Garamond", Georgia, "Times New Roman", serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Single shared transition so the whole page recolours in sync on toggle */
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
}

::selection {
    background: var(--accent);
    color: var(--bg);
}

html {
    font-size: 20px;
    background-color: var(--bg);
}

body {
    font-family: var(--font-body);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    max-width: 720px;
    margin: 0 0 0 var(--page-left);
    padding: 6rem var(--page-right) 4rem 0;
    font-size: 1.05rem;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}

a:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ---------- Header ---------- */
header {
    margin-bottom: 2.5rem;
}

h1 {
    font-family: var(--font-head);
    font-size: 2.4rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.interactive-name {
    display: inline-block;
    line-height: 1.15;
    cursor: default;
    user-select: none;
    white-space: nowrap;
}

.name-slot {
    display: inline-block;
    position: relative;
    width: 3ch;
    height: 1.15em;
    vertical-align: bottom;
}

.name-ending {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: baseline;
    color: inherit;
    line-height: 1.15;
    opacity: 1;
    transform: translateY(0) scale(1);
    transform-origin: left center;
    transition: none;
}

.interactive-name.swapping .name-ending,
.interactive-name.animating .name-ending {
    transition:
        opacity 0.09s ease,
        transform 0.09s ease,
        color 0.2s ease;
}

.interactive-name.swapping .name-ending {
    opacity: 0;
    transform: translateY(0.12em) scale(0.94);
}

.interactive-name.animating .name-ending {
    color: var(--accent);
}

.bio {
    color: var(--text);
    font-size: 1.25rem;
    margin-bottom: 1.75rem;
    max-width: 50ch;
}

/* ---------- Inline nav ---------- */
nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    font-size: 1.05rem;
}

nav a {
    color: var(--secondary);
    border-bottom: none;
}

nav a:hover {
    color: var(--accent);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--secondary);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.theme-toggle:hover {
    color: var(--accent);
}

/* ---------- Home hero animation (right 60%) ---------- */
/* When there's room the screen splits 40% text / 60% animation space, and the
   square animation sits centred in that right-hand space (spanning 20%–80% of
   it). Below the breakpoint the animation is dropped and only the text remains.
   The square is an invisible hit-area whose frame highlights on hover; the
   flow itself is drawn by hero.js. */
.hero-box {
    display: none; /* shown only when there's space (see media query) */
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    --side: min(36vw, 78vh);
    width: var(--side);
    height: var(--side);
    left: calc(40vw + (60vw - var(--side)) / 2);
}

/* No frame: the animation fades out radially toward the edges (hero.js) */
.hero-anim {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.hero-anim canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.hero-project-image {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: 82%;
    height: 82%;
    object-fit: cover;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 18px 45px -30px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.97);
    pointer-events: none;
    transition:
        opacity 0.22s ease,
        transform 0.28s ease;
}

.hero-project-image.loaded {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ---------- Animation control (wheel logo + name + tuning panel) ---------- */
.anim-control {
    display: none; /* shown only when the animation is (see media query) */
    position: relative;
    align-items: center;
    gap: 0.5rem;
}

.anim-logo {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--secondary);
    display: inline-flex;
    align-items: center;
}

.anim-logo:hover {
    color: var(--accent);
}

.anim-logo-glyph {
    font-size: 1rem;
    letter-spacing: -0.04em;
    font-weight: 400;
}

.anim-name {
    color: var(--secondary);
    font-size: 1.05rem;
    opacity: 0;
    transform: translateX(-4px);
    transition:
        opacity 0.35s ease,
        transform 0.35s ease;
    pointer-events: none;
    white-space: nowrap;
}

.anim-name.show {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    cursor: pointer;
}

/* Tuning panel */
.anim-panel {
    position: absolute;
    /* contiguous with the control (no dead gap) so moving onto it doesn't
       trigger the control's mouseleave; visual spacing comes from padding */
    top: 100%;
    left: 0;
    width: 250px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem 1rem 1rem;
    z-index: 50;
    box-shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.45);
}

.anim-panel[hidden] {
    display: none;
}

/* Animation chooser */
.anim-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.7rem;
    margin-bottom: 0.9rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.anim-item {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    font-size: 0.88rem;
    color: var(--dim);
}

.anim-item:hover {
    color: var(--text);
}

.anim-item.active {
    color: var(--accent);
}

.anim-panel .row {
    margin: 0.6rem 0;
}

.anim-panel label {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--secondary);
    margin-bottom: 0.3rem;
}

.anim-panel .val {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.anim-panel input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.anim-panel input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    transition: transform 0.15s ease;
}

.anim-panel input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.anim-panel input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

/* Enough room: 40 / 60 split — text column left, animation space right */
@media (min-width: 1100px) {
    body {
        max-width: 40vw;
    }
    .hero-box {
        display: block;
    }
    .anim-control {
        display: inline-flex;
    }
}

/* ---------- Sections ---------- */
section {
    margin-top: 3rem;
}

.section-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--dim);
    margin-bottom: 1.5rem;
}

/* ---------- Project list ---------- */
.project {
    display: block;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.project-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.project-title {
    font-weight: 500;
    font-size: 1.2rem;
}

.project:hover .project-title {
    color: var(--accent);
}

.project-date {
    color: var(--dim);
    font-size: 0.95rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.project-desc {
    color: var(--secondary);
    font-size: 1rem;
    margin-top: 0.3rem;
    max-width: 60ch;
}

/* ---------- Footer ---------- */
footer {
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--dim);
    font-size: 0.9rem;
}

.project-list {
    max-width: 460px;
    margin-top: 3rem;
}

@media (max-width: 1099px) {
    .project-list {
        max-width: none;
    }
}

@media (max-width: 540px) {
    :root {
        --page-left: 1.5rem;
        --page-right: 1.5rem;
    }
    html {
        font-size: 16px;
    }
    body {
        padding-top: 3.5rem;
        padding-bottom: 3rem;
    }
    .project-head {
        flex-direction: column;
        gap: 0.2rem;
    }
}
