:root {
    --bg-color: #03030c;
    --card-bg: rgba(16, 17, 46, 0.88);
    --accent: #7f5af0;
    --accent-soft: rgba(127, 90, 240, 0.18);
    --brand-x: #1D9BF0;
    --brand-linkedin: #0A66C2;
    --brand-github: #6e7681;
    --text-primary: #f8f9ff;
    --text-muted: #a4a8c1;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow: 0 24px 48px rgba(3, 4, 24, 0.6);
    --radius-lg: 24px;
    --radius-md: 16px;
    --transition: 200ms ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, rgba(33, 30, 60, 0.65), transparent 55%), var(--bg-color);
    color: var(--text-primary);
    font-family: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    padding: 2rem 1rem 3rem;
}

img, svg {
    max-width: 100%;
    height: auto;
}

/* Fixed banner with starfield and gradient mask */
.banner {
    position: fixed;
    inset: 0;
    background: url('assets/banner.jpg') center/cover no-repeat;
    filter: brightness(0.4) saturate(1.2);
    pointer-events: none;
    z-index: -2;
    overflow: hidden;
}

.banner::before {
    content: '';
    position: absolute;
    inset: -15%;
    background:
        radial-gradient(1px 1px at 10px 20px, rgba(255, 255, 255, 0.6), transparent 60%),
        radial-gradient(1.5px 1.5px at 60px 80px, rgba(127, 90, 240, 0.45), transparent 65%),
        radial-gradient(2px 2px at 120px 160px, rgba(180, 190, 255, 0.35), transparent 60%);
    background-size: 220px 220px, 320px 320px, 420px 420px;
    opacity: 0.55;
    animation: starfield-drift 110s linear infinite, starfield-twinkle 9s ease-in-out infinite;
    transform: translate3d(var(--star-parallax-x, 0), var(--star-parallax-y, 0), 0);
    will-change: transform, opacity, background-position;
    z-index: 0;
}

.banner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, var(--mask-start, rgba(3, 3, 12, 0.25)) 0%, var(--mask-end, rgba(3, 3, 12, 0.9)) 80%);
    z-index: 1;
}

/* Constellation canvas overlay (beneath mask) */
.constellation-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0; /* toggled via JS */
    transition: opacity var(--transition);
    z-index: 0;
    pointer-events: none;
}

/* Shooting stars */
.shooting-stars {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.shooting-stars span {
    position: absolute;
    top: -10%;
    right: -10%;
    width: 2px;
    height: 120px;
    background: linear-gradient(180deg, rgba(255,255,255,0.8), rgba(255,255,255,0) 70%);
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.45));
    transform: rotate(-28deg);
    opacity: 0;
    animation: shooting 16s linear infinite;
}

.shooting-stars span:nth-child(1) { animation-delay: 1.5s; top: 6%; right: -8%; }
.shooting-stars span:nth-child(2) { animation-delay: 4s; top: -3%; right: 8%; }
.shooting-stars span:nth-child(3) { animation-delay: 6.5s; top: -6%; right: -2%; }
.shooting-stars span:nth-child(4) { animation-delay: 9s; top: 3%; right: 20%; }
.shooting-stars span:nth-child(5) { animation-delay: 11.5s; top: -7%; right: 34%; }
.shooting-stars span:nth-child(6) { animation-delay: 14s; top: 5%; right: 47%; }
.shooting-stars span:nth-child(7) { animation-delay: 16.5s; top: -5%; right: 59%; }
.shooting-stars span:nth-child(8) { animation-delay: 19s; top: 2%; right: 71%; }

@keyframes shooting {
    0%   { opacity: 0; transform: translate3d(0,0,0) rotate(-28deg); }
    4%   { opacity: 1; }
    12%  { opacity: 0; }
    100% { transform: translate3d(-140vw, 90vh, 0) rotate(-28deg); }
}

/* When constellation is OFF, pause any motion elements tied to the backdrop */
:root:not(.constellation-on) .banner::before { animation: none; opacity: 0.25; }
:root:not(.constellation-on) .shooting-stars span { animation: none; opacity: 0; }

.card {
    width: min(960px, 100%);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: linear-gradient(180deg, rgba(16, 17, 46, 0.95) 0%, rgba(10, 11, 32, 0.95) 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: clamp(1.5rem, 2vw, 2.5rem);
    backdrop-filter: blur(8px);
    transform: translate3d(var(--card-parallax-x, 0), var(--card-parallax-y, 0), 0);
    transition: transform var(--transition);
}

.profile {
    display: grid;
    grid-template-columns: minmax(120px, 180px) 1fr;
    gap: clamp(1.5rem, 3vw, 2.5rem);
    align-items: center;
}

.avatar {
    width: clamp(120px, 25vw, 180px);
    aspect-ratio: 1;
    border-radius: 50%;
    border: 4px solid rgba(127, 90, 240, 0.6);
    object-fit: cover;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.identity h1 {
    font-size: clamp(2rem, 3vw, 2.8rem);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.subtitle {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-weight: 500;
}

.bio {
    margin-top: 1rem;
    color: var(--text-primary);
    font-style: italic;
    font-weight: 400;
}

.socials {
    list-style: none;
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.socials a {
    text-decoration: none;
    color: var(--text-primary);
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid rgba(127, 90, 240, 0.5);
    transition: transform var(--transition), background var(--transition), color var(--transition);
}

.socials svg { width: 20px; height: 20px; }

.socials a:hover,
.socials a:focus-visible {
    background: var(--accent);
    transform: translateY(-2px);
}

.actions {
    margin-top: 1.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.5rem;
    border-radius: 999px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-primary);
    background: var(--accent);
    box-shadow: 0 12px 24px rgba(127, 90, 240, 0.35);
    transition: transform var(--transition), box-shadow var(--transition);
}

.btn:hover,
.btn:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(127, 90, 240, 0.45);
}

.btn.secondary {
    background: transparent;
    border: 1px solid rgba(127, 90, 240, 0.65);
    box-shadow: none;
}

.section {
    background: rgba(12, 13, 34, 0.9);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.section h2 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.verified-list {
    list-style: none;
    display: grid;
    gap: 1rem;
}

.verified-list li {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    background: rgba(20, 21, 46, 0.6);
    border-radius: calc(var(--radius-md) - 6px);
    padding: 0.8rem 1rem;
    border: 1px solid rgba(127, 90, 240, 0.2);
    border-left: 3px solid var(--platform-color, var(--accent));
}

.verified-list .label {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.verified-list a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    word-break: break-word;
}

.verified-list a:hover,
.verified-list a:focus-visible {
    text-decoration: underline;
}

.interest-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.interest-tags span {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background: rgba(127, 90, 240, 0.15);
    border: 1px solid rgba(127, 90, 240, 0.4);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
}

/* Brand accents for verified list */
.verified-list .brand { width: 16px; height: 16px; color: var(--platform-color, var(--accent)); }
.verified-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: var(--platform-color, var(--accent));
    box-shadow: 0 0 0 1px rgba(0,0,0,0.2), 0 6px 14px rgba(0,0,0,0.25);
}

.platform-x { --platform-color: var(--brand-x); }
.platform-linkedin { --platform-color: var(--brand-linkedin); }
.platform-github { --platform-color: var(--brand-github); }

@keyframes starfield-drift {
    0% { background-position: 0 0, 0 0, 0 0; }
    50% { background-position: 60px 90px, 140px 200px, 220px 320px; }
    100% { background-position: 120px 180px, 280px 400px, 440px 640px; }
}

@keyframes starfield-twinkle {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.85; }
}

@media (prefers-reduced-motion: reduce) {
    .banner::before { animation: none; opacity: 0.3; }
    .shooting-stars span { animation: none; opacity: 0; }
}

@media (max-width: 720px) {
    body { padding: 1.5rem 1rem 2.5rem; }
    .card { padding: 1.5rem; }
    .profile { grid-template-columns: 1fr; text-align: center; }
    .identity { display: flex; flex-direction: column; align-items: center; }
    .identity h1 { font-size: 1.75rem; }
    .subtitle { font-size: 0.95rem; }
    .bio { font-size: 1rem; }
    .socials { justify-content: center; }
    .socials a { width: 48px; height: 48px; }
    .actions { justify-content: center; }
    .section { padding: 1.25rem; }
    .verified-list li { flex-direction: column; align-items: flex-start; }
    /* Place toggles near bottom on mobile for reachability */
    .theme-toggle { top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); right: calc(16px + env(safe-area-inset-right)); }
    .constellation-toggle { top: auto; bottom: calc(72px + env(safe-area-inset-bottom)); right: calc(16px + env(safe-area-inset-right)); }
    /* Stronger perf tweaks on small screens */
    .shooting-stars { display: none; }
    .banner::before { animation: none; opacity: 0.35; }
    .card { backdrop-filter: none; background: linear-gradient(180deg, rgba(16, 17, 46, 0.98) 0%, rgba(10, 11, 32, 0.98) 100%); }
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(3, 3, 12, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
    z-index: 1000;
}

.modal.is-open { opacity: 1; visibility: visible; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: transparent;
    border: none;
}

.modal-dialog {
    position: relative;
    width: min(440px, 92vw);
    background: rgba(16, 17, 46, 0.98);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.25rem 1rem;
    outline: none;
}

.modal h3 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 0.75rem;
}

.contact-email { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.contact-email a { color: var(--text-primary); text-decoration: none; font-weight: 600; }
.contact-email a:hover, .contact-email a:focus-visible { text-decoration: underline; }

.copy-btn {
    cursor: pointer;
    border: 1px solid rgba(127, 90, 240, 0.65);
    background: var(--accent);
    color: var(--text-primary);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    font-weight: 600;
}

.copy-btn:hover, .copy-btn:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(127, 90, 240, 0.35);
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(12, 13, 34, 0.8);
    color: var(--text-primary);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 20px;
    line-height: 1;
}

.modal-close:hover, .modal-close:focus-visible {
    background: var(--accent);
    border-color: rgba(127, 90, 240, 0.8);
}

.copy-status { color: var(--text-muted); font-weight: 600; }

/* Default gradient mask vars (dark theme) */
:root {
    --mask-start: rgba(3, 3, 12, 0.25);
    --mask-end: rgba(3, 3, 12, 0.9);
}

/* Light theme overrides */
:root[data-theme="light"] {
    --bg-color: #f6f8ff;
    --card-bg: rgba(255, 255, 255, 0.9);
    --accent: #6b5df0;
    --accent-soft: rgba(107, 93, 240, 0.18);
    --text-primary: #0b0c15;
    --text-muted: #4a5175;
    --border-color: rgba(11, 12, 21, 0.12);
    --mask-start: rgba(255, 255, 255, 0.15);
    --mask-end: rgba(255, 255, 255, 0.8);
}

:root[data-theme="light"] .banner { filter: brightness(0.8) saturate(1.1); }
:root[data-theme="light"] .banner::before { opacity: 0.3; }

:root[data-theme="light"] .card {
    background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(246,248,255,0.92) 100%);
    border-color: var(--border-color);
}

:root[data-theme="light"] .section {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--border-color);
}

:root[data-theme="light"] .verified-list li {
    background: rgba(255, 255, 255, 0.7);
}

/* Theme toggle button */
.theme-toggle {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top));
    right: calc(16px + env(safe-area-inset-right));
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 10px 24px rgba(3,4,24,0.25);
    backdrop-filter: blur(6px);
    cursor: pointer;
}

.theme-toggle:hover, .theme-toggle:focus-visible { transform: translateY(-1px); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: inline; }

/* Constellation toggle button */
.constellation-toggle {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top));
    right: calc(68px + env(safe-area-inset-right));
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 10px 24px rgba(3,4,24,0.25);
    backdrop-filter: blur(6px);
    cursor: pointer;
}

.constellation-toggle:hover, .constellation-toggle:focus-visible { transform: translateY(-1px); }
.icon-constellation { width: 20px; height: 20px; }

.constellation-toggle[aria-pressed="true"] {
    background: var(--accent);
    color: var(--text-primary);
    border-color: rgba(127, 90, 240, 0.75);
    box-shadow: 0 8px 22px rgba(127, 90, 240, 0.4);
}
