:root {
    --bg: #050508;
    --text: #e8e4dc;
    --text-dim: #9a9690;
    --accent: #c4b99a;
    --panel-bg: rgba(8, 8, 11, 0.88);
    --panel-border: rgba(196, 185, 154, 0.28);

    /* Spacing scale */
    --space-xs: 0.3rem;
    --space-sm: 0.55rem;
    --space-md: 1rem;
    --space-ml: 1.4rem;
    --space-lg: 1.8rem;
    --space-xl: 2.5rem;

    /* Type scale */
    --text-lg: 1.1rem;
    --text-body: 0.94rem;
    --text-secondary: 0.83rem;
    --text-label: 0.72rem;
    --text-label-sm: 0.62rem;
    --text-hint: 0.55rem;

    /* Motion */
    --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
}

* {
    box-sizing: border-box;
}

:focus {
    outline: none;
}

:focus-visible {
    outline: 1px solid rgba(196, 185, 154, 0.55);
    outline-offset: 2px;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(circle at 22% 15%, #0e0e10 0%, var(--bg) 45%, #030303 100%);
    color: var(--text);
    font-family: "DM Sans", sans-serif;
}

#scene-root {
    position: fixed;
    inset: 0;
}

canvas {
    display: block;
}

#intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #050508;
    pointer-events: none;
    transition: opacity 1.5s ease;
}

#site-identity {
    position: fixed;
    top: max(1.3rem, calc(env(safe-area-inset-top) + 0.5rem));
    left: max(1.4rem, calc(env(safe-area-inset-left) + 1rem));
    z-index: 8;
    pointer-events: none;
}

.site-name {
    font-family: "Space Mono", monospace;
    font-size: var(--text-label);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text);
}

@keyframes reticle-spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

#planet-label {
    display: none;
}

#hover-reticle {
    position: fixed;
    z-index: 5;
    border: 1px solid rgba(232, 228, 220, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 180ms ease, width 120ms ease, height 120ms ease;
}

#hover-reticle.visible {
    opacity: 1;
    animation: reticle-spin 18s linear infinite;
}



.body-label {
    position: fixed;
    z-index: 6;
    transform: translate(-50%, -60%);
    color: rgba(232, 228, 220, 0.52);
    font-family: "Space Mono", monospace;
    font-size: var(--text-hint);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    pointer-events: none;
    opacity: 0;
    transition: opacity 400ms ease;
    white-space: nowrap;
}

#back-btn {
    position: fixed;
    top: max(1.3rem, calc(env(safe-area-inset-top) + 0.5rem));
    right: max(1.2rem, calc(env(safe-area-inset-right) + 0.5rem));
    z-index: 8;
    border: 1px solid var(--panel-border);
    background: var(--panel-bg);
    color: var(--text);
    font-family: "Space Mono", monospace;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: var(--text-label);
    padding: 0.6rem 1.1rem;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 280ms ease, border-color 200ms ease, transform 120ms ease;
}

#back-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

#back-btn:hover {
    border-color: rgba(196, 185, 154, 0.55);
}

#back-btn:active {
    transform: scale(0.95);
    transition-duration: 60ms;
}

#back-btn:focus-visible {
    outline: 1px solid rgba(196, 185, 154, 0.6);
    outline-offset: 2px;
    border-color: rgba(196, 185, 154, 0.55);
}

#panels {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 7;
    pointer-events: none;
}

#panels::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 280ms ease;
    background: radial-gradient(circle at 50% 45%, rgba(245, 230, 200, 0.05), rgba(5, 5, 8, 0.7));
}

#panels.has-open::before {
    opacity: 1;
}

.panel::-webkit-scrollbar {
    display: none;
}

.panel {
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    position: absolute;
    width: min(720px, 92vw);
    max-height: min(82vh, 760px);
    transform: translateY(22px) scale(0.96);
    opacity: 0;
    padding: clamp(1.2rem, 3.2vw, 2.1rem);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.36);
    background: linear-gradient(170deg, rgba(10, 10, 13, 0.98), var(--panel-bg));
    transition: transform 450ms var(--ease-out), opacity 380ms var(--ease-out);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    pointer-events: none;
}

.panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

@keyframes panel-item-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.panel.open > * {
    animation: panel-item-in 0.38s ease both;
}

.panel.open > *:nth-child(1) { animation-delay: 0.10s; }
.panel.open > *:nth-child(2) { animation-delay: 0.18s; }
.panel.open > *:nth-child(3) { animation-delay: 0.26s; }
.panel.open > *:nth-child(4) { animation-delay: 0.34s; }
.panel.open > *:nth-child(5) { animation-delay: 0.42s; }
.panel.open > *:nth-child(6) { animation-delay: 0.50s; }

.panel h2 {
    margin: 0 0 var(--space-md);
    font-family: "Space Mono", monospace;
    font-size: clamp(1.3rem, 2.8vw, 1.9rem);
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.panel p,
.panel li {
    color: var(--text);
    font-family: "DM Sans", sans-serif;
    font-size: var(--text-body);
    font-weight: 300;
    line-height: 1.65;
    margin: 0 0 var(--space-sm);
}

.panel .dim {
    color: var(--text-dim);
}

.about-hero {
    margin-bottom: 0;
}


.panel .about-name {
    font-family: "Space Mono", monospace;
    font-size: clamp(1.85rem, 4.4vw, 3rem);
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: 0.04em;
    text-transform: none;
    margin: 0 0 var(--space-xs);
}

.panel .about-subtitle {
    font-family: "DM Sans", sans-serif;
    font-size: var(--text-body);
    font-weight: 300;
    color: var(--text-dim);
    margin: 0 0 var(--space-md);
    line-height: 1.5;
}


.about-divider {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: var(--space-md) 0;
}

.about-divider div {
    flex: 1;
    height: 1px;
    background: rgba(196, 185, 154, 0.22);
}

@keyframes diamond-pulse {
    0%, 100% { opacity: 0.45; transform: scale(1); }
    50%       { opacity: 0.7;  transform: scale(1.15); }
}

.about-divider span {
    font-size: var(--text-hint);
    color: rgba(196, 185, 154, 0.55);
    letter-spacing: 0;
    line-height: 1;
    animation: diamond-pulse 3.5s ease-in-out infinite;
}


.about-explore {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-ml);
}

.about-explore-btn {
    font-family: "Space Mono", monospace;
    font-size: var(--text-secondary);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text);
    background: none;
    border: 1px solid rgba(196, 185, 154, 0.25);
    padding: 0.35em 0.75em;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.about-explore-btn:hover {
    color: var(--text);
    border-color: rgba(196, 185, 154, 0.55);
    background: rgba(196, 185, 154, 0.06);
}

.about-explore-btn:active {
    opacity: 0.7;
    transition-duration: 60ms;
}

.about-explore-btn:focus-visible {
    outline: 1px solid rgba(196, 185, 154, 0.6);
    outline-offset: 3px;
}

.about-links {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-ml);
}

.about-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: "DM Sans", sans-serif;
    font-size: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 0;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 999px;
    padding: 0.28rem 0.7rem 0.28rem 0.5rem;
    min-width: 0;
    transition: color 0.18s ease, background 0.18s ease, transform 0.2s var(--ease-out);
}


.about-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.about-link:hover {
    color: var(--text);
    background: rgba(232, 228, 220, 0.05);
    transform: translateY(-1px);
}

.about-link:active {
    transform: scale(0.97);
    transition-duration: 60ms;
}

.about-link:focus-visible {
    outline: 1px solid rgba(196, 185, 154, 0.55);
    outline-offset: 2px;
    color: var(--text);
    background: rgba(232, 228, 220, 0.05);
}

.about-link svg {
    flex-shrink: 0;
    opacity: 0.75;
}

.project-grid {
    display: grid;
    gap: var(--space-ml);
}

.project-card {
    border: 1px solid rgba(196, 185, 154, 0.18);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(13, 13, 16, 0.74);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.project-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(196, 185, 154, 0.32);
    border-color: rgba(196, 185, 154, 0.32);
}

.project-img-wrap {
    overflow: hidden;
}

.project-card img {
    width: 100%;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: rgba(13, 13, 16, 0.9);
    filter: saturate(0.65) contrast(0.88) brightness(0.92);
    transition: filter 0.25s ease;
}

.project-card:hover img {
    filter: saturate(0.95) contrast(0.96) brightness(1.0);
}

.project-content {
    padding: var(--space-md);
}

.project-content h3 {
    margin: 0 0 var(--space-sm);
    font-family: "DM Sans", sans-serif;
    font-size: var(--text-lg);
    font-weight: 400;
    line-height: 1.25;
    overflow-wrap: break-word;
}

.project-content p {
    margin: 0 0 var(--space-sm);
    color: var(--text);
    font-family: "DM Sans", sans-serif;
    font-size: var(--text-body);
    font-weight: 300;
}

.project-content .project-tech {
    margin: 0 0 var(--space-sm);
    color: var(--text-dim);
    font-size: var(--text-secondary);
    overflow-wrap: break-word;
}

.project-links {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.project-links a {
    font-family: "Space Mono", monospace;
    font-size: var(--text-label);
    color: var(--text);
    text-decoration: none;
    border: 1px solid rgba(196, 185, 154, 0.22);
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.project-links a:hover {
    color: var(--text);
    background: rgba(196, 185, 154, 0.07);
    border-color: rgba(196, 185, 154, 0.38);
}

.project-links a:active {
    transform: scale(0.94);
    transition-duration: 60ms;
}

.project-links a:focus-visible {
    outline: 1px solid rgba(196, 185, 154, 0.55);
    outline-offset: 2px;
    color: var(--text);
    background: rgba(196, 185, 154, 0.07);
    border-color: rgba(196, 185, 154, 0.38);
}

#skills-panel {
    width: min(576px, 92vw);
    max-height: fit-content;
}

.skills-list {
    display: grid;
    gap: var(--space-ml);
}

.skills-group {
    border-left: 2px solid rgba(196, 185, 154, 0.42);
    padding-left: var(--space-md);
}

.skills-list h3 {
    margin: 0 0 var(--space-xs);
    font-size: var(--text-label-sm);
    letter-spacing: 0.12em;
    font-family: "Space Mono", monospace;
    font-weight: 400;
    color: rgba(196, 185, 154, 0.7);
    text-transform: uppercase;
}

.skills-group p {
    margin: 0;
    font-family: "DM Sans", sans-serif;
    font-size: var(--text-body);
    font-weight: 300;
    color: var(--text);
    line-height: 1.6;
    overflow-wrap: break-word;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.38rem;
}

.skill-tag {
    font-family: "Space Mono", monospace;
    font-size: var(--text-label-sm);
    letter-spacing: 0.07em;
    color: var(--text);
    background: rgba(196, 185, 154, 0.05);
    border: 1px solid rgba(196, 185, 154, 0.2);
    border-radius: 3px;
    padding: 0.24rem 0.6rem;
    white-space: nowrap;
    line-height: 1.5;
}

@media (max-width: 900px) {
    :root {
        --text-body: 1rem;
    }

    #back-btn {
        top: max(0.75rem, calc(env(safe-area-inset-top) + 0.3rem));
        right: max(0.75rem, calc(env(safe-area-inset-right) + 0.4rem));
        font-size: 0.66rem;
        letter-spacing: 0.08em;
        padding: 0.72rem 1.1rem;
    }

    #planet-label {
        font-size: 0.66rem;
        padding: 0.24rem 0.44rem;
    }

    .panel {
        width: 95vw;
        max-height: 76vh;
        border-radius: 10px;
        padding: 1rem 0.95rem 1.1rem;
        transform: translateY(18px) scale(0.97);
    }

    .panel.open {
        transform: translateY(0) scale(1);
    }

    .panel h2 {
        font-size: clamp(1.05rem, 5vw, 1.4rem);
        margin-bottom: 0.62rem;
    }

    .panel p,
    .panel li {
        font-size: var(--text-body);
    }

    .project-content p {
        font-size: 0.92rem;
    }

    .skill-tag {
        font-size: 0.62rem;
    }
}

@media (max-width: 640px) {
    #panels {
        align-items: center;
        justify-items: center;
        padding: 0 0.7rem;
    }

    .panel {
        width: 100%;
        max-height: 82vh;
        border-radius: 10px;
    }

    .project-grid {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .project-card {
        width: 100%;
        margin: 0 auto;
    }

    .project-content {
        padding: var(--space-sm) var(--space-md);
    }

    .project-links {
        justify-content: center;
        gap: var(--space-md);
    }

    .project-links a {
        padding: 0.6rem 1.1rem;
    }

    .about-link {
        padding: 0.5rem 0.9rem 0.5rem 0.65rem;
    }

    .about-explore-btn {
        padding: 0.85rem 1rem;
    }
}

/* Disable hover effects on touch — prevents sticky-hover on tap */
@media (hover: none) and (pointer: coarse) {
    .about-explore-btn:hover {
        color: var(--text);
        border-color: rgba(196, 185, 154, 0.25);
        background: none;
    }
    .about-link:hover {
        color: var(--text-dim);
        background: transparent;
        transform: none;
    }
    .project-card:hover {
        transform: none;
        box-shadow: none;
        border-color: rgba(196, 185, 154, 0.18);
    }
    .project-card:hover img {
        filter: saturate(0.65) contrast(0.88) brightness(0.92);
    }
    .project-links a:hover {
        background: transparent;
        border-color: rgba(196, 185, 154, 0.22);
        transform: none;
    }
    #back-btn:hover {
        border-color: var(--panel-border);
    }
}

/* Landscape phone — keep panel usable when height is constrained */
@media (max-height: 500px) and (orientation: landscape) {
    .panel {
        max-height: 90vh;
    }
    .about-divider {
        margin: 0.5rem 0;
    }
    .panel .about-name {
        font-size: clamp(1.4rem, 4vw, 1.9rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .about-divider span {
        animation: none;
        opacity: 0.45;
        transform: none;
    }
    .panel {
        transition: opacity 0.01ms !important;
    }
    .panel.open > * {
        animation: none;
    }
    .about-explore-btn {
        transition: color 0.01ms !important;
    }
    .about-link,
    .about-link:hover,
    .about-link:active {
        transform: none !important;
        transition: color 0.01ms, background 0.01ms !important;
    }
    .project-links a,
    .project-links a:hover,
    .project-links a:active {
        transition: background 0.01ms, border-color 0.01ms, color 0.01ms !important;
    }
    #back-btn,
    #back-btn:active {
        transform: none !important;
        transition: opacity 0.01ms, border-color 0.01ms !important;
    }
}
