/* ============================================================
   RESET & BASE STYLES
   ============================================================ */

/* --- SKIP LINK (visible on focus for keyboard/screen reader) --- */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    padding: 12px 24px;
    background: var(--accent);
    color: #0F172A;
    font-weight: 600;
    border-radius: 8px;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 16px;
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

/* --- SCROLL PROGRESS BAR (theme-aware) --- */
.scroll-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--accent);
    z-index: 1001;
    transition: width 0.05s ease-out;
    will-change: width;
}

/* --- FOCUS VISIBILITY (keyboard accessibility) --- */
a:focus,
button:focus {
    outline: none;
}

a:focus-visible,
button:focus-visible,
.project-card:focus-visible,
.back-to-top:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.bg-canvas {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    line-height: 1.6;
    transition: background-color 0.4s ease, color 0.4s ease;
}

section {
    padding: 100px 5%;
    position: relative;
    content-visibility: auto;
    contain-intrinsic-size: 0 800px;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

ul {
    list-style: none;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

/* --- GLOBAL ANIMATIONS & OVERLAYS --- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    background-size: 200px;
    pointer-events: none;
    z-index: -1;
    opacity: var(--noise-opacity);
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background:
        radial-gradient(60vw 60vw at 95% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
        radial-gradient(55vw 55vw at -10% 105%, color-mix(in srgb, var(--accent2) 10%, transparent), transparent 64%);
    opacity: 0.55;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .4;
    }
}

@keyframes scanline {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(4px);
    }
}

/* --- HACKER-MODE RED ANIMATIONS --- */
@keyframes hacker-glitch {
    0% {
        clip-path: inset(0 0 98% 0);
        transform: translateX(-3px);
    }
    10% {
        clip-path: inset(20% 0 60% 0);
        transform: translateX(3px);
    }
    20% {
        clip-path: inset(55% 0 30% 0);
        transform: translateX(-2px);
    }
    30% {
        clip-path: inset(10% 0 80% 0);
        transform: translateX(4px);
    }
    40% {
        clip-path: inset(70% 0 10% 0);
        transform: translateX(-3px);
    }
    50% {
        clip-path: inset(40% 0 50% 0);
        transform: translateX(2px);
    }
    60% {
        clip-path: inset(85% 0 5% 0);
        transform: translateX(-4px);
    }
    70% {
        clip-path: inset(5% 0 88% 0);
        transform: translateX(3px);
    }
    80% {
        clip-path: inset(60% 0 28% 0);
        transform: translateX(-2px);
    }
    90% {
        clip-path: inset(30% 0 62% 0);
        transform: translateX(4px);
    }
    100% {
        clip-path: inset(0 0 98% 0);
        transform: translateX(0);
    }
}

@keyframes hacker-flicker {
    0%,
    19%,
    21%,
    23%,
    25%,
    54%,
    56%,
    100% {
        opacity: 1;
    }
    20%,
    24%,
    55% {
        opacity: 0.4;
    }
}

@keyframes hacker-red-pulse {
    0%,
    100% {
        box-shadow: 0 0 8px var(--glow), 0 0 20px var(--hacker-glow-soft);
    }
    50% {
        box-shadow: 0 0 18px var(--glow), 0 0 40px var(--hacker-glow-mid), 0 0 60px var(--hacker-glow-soft);
    }
}

@keyframes hacker-border-flare {
    0% {
        border-color: rgba(255, 26, 26, 0.2);
    }
    50% {
        border-color: rgba(255, 26, 26, 0.6);
    }
    100% {
        border-color: rgba(255, 26, 26, 0.2);
    }
}

@keyframes hacker-grid-drift {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 40px 40px;
    }
}

@keyframes hacker-text-flicker {
    0%,
    96%,
    98%,
    100% {
        text-shadow: 0 0 8px var(--glow);
    }
    97%,
    99% {
        text-shadow: none;
    }
}

@keyframes hacker-scanline-drift {
    0% {
        transform: translateY(-100vh);
    }
    100% {
        transform: translateY(100vh);
    }
}

/* --- T4-A: GPU LAYER HINTS --- */
.hero-orb {
    will-change: transform;
}

.cursor-dot,
.cursor-outline {
    will-change: left, top;
}

/* --- T5-E: SECTION LABEL UNDERLINE DRAW-IN --- */
.section-label {
    position: relative;
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    padding-bottom: 6px;
}

.section-label::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: var(--grad);
    border-radius: 2px;
    transition: width 0.5s ease 0.2s;
}

.section-label.visible::after,
.fade-up.visible .section-label::after,
.section-inner .section-label::after {
    width: 100%;
}

/* --- T4-D: THEME SWITCH FLASH OVERLAY --- */
.theme-flash {
    position: fixed;
    inset: 0;
    background: var(--accent);
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.theme-flash.active {
    opacity: 0.06;
}

/* --- NEW KEYFRAMES --- */

/* T1-A: Hero image rotating glow ring */
@keyframes ring-spin {
    to {
        transform: rotate(360deg);
    }
}

/* T1-B: Caret blink for typewriter */
@keyframes caret-blink {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* T1-D: Orbit chip around hero */
@keyframes orbit-chip {
    from {
        transform: rotate(var(--orbit-start)) translateX(var(--orbit-r)) rotate(calc(-1 * var(--orbit-start)));
    }

    to {
        transform: rotate(calc(var(--orbit-start) + 360deg)) translateX(var(--orbit-r)) rotate(calc(-1 * (var(--orbit-start) + 360deg)));
    }
}

/* T2-B: Button ripple burst */
@keyframes ripple-burst {
    from {
        transform: scale(0);
        opacity: 0.5;
    }

    to {
        transform: scale(3);
        opacity: 0;
    }
}

/* T5-A: Expertise icon float */
@keyframes icon-float {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-7px);
    }
}

/* T5-B: Timeline dot spring bounce */
@keyframes scale-in {
    0% {
        transform: scale(0);
    }

    70% {
        transform: scale(1.18);
    }

    100% {
        transform: scale(1);
    }
}

/* T3-C: Confetti particle fall */
@keyframes confetti-fall {
    to {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

/* T4-D: Theme crossfade mesh pulse */
@keyframes mesh-pulse {
    0%,
    100% {
        opacity: 0.55;
    }

    50% {
        opacity: 0.75;
    }
}

/* T5-C: Shimmer sweep on cert/award cards */
@keyframes shimmer-sweep {
    from {
        background-position: -200% center;
    }

    to {
        background-position: 200% center;
    }
}

/* T5-F: Hero CTA one-time load shimmer */
@keyframes btn-load-shimmer {
    0% {
        background-position: -200% center;
    }

    100% {
        background-position: 200% center;
    }
}

/* SCROLL REVEAL: fade-up base state & transition */
.fade-up {
    --fade-x: 0px;
    --fade-y: 32px;

    opacity: 0;
    transform: translate(var(--fade-x), var(--fade-y));
    transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform, opacity;
}

.fade-up.visible {
    --fade-x: 0px;
    --fade-y: 0px;

    opacity: 1;
    will-change: auto;
}

/* PAGE LOAD: hero content entry */
@keyframes hero-entry {
    from {
        opacity: 0;
        transform: translateY(22px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes hero-img-pop {
    from {
        opacity: 0;
        transform: scale(0.88);
        filter: blur(6px);
    }

    to {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

.hero-content {
    animation: hero-entry 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

.hero-visual {
    animation: hero-img-pop 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both;
}

/* TAB PANE: crossfade + micro-slide */
.tab-pane {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.38s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-pane.active {
    display: block;
    animation: pane-in 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes pane-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* HIGHLIGHT ITEMS: scale-in on reveal */
.highlight-item {
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.35s ease,
                border-color 0.35s ease,
                opacity 0.45s ease;
}

/* HIGHLIGHT NUMBERS: shimmer gradient sweep on enter */
@keyframes num-reveal {
    from {
        opacity: 0;
        transform: scale(0.75) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.highlight-item.visible .highlight-num {
    animation: num-reveal 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

/* TIMELINE LINE: animated draw-in */
.timeline::before {
    width: 2px;
    transform-origin: top;
    transform: scaleY(0);
    transition: transform 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.timeline.visible::before {
    transform: scaleY(1);
}

/* SECTION TITLE: word-by-word reveal */
@keyframes word-slide {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title .grad {
    display: inline-block;
    animation: word-slide 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.18s both;
}

/* CARD PERFORMANCE CONTAIN */
.project-card,
.expertise-card,
.education-card,
.cert-card,
.highlight-item {
    contain: layout style;
}

/* CUSTOM CURSOR */
.cursor-dot {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    pointer-events: none;
    z-index: 99999;
    transform: translate(-50%, -50%);
    transition: transform 0.1s ease, background 0.2s ease, width 0.2s ease, height 0.2s ease;
    box-shadow: 0 0 8px color-mix(in srgb, var(--glow) 80%, transparent);
}

.cursor-outline {
    position: fixed;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid color-mix(in srgb, var(--accent) 55%, transparent);
    pointer-events: none;
    z-index: 99998;
    transform: translate(-50%, -50%);
    transition: border-color 0.25s ease, width 0.25s ease, height 0.25s ease;
}

.cursor-dot.hovered {
    width: 12px;
    height: 12px;
    background: var(--accent2);
}

.cursor-outline.hovered {
    width: 52px;
    height: 52px;
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

@media (pointer: coarse) {
    .cursor-dot,
    .cursor-outline { display: none; }
}

/* --- SCROLL-LINKED ACTIVE NAV PILL --- */
.nav-links a.active {
    color: var(--text);
    background: var(--accent-soft);
    border-color: var(--accent-border-soft);
}

/* --- HIGHLIGHT-ITEM HOVER LIFT --- */
.highlight-item:hover {
    transform: translateY(-6px) scale(1.03);
    border-color: var(--accent-border-soft);
    box-shadow: 0 16px 40px color-mix(in srgb, var(--glow) 30%, transparent);
}

/* Respect user motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .hacker-scanline {
        display: none !important;
    }
}
