/* --- 1. CONFIG & RESET --- */
:root {
    /* Colors */
    --color-black: #050505;
    --color-white: #ffffff;
    --neutral-300: #d4d4d4;
    --neutral-400: #a3a3a3;
    --neutral-500: #737373;
    --neutral-600: #525252;
    --neutral-700: #404040;
    --neutral-800: #262626;
    --neutral-900: #171717;
    --neutral-950: #0a0a0a;
    
    /* Brand Colors */
    --bg-orange-500: #f97316;
    --bg-blue-500: #3b82f6;
    --bg-teal-500: #14b8a6;
    --bg-green-500: #22c55e;
    --bg-purple-500: #a855f7;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* ANIMATION VARIABLES */
    --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { 
    scroll-behavior: smooth; 
    scrollbar-color: var(--neutral-800) var(--color-black);
    scrollbar-width: thin;
}

body {
    background-color: var(--color-black);
    color: var(--color-white);
    font-family: var(--font-sans);
    margin: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    opacity: 0;
    transition: opacity 0.6s ease;
}
body.loaded { opacity: 1; }

a { text-decoration: none; color: inherit; transition: color 0.2s; }
button { border: none; background: none; cursor: pointer; font-family: inherit; padding: 0; color: inherit; }
ul { list-style: none; padding: 0; margin: 0; }

/* --- 2. UTILITIES --- */
.container { max-width: 1152px; margin: 0 auto; padding: 0 24px; box-sizing: border-box; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.uppercase { text-transform: uppercase; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-neutral-400 { color: var(--neutral-400); }
.text-neutral-500 { color: var(--neutral-500); }
.tracking-tighter { letter-spacing: -0.05em; }
.tracking-wide { letter-spacing: 0.1em; }

/* --- 3. ICONS & UI ELEMENTS --- */
.icon { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.icon-sm { width: 16px; height: 16px; }

.project-tag {
    display: inline-block; padding: 4px 10px; border-radius: 9999px;
    font-size: 0.75rem; font-weight: 500; border: 1px solid var(--neutral-800);
    background: rgba(255, 255, 255, 0.03);
}

/* --- 4. LAYOUT COMPONENTS --- */
header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50; padding: 24px 0;
    transition: all 0.4s var(--ease-out-expo);
}
header.scrolled {
    background-color: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 16px 0;
}
.logo { font-size: 1.25rem; }
.nav-link { font-size: 0.875rem; color: var(--neutral-400); margin-left: 2rem; position: relative; }
.nav-link:hover { color: var(--color-white); }

/* Hero */
.hero { padding-top: 130px; padding-bottom: 50px; }
.status-pill {
    display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px;
    background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9999px; margin-bottom: 24px;
    transition: transform 0.3s var(--ease-spring);
}
.status-pill:hover { transform: scale(1.05); border-color: rgba(255,255,255,0.2); }

.status-dot {
    width: 8px; height: 8px; background-color: #22c55e; border-radius: 50%;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.6);
    animation: pulse 2s infinite;
}
@keyframes pulse { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.9); } 100% { opacity: 1; transform: scale(1); } }

h1 {
    font-size: clamp(2.75rem, 7vw, 5rem); line-height: 0.98; font-weight: 700;
    letter-spacing: -0.04em; margin: 0 0 24px 0;
}
h1 span { color: var(--neutral-500); }
.hero-desc {
    font-size: clamp(1rem, 2vw, 1.25rem); color: var(--neutral-400); 
    max-width: 580px; font-weight: 300; line-height: 1.6; margin-bottom: 32px;
}

.btn-primary {
    display: inline-flex; align-items: center; gap: 12px;
    background: var(--color-white); color: var(--color-black);
    padding: 14px 28px; border-radius: 9999px; font-weight: 700;
    transition: all 0.3s var(--ease-spring);
}
.btn-primary:hover { 
    background-color: #f0f0f0; 
    transform: translateY(-3px) scale(1.02); 
    box-shadow: 0 10px 20px rgba(255,255,255,0.1);
}
.btn-primary:active { transform: translateY(-1px) scale(0.98); }
.btn-primary.disabled { opacity: 0.5; cursor: not-allowed; background: var(--neutral-800); color: var(--neutral-500); box-shadow: none; transform: none; }

/* Stack */
.stack-section { 
    padding: 36px 0 48px; 
    border-top: 1px solid var(--neutral-900); 
    border-bottom: 1px solid var(--neutral-900); 
    scroll-margin-top: 90px;
}
.tech-list { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.tech-badge {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px;
    border: 1px solid var(--neutral-800); background: var(--neutral-950);
    border-radius: 9999px; color: var(--neutral-300); font-size: 0.875rem; font-weight: 500;
    transition: all 0.3s ease; cursor: default;
}
.tech-badge:hover { background: var(--neutral-900); border-color: var(--neutral-600); transform: translateY(-2px); }

/* Work Grid */
.work-section { 
    padding: 48px 0 80px; 
    scroll-margin-top: 24px;
}

/* Zabezpieczenie: jesli .section-header lub .projects-grid nie sa wewnatrz .container w HTML */
.work-section > .section-header,
.work-section > .projects-grid {
    max-width: 1152px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
    box-sizing: border-box;
}

.section-header { 
    margin-bottom: 24px; 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-end; 
}
.section-title { font-size: 2.5rem; margin: 0; letter-spacing: -0.05em; line-height: 1; }

.projects-grid {
    display: grid; grid-template-columns: 1fr; gap: 48px 36px; margin-top: 32px;
}
@media (min-width: 768px) { .projects-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .projects-grid { grid-template-columns: repeat(3, 1fr); } }

/* --- 5. PROJECT CARD MOCKUPS --- */
.project-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
    justify-content: flex-start;
    height: 100%;
    perspective: 1000px;
}

.mockup-base {
    background: var(--color-black); overflow: hidden;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
    transition: transform 0.6s var(--ease-out-expo), box-shadow 0.6s var(--ease-out-expo), border-color 0.5s;
}
.project-card:hover .mockup-base {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.9);
    border-color: var(--neutral-600);
}

.mockup-mobile {
    position: relative;
    width: 210px;
    height: 380px;
    border: 9px solid var(--neutral-900);
    border-radius: 2.8rem;
    will-change: transform;
    margin: 0 auto;
}
.dynamic-island {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: 65px; height: 18px; background: #000;
    border-radius: 14px; z-index: 20;
    transition: width 0.3s ease;
}
.project-card:hover .dynamic-island { width: 78px; }

/* Wysrodkowanie okna desktopowego wzgledem wysokosci telefonu (380px) */
.mockup-desktop {
    width: 320px;
    height: 210px;
    border: 1px solid var(--neutral-800);
    border-radius: 14px;
    background: #000;
    margin: 85px auto;
}
.window-bar {
    height: 30px; background: var(--neutral-950); border-bottom: 1px solid var(--neutral-900);
    display: flex; align-items: center; padding: 0 12px; gap: 6px;
}
.win-dot { width: 8px; height: 8px; border-radius: 50%; }
.win-dot.red { background:#ef4444; }
.win-dot.yellow { background:#eab308; }
.win-dot.green { background:#22c55e; }

.screen { width: 100%; height: 100%; background: var(--neutral-950); display: flex; flex-direction: column; position: relative; }

.hover-overlay {
    position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; opacity: 0;
    transition: opacity 0.4s ease; z-index: 30;
}
.project-card:hover .hover-overlay { opacity: 1; }

.view-btn {
    display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2); color: var(--color-white); padding: 10px 20px;
    border-radius: 9999px; font-weight: 500; font-size: 0.85rem; transform: translateY(10px);
    transition: transform 0.4s var(--ease-spring);
}
.project-card:hover .view-btn { transform: translateY(0); }

.mockup-padding { padding: 18px; display: flex; flex-direction: column; height: 100%; }
.mockup-desktop-content { display: flex; height: 100%; gap: 14px; padding: 16px; }
.mockup-icon { width: 40px; height: 40px; border-radius: 12px; margin-bottom: 12px; }
.mockup-icon-sm { width: 28px; height: 28px; border-radius: 8px; margin-bottom: 6px; }

.mockup-bar { background: rgba(255,255,255,0.08); border-radius: 99px; height: 10px; margin-bottom: 8px; }
.mockup-bar.thin { height: 6px; }
.mockup-bar.dim { background: rgba(255,255,255,0.04); }
.mockup-area { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); border-radius: 10px; }

.project-info {
    margin-top: 24px;
    text-align: center;
    color: var(--color-white);
    width: 100%;
    position: relative;
    z-index: 10;
}
.project-info h3 { font-size: 1.35rem; margin: 0 0 6px 0; letter-spacing: -0.025em; font-weight: 600; }
.project-cat { color: var(--neutral-500); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.15em; font-weight: 600; }
.project-desc { color: var(--neutral-400); font-size: 0.875rem; margin-top: 8px; line-height: 1.5; max-width: 300px; margin-left: auto; margin-right: auto;}

/* --- 6. ANIMATIONS --- */
.animate-up {
    opacity: 0; transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s var(--ease-out-expo);
}
.animate-up.visible { opacity: 1; transform: translateY(0); }

/* --- 7. MODAL --- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    z-index: 100; display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.4s ease; padding: 24px;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal-content {
    background: #0a0a0a; border: 1px solid var(--neutral-800);
    width: 100%; max-width: 1024px; max-height: 90vh; border-radius: 24px;
    position: relative; 
    transform: scale(0.9) translateY(20px); 
    transition: transform 0.5s var(--ease-spring);
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 40px 100px -20px rgba(0,0,0,0.9);
}
.modal-overlay.open .modal-content { transform: scale(1) translateY(0); }

.modal-header {
    padding: 28px 36px; border-bottom: 1px solid var(--neutral-900); background: #0a0a0a;
    display: flex; justify-content: space-between; align-items: flex-start; flex-shrink: 0;
}
.modal-title-group h2 { font-size: clamp(1.75rem, 3vw, 2.25rem); margin: 0; line-height: 1.1; font-weight: 700; }
.modal-subtitle { display: flex; align-items: center; gap: 12px; margin-top: 10px; }

.modal-body {
    padding: 36px; overflow-y: auto; flex: 1;
    display: flex; flex-direction: column; gap: 36px;
}
@media (min-width: 1024px) {
    .modal-body { flex-direction: row; }
    .modal-left { width: 35%; flex-shrink: 0; }
    .modal-right { flex: 1; }
}

.modal-close {
    padding: 10px; border-radius: 50%; background: var(--neutral-900); color: white;
    transition: background 0.2s, transform 0.2s;
}
.modal-close:hover { background: var(--neutral-800); transform: rotate(90deg); }

.gallery-grid { display: grid; gap: 16px; }
.gallery-grid.mobile { grid-template-columns: repeat(2, 1fr); }
.gallery-grid.mobile .item:nth-child(3) { display: none; }
@media(min-width: 768px) { .gallery-grid.mobile { grid-template-columns: repeat(3, 1fr); .item:nth-child(3) { display: block; } } }
.gallery-grid.desktop { grid-template-columns: 1fr; }
@media(min-width: 768px) { .gallery-grid.desktop { grid-template-columns: repeat(2, 1fr); } }

.screenshot-placeholder {
    background: var(--neutral-900); border: 1px solid var(--neutral-800);
    border-radius: 16px; overflow: hidden; position: relative;
    transition: transform 0.3s ease;
}
.screenshot-placeholder:hover { transform: scale(1.02); }
.screenshot-placeholder.mobile { aspect-ratio: 9/19.5; }
.screenshot-placeholder.desktop { aspect-ratio: 16/9; }

.ph-wrap { padding: 20px; opacity: 0.3; display: flex; flex-direction: column; gap: 12px; height: 100%; }
.ph-header { display: flex; gap: 8px; align-items: center; }
.ph-dot { width: 8px; height: 8px; background: #555; border-radius: 50%; }
.ph-bar { height: 8px; width: 40%; background: #555; border-radius: 4px; }
.ph-body { flex: 1; background: #333; border-radius: 8px; }
.ph-footer { height: 8px; width: 80%; background: #444; border-radius: 4px; }

/* --- 8. CONTACT SECTION & FOOTER --- */
#contact {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 100px 0 40px;
    border-top: 1px solid var(--neutral-900);
    background: var(--neutral-950);
    text-align: center;
    scroll-margin-top: 0;
    box-sizing: border-box;
}

#contact .container {
    width: 100%;
    margin: auto 0;
}

.contact-heading { 
    font-size: clamp(2rem, 5vw, 3.25rem); 
    margin-bottom: 24px; 
    font-weight: 700; 
    letter-spacing: -0.04em; 
}
.email-large { 
    font-size: clamp(1.75rem, 5vw, 2.75rem); 
    font-weight: 700; 
    border-bottom: 2px solid var(--neutral-800); 
    padding-bottom: 6px; 
    color: var(--neutral-400); 
    transition: all 0.3s; 
    word-break: break-all; 
}
.email-large:hover { 
    color: var(--color-white); 
    border-color: var(--color-white); 
}
.social-link { 
    padding: 12px; 
    background: var(--neutral-900); 
    border-radius: 50%; 
    color: white; 
    display: inline-flex; 
    transition: transform 0.2s var(--ease-spring); 
}
.social-link:hover { 
    transform: scale(1.1); 
    background: var(--neutral-800); 
}

/* Dynamic Palette Classes */
.bg-orange-500 { background-color: var(--bg-orange-500); }
.bg-blue-500 { background-color: var(--bg-blue-500); }
.bg-teal-500 { background-color: var(--bg-teal-500); }
.bg-green-500 { background-color: var(--bg-green-500); }
.bg-purple-500 { background-color: var(--bg-purple-500); }

.bg-orange-500-20 { background-color: rgba(249, 115, 22, 0.2); }
.bg-blue-500-20 { background-color: rgba(59, 130, 246, 0.2); }
.bg-teal-500-20 { background-color: rgba(20, 184, 166, 0.2); }
.bg-green-500-20 { background-color: rgba(34, 197, 94, 0.2); }
.bg-purple-500-20 { background-color: rgba(168, 85, 247, 0.2); }

/* Loader */
#app-loader {
    position: fixed; inset: 0; background: #000; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s;
}
.spinner {
    width: 40px; height: 40px; border: 3px solid rgba(255,255,255,0.1);
    border-top-color: white; border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   MOBILE & RESPONSIVE TWEAKS
   ========================================================================== */
@media (max-width: 860px) {
  .modal-overlay {
    padding: 12px;
    align-items: flex-end;
  }
  .modal-content {
    max-height: 90vh;
    border-radius: 20px 20px 12px 12px;
  }
  .modal-header {
    padding: 18px 20px;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .modal-body {
    flex-direction: column !important;
    padding: 20px !important;
    gap: 24px !important;
  }
  .modal-left, .modal-right {
    width: 100% !important;
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  .container {
    padding-left: 20px;
    padding-right: 20px;
  }
  
  /* Wymuszenie równego marginesu bocznego 20px dla nagłówka Selected Work */
  .work-section > .section-header,
  .work-section > .projects-grid {
    padding-left: 20px;
    padding-right: 20px;
  }

  header {
    padding: 18px 0;
  }
  .hero {
    padding-top: 100px;
    padding-bottom: 36px;
  }
  .work-section {
    padding: 36px 0 60px;
  }
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .section-title {
    font-size: 2rem;
    text-align: left;
  }
  .projects-grid {
    grid-template-columns: 1fr !important;
    gap: 40px !important;
    margin-top: 24px;
  }
  .mockup-desktop {
    width: 100% !important;
    max-width: 290px !important;
    height: 190px !important;
    margin: 20px auto !important;
  }
  .mockup-mobile {
    width: 180px !important;
    height: 330px !important;
    margin: 0 auto !important;
  }
  #contact {
    min-height: auto;
    padding: 80px 0 40px;
  }
  #contact .flex.justify-between {
    flex-direction: column;
    gap: 12px;
    text-align: center;
    margin-top: 48px !important;
  }
}