/* ══════════════════════════════════════════════════
   Shared Design System — v-i-s-h-a-l.github.io
   Single source of truth for colors, typography,
   background, theme toggle, tilt cards, and reveals.
   ══════════════════════════════════════════════════ */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Design Tokens ── */
:root {
    --mono: 'JetBrains Mono', monospace;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 12px;
    --transition: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
    --bg-primary: #0e0e14;
    --bg-secondary: #16161e;
    --bg-tertiary: #1e1e28;
    --bg-card: rgba(255, 255, 255, 0.025);
    --bg-card-hover: rgba(255, 255, 255, 0.055);
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.14);
    --text-primary: #ececf1;
    --text-secondary: #a0a0b0;
    --text-muted: #62627a;
    --accent: #d4a053;
    --accent-rgb: 212, 160, 83;
    --accent-dim: rgba(212, 160, 83, 0.1);
    --accent-glow: rgba(212, 160, 83, 0.2);
    --accent-secondary: #a78bfa;
    --green: #6ee7b7;
    --green-dim: rgba(110, 231, 183, 0.1);
    --orange: #fb923c;
    --purple: #a78bfa;
    --pink: #f472b6;
    --shadow-card: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-card-hover: 0 12px 40px rgba(0,0,0,0.5);
    --bg-gradient: linear-gradient(145deg, #0e0e14 0%, #141422 30%, #0f1520 60%, #0e0e14 100%);
}

[data-theme="light"] {
    --bg-primary: #f5f2ed;
    --bg-secondary: #eae6df;
    --bg-tertiary: #dfd9d0;
    --bg-card: rgba(0, 0, 0, 0.025);
    --bg-card-hover: rgba(0, 0, 0, 0.05);
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text-primary: #1a1a2e;
    --text-secondary: #555568;
    --text-muted: #8888a0;
    --accent: #9a6b34;
    --accent-rgb: 154, 107, 52;
    --accent-dim: rgba(154, 107, 52, 0.08);
    --accent-glow: rgba(154, 107, 52, 0.15);
    --accent-secondary: #6d5daf;
    --green: #2a9d6e;
    --green-dim: rgba(42, 157, 110, 0.1);
    --orange: #c2630b;
    --purple: #6d5daf;
    --pink: #c44a80;
    --shadow-card: 0 4px 20px rgba(0,0,0,0.06);
    --shadow-card-hover: 0 12px 36px rgba(0,0,0,0.12);
    --bg-gradient: linear-gradient(145deg, #f5f2ed 0%, #efe8de 30%, #f0ede6 60%, #f5f2ed 100%);
}

/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--accent) var(--bg-secondary); }
html::-webkit-scrollbar { width: 5px; }
html::-webkit-scrollbar-track { background: var(--bg-secondary); }
html::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

body {
    font-family: var(--sans);
    background: var(--bg-gradient);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: hidden;
    transition: background 0.5s ease, color 0.5s ease;
    min-height: 100vh;
}

::selection { background: var(--accent); color: var(--bg-primary); }

/* ── Animated Background Orbs ── */
.bg-animation {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0; pointer-events: none; overflow: hidden;
}
.bg-orb {
    position: absolute; border-radius: 50%; filter: blur(80px);
    opacity: 0.35; will-change: transform;
}
[data-theme="light"] .bg-orb { opacity: 0.2; }
.bg-orb:nth-child(1) {
    width: 500px; height: 500px; top: -10%; left: -5%;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.5), transparent 70%);
    animation: orb-drift-1 18s ease-in-out infinite alternate;
}
.bg-orb:nth-child(2) {
    width: 400px; height: 400px; top: 40%; right: -8%;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.4), transparent 70%);
    animation: orb-drift-2 22s ease-in-out infinite alternate;
}
.bg-orb:nth-child(3) {
    width: 350px; height: 350px; bottom: -5%; left: 25%;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.35), transparent 70%);
    animation: orb-drift-3 20s ease-in-out infinite alternate;
}
.bg-orb:nth-child(4) {
    width: 300px; height: 300px; top: 20%; left: 50%;
    background: radial-gradient(circle, rgba(110, 231, 183, 0.25), transparent 70%);
    animation: orb-drift-4 25s ease-in-out infinite alternate;
}
.bg-orb:nth-child(5) {
    width: 250px; height: 250px; top: 65%; left: 10%;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.3), transparent 70%);
    animation: orb-drift-5 19s ease-in-out infinite alternate;
}
@keyframes orb-drift-1 {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(120px, 80px) scale(1.1); }
    66% { transform: translate(50px, 150px) scale(0.95); }
    100% { transform: translate(180px, 60px) scale(1.05); }
}
@keyframes orb-drift-2 {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-100px, 60px) scale(1.08); }
    66% { transform: translate(-60px, -80px) scale(0.92); }
    100% { transform: translate(-150px, 40px) scale(1.05); }
}
@keyframes orb-drift-3 {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(80px, -70px) scale(1.12); }
    66% { transform: translate(-40px, -30px) scale(0.9); }
    100% { transform: translate(60px, -100px) scale(1.08); }
}
@keyframes orb-drift-4 {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-70px, 90px) scale(1.06); }
    66% { transform: translate(50px, 50px) scale(0.94); }
    100% { transform: translate(-90px, 120px) scale(1.1); }
}
@keyframes orb-drift-5 {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(100px, -50px) scale(1.1); }
    66% { transform: translate(60px, 70px) scale(0.95); }
    100% { transform: translate(130px, 30px) scale(1.05); }
}

/* ── Interactive Hover Glow Layer ── */
.bg-hover-layer {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0; pointer-events: none;
    background: radial-gradient(600px circle at var(--mx, 50%) var(--my, 50%), rgba(var(--accent-rgb), 0.06), transparent 40%);
    opacity: 0; transition: opacity 0.5s ease;
}
.bg-hover-layer.active { opacity: 1; }

/* ── Theme Toggle ── */
.theme-toggle {
    background: none; border: 1px solid var(--border); border-radius: 8px;
    width: 36px; height: 36px; cursor: pointer; display: flex; align-items: center;
    justify-content: center; color: var(--text-secondary); transition: all 0.3s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ── Tilt Card System ── */
.tilt-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); transition: all var(--transition);
    box-shadow: var(--shadow-card); position: relative; overflow: hidden;
    transform-style: preserve-3d; perspective: 800px;
}
.tilt-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(var(--accent-rgb), 0.06), transparent 40%);
    opacity: 0; transition: opacity 0.4s ease; pointer-events: none; z-index: 1;
}
.tilt-card::after {
    content: ''; position: absolute; top: -1px; left: -1px; right: -1px; bottom: -1px;
    border-radius: inherit;
    background: radial-gradient(400px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(var(--accent-rgb), 0.25), transparent 40%);
    opacity: 0; transition: opacity 0.4s ease; pointer-events: none; z-index: 0;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude; -webkit-mask-composite: xor; padding: 1px;
}
.tilt-card:hover { background: var(--bg-card-hover); box-shadow: var(--shadow-card-hover); transform: translateY(-4px); }
.tilt-card:hover::before, .tilt-card:hover::after { opacity: 1; }
.tilt-card > * { position: relative; z-index: 2; }

/* ── Section Labels ── */
.section-label {
    font-family: var(--mono); font-size: 0.7rem; font-weight: 500;
    color: var(--accent); text-transform: uppercase; letter-spacing: 3px;
    margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.75rem;
}
.section-label::before { content: ''; width: 24px; height: 1px; background: var(--accent); }
[dir="rtl"] .section-label { flex-direction: row-reverse; }

/* ── Reveal Animation ── */
.reveal {
    opacity: 0; transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }

.stagger-children > .tilt-card,
.stagger-children > a > .tilt-card { opacity: 0; transform: translateY(20px); transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
.stagger-children.visible > .tilt-card,
.stagger-children.visible > a > .tilt-card { opacity: 1; transform: translateY(0); }
.stagger-children.visible > :nth-child(1) .tilt-card,
.stagger-children.visible > :nth-child(1).tilt-card { transition-delay: 0s; }
.stagger-children.visible > :nth-child(2) .tilt-card,
.stagger-children.visible > :nth-child(2).tilt-card { transition-delay: 0.08s; }
.stagger-children.visible > :nth-child(3) .tilt-card,
.stagger-children.visible > :nth-child(3).tilt-card { transition-delay: 0.16s; }
.stagger-children.visible > :nth-child(4) .tilt-card,
.stagger-children.visible > :nth-child(4).tilt-card { transition-delay: 0.24s; }
.stagger-children.visible > :nth-child(5) .tilt-card,
.stagger-children.visible > :nth-child(5).tilt-card { transition-delay: 0.32s; }
.stagger-children.visible > :nth-child(6) .tilt-card,
.stagger-children.visible > :nth-child(6).tilt-card { transition-delay: 0.4s; }

/* ── Screenshot Carousel ── */
.screenshot-carousel {
    margin: 0.75rem 0;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}
.screenshot-track {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding: 0.25rem 0;
}
.screenshot-track::-webkit-scrollbar {
    display: none;
}
.screenshot-img {
    flex: 0 0 90px;
    width: 90px;
    min-width: 90px;
    max-width: none;
    height: auto;
    aspect-ratio: 392 / 696;
    object-fit: cover;
    border-radius: 8px;
    scroll-snap-align: start;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    pointer-events: auto;
    -webkit-user-drag: none;
}
.screenshot-img:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
@media (max-width: 600px) {
    .screenshot-img {
        flex: 0 0 76px;
        width: 76px;
        min-width: 76px;
        max-width: none;
    }
}

/* ── Section Divider (for links page etc.) ── */
.section-divider {
    width: 100%; margin: 1.5rem 0; position: relative;
    display: flex; align-items: center;
}
.section-divider::before {
    content: ''; flex: 1; height: 1px;
    background: linear-gradient(to right, transparent, var(--accent), transparent);
}
.section-divider-badge {
    font-family: var(--mono); font-size: 0.65rem; font-weight: 600;
    color: var(--accent); text-transform: uppercase; letter-spacing: 3px;
    padding: 0.4rem 1rem; border: 1px solid var(--accent);
    border-radius: 20px; background: var(--accent-dim);
    white-space: nowrap; flex-shrink: 0;
}
.section-divider::after {
    content: ''; flex: 1; height: 1px;
    background: linear-gradient(to left, transparent, var(--accent), transparent);
}
