/* ===================================
   Hamdi Bougattaya Portfolio
   Bento Grid Design System (Apple-inspired)
   =================================== */

/* CSS Variables */
:root {
    --bg: #F5F5F7;
    --card-bg: #FFFFFF;
    --text: #1D1D1F;
    --text-muted: #86868B;
    --accent: #0071E3;
    --accent-hover: #0077ED;
    --success: #34C759;
    --orange: #FF9500;
    --purple: #AF52DE;

    /* Layout */
    --grid-gap: 16px;
    --card-radius: 24px;
    --card-radius-sm: 16px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 12px 24px rgba(0, 0, 0, 0.08);

    /* Animation */
    --transition-fast: 150ms ease-out;
    --transition-medium: 250ms ease-out;
    --transition-slow: 350ms ease-out;
}

/* Base Styles */
html {
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
    background: var(--bg);
}

/* ===================================
   Bento Card Components
   =================================== */

/* Bento Card */
.bento-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    transition: transform var(--transition-medium), box-shadow var(--transition-medium);
    cursor: pointer;
}

.bento-card:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-hover);
}

.bento-card-flat {
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.bento-card-flat:hover {
    box-shadow: var(--shadow);
}

.bento-card-highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.bento-card-highlight .text-muted {
    color: rgba(255, 255, 255, 0.8);
}

/* Bento Portrait */
.bento-portrait {
    width: 300px;
    height: 380px;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-hover);
    overflow: hidden;
    position: relative;
}

.bento-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (min-width: 768px) {
    .bento-portrait {
        width: 350px;
        height: 450px;
    }
}

/* Bento Avatar */
.bento-avatar {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    box-shadow: var(--shadow-hover);
    overflow: hidden;
    background: var(--card-bg);
}

@media (min-width: 768px) {
    .bento-avatar {
        width: 320px;
        height: 320px;
    }
}

/* Bento Buttons */
.bento-button-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    font-weight: 600;
    border-radius: 980px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.bento-button-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.bento-button-primary:active {
    transform: scale(0.98);
}

.bento-button-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: transparent;
    color: var(--accent);
    font-weight: 600;
    border-radius: 980px;
    border: 1px solid var(--accent);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.bento-button-secondary:hover {
    background: var(--accent);
    color: white;
}

.bento-button-secondary:active {
    transform: scale(0.98);
}

.bento-button-sm {
    padding: 10px;
    background: var(--card-bg);
    border-radius: 12px;
    border: none;
    box-shadow: var(--shadow);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.bento-button-sm:hover {
    box-shadow: var(--shadow-hover);
}

/* Bento Badge */
.bento-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(0, 113, 227, 0.1);
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
    border-radius: 980px;
}

.bento-badge-sm {
    padding: 4px 10px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    border-radius: 980px;
}

.bento-badge-accent {
    padding: 4px 12px;
    background: var(--accent);
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 980px;
}

.bento-badge-orange {
    background: var(--orange);
}

.bento-badge-purple {
    background: var(--purple);
}

.bento-badge-success {
    background: var(--success);
}

/* Bento Pill */
.bento-pill {
    display: inline-block;
    padding: 8px 16px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    border-radius: var(--card-radius-sm);
    box-shadow: var(--shadow);
    transition: all var(--transition-fast);
}

.bento-pill:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

/* ===================================
   Navigation
   =================================== */

.nav-link {
    color: var(--text-muted);
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.04);
}

.nav-link.active {
    color: var(--accent);
}

.mobile-nav-link {
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
    padding: 12px 24px;
    border-radius: var(--card-radius-sm);
    transition: all var(--transition-fast);
}

.mobile-nav-link:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* ===================================
   Section Title
   =================================== */

.section-title {
    font-family: 'Inter', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin-bottom: 3rem;
    letter-spacing: -0.02em;
}

/* ===================================
   Bento Grid Layout
   =================================== */

.bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 200px;
    gap: var(--grid-gap);
}

.bento-span-1 { grid-column: span 1; grid-row: span 1; }
.bento-span-2 { grid-column: span 2; grid-row: span 1; }
.bento-span-2-tall { grid-column: span 2; grid-row: span 2; }
.bento-span-1-tall { grid-column: span 1; grid-row: span 2; }
.bento-span-4 { grid-column: span 4; grid-row: span 1; }
.bento-span-3 { grid-column: span 3; grid-row: span 1; }

@media (max-width: 1023px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 180px;
    }

    .bento-span-2-tall { grid-column: span 2; grid-row: span 2; }
    .bento-span-4 { grid-column: span 2; }
    .bento-span-3 { grid-column: span 2; }
}

@media (max-width: 639px) {
    .bento-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }

    .bento-span-1,
    .bento-span-2,
    .bento-span-2-tall,
    .bento-span-1-tall,
    .bento-span-3,
    .bento-span-4 {
        grid-column: span 1;
        grid-row: span 1;
    }
}

/* ===================================
   Timeline
   =================================== */

.timeline {
    position: relative;
    padding-left: 40px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--accent) 0%, var(--purple) 100%);
    border-radius: 2px;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-node {
    position: absolute;
    left: -33px;
    top: 24px;
    width: 18px;
    height: 18px;
    background: var(--card-bg);
    border: 3px solid var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--bg);
    z-index: 1;
    transition: all var(--transition-fast);
}

.timeline-item:hover .timeline-node {
    background: var(--accent);
    transform: scale(1.15);
}

.timeline-content {
    padding-left: 16px;
}

/* ===================================
   Project Cards
   =================================== */

.project-card {
    padding: 16px;
    background: var(--bg);
    border-radius: var(--card-radius-sm);
}

.tech-tag {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(0, 113, 227, 0.08);
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.tech-tag:hover {
    background: var(--accent);
    color: white;
}

/* ===================================
   Skills
   =================================== */

.skill-tag {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    transition: all var(--transition-fast);
    cursor: default;
}

.skill-tag:hover {
    background: rgba(0, 113, 227, 0.08);
    color: var(--accent);
    transform: translateY(-2px);
}

.skill-tag-ai {
    display: inline-block;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.1) 0%, rgba(175, 82, 222, 0.1) 100%);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--accent);
    transition: all var(--transition-fast);
    cursor: default;
}

.skill-tag-ai:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
}

/* ===================================
   Animations
   =================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDelay {
    0%, 30% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounceSlow {
    0%, 100% {
        transform: translateY(0) translateX(-50%);
    }
    50% {
        transform: translateY(10px) translateX(-50%);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Animation Classes */
.animate-fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

.animate-fade-in-delay {
    animation: fadeInDelay 1.2s ease-out forwards;
}

.animate-slide-down {
    animation: slideDown 0.6s ease-out forwards;
}

.animate-bounce-slow {
    animation: bounceSlow 2s ease-in-out infinite;
}

/* Scroll Reveal */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    transition-delay: var(--delay, 0s);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ===================================
   Reduced Motion
   =================================== */

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

    .scroll-reveal {
        opacity: 1;
        transform: none;
    }

    .bento-card:hover {
        transform: none;
    }
}

/* ===================================
   Responsive Adjustments
   =================================== */

@media (max-width: 767px) {
    .section-title {
        font-size: 2rem;
    }

    .timeline {
        padding-left: 30px;
    }

    .timeline::before {
        left: 10px;
    }

    .timeline-node {
        left: -28px;
        width: 14px;
        height: 14px;
    }

    .bento-button-primary,
    .bento-button-secondary {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* Focus States for Accessibility */
a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    nav,
    .animate-bounce-slow {
        display: none;
    }

    .bento-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Stat Number */
.stat-number {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Icon Container */
.icon-container {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-container-blue { background: rgba(0, 113, 227, 0.1); color: var(--accent); }
.icon-container-purple { background: rgba(175, 82, 222, 0.1); color: var(--purple); }
.icon-container-orange { background: rgba(255, 149, 0, 0.1); color: var(--orange); }
.icon-container-green { background: rgba(52, 199, 89, 0.1); color: var(--success); }
