/* Modern CSS Reset & Variables */
:root {
    --bg-deep: #0a0e17;
    --bg-card: #121927;
    --bg-card-hover: #1a2333;
    --accent-cyan: #38bdf8;
    --accent-cyan-glow: rgba(56, 189, 248, 0.15);
    --accent-blue: #2563eb;
    --accent-blue-hover: #1d4ed8;
    --linkedin-blue: #0a66c2;
    --linkedin-blue-hover: #004182;
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --border-subtle: rgba(255, 255, 255, 0.08);
    
    --section-padding: clamp(3rem, 6vw, 5rem); 
    --container-max: 1100px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 6rem; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-deep);
    
    /* Architectural Vector Grid Pattern */
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center top;
    background-attachment: fixed;
    
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Accessibility Focus States */
a:focus-visible, button:focus-visible, input:focus-visible {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 4px;
    border-radius: 4px;
}

/* Navigation */
nav {
    position: fixed; top: 0; left: 0; right: 0;
    background: rgba(10, 14, 23, 0.90); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle); 
    z-index: 1002; /* Sits above the fullscreen menu */
    transition: background 0.3s ease, border-color 0.3s ease;
}

/* Hide background and border when menu is open */
nav:has(.menu-btn.active) {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-color: transparent;
}

/* Hide the logo when menu is open */
nav:has(.menu-btn.active) .logo-wrapper {
    opacity: 0;
    pointer-events: none;
}

.nav-container { max-width: var(--container-max); margin: 0 auto; display: flex; justify-content: space-between; align-items: center; min-height: 5rem; padding: 0.5rem 1.5rem; }
.logo-wrapper { display: flex; align-items: center; gap: 1.125rem; text-decoration: none; outline: none; z-index: 1001; transition: opacity 0.3s ease; }
.logo-icon { width: 48px; height: 48px; flex-shrink: 0; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3)); transition: filter 0.3s ease, transform 0.3s ease; }
.logo-wrapper:hover .logo-icon { filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.4)); transform: translateY(-1px); }
.logo-wrapper:hover .logo-title { color: #ffffff; }
.logo-text-container { display: flex; flex-direction: column; justify-content: center; text-align: left; }
.logo-title { font-size: clamp(1.2rem, 2.5vw, 1.4rem); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; color: var(--text-main); margin-bottom: 0.15rem; transition: color 0.3s ease; }
.logo-sub { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--accent-cyan); font-weight: 600; }

/* Desktop Links */
.nav-links { display: flex; gap: 0.75rem; align-items: center; }
.nav-links a { color: var(--text-main); background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08); padding: 0.5rem 1.25rem; border-radius: 2rem; text-decoration: none; font-size: 0.95rem; font-weight: 600; transition: all 0.2s ease; }
.nav-links a:hover { background: rgba(255,255,255,0.08); border-color: var(--accent-cyan); color: #ffffff; transform: translateY(-2px); }

/* Mobile Menu Button */
.menu-btn { display: none; background: transparent; border: none; cursor: pointer; width: 45px; height: 45px; position: relative; z-index: 1003; }
.hamburger-line { display: block; width: 35px; height: 4px; background-color: var(--text-main); border-radius: 4px; position: absolute; left: 5px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.hamburger-line:nth-child(1) { top: 12px; }
.hamburger-line:nth-child(2) { top: 21px; }
.hamburger-line:nth-child(3) { top: 30px; }
.menu-btn.active .hamburger-line:nth-child(1) { top: 21px; transform: rotate(45deg); background-color: var(--accent-cyan); }
.menu-btn.active .hamburger-line:nth-child(2) { opacity: 0; }
.menu-btn.active .hamburger-line:nth-child(3) { top: 21px; transform: rotate(-45deg); background-color: var(--accent-cyan); }

/* Fullscreen Menu Overlay */
.fullscreen-menu { 
    position: fixed; inset: 0; background: rgba(10, 14, 23, 0.98); backdrop-filter: blur(20px); 
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2.5rem; 
    z-index: 1001; /* Sits directly below the nav bar */
    opacity: 0; pointer-events: none; transform: translateY(-20px); transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); 
}
.fullscreen-menu.active { opacity: 1; pointer-events: auto; transform: translateY(0); }
.fullscreen-menu a { font-size: 2.5rem; font-weight: 900; color: var(--text-muted); text-decoration: none; letter-spacing: -0.03em; transition: all 0.3s ease; text-align: center; }
.fullscreen-menu a:hover, .fullscreen-menu a:focus { color: var(--text-main); transform: scale(1.05); }
.fullscreen-menu .menu-btn-wrapper { margin-top: 1.5rem; width: 100%; max-width: 280px; }
.fullscreen-menu .menu-btn-wrapper .btn { font-size: 1.05rem; font-weight: 600; letter-spacing: normal; width: 100%; }

/* Typography & Layout */
.section-container { max-width: var(--container-max); margin: 0 auto; padding: var(--section-padding) 1.5rem; }
h1.hero-title { font-size: clamp(2.5rem, 6vw, 4rem); font-weight: 900; line-height: 1.1; margin-bottom: 1.5rem; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.8rem, 4vw, 2.2rem); font-weight: 700; letter-spacing: -0.02em; margin-bottom: 3.5rem; position: relative; text-align: center; }
h2::after { content: ''; position: absolute; bottom: -1rem; left: 50%; transform: translateX(-50%); width: 4rem; height: 4px; background-color: var(--accent-cyan); border-radius: 2px; }
h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text-main); text-align: left; }
p { color: var(--text-muted); font-size: 1.05rem; text-align: left; }

/* Hero */
header { padding: 7rem 1.5rem 2rem; max-width: 900px; margin: 0 auto; text-align: center; }
.hero-image { width: 100%; max-width: 650px; max-height: 45vh; border-radius: 1rem; margin: 0 auto 1.75rem auto; box-shadow: 0 20px 40px rgba(0,0,0,0.5); border: 1px solid var(--border-subtle); object-fit: cover; object-position: center 20%; display: block; }
.hero-bio { font-size: clamp(1.05rem, 2vw, 1.15rem); margin: 0 auto 1.75rem; line-height: 1.6; max-width: 750px; text-align: center; }

/* Buttons */
.btn-group { display: flex; gap: 1rem; justify-content: center; align-items: center; flex-wrap: wrap; }
.btn { display: inline-flex; justify-content: center; align-items: center; text-decoration: none; padding: 1rem 2.5rem; font-weight: 600; font-size: 1.05rem; border-radius: 0.5rem; transition: all 0.3s ease; cursor: pointer; width: auto; min-width: 220px; border: none; }
.btn-primary { background: var(--accent-blue); color: #ffffff; border: 1px solid var(--accent-blue); }
.btn-primary:hover { background: var(--accent-blue-hover); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4); }
.btn-linkedin { background: var(--linkedin-blue); color: #ffffff; border: 1px solid var(--linkedin-blue); }
.btn-linkedin:hover { background: var(--linkedin-blue-hover); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(10, 102, 194, 0.4); }

/* Grids & Cards */
.grid { display: grid; gap: 1.5rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--bg-card); padding: 3rem 2rem; border-radius: 1rem; border: 1px solid var(--border-subtle); transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); display: flex; flex-direction: column; height: 100%; align-items: flex-start; }
.card:hover { transform: translateY(-8px); border-color: var(--accent-cyan); box-shadow: 0 20px 40px -10px var(--accent-cyan-glow); }
.service-icon { margin-bottom: 1.25rem; display: block; }

/* Horizontal Timeline */
.horizontal-timeline {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 1.5rem;
    padding: 1rem 0 2rem 0;
    scrollbar-width: none; /* Firefox */
}
.horizontal-timeline::-webkit-scrollbar { display: none; /* Chrome/Safari */ }
.horizontal-timeline-item {
    flex: 0 0 85%;
    max-width: 320px;
    scroll-snap-align: start;
    background: var(--bg-card);
    padding: 2.5rem 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
}
.horizontal-timeline-year {
    font-size: 2rem;
    font-weight: 900;
    color: var(--accent-cyan);
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-subtle);
    padding-bottom: 0.5rem;
    text-align: left;
}

/* Sections & Tags */
.accent-section { background: var(--bg-card); border-radius: 1.5rem; border: 1px solid var(--border-subtle); padding: 4rem 2rem; text-align: center; }
.accent-content { margin: 0 auto; }
.wide-content { max-width: 1000px; } /* Allows tags to stay on one row on desktop */
.cta-wrapper { background: var(--bg-card); padding: 4rem 2rem; border-radius: 1.5rem; border: 1px solid var(--border-subtle); text-align: center; max-width: 800px; margin: 0 auto; }

.tags-container { 
    margin-top: 2.5rem; 
    display: flex; 
    flex-wrap: nowrap; /* Forces one row on desktop */
    gap: 0.75rem; 
    justify-content: center; 
}
.tag { background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.3); color: var(--accent-cyan); padding: 0.5rem 1rem; border-radius: 2rem; font-size: 0.9rem; font-weight: 600; white-space: nowrap; }

/* Tetris Game Styles */
.tetris-wrapper { display: flex; flex-direction: column; align-items: center; gap: 2rem; max-width: 600px; margin: 0 auto; }
.tetris-sidebar { display: flex; flex-direction: row; gap: 1rem; align-items: center; width: 100%; justify-content: center; }
.tetris-score-box { background: var(--bg-deep); border: 1px solid var(--border-subtle); padding: 0.75rem 1.5rem; border-radius: 0.5rem; display: flex; align-items: center; gap: 1rem; }
.tetris-score-box h3 { margin: 0; font-size: 1rem; color: var(--text-muted); }
#tetris-score { font-size: 1.5rem; font-weight: 900; color: var(--accent-cyan); }
.tetris-game-area { background: #000; padding: 10px; border-radius: 10px; border: 2px solid var(--border-subtle); box-shadow: 0 10px 30px rgba(0,0,0,0.5); display: flex; flex-direction: column; align-items: center; }
#tetris-canvas { background: #0a0e17; display: block; margin-bottom: 1rem; border-radius: 4px; }
.tetris-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; width: 100%; }
.tetris-controls button { background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-subtle); padding: 1rem; border-radius: 0.5rem; font-weight: bold; font-size: 1.25rem; cursor: pointer; user-select: none; transition: background 0.1s; }
.tetris-controls button:active { background: var(--accent-cyan); color: #000; }

/* Footer */
footer { text-align: center; padding: 3rem 1.5rem; border-top: 1px solid var(--border-subtle); background: rgba(18, 25, 39, 0.8); backdrop-filter: blur(10px); }
.footer-text { color: #cbd5e1; font-size: 1.1rem; margin-bottom: 0.25rem; }
.footer-link { color: var(--accent-cyan); text-decoration: none; transition: color 0.3s ease; }
.footer-link:hover { color: #ffffff; }
.separator { color: var(--border-subtle); margin: 0 0.5rem; }
.footer-subtext { font-size: 0.9rem; color: var(--text-muted); letter-spacing: 0.05em; text-transform: uppercase; }

/* Scroll Reveals */
.reveal { opacity: 0; transform: translateY(30px); transition: all 0.8s cubic-bezier(0.5, 0, 0, 1); }
.reveal.active { opacity: 1; transform: translateY(0); }
.delay-100 { transition-delay: 100ms; }
.delay-200 { transition-delay: 200ms; }

/* Breakpoints */
@media (min-width: 1025px) {
    .mobile-only { display: none !important; }
    .tetris-wrapper { flex-direction: row; align-items: flex-start; justify-content: center; }
    .tetris-sidebar { flex-direction: column; width: auto; align-items: stretch; }
    .tetris-controls { display: none; }
}

/* Trigger Mobile Menu on Tablets & Phones */
@media (max-width: 1024px) {
    .desktop-only { display: none !important; }
    .menu-btn { display: block; }
    .tags-container { flex-wrap: wrap; }
}

@media (max-width: 900px) {
    .grid-3 { grid-template-columns: 1fr; }
}

/* Mobile-Specific Adjustments (Fixing the Fold) */
@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    
    /* Tighten up top padding */
    header { padding: 5rem 1.5rem 1.5rem; } 
    
    /* Shrink Philip-Philipov.jpg so buttons fit on screen */
    .hero-image { max-height: 28vh; margin-bottom: 1rem; } 
    
    /* Tighten text elements */
    h1.hero-title { font-size: 2.1rem; margin-bottom: 0.5rem; }
    .hero-bio { font-size: 0.95rem; margin-bottom: 1rem; line-height: 1.4; }
    
    /* Stack buttons compactly */
    .btn-group { flex-direction: column; width: 100%; gap: 0.6rem; }
    .btn { width: 100%; padding: 0.8rem 1.5rem; }
}