@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800;900&family=Fira+Code:wght@400;500&display=swap');

:root {
    --bg-dark: #000000;
    --bg-panel: #0a0a0a;
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --secondary: #3b82f6;
    --accent: #ec4899;
    --cyan: #06b6d4;
    --text-main: #f8f8f8;
    --text-muted: #c4c4cc; /* WCAG AA: ~6.8:1 contrast on #000 */
    --glass-bg: rgba(10, 10, 10, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-light: rgba(255, 255, 255, 0.03);
    --glass-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --radius-xl: 1.25rem;
    --radius-2xl: 2rem;
}

[data-theme="light"] {
    --bg-dark: #f0f4f8; /* Soft bluish-gray background */
    --bg-panel: #ffffff; /* Keep panels clean white */
    --text-main: #0f172a;
    --text-muted: #334155; /* WCAG AA: ~8.2:1 contrast on #fff */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(124, 58, 237, 0.12); /* Subtle purple-tinted borders */
    --glass-light: rgba(124, 58, 237, 0.05); /* Subtle purple tint on hovers */
    --glass-glow: 0 10px 40px rgba(124, 58, 237, 0.06); /* Soft colored shadow */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 1rem; /* 16px explicit base */
    overflow-x: hidden;
    line-height: 1.75; /* WCAG: min 1.5, we use 1.75 for comfort */
    transition: background-color 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Readable Prose Utility — use on any paragraph block */
.prose-readable {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-muted);
    max-width: 68ch; /* Optimal reading line length */
}

/* Small text — still accessible */
.text-readable-sm {
    font-size: 0.875rem; /* 14px min for secondary labels */
    line-height: 1.6;
    color: var(--text-muted);
}

/* Section description paragraphs */
.section-desc {
    font-size: 1.0625rem; /* 17px */
    line-height: 1.8;
    color: var(--text-muted);
    max-width: 60ch;
}

h1, h2, h3, h4, h5, h6, .outfit-font { font-family: 'Outfit', sans-serif; letter-spacing: -0.02em; }

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-glow);
    border-radius: var(--radius-xl);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.glass-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 0;
}

.glass-panel:hover::before {
    opacity: 1;
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.glass-nav {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    transform: translateZ(0);
}

[data-theme="light"] .glass-nav { background: rgba(255, 255, 255, 0.7); }

/* Gradients */
.text-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Buttons */
.glow-btn {
    position: relative;
    background: var(--text-main);
    color: var(--bg-dark);
    border: none;
    font-weight: 600;
    z-index: 1;
    overflow: hidden;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
}

.glow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(255, 255, 255, 0.2);
}
[data-theme="light"] .glow-btn:hover { box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); }

.outline-glow-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
}

.outline-glow-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.2);
    background: rgba(124, 58, 237, 0.05);
}

/* Background Effects */
.aurora-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.15;
    animation: drift 20s ease-in-out infinite alternate;
}
[data-theme="light"] .aurora-blob { opacity: 0.25; }
@keyframes drift {
    0% { transform: translate(0,0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

.grid-overlay {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(var(--glass-border) 1px, transparent 1px),
        linear-gradient(90deg, var(--glass-border) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.5;
}
.grid-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, transparent 0%, var(--bg-dark) 80%);
}

.section-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 1rem;
    background: rgba(124, 58, 237, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.divider-glow {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
    width: 100%;
}

.stat-number { font-family: 'Outfit', sans-serif; font-weight: 900; color: var(--text-main); }
.animate-float { animation: float 6s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }

.nav-link { font-size: 0.875rem; font-weight: 500; color: var(--text-muted); transition: color 0.3s; position: relative; }
.nav-link:hover, .nav-link.active { color: var(--text-main); }
.nav-link::after { content: ''; position: absolute; bottom: -4px; left: 0; width: 0; height: 2px; background: var(--text-main); transition: width 0.3s ease; }
.nav-link:hover::after, .nav-link.active::after { width: 100%; }

.hover-up { transition: transform 0.3s ease, box-shadow 0.3s ease; }
.hover-up:hover { transform: translateY(-5px); box-shadow: var(--glass-glow); }

.modern-input { width: 100%; padding: 0.75rem 1rem; background: var(--glass-light); border: 1px solid var(--glass-border); border-radius: 0.75rem; color: var(--text-main); font-family: 'Inter', sans-serif; outline: none; transition: all 0.3s ease; }
[data-theme="light"] .modern-input { background: rgba(0, 0, 0, 0.02); }
.modern-input:focus { border-color: var(--primary); background: rgba(124, 58, 237, 0.05); box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Animations */
@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.animate-spin-slow {
    animation: spin-slow linear infinite;
}

/* AlpineJS Cloak */
[x-cloak] { display: none !important; }

/* Noise Texture Overlay */
.noise-bg {
    position: fixed;
    inset: 0;
    z-index: 1;
    opacity: 0.03;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Enhanced Gradient Text */
.text-gradient-rich {
    background: linear-gradient(135deg, #7c3aed 0%, #3b82f6 60%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 10px rgba(124, 58, 237, 0.3));
}

.card-reveal {
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.6s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(124, 58, 237, 0.3);
}

/* Glow Input - Custom Dark Style for Admin Forms */
.glow-input {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glow-input:focus {
    background: rgba(255, 255, 255, 0.07) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.15), inset 0 0 10px rgba(124, 58, 237, 0.05) !important;
    outline: none !important;
    transform: translateY(-1px);
}

.glow-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

/* Fix for Select elements using glow-input */
select.glow-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    padding-right: 3rem;
}

select.glow-input option {
    background-color: #0f172a;
    color: #fff;
}

/* ─── Code Block System ───────────────────────────────────────────── */
.code-block-wrapper {
    position: relative;
    margin: 1.5rem 0;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    background: #1a1b26; /* Slightly lighter than black for depth */
}

/* Language badge — top left */
.code-lang-badge {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(124, 58, 237, 0.3);
    border-right: 1px solid rgba(255,255,255,0.08);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    color: var(--primary-light, #a78bfa);
    font-family: 'Fira Code', monospace;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.3rem 0.75rem;
    border-radius: 0 0 0.5rem 0;
    z-index: 10;
    user-select: none;
    backdrop-filter: blur(8px);
}

/* Copy button — top right */
.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    opacity: 0;
}
.code-block-wrapper:hover .code-copy-btn {
    opacity: 1;
}
.code-copy-btn:hover {
    background: rgba(124, 58, 237, 0.3);
    border-color: rgba(124, 58, 237, 0.5);
    color: #fff;
    transform: scale(1.1);
}
.code-copy-btn.copied {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

/* Override highlight.js pre to fit our wrapper */
.code-block-wrapper pre {
    margin: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    padding: 2.75rem 1.5rem 1.5rem !important; /* top padding for badge */
    overflow-x: auto;
    font-family: 'Fira Code', 'Fira Mono', monospace !important;
    font-size: 0.875rem !important;
    line-height: 1.75 !important;
    tab-size: 4;
}

/* Scrollbar for code blocks */
.code-block-wrapper pre::-webkit-scrollbar { height: 6px; }
.code-block-wrapper pre::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); }
.code-block-wrapper pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.code-block-wrapper pre::-webkit-scrollbar-thumb:hover { background: rgba(124, 58, 237, 0.5); }

/* Inline code (not in a pre block) */
:not(pre) > code {
    font-family: 'Fira Code', monospace;
    font-size: 0.85em;
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.2);
    color: var(--primary-light, #a78bfa);
    padding: 0.15em 0.45em;
    border-radius: 0.35rem;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE FIXES — Mobile First
   Tested breakpoints: 320px, 375px (iPhone SE), 412px (Pixel), 480px
   ═══════════════════════════════════════════════════════════════════ */

/* ─── 768px and below (tablet edge) ─── */
@media (max-width: 768px) {

    /* Sections: tighter padding on tablet */
    section { padding-top: 4rem !important; padding-bottom: 4rem !important; }

    /* Hero: scale down massive headline */
    #home h1 { font-size: clamp(2.25rem, 8vw, 4rem) !important; }

    /* Services: 2-col on tablet, not 4 */
    #services .grid { grid-template-columns: repeat(2, 1fr) !important; }

    /* Hero stats grid: ensure 3-col stays intact */
    #home .grid.grid-cols-3 { gap: 1rem !important; }
    #home .grid.grid-cols-3 .text-3xl { font-size: 1.75rem !important; }

    /* Contact form: full gap reduce */
    #contact .grid { gap: 2.5rem !important; }
}

/* ─── 480px and below (large phones) ─── */
@media (max-width: 480px) {

    /* Global section padding */
    section { padding-top: 3rem !important; padding-bottom: 3rem !important; }
    .max-w-6xl, .max-w-5xl, .max-w-7xl, .max-w-4xl {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Services: single column */
    #services .grid { grid-template-columns: 1fr !important; }

    /* Skills: single column */
    #skills .grid { grid-template-columns: 1fr !important; }

    /* Projects: single column */
    #projects .grid { grid-template-columns: 1fr !important; }

    /* Hero section: prevent overflow */
    #home h1 { font-size: clamp(2rem, 9vw, 2.75rem) !important; line-height: 1.2 !important; }
    #home p { font-size: 1rem !important; }

    /* Hero CTA buttons: full width stack */
    #home .flex.flex-col.sm\:flex-row { flex-direction: column !important; }
    #home .glow-btn,
    #home .outline-glow-btn { width: 100% !important; justify-content: center !important; }

    /* Hero stat strip: compress */
    #home .grid.grid-cols-3 { gap: 0.5rem !important; }
    #home .grid.grid-cols-3 .text-3xl { font-size: 1.5rem !important; }
    #home .grid.grid-cols-3 .text-xs { font-size: 0.6rem !important; }

    /* Freelance section: stack icon + cards vertically */
    #freelance .flex-col.lg\:flex-row { flex-direction: column !important; }
    #freelance .lg\:w-1\/3,
    #freelance .lg\:w-2\/3 { width: 100% !important; }
    #freelance .sm\:grid-cols-3 { grid-template-columns: 1fr !important; }

    /* Experience: vertical stack */
    #experience .flex-col.sm\:flex-row { flex-direction: column !important; gap: 0.75rem !important; }
    #experience .sm\:w-1\/4 { width: 100% !important; }

    /* Code blocks: ensure no horizontal overflow of wrapper */
    .code-block-wrapper { border-radius: 0.75rem !important; }
    .code-block-wrapper pre { font-size: 0.8rem !important; padding: 2.5rem 1rem 1rem !important; }

    /* Section headings: scale down */
    h2.outfit-font { font-size: clamp(1.75rem, 8vw, 2.5rem) !important; }

    /* Glass panels: reduce internal padding on small screens */
    .glass-panel { border-radius: 0.875rem !important; }
    #contact .glass-panel { padding: 1.5rem !important; }
    #freelance .glass-panel.p-8 { padding: 1.5rem !important; }
}

/* ─── 375px (iPhone SE / standard small phone) ─── */
@media (max-width: 375px) {

    #home h1 { font-size: clamp(1.75rem, 9.5vw, 2.25rem) !important; }

    /* Nav brand name: truncate gracefully */
    nav .outfit-font { max-width: 120px; }

    /* Prevent button text wrap breaking layout */
    .glow-btn, .outline-glow-btn {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
        font-size: 0.875rem !important;
    }

    /* Project/Service cards: reduce padding */
    #projects .glass-panel,
    #services .glass-panel { padding: 1.25rem !important; }

    /* Skills chips: allow more wrapping room */
    #skills .flex.flex-wrap { gap: 0.5rem !important; }
    #skills .px-3 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }

    /* Stats strip: very tight */
    #home .grid.grid-cols-3 .text-3xl { font-size: 1.25rem !important; }
}

/* ─── 320px (absolute minimum) ─── */
@media (max-width: 320px) {
    #home h1 { font-size: 1.6rem !important; }

    .max-w-6xl, .max-w-5xl, .max-w-7xl, .max-w-4xl {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .section-tag { font-size: 0.6rem !important; }
}

/* ─── Safe: ensure images never overflow their container globally ─── */
img { max-width: 100%; height: auto; }
iframe { max-width: 100%; }

/* ─── Prevent orphaned horizontal scroll ─── */
.overflow-x-hidden, body { overflow-x: hidden !important; }
