/* =========================================
   1. ZMIENNE GŁÓWNE I RESET
   ========================================= */
:root {
    /* Kolory dla symulatora */
    --brand-blue: #2563eb;
    --brand-dark: #1e293b;
    --text-main: #334155;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --card-bg: #ffffff;
    --bg-main: #f8fafc;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #eab308;
    --danger: #ef4444;

    /* Zmienne dla nagłówka i stopki (z pliku baza) */
    --accent: #916a2d; 
    --accent-dark: #0f172a;
    --bg-light: #ffffff;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

body { 
    margin: 0; 
    padding: 0;
    font-family: 'Segoe UI', 'Inter', system-ui, sans-serif; 
    background: var(--bg-main); 
    color: var(--text-main); 
    font-size: 14.5px; 
    line-height: 1.6; 
    overflow-x: hidden;
}


/* =========================================
   2. NAGŁÓWEK I MENU (1:1 wg. wzorca)
   ========================================= */
.main-header {
    display: flex;
    justify-content: space-between; 
    align-items: center;
    padding: 0.8rem 5vw; 
    position: sticky; 
    top: 0; 
    z-index: 99999; 
    background: rgba(255,255,255,0.95); 
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    min-height: 85px;
}

.logo-link img { 
    display: block; 
    filter: grayscale(1) contrast(1.2);
    transition: var(--transition); 
}

.logo-link:hover img { 
    filter: grayscale(0);
    transform: scale(1.02); 
}

nav { justify-self: end; }

.menu {
    display: flex;
    gap: clamp(1rem, 3vw, 3.5rem); 
    list-style: none; 
    align-items: center;
    margin: 0;
    padding: 0;
}

.menu > li > a {
    text-decoration: none;
    color: var(--text-main); 
    font-weight: 500; 
    font-size: 0.8rem; 
    text-transform: uppercase; 
    letter-spacing: 0.15em;
    transition: var(--transition);
    position: relative;
    white-space: nowrap;
}

.menu > li > a::after {
    content: '';
    position: absolute;
    bottom: -5px; left: 0; width: 0; height: 1px;
    background: var(--accent); 
    transition: var(--transition);
}

.menu > li > a:hover { color: var(--accent); }
.menu > li > a:hover::after { width: 100%; }

#menu-toggle { display: none; }

.menu-icon {
    display: none;
    cursor: pointer;
    font-size: 1.8rem;
    color: var(--text-main); 
    padding: 0.5rem;
}

.has-sub { position: relative; }

.submenu {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    transition: var(--transition);
    z-index: 100;
}

.has-sub:hover > .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.submenu-list {
    background: var(--bg-light);
    min-width: 240px;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    list-style: none;
    border: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
    text-align: left;
    margin: 0;
}

.submenu-list li { width: 100%; padding: 0; }

.submenu-list a {
    color: var(--text-main);
    font-weight: 500;
    padding: 0.6rem 1rem;
    display: block;
    text-decoration: none;
    font-size: 0.85rem;
    transition: 0.2s;
}

.submenu-list a:hover {
    background: #f1f5f9;
    color: var(--accent); 
    border-radius: 4px;
}


/* =========================================
   3. SYMULATOR KOMINA (Oryginalny kod)
   ========================================= */
.wind-wrapper { max-width: 1050px; margin: 40px auto; background: var(--card-bg); border-radius: 16px; padding: 35px; box-shadow: 0 10px 40px rgba(0,0,0,0.04); border: 1px solid var(--border); }
.wind-header { border-left: 6px solid var(--brand-blue); padding-left: 18px; margin-bottom: 30px; }
.wind-header h1 { margin: 0 0 5px 0; font-size: 1.8rem; color: var(--brand-dark); text-transform: uppercase; letter-spacing: 0.5px; }

.historical-btn { background: var(--brand-dark); color: #fff; border: none; padding: 12px 20px; border-radius: 8px; font-weight: 800; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
.historical-btn:hover { background: var(--brand-blue); transform: translateY(-2px); }

/* PANELE INFO */
.history-panel { background: #ffffff; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 35px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }
.history-header { background: #f1f5f9; padding: 15px 25px; border-bottom: 1px solid var(--border); font-weight: 700; color: var(--brand-dark); text-transform: uppercase; letter-spacing: 0.5px; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0; }
.history-item { padding: 25px; border-right: 1px solid var(--border); }
.history-item:last-child { border-right: none; }
.history-item h4 { margin: 0 0 10px 0; color: var(--brand-blue); font-size: 1rem; }
.history-item ul { margin: 0; padding-left: 20px; font-size: 0.9rem; color: var(--text-muted); }

/* STEROWANIE */
.controls-panel { background: #f8fafc; padding: 25px 30px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 35px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.full-width { grid-column: 1 / -1; }
.slider-group { display: flex; flex-direction: column; }
.slider-group label { font-weight: 700; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; display: flex; justify-content: space-between; }
.slider-val { color: var(--brand-blue); font-weight: 800; font-size: 1rem;}
input[type=range] { width: 100%; accent-color: var(--brand-blue); cursor: pointer; }

/* KARTY KSZTAŁTÓW */
.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; }
.shape-card { background: var(--card-bg); border: 2px solid var(--border); border-radius: 12px; padding: 25px; position: relative; transition: all 0.3s ease; }
.shape-card.winner { border-color: var(--success); box-shadow: 0 0 0 4px var(--success-bg); }
.winner-badge { display: none; position: absolute; top: -14px; right: 20px; background: var(--success); color: white; padding: 5px 15px; border-radius: 20px; font-size: 0.75rem; font-weight: 800; text-transform: uppercase; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.shape-card.winner .winner-badge { display: block; }
.shape-header { padding-top: 15px; margin-bottom: 20px; border-top: 1px solid var(--border); }
.shape-title h2 { margin: 0; font-size: 1.3rem; color: var(--brand-dark); }
.shape-title span { font-size: 0.9rem; color: var(--text-muted); font-weight: 600;}

/* OBLICZENIA POŚREDNIE */
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
.calc-item { background: #f8fafc; padding: 8px 12px; border-radius: 6px; border: 1px solid #e2e8f0; display: flex; flex-direction: column; }
.calc-item span { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; margin-bottom: 2px; }
.calc-item strong { font-size: 0.95rem; color: var(--brand-dark); font-family: monospace; }

/* WYNIK KOŃCOWY */
.result-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.result-row.final-stress { border-bottom: none; margin-top: 15px; background: #f1f5f9; padding: 18px; border-radius: 8px; flex-direction: column; align-items: flex-start; }
.result-label { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.stress-group { display: flex; align-items: baseline; gap: 15px; margin-top: 10px; width: 100%; justify-content: space-between;}
.stress-old { font-size: 1.5rem; font-weight: 800; color: var(--brand-dark); transition: color 0.3s;}
.stress-new { font-size: 1.0rem; color: var(--text-muted); font-weight: 700; }
.danger-text { color: var(--danger) !important; }
.shape-card.winner .stress-old:not(.danger-text) { color: var(--success); }

/* LEGENDA MATEMATYCZNA */
.math-legend { margin-top: 35px; }
.legend-content { padding: 25px; }
.legend-content p { color: var(--text-muted); margin-top: 0; margin-bottom: 25px; }
.math-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.math-block { background: #f8fafc; padding: 15px; border-radius: 8px; border: 1px solid var(--border); border-left: 4px solid var(--brand-blue); }
.math-block h4 { margin: 0 0 10px 0; color: var(--brand-dark); font-size: 0.95rem; }
.math-block p { font-size: 0.85rem; margin-bottom: 10px; line-height: 1.4; }
.math-block small { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 5px; font-weight: bold; }

/* SCENA INŻYNIERSKA (Animacja) */
.simulation-stage { height: 220px; background: linear-gradient(to bottom, #cbd5e1 0%, #f1f5f9 100%); border-radius: 8px; margin-bottom: 20px; position: relative; overflow: hidden; border: 1px solid var(--border); display: flex; align-items: flex-end; justify-content: center; }
.ground-line { position: absolute; bottom: 0; left: 0; right: 0; height: 16px; background: #334155; border-top: 4px solid #475569; z-index: 10; }
.tower-wrapper { position: relative; z-index: 5; margin-bottom: 16px; transform-origin: bottom center; transition: transform 0.6s cubic-bezier(0.55, 0.055, 0.675, 0.19); display: flex; justify-content: center; }
.tower { background: linear-gradient(to right, #94a3b8 0%, #e2e8f0 40%, #94a3b8 100%); transition: height 0.3s ease, width 0.3s ease, clip-path 0.3s ease; z-index: 1; }
.oct-tower { background: repeating-linear-gradient(90deg, #64748b, #94a3b8 10px, #475569 20px); }
.ladder { position: absolute; bottom: 0; left: 50%; margin-left: 10px; width: 14px; height: 100%; background: repeating-linear-gradient(0deg, transparent, transparent 10px, #64748b 10px, #64748b 13px); border-left: 2px solid #475569; border-right: 2px solid #475569; z-index: 5; }
.climbing-person { position: absolute; bottom: 0; left: 50%; margin-left: 8px; width: 18px; height: 35px; z-index: 10; animation: climb-ladder 5s linear infinite alternate; transition: all 0.4s ease-in; }
.climbing-person > div { position: absolute; border-radius: 2px; }
.person-head { background: #f59e0b; width: 10px; height: 10px; border-radius: 50%; top: 0; left: 4px; box-shadow: 0 -1px 2px rgba(0,0,0,0.3); }
.person-body { background: #0ea5e9; width: 14px; height: 16px; top: 10px; left: 2px; }
.person-leg-left { background: #0284c7; width: 5px; height: 12px; top: 25px; left: 2px; }
.person-leg-right { background: #0284c7; width: 5px; height: 12px; top: 25px; left: 11px; }
.person-arm-left { background: #0ea5e9; width: 4px; height: 12px; top: 12px; left: -2px; }
.person-arm-right { background: #0ea5e9; width: 4px; height: 12px; top: 12px; left: 16px; }

@keyframes climb-ladder { 0% { bottom: 0; transform: rotate(0deg); } 10% { transform: translateY(-5px) rotate(5deg); } 20% { transform: translateY(-10px) rotate(-5deg); } 100% { bottom: 80%; } }
.tower-wrapper.fall { transform: rotate(85deg); }
.tower-wrapper.fall .climbing-person { animation: none !important; bottom: -15px !important; left: 80% !important; transform: rotate(-120deg) scale(1.1) !important; }

.boom-effect { position: absolute; bottom: 15px; left: 65%; transform: translate(-50%, 50%) scale(0.2); width: 150px; height: 150px; background: radial-gradient(circle, #facc15, #ea580c, #991b1b, transparent 70%); border-radius: 50%; z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.1s; }
.boom-effect.active { animation: boom-expand 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.boom-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 40px; color: #ffffff; font-weight: 900; text-shadow: 2px 2px 0 #000; font-style: italic; }
@keyframes boom-expand { 0% { transform: translate(-50%, 50%) scale(0.2); opacity: 1; } 50% { opacity: 1; } 100% { transform: translate(-50%, 50%) scale(1.3); opacity: 0; } }

.wind-particle { position: absolute; background: rgba(255,255,255,0.8); height: 2px; border-radius: 2px; animation: blow linear infinite; z-index: 2; }
@keyframes blow { 0% { transform: translateX(-80px); opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { transform: translateX(350px); opacity: 0; } }
.cloud { position: absolute; background: rgba(255,255,255,0.8); border-radius: 50px; animation: float-cloud linear infinite; z-index: 1; }
.cloud::before, .cloud::after { content: ''; position: absolute; background: rgba(255,255,255,0.8); border-radius: 50%; }
.cloud::before { width: 50%; height: 100%; top: -40%; left: 15%; }
.cloud::after { width: 40%; height: 80%; top: -30%; right: 15%; }
@keyframes float-cloud { 0% { transform: translateX(-100px); } 100% { transform: translateX(400px); } }


/* =========================================
   4. STOPKA (1:1 wg. wzorca)
   ========================================= */
footer.main-footer {
    margin-top: 5rem;
    background: #141618; 
    color: rgba(255, 255, 255, 0.8);
    padding: 3rem 0 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-container { max-width: 1100px; margin: 0 auto; padding: 0 6vw; }

.footer-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr 1fr;
    gap: 2.5rem;
    margin-bottom: 2.5rem;
}

.footer-tag { font-family: monospace; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.2em; color: var(--accent); margin-bottom: 0.75rem; display: block; font-weight: 700; }
.footer-header { font-size: 1.1rem; font-weight: 700; color: #ffffff; margin-bottom: 0.8rem; letter-spacing: -0.01em; }
.footer-p { font-size: 0.85rem; line-height: 1.6; opacity: 0.7; font-weight: 500; }
.footer-nav { list-style: none; padding: 0; }
.footer-link { color: #ffffff; text-decoration: none; font-size: 0.9rem; display: block; margin-bottom: 0.5rem; opacity: 0.6; transition: 0.3s ease; font-weight: 600; }
.footer-link:hover { opacity: 1; color: var(--accent); transform: translateX(5px); }
.footer-contact-item { font-size: 0.9rem; margin-bottom: 0.3rem; color: #fff; font-weight: 600; }

.manifesto {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
}

.status-mini { display: flex; align-items: center; gap: 8px; font-family: monospace; color: var(--accent); font-weight: 700; }
.dot-pulse { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 8px var(--accent); animation: footerPulse 2s infinite ease-in-out; }

@keyframes footerPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.8); } }

.footer-bottom-info {
    margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid rgba(255,255,255,0.03); text-align: center;
    font-family: monospace; font-size: 0.52rem; letter-spacing: 0.12em; line-height: 1.4; color: #ffffff; font-weight: 300;
}
.footer-bottom-info p { margin: 0.15rem 0; }


/* =========================================
   5. RESPONSYWNOŚĆ (Mobile)
   ========================================= */
@media (max-width: 1024px) {
    .menu-icon { display: inline-flex; z-index: 10001; }
    
    .menu {
        display: none; position: absolute; top: 100%; left: 0; width: 100%;
        background: var(--bg-light); flex-direction: column; padding: 1.5rem 0;
        box-shadow: 0 10px 15px rgba(0,0,0,0.1); border-top: 1px solid #eee; z-index: 10000;
    }
    
    #menu-toggle:checked ~ .menu { display: flex; }
    
    .menu > li > a { color: var(--text-main); padding: 10px 0; }
    .menu > li > a::after { display: none; }

    .submenu { position: static; opacity: 1; visibility: visible; transform: none; display: none; padding: 0; width: 100%; pointer-events: auto; }
    .has-sub { width: 100%; position: relative; text-align: center; }
    .has-sub:hover .submenu { display: block; }
    
    .submenu-list { box-shadow: none; padding: 0.5rem 0; border: none; background: #f9fafb; margin: 0; width: 100%; }
    .submenu-list li a { padding: 0.8rem 2.5rem; display: block; width: 100%; text-align: center; }

    .footer-grid { grid-template-columns: 1fr; gap: 2rem; text-align: center; }
    .footer-p { margin: 0 auto; max-width: 80vw; }
    .footer-link:hover { transform: none; }
    .manifesto { flex-direction: column; gap: 1rem; text-align: center; }
}

/* =========================================
   5. RESPONSYWNOŚĆ (Mobile) - Wersja zoptymalizowana pod Symulator
   ========================================= */
@media (max-width: 1024px) {
    .menu-icon { display: inline-flex; z-index: 10001; }
    
    .menu {
        display: none; position: absolute; top: 100%; left: 0; width: 100%;
        background: var(--bg-light); flex-direction: column; padding: 1.5rem 0;
        box-shadow: 0 10px 15px rgba(0,0,0,0.1); border-top: 1px solid #eee; z-index: 10000;
    }
    
    #menu-toggle:checked ~ .menu { display: flex; }
    
    .menu > li > a { color: var(--text-main); padding: 10px 0; }
    .menu > li > a::after { display: none; }

    .submenu { position: static; opacity: 1; visibility: visible; transform: none; display: none; padding: 0; width: 100%; pointer-events: auto; }
    .has-sub { width: 100%; position: relative; text-align: center; }
    .has-sub:hover .submenu { display: block; }
    
    .submenu-list { box-shadow: none; padding: 0.5rem 0; border: none; background: #f9fafb; margin: 0; width: 100%; }
    .submenu-list li a { padding: 0.8rem 2.5rem; display: block; width: 100%; text-align: center; }

    .footer-grid { grid-template-columns: 1fr; gap: 2rem; text-align: center; }
    .footer-p { margin: 0 auto; max-width: 80vw; }
    .footer-link:hover { transform: none; }
    .manifesto { flex-direction: column; gap: 1rem; text-align: center; }
}

/* =========================================
   5. RESPONSYWNOŚĆ (Mobile) - Wersja zoptymalizowana pod Symulator
   ========================================= */
@media (max-width: 1024px) {
    .menu-icon { display: inline-flex; z-index: 10001; }
    
    .menu {
        display: none; position: absolute; top: 100%; left: 0; width: 100%;
        background: var(--bg-light); flex-direction: column; padding: 1.5rem 0;
        box-shadow: 0 10px 15px rgba(0,0,0,0.1); border-top: 1px solid #eee; z-index: 10000;
    }
    
    #menu-toggle:checked ~ .menu { display: flex; }
    
    .menu > li > a { color: var(--text-main); padding: 10px 0; }
    .menu > li > a::after { display: none; }

    .submenu { position: static; opacity: 1; visibility: visible; transform: none; display: none; padding: 0; width: 100%; pointer-events: auto; }
    .has-sub { width: 100%; position: relative; text-align: center; }
    .has-sub:hover .submenu { display: block; }
    
    .submenu-list { box-shadow: none; padding: 0.5rem 0; border: none; background: #f9fafb; margin: 0; width: 100%; }
    .submenu-list li a { padding: 0.8rem 2.5rem; display: block; width: 100%; text-align: center; }

    .footer-grid { grid-template-columns: 1fr; gap: 2rem; text-align: center; }
    .footer-p { margin: 0 auto; max-width: 80vw; }
    .footer-link:hover { transform: none; }
    .manifesto { flex-direction: column; gap: 1rem; text-align: center; }
}

@media (max-width: 768px) {
    /* Poprawa marginesów kontenera, aby zyskać więcej miejsca na ekranie */
    .wind-wrapper {
        padding: 15px;
        margin: 15px auto;
        display: flex;
        flex-direction: column;
    }

    /* REORGANIZACJA KOLEJNOŚCI - Komin ładuje się NAD suwakami */
    .wind-header { order: 1; }
    .history-panel:not(.math-legend) { order: 2; }
    .comparison-grid { order: 3; margin-bottom: 20px; }
    .math-legend { order: 5; margin-top: 30px; }

    /* MAGIA UX: Przyklejony, kompaktowy panel suwaków na dole ekranu */
    .controls-panel {
        order: 4;
        position: sticky;
        bottom: 0;
        z-index: 1000;
        grid-template-columns: 1fr 1fr; /* 2 kolumny zamiast 1 = oszczędność miejsca */
        gap: 12px 10px;
        padding: 15px;
        margin: 0 -15px; /* Rozciągnięcie od krawędzi do krawędzi telefonu */
        background: rgba(248, 250, 252, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -10px 25px rgba(0,0,0,0.15); /* Cień rzucany w górę */
        border: 1px solid rgba(0,0,0,0.05);
        border-bottom: none;
    }

    /* Suwak wysokości (H) na całą szerokość nad dwiema kolumnami */
    .controls-panel .full-width { grid-column: 1 / -1; }

    /* Mniejsza typografia dla suwaków, by zmieścić je pod palcem */
    .slider-group label {
        font-size: 0.65rem;
        margin-bottom: 4px;
    }
    .slider-val { font-size: 0.85rem; }

    /* WŁAŚCIWA WYSOKOŚĆ: 210px zapobiega uderzaniu komina o górną ramkę */
    .simulation-stage { height: 210px; }

    .history-item { border-right: none; border-bottom: 1px solid var(--border); }
    .comparison-grid { grid-template-columns: 1fr; }
}