/* Global Variables & Reset */
:root {
    --bg-color: #121212;
    --surface-color: #1E1E1E;
    --primary-color: #00D1FF;
    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B0;
    --card-radius: 20px;
    --transition-speed: 0.3s ease;
    --font-heading: 'Poppins', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
}

body {
    background-color: var(--bg-color);
    color: var(--text-secondary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Preloader */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    /* Use viewport height */
    background-color: #121212;
    z-index: 9999;
    display: flex !important;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader-logo {
    width: 80px;
    height: auto;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(0, 209, 255, 0.4));
    /* Glow */
}

@keyframes pulse {
    0% {
        transform: scale(0.9);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(0.9);
        opacity: 0.8;
    }
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-weight: 700;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-speed);
}

/* Layout Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.section-spacer {
    height: 80px;
}

/* Typography Utilities */
.section-title {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 1rem;
    position: relative;
    display: inline-block;
    width: 100%;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background-color: var(--primary-color);
    margin: 10px auto 0;
    border-radius: 2px;
}

.highlight {
    color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-heading);
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
    transition: all var(--transition-speed);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #000;
    border: 2px solid var(--primary-color);
}

.btn-primary:hover {
    background-color: transparent;
    color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 209, 255, 0.4);
}

.btn-outlined {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outlined:hover {
    background-color: var(--primary-color);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 209, 255, 0.4);
}

/* Bio Section */
.bio-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 80vh;
    padding: 40px 0;
    gap: 40px;
}

.bio-content {
    flex: 1;
}

.bio-title {
    /* font-size: 3.5rem; */
    line-height: 1.2;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* Left align on desktop */
}

.greeting-line {
    display: block;
    width: 100%;
}

.intro-line {
    display: flex;
    align-items: center;
    white-space: nowrap;
    /* Prevent wrapping on desktop too */
}

.static-text {
    margin-right: 12px;
}

/* Ensure typewriter cursor doesn't wrap */
.dynamic-text-container {
    white-space: nowrap;
}

.bio-subtitle {
    font-size: 1.1rem;
    margin-bottom: 30px;
    max-width: 600px;
}

.bio-actions {
    display: flex;
    gap: 15px;
}

.bio-image {
    flex: 1;
    display: flex;
    justify-content: center;
    position: relative;
}

.bio-image img {
    width: clamp(250px, 30vw, 350px);
    height: auto;
    aspect-ratio: 1/1;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    border: 4px solid var(--surface-color);
    box-shadow: 0 0 30px rgba(0, 209, 255, 0.2);
    animation: float 6s ease-in-out infinite;
}

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

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

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

/* Cursor Blink Animation */
.cursor {
    display: inline-block;
    width: 3px;
    background-color: var(--primary-color);
    animation: blink 1s step-end infinite;
}

.highlight {
    color: var(--primary-color);
    font-size: 1.2em;
    /* Increase dynamic text size relative to "I'm" */
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 30px;
}

.project-card {
    background-color: var(--surface-color);
    border-radius: var(--card-radius);
    overflow: hidden;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.project-image {
    height: 250px;
    overflow: hidden;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.project-card:hover .project-image img {
    transform: scale(1.1);
}

.project-info {
    padding: 30px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.project-info h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.project-info p {
    font-size: 0.95rem;
    margin-bottom: 20px;
    flex-grow: 1;
    color: #ccc;
}

.project-links {
    display: flex;
    gap: 15px;
}

.icon-link {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.icon-link:hover {
    color: var(--primary-color);
}

/* Course Card Specifics */
/* Reusing project-card styles effectively */

/* --- Experience Section (Zig-Zag Layout) --- */
.timeline {
    position: relative;
    max-width: 1200px;
    /* Wider for alternating */
    margin: 0 auto;
    padding: 20px 0;
}

/* The vertical line - CENTERED */
.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #00C9B1;
    /* Cyan/Teal line */
    transform: translateX(-50%);
    opacity: 0.3;
}

/* Common Item Styles */
.timeline-item {
    position: relative;
    width: 50%;
    margin-bottom: 40px;
    padding: 0 30px;
    /* Space from center line */
}

/* Left Side (Odd Items) */
.timeline-item:nth-child(odd) {
    left: 0;
    text-align: right;
    /* Text aligns to center */
}

/* Right Side (Even Items) */
.timeline-item:nth-child(even) {
    left: 50%;
    text-align: left;
    /* Text aligns to center */
}

/* The Glowing Dot - CENTERED */
.timeline-dot {
    position: absolute;
    top: 24px;
    width: 20px;
    height: 20px;
    background: #111;
    border: 2px solid #00C9B1;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 0 10px rgba(0, 209, 255, 0.4);
}

/* Dot Positioning for Odd/Left items */
.timeline-item:nth-child(odd) .timeline-dot {
    right: -11px;
    /* Half width + border */
    /* On left side items, dot should be on the right edge */
}

/* Dot Positioning for Even/Right items */
.timeline-item:nth-child(even) .timeline-dot {
    left: -11px;
    /* Half width + border */
    /* On right side items, dot should be on the left edge */
}

/* Education Section Layout (Card Left, Icon Right) */
#education .timeline {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 0;
}

#education .timeline::before {
    display: none;
    /* Remove default center line */
}

#education .timeline-item {
    width: 100%;
    left: 0;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 40px;
    /* Space between card and icon line */
}

/* 1. The Card (Left Side) */
#education .timeline-content.experience-card {
    width: 65%;
    max-width: 700px;
    margin: 0 !important;
    text-align: left;
    border: 2px solid var(--accent-color);
    /* Cyan border like reference */
    background: #1E1E1E;
    z-index: 1;
    order: 1;
    /* Card first */
}

/* 2. The Icon & Line Container (Right Side) */
#education .timeline-icon-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 50px;
    order: 2;
    /* Icon second */
    padding-top: 20px;
    /* Align icon with card top roughly */
}

/* The Vertical Line */
#education .timeline-icon-container::after {
    content: '';
    position: absolute;
    top: 50px;
    /* Start below icon */
    bottom: -100px;
    /* Extend down */
    width: 2px;
    background: #333;
    z-index: 0;
}

/* The Icon Circle */
#education .timeline-icon {
    position: relative;
    width: 50px;
    height: 50px;
    background: #1E1E1E;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--accent-color);
    box-shadow: 0 0 10px rgba(0, 201, 177, 0.2);
    z-index: 2;
}



/* Experience Card Design */
.experience-card {
    background-color: #1E1E1E;
    border: 1px solid #333333;
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s ease;
    cursor: default;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    text-align: left;
    /* Reset text align inside card for readability */
}

/* Align card text based on side if preferred, but usually Left Align inside card is better reading experience */
.timeline-item:nth-child(odd) .experience-card {
    /* Optional: keep text left aligned inside the card even if the card is on the left */
    text-align: right;
}

.timeline-item:nth-child(even) .experience-card {
    text-align: left;
}

/* Wait, reading long text right-aligned is bad. Let's force Left Align inside the card content, but align the Card Header maybe? */
/* Actually, standard is usually left-aligned text inside all cards. Let's enforce that. */
.experience-card {
    text-align: left !important;
}

/* But the badge alignment might look cool if it follows the side. Let's leave content left aligned for readability. */


.experience-card:hover {
    border-color: #00C9B1;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 201, 177, 0.1);
}

/* Typography */
.card-header {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.timeline-item:nth-child(odd) .card-header {
    align-items: flex-end;
    /* Title aligns to timeline */
}

/* Badges Alignment */
.meta-badges {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.timeline-item:nth-child(odd) .meta-badges {
    justify-content: flex-end;
}

.role-title {
    font-size: 1.25rem;
    color: #00C9B1;
    font-weight: 700;
    margin-bottom: 4px;
}

.company-name {
    font-size: 1rem;
    color: #FFFFFF;
    font-weight: 500;
    margin: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #2A2A2A;
    color: #999999;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    transition: color 0.3s;
}

.badge i {
    font-size: 0.9rem;
}

.experience-card:hover .badge {
    color: #CCCCCC;
}

.description {
    color: #AAAAAA;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .timeline {
        padding-left: 0;
    }

    /* Move line to left on mobile */
    .timeline::before {
        left: 20px;
        transform: none;
    }

    /* Make all items full width */
    .timeline-item {
        width: 100%;
        padding-left: 20px;
        /* Reduced from 50px to prevent overflow */
        padding-right: 0;
        margin-bottom: 30px;
    }

    /* Reset Odd/Even positioning */
    .timeline-item:nth-child(odd),
    .timeline-item:nth-child(even) {
        left: 0;
        text-align: left;
    }

    /* Reset Dot positioning */
    .timeline-item:nth-child(odd) .timeline-dot,
    .timeline-item:nth-child(even) .timeline-dot {
        left: -9px;
        /* Align dot correctly with new line position */
        /* Line is now at 20px (from left:20px in ::before). Dot needs to be centered on it. */
        right: auto;
    }

    .timeline-item:nth-child(odd) .meta-badges,
    .timeline-item:nth-child(even) .meta-badges {
        justify-content: flex-start;
        flex-wrap: wrap !important;
        /* CRITICAL: Force wrap for long locations on mobile */
    }

    /* Force wrap on ALL badges globally on mobile */
    .meta-badges {
        flex-wrap: wrap !important;
    }

    .timeline-item:nth-child(odd) .card-header {
        align-items: flex-start;
    }

    .role-title {
        font-size: 1.1rem;
    }

    .experience-card {
        padding: 20px;
    }
}

/* Skills Section */
/* Skills Section - Pixel Perfect Rewrite */
/* Skills Section - Reference Match (4 Columns) */
.skills-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* 4 Columns as per reference image */
    gap: 20px;
    margin-top: 40px;
    margin-bottom: 60px;
}

.skill-category {
    background-color: #1A1A1A;
    border: 1px solid #333;
    padding: 25px;
    border-radius: 16px;
    text-align: center;
    height: 100%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Highlight the first card (Architecture) as shown in reference */


/* Active state for interactivity */
.skill-category.active h3,
.skill-category.active i {
    color: var(--primary-color);
}

.skill-category.active {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(0, 209, 255, 0.15);
    /* Add subtle glow for active too */
}

/* Hover remains same but can stack/co-exist */
.skill-category:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
}

.skill-category h3 {
    margin-bottom: 25px;
    color: #FFFFFF;
    font-size: 1.4rem;
    font-weight: 600;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.skill-tags span {
    background-color: #252525;
    /* Live site chip bg default */
    border: 1px solid #444;
    /* Live site chip border */
    color: #E0E0E0;
    /* Live site text default */
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: default;
}

.skill-tags span:hover {
    background-color: var(--primary-color);
    /* Cyan on hover */
    color: #000000;
    /* Black text on hover */
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 209, 255, 0.4);
    transform: translateY(-2px);
}

/* Responsive adjustment for skills */
@media (max-width: 1200px) {
    .skills-container {
        grid-template-columns: repeat(2, 1fr);
        /* 2 Columns on Tablet */
    }
}

@media (max-width: 768px) {
    .skills-container {
        grid-template-columns: repeat(2, 1fr);
        /* 2 Columns on Mobile as requested */
    }
}

/* Premium Footer */
footer {
    background-color: #121212;
    /* Match main bg for seamless look */
    padding: 60px 0 40px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    /* Subtle separator */
}

.footer-title {
    color: #FFFFFF;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 40px;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 30px;
    /* More space */
    margin-bottom: 50px;
}

.social-links a {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    /* Larger touch target */
    height: 60px;
    background-color: rgba(255, 255, 255, 0.05);
    /* Glassy dark */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.social-links i {
    font-size: 1.5rem;
    color: #CCCCCC;
    transition: all 0.3s ease;
    z-index: 2;
}

/* Premium Hover Effect */
.social-links a:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-8px);
    /* Higher lift */
    box-shadow: 0 10px 20px rgba(0, 209, 255, 0.3);
}

.social-links a:hover i {
    color: #000000;
    /* High contrast black icon */
    transform: scale(1.1);
}

.copyright {
    color: #666666;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 20px;
    margin-top: 20px;
}

.center-btn-container {
    text-align: center;
    margin-top: 40px;
}

/* Responsive */
@media (max-width: 768px) {
    .section-title {
        font-size: 2rem;
    }

    .bio-section {
        flex-direction: column-reverse;
        /* Text on top on mobile usually, or image on top? Let's stick closely to common patterns */
        flex-direction: column;
        text-align: center;
        justify-content: flex-start;
        padding-top: 120px;
        min-height: auto;
    }

    .bio-subtitle {
        margin: 0 auto 30px;
        font-size: 1.15rem;
        /* Increased from default */
    }

    .bio-actions {
        justify-content: center;
    }

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

    .timeline-item {
        width: 100%;
        padding-left: 50px;
        padding-right: 0;
        text-align: left;
    }

    .timeline-item:nth-child(odd),
    .timeline-item:nth-child(even) {
        left: 0;
        text-align: left;
    }

    .timeline-item::after {
        left: 12px;
    }

    .bio-image img {
        width: 250px;
        height: 250px;
    }

    /* Mobile Header Fixes - Robust Layout */
    .bio-title {
        display: flex;
        flex-direction: column;
        align-items: center;
        /* Center everything on mobile */
        gap: 5px;
        line-height: 1.2;
    }

    .greeting-line {
        font-size: 3rem;
        /* Increased from 2.5rem */
        width: 100%;
        text-align: center;
    }

    .intro-line {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        /* CRITICAL: Prevent wrapping */
        width: 100%;
        max-width: 100%;
    }

    /* Scaling font size for the "I'm ..." line */
    /* Dynamic scale */
}

.highlight {
    font-size: 1.5em;
    /* Make "Mohamed Magdy" significantly larger on mobile */
}

.static-text {
    margin-right: 8px;
    /* Space between I'm and Name */
}

.dynamic-text-container {
    white-space: nowrap;
    overflow: visible;
    /* Let it show, font size handles the width */
}

#typewriter-text {
    white-space: nowrap;
}

/* --- Mobile Fixes for Education Section --- */
#education .timeline-item {
    flex-direction: column;
    gap: 20px;
    padding-left: 0;
}

/* Reset Card Width */
#education .timeline-content.experience-card {
    width: 100%;
    max-width: 100%;
    order: 2;
    /* Content below icon on mobile? Or just standard stack */
    margin-bottom: 0 !important;
}

/* Icon Container on Mobile */
#education .timeline-icon-container {
    width: 100%;
    order: 1;
    /* Icon on top */
    padding-top: 0;
    margin-bottom: 10px;
}

/* Horizontal Line connector instead of vertical? or just hide line */
#education .timeline-icon-container::after {
    display: none;
    /* Hide complex vertical line on mobile */
}

#education .timeline-icon {
    margin: 0 auto;
    /* Center icon */
    box-shadow: 0 0 15px rgba(0, 201, 177, 0.4);
}
}