/* ==========================================================================
   POLISH — second design pass (see js/fx/polish.js)
   ========================================================================== */

/* ---------- Theme button: auto badge + smooth theme switch ---------- */
.theme-toggle { position: relative; }
.theme-auto-dot {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: #fff;
    font: 700 9px/16px var(--font-primary);
    text-align: center;
    box-shadow: 0 0 0 2px var(--background-color);
}
body.theme-transition,
body.theme-transition *:not(.fx-cursor):not(.fx-trail):not(.galaxy-planet):not(.phone) {
    transition: background-color .6s ease, color .6s ease, border-color .6s ease, fill .6s ease !important;
}

/* ---------- Film grain for depth ---------- */
body::after {
    content: '';
    position: fixed;
    inset: -50%;
    z-index: 1;
    pointer-events: none;
    opacity: .035;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
body.dark-theme::after { opacity: .06; }

/* ---------- Scroll progress ---------- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 1100;
    background: linear-gradient(90deg, #2563eb, #7c3aed, #0ea5e9);
    transform: scaleX(0);
    transform-origin: left;
    box-shadow: 0 0 12px var(--glow-primary);
    pointer-events: none;
}

/* ---------- Live hero sky ---------- */
/* The hero glow and sky are allowed to bleed past the content column;
   the page itself never scrolls sideways (clip, unlike hidden, keeps sticky working). */
html { overflow-x: clip; }
section#about { overflow: visible; }
.hero-sky {
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(50% - 50vw);
    width: 100vw;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.sky-arc {
    position: absolute;
    left: max(6%, calc(50% - 620px));
    right: max(6%, calc(50% - 620px));
    top: 8%;
    height: 76%;
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    border: 1px dashed var(--border-color);
    border-bottom: 0;
    opacity: .55;
    mask-image: linear-gradient(180deg, #000 40%, transparent 75%);
    -webkit-mask-image: linear-gradient(180deg, #000 40%, transparent 75%);
}
.sky-body {
    position: absolute;
    width: 76px;
    height: 76px;
    transform: translate(-50%, -50%);
    transition: left 2s ease, top 2s ease;
}
.sky-sun, .sky-moon {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    transition: opacity 1s ease, transform 1s ease;
}
.sky-sun {
    background: radial-gradient(circle at 40% 40%, #fff7d6, #fde047 35%, #f59e0b 70%);
    box-shadow: 0 0 40px 10px rgba(253, 224, 71, .55), 0 0 120px 40px rgba(251, 146, 60, .25);
    animation: sunPulse 6s ease-in-out infinite;
}
.sky-moon {
    background: radial-gradient(circle at 35% 35%, #f8fafc, #cbd5e1 60%, #94a3b8);
    box-shadow: 0 0 40px 6px rgba(191, 219, 254, .35), 0 0 120px 30px rgba(129, 140, 248, .15);
    opacity: 0;
    transform: scale(.7);
}
.sky-moon::before, .sky-moon::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(100, 116, 139, .35);
}
.sky-moon::before { width: 16px; height: 16px; left: 18px; top: 22px; }
.sky-moon::after { width: 10px; height: 10px; left: 44px; top: 44px; }
.hero-sky.is-night .sky-sun { opacity: 0; transform: scale(.7); }
.hero-sky.is-night .sky-moon { opacity: 1; transform: none; }
@keyframes sunPulse { 50% { box-shadow: 0 0 55px 14px rgba(253, 224, 71, .6), 0 0 150px 50px rgba(251, 146, 60, .3); } }

.sky-stars i {
    position: absolute;
    border-radius: 50%;
    background: #fff;
    opacity: 0;
    animation: twinkle 3.5s ease-in-out infinite;
}
.hero-sky.is-night .sky-stars i { opacity: .7; }
body:not(.dark-theme) .hero-sky.is-night .sky-stars i { background: #6366f1; }
@keyframes twinkle { 50% { opacity: .15; transform: scale(.6); } }

.sky-cloud {
    position: absolute;
    height: 34px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .85);
    filter: blur(1px);
    box-shadow: 0 10px 30px rgba(148, 163, 184, .25);
    opacity: 0;
    transition: opacity 1s ease;
    animation: drift 70s linear infinite;
}
.sky-cloud::before, .sky-cloud::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: inherit;
}
.sky-cloud::before { width: 46%; height: 160%; left: 14%; top: -70%; }
.sky-cloud::after { width: 34%; height: 130%; left: 48%; top: -50%; }
.sky-cloud.c1 { width: 140px; top: 16%; left: -10%; }
.sky-cloud.c2 { width: 100px; top: 30%; left: -30%; animation-duration: 95s; animation-delay: -40s; transform: scale(.8); }
.sky-cloud.c3 { width: 120px; top: 9%; left: -20%; animation-duration: 120s; animation-delay: -80s; }
.hero-sky.is-day .sky-cloud { opacity: .9; }
body.dark-theme .hero-sky.is-day .sky-cloud { opacity: .12; }
@keyframes drift { to { left: 110%; } }

.sky-clock {
    position: absolute;
    right: max(6%, calc(50% - 600px));
    top: calc(80px + 1rem);
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    color: var(--text-muted);
    font: 600 .75rem ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: .04em;
}
@media (max-width: 768px) {
    .sky-body { width: 48px; height: 48px; }
    .sky-clock { display: none; }
    .sky-arc { display: none; }
}

/* ---------- Eyebrows ---------- */
.eyebrow {
    display: block;
    margin-bottom: .6rem;
    font: 600 .78rem ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--primary-color);
}
.section-title .eyebrow::before, .section-title .eyebrow::after {
    content: '';
    display: inline-block;
    width: 28px;
    height: 1px;
    margin: 0 10px;
    vertical-align: middle;
    background: currentColor;
    opacity: .5;
}
.section-title h1 {
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    letter-spacing: -0.02em;
}
.section-title h1::after { width: 0; }
.section-title p { max-width: 620px; margin: .6rem auto 0; color: var(--text-muted); }

/* ---------- Glow cards (spotlight + gradient border) ---------- */
.glow-card {
    position: relative;
    isolation: isolate;
    --mx: 50%;
    --my: 0%;
}
.glow-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(420px circle at var(--mx) var(--my), rgba(37, 99, 235, .10), transparent 45%);
    opacity: 0;
    transition: opacity .35s ease;
}
body.dark-theme .glow-card::before { background: radial-gradient(420px circle at var(--mx) var(--my), rgba(96, 165, 250, .14), transparent 45%); }
.glow-card::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    pointer-events: none;
    background: radial-gradient(260px circle at var(--mx) var(--my), #7c3aed, #2563eb 40%, transparent 70%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    opacity: 0;
    transition: opacity .35s ease;
}
.glow-card:hover::before, .glow-card:hover::after { opacity: 1; }
.glow-card:hover { border-color: transparent !important; }

/* ---------- Project cards ---------- */
.project-item {
    transition: transform .25s ease-out, box-shadow .35s ease, border-color .35s ease;
    transform-style: preserve-3d;
}
.project-item:hover { transform: translateY(-6px); }
.project-num {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    font: 700 2.4rem/1 var(--font-heading);
    color: transparent;
    -webkit-text-stroke: 1px var(--border-color);
    transition: -webkit-text-stroke-color .3s, transform .3s;
    pointer-events: none;
}
.project-item:hover .project-num { -webkit-text-stroke-color: var(--primary-color); transform: translateY(-3px); }
.project-details h3 { padding-right: 3.5rem; font-size: 1.3rem; letter-spacing: -0.01em; }
.project-details p { color: var(--text-muted); line-height: 1.65; }
.btn-demo {
    position: relative;
    overflow: hidden;
    justify-content: space-between;
    background: transparent;
    color: var(--heading-color);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: .7rem 1.2rem;
    z-index: 0;
}
.btn-demo::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--brand-gradient);
    transform: translateY(101%);
    transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}
.btn-demo i { transition: transform .35s ease; }
.btn-demo:hover, .project-item:hover .btn-demo { color: #fff; border-color: transparent; }
.btn-demo:hover::before, .project-item:hover .btn-demo::before { transform: none; }
.project-item:hover .btn-demo i { transform: translate(3px, -3px); }

/* ---------- Experience: accent rail ---------- */
.experience-item { overflow: hidden; }
.experience-item .exp-header h2 { letter-spacing: -0.01em; }
.experience-item > .exp-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--brand-gradient);
    transform: scaleY(.25);
    transform-origin: top;
    transition: transform .5s cubic-bezier(.2, .8, .2, 1);
}
.experience-item:hover > .exp-header::before { transform: scaleY(1); }
.exp-tech-item { transition: transform .2s ease, background .2s ease, color .2s ease; }
.experience-item:hover .exp-tech-item { transform: translateY(-1px); }

/* ---------- Hero touches ---------- */
.name {
    background: linear-gradient(100deg, var(--heading-color) 0%, var(--heading-color) 40%, var(--primary-color) 50%, var(--heading-color) 60%, var(--heading-color) 100%);
    background-size: 250% 100%;
    background-position: 100% 0;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: nameShine 7s ease-in-out 3s infinite;
}
.name .fx-letter { color: var(--heading-color); -webkit-text-fill-color: currentColor; }
@keyframes nameShine { 0%, 70% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.text-section { position: relative; z-index: 1; }
.btn { border-radius: 999px; }

/* ---------- Marquee ---------- */
.marquee {
    position: relative;
    overflow: hidden;
    padding: 1.4rem 0;
    margin: 2rem 0 0;
    border-block: 1px solid var(--border-color);
    background: var(--secondary-background);
    transform: rotate(-1.5deg) scale(1.03);
    mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
.marquee-track {
    display: flex;
    gap: 2rem;
    width: max-content;
    align-items: center;
    animation: marquee 38s linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee span {
    font: 700 clamp(1.4rem, 3.4vw, 2.4rem)/1 var(--font-heading);
    color: var(--heading-color);
    white-space: nowrap;
    letter-spacing: -0.02em;
}
.marquee span:nth-of-type(even) {
    color: transparent;
    -webkit-text-stroke: 1px var(--text-muted);
}
.marquee b { color: var(--primary-color); font-size: 1.2rem; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Footer CTA ---------- */
.footer { position: relative; overflow: hidden; }
.footer::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -260px;
    width: 700px;
    height: 400px;
    transform: translateX(-50%);
    background: var(--brand-gradient);
    filter: blur(140px);
    opacity: .18;
    pointer-events: none;
}
/* ---------- Contact form & cards ---------- */
.contact-card { border-radius: 20px; }

@media (prefers-reduced-motion: reduce) {
    .marquee-track, .name, .sky-sun, .sky-stars i, .sky-cloud { animation: none !important; }
}
