/* ===========================================================================
   Arnav Dugad — Portfolio Styles
   Split out of the original single-file build. Organised into:
   1. Base / background   2. Overlays (cursor, canvases, bars)
   3. Glass cards + views 4. Controls  5. Modals  6. Timeline
   7. New premium features (loading screen, hero, detail modal, reveal, magnetic)
   =========================================================================== */

/* ---------- 1. Base / animated background -------------------------------- */
body {
    background: linear-gradient(-45deg, #0f172a, #1e1b4b, #312e81, #0f172a);
    background-size: 400% 400%;
    animation: gradient-x 15s ease infinite;
    color: white;
    min-height: 100vh;
    cursor: none; /* Custom cursor replaces the default */
    overflow-x: hidden;
    scroll-behavior: smooth;
    transition: background 0.5s ease;
}

/* Theme Classes */
body.theme-midnight { background: linear-gradient(-45deg, #000000, #1a1a1a, #0d0d0d, #000000); background-size: 400% 400%; }
body.theme-sunset   { background: linear-gradient(-45deg, #4c1d95, #be185d, #f59e0b, #4c1d95); background-size: 400% 400%; }
body.theme-ocean    { background: linear-gradient(-45deg, #0c4a6e, #0284c7, #38bdf8, #0c4a6e); background-size: 400% 400%; }

/* Keyframes that used to live in the inline Tailwind config now live here so
   the config stays lean. Tailwind's animate-* utilities still reference them. */
@keyframes gradient-x {
    0%, 100% { background-size: 200% 200%; background-position: left center; }
    50%      { background-size: 200% 200%; background-position: right center; }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}
@keyframes fadeInUp {
    0%   { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes pulseGlow {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.2); }
}
@keyframes slideInRight {
    0%   { transform: translateX(100%); opacity: 0; }
    100% { transform: translateX(0);    opacity: 1; }
}
@keyframes slideOutRight {
    0%   { transform: translateX(0);    opacity: 1; }
    100% { transform: translateX(100%); opacity: 0; }
}

/* ---------- 2. Overlays -------------------------------------------------- */
/* Scroll Progress Bar */
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, #4f46e5, #ec4899, #f59e0b);
    z-index: 99999;
    width: 0%;
    transition: width 0.1s;
    box-shadow: 0 0 10px rgba(79, 70, 229, 0.5);
}

/* Starfield Canvas */
#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -5; /* Behind content, in front of gradient */
    pointer-events: none;
}

/* Confetti Canvas */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99999;
}

/* Custom Cursor */
.cursor-dot,
.cursor-outline {
    position: fixed;
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    z-index: 9999;
    pointer-events: none;
}
.cursor-dot {
    width: 8px;
    height: 8px;
    background-color: white;
}
.cursor-outline {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: width 0.2s, height 0.2s, background-color 0.2s;
}
/* Grow the outline over interactive targets */
.cursor-outline.cursor-hover {
    width: 60px;
    height: 60px;
    background-color: rgba(99, 102, 241, 0.15);
    border-color: rgba(129, 140, 248, 0.8);
}

/* Hide custom cursor on touch devices to prevent stuck hover states */
@media (hover: none) and (pointer: coarse) {
    .cursor-dot, .cursor-outline { display: none; }
    body { cursor: auto; }
}

/* ---------- 3. Glass cards + views -------------------------------------- */
.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.1s ease-out; /* Fast for the tilt follow */
    transform-style: preserve-3d;
    perspective: 1000px;
}
.glass-card-content { transform: translateZ(20px); } /* Parallax lift */
.glass-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.2);
}

/* List View */
.list-view .project-card { flex-direction: row; height: auto; min-height: 140px; }
.list-view .project-card .glass-card-content {
    flex-direction: row;
    align-items: center;
    width: 100%;
    gap: 20px;
}
.list-view .project-card .icon-wrapper {
    margin-bottom: 0;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}
.list-view .project-card .text-content { flex: 1; margin-bottom: 0; margin-top: 0; }
.list-view .project-card .tags-container {
    margin-top: 0;
    width: auto;
    max-width: 30%;
    justify-content: flex-end;
}
@media (max-width: 768px) {
    .list-view .project-card { flex-direction: column; }
    .list-view .project-card .glass-card-content { flex-direction: column; align-items: flex-start; gap: 10px; }
    .list-view .project-card .tags-container { max-width: 100%; justify-content: flex-start; }
}

/* Icon glow */
.icon-glow {
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.3));
    transition: all 0.3s ease;
}
.glass-card:hover .icon-glow {
    filter: drop-shadow(0 0 15px rgba(99, 102, 241, 0.6));
    transform: scale(1.1) rotate(5deg);
    color: #818cf8;
}

/* ---------- 4. Controls -------------------------------------------------- */
.filter-btn.active {
    background-color: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.5);
    color: white;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.tag-chip { cursor: pointer; transition: all 0.2s; }
.tag-chip:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-1px); }

.icon-option { cursor: pointer; transition: all 0.2s; }
.icon-option:hover { color: white; transform: scale(1.2); }

/* Scroll To Top Button */
#scrollTopBtn {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    pointer-events: none;
}
#scrollTopBtn.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Stagger delays (kept for anything not using the reveal observer) */
.stagger-1 { animation-delay: 100ms; }
.stagger-2 { animation-delay: 200ms; }
.stagger-3 { animation-delay: 300ms; }
.stagger-4 { animation-delay: 400ms; }
.stagger-5 { animation-delay: 500ms; }
.stagger-6 { animation-delay: 600ms; }
.stagger-7 { animation-delay: 700ms; }
.stagger-8 { animation-delay: 800ms; }
.stagger-9 { animation-delay: 900ms; }

/* Typing cursor */
.typing-cursor::after { content: '|'; animation: blink 1s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ---------- 5. Modals ---------------------------------------------------- */
.modal-overlay { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); }

.form-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    outline: none;
    transition: all 0.2s;
}
.form-input:focus { background: rgba(255, 255, 255, 0.1); border-color: rgba(99, 102, 241, 0.5); }
/* Dropdown option visibility on dark theme */
select.form-input option { background-color: #1e1b4b; color: white; }

/* Delete button (admin only) */
.delete-btn { opacity: 0; pointer-events: none; transition: all 0.3s; }
.admin-mode .delete-btn { opacity: 1; pointer-events: auto; }

/* ---------- 6. Timeline (kept from original, currently unused) ----------- */
.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-50%);
}
.timeline-dot {
    position: absolute;
    left: 50%;
    top: 0;
    width: 16px;
    height: 16px;
    background: #4f46e5;
    border-radius: 50%;
    transform: translateX(-50%);
    border: 3px solid rgba(15, 23, 42, 1);
    z-index: 10;
}
@media (max-width: 768px) {
    .timeline-line { left: 20px; }
    .timeline-dot  { left: 20px; }
}

/* =========================================================================
   7. NEW PREMIUM FEATURES
   ========================================================================= */

/* ---------- Loading screen ---------------------------------------------- */
#loader {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    background: #0b1020;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}
#loader.loaded { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-name {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    background: linear-gradient(90deg, #818cf8, #ec4899, #f59e0b, #818cf8);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: gradient-x 3s ease infinite;
}
.loader-ring {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid rgba(129, 140, 248, 0.2);
    border-top-color: #818cf8;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Hero -------------------------------------------------------- */
.hero-name span { display: inline-block; opacity: 0; transform: translateY(24px); animation: heroLetter 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
@keyframes heroLetter { to { opacity: 1; transform: translateY(0); } }

.stat-value { font-variant-numeric: tabular-nums; }

/* CTA buttons */
.btn-primary, .btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.85rem;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.3s ease, background 0.3s ease;
    will-change: transform;
}
.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    box-shadow: 0 10px 25px -8px rgba(99, 102, 241, 0.6);
}
.btn-primary:hover { box-shadow: 0 14px 32px -8px rgba(124, 58, 237, 0.8); }
.btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

/* Magnetic wrapper — JS nudges the transform, CSS eases it back */
.magnetic { transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* ---------- Scroll reveal ----------------------------------------------- */
.reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.7s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: opacity, transform;
}
.reveal.revealed { opacity: 1; transform: translateY(0); }

/* ---------- Project cards: clickable + coming soon ---------------------- */
.project-card { cursor: pointer; }

.glass-card.coming-soon { border-style: dashed; opacity: 0.7; }
.glass-card.coming-soon:hover { opacity: 1; border-style: solid; }

/* Empty / skeleton state */
.skeleton-card {
    height: 16rem;
    border-radius: 1rem;
    background: linear-gradient(100deg, rgba(255,255,255,0.03) 30%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Project detail modal ---------------------------------------- */
#detailModal .detail-panel {
    background: #14122e;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.detail-frame-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #0b1020;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.detail-frame-wrap iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.detail-frame-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: #94a3b8;
    text-align: center;
    padding: 1rem;
}

/* ---------- v2: badges, stats bar, language bar, detail nav ------------- */

/* Featured star badge (top-right of card / preview) */
.feat-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 15;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #fde047;
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.4);
    box-shadow: 0 0 12px rgba(234, 179, 8, 0.25);
}

/* Deploy platform pill */
.deploy-pill i { font-size: 0.75rem; }

/* Portfolio stats bar */
.stat-tile {
    text-align: center;
    padding: 1rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.stat-tile:hover {
    transform: translateY(-3px);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 12px 28px -12px rgba(99, 102, 241, 0.5);
}
.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(135deg, #a5b4fc, #818cf8, #c4b5fd);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.stat-label {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

/* Card GitHub star badge */
.gh-star:empty { display: none; }

/* Language breakdown bar (detail modal) */
.lang-bar {
    display: flex;
    width: 100%;
    height: 9px;
    border-radius: 9999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
}
.lang-bar span { height: 100%; transition: width 0.6s ease; }

/* Detail modal prev/next navigation */
.detail-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #cbd5e1;
    z-index: 10;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.detail-nav:hover { background: rgba(99, 102, 241, 0.45); color: #fff; }
.detail-nav-prev { left: 1.5rem; }
.detail-nav-next { right: 1.5rem; }
@media (max-width: 640px) {
    .detail-nav { width: 2.25rem; height: 2.25rem; }
    .detail-nav-prev { left: 0.4rem; }
    .detail-nav-next { right: 0.4rem; }
}

/* ---------- v3: sort dropdown, icon picker, mobile --------------------- */

/* Sort dropdown — readable options on dark theme */
#sortSelect { color: #e2e8f0; }
#sortSelect option { background-color: #1e1b4b; color: #ffffff; }

/* Hide scrollbars (filter row, icon grid) while keeping scroll */
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* Searchable icon picker */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(2.25rem, 1fr));
    gap: 0.25rem;
    max-height: 9.5rem;
    overflow-y: auto;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
}
.icon-grid .icon-option {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2.25rem;
    border-radius: 0.5rem;
    font-size: 1.05rem;
}
.icon-grid .icon-option:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #fff;
    transform: none;
}

/* Filter chips: comfortable tap targets */
.filter-btn { scroll-snap-align: start; }

/* Mobile: move detail-nav arrows to the bottom so they don't cover body text */
@media (max-width: 640px) {
    .detail-nav { top: auto; bottom: 1rem; transform: none; width: 2.5rem; height: 2.5rem; }
    .detail-nav-prev { left: 1rem; }
    .detail-nav-next { right: 1rem; }
    .project-card { padding: 1.25rem; }
}

/* ---------- Reduced motion ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    body { animation: none; }
    .reveal { opacity: 1; transform: none; }
    .hero-name span { opacity: 1; transform: none; }
}
