/* =========================================
   0. RESET SCROLLOWANIA (Wyłącza snap)
========================================= */
html, body, .site-main {
    scroll-snap-type: none !important;
    overflow-y: auto !important;
    height: auto !important;
}

/* =========================================
   1. LAYOUT GŁÓWNY (post.css)
========================================= */
.post-section {
    padding: 4.5rem 2rem 6rem 2rem; 
    min-height: 100vh;
    display: block; 
}

.post-container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

/* =========================================
   2. PRZYCISK "BACK TO BLOG"
========================================= */
.back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin-bottom: 3rem;
    padding: 0.8rem 1.5rem;
    border: 1px solid var(--color-primary-blue);
    border-radius: 20px;
    color: var(--color-primary-blue);
    text-decoration: none;
    font-family: var(--font-pixel);
    font-size: 0.8rem;
    background-color: transparent;
    transition: all 0.3s ease;
}

.back-btn:hover {
    box-shadow: 0 0 15px var(--color-primary-glow);
    background-color: rgba(15, 73, 190, 0.1);
    transform: translateX(-5px);
}

.back-btn .arrow {
    font-family: var(--font-main);
    font-size: 1.4rem;
    margin-right: 0.5rem;
    position: relative;
    top: -2px;
    line-height: 1;
}

/* =========================================
   3. NAGŁÓWEK (Tytuł, Data, Główne zdjęcie)
========================================= */
.post-header {
    margin-bottom: 4rem;
}

.post-header h1 {
    font-family: var(--font-pixel) !important;
    color: var(--color-primary-blue) !important;
    text-shadow: 0 0 15px var(--color-primary-glow);
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.post-date {
    color: var(--color-text-dimmed);
    font-family: var(--font-main);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2rem;
    display: block;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 1rem;
}

.post-hero-image {
    width: 100%;
    aspect-ratio: 16 / 9; 
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    margin-bottom: 3rem;
}

.post-hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* =========================================
   4. TREŚĆ ARTYKUŁU (Formatowanie Markdown)
========================================= */
.post-content {
    color: var(--color-text-muted);
    font-size: 1.1rem;
    line-height: 1.8;
    font-family: var(--font-main);
}

.post-content h2, 
.post-content h3 {
    color: var(--color-text-main);
    font-family: var(--font-pixel);
    margin-top: 3rem;
    margin-bottom: 1.5rem;
}

.post-content h2 { font-size: 1.8rem; color: var(--color-primary-blue); }
.post-content h3 { font-size: 1.4rem; }
.post-content p { margin-bottom: 1.5rem; }
.post-content ul, .post-content ol { margin-bottom: 1.5rem; padding-left: 2rem; }
.post-content li { margin-bottom: 0.5rem; }

.post-content a {
    color: var(--color-primary-blue);
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: color 0.3s ease;
}

.post-content a:hover { color: var(--color-secondary-yellow); }

.post-content code {
    background-color: rgba(20, 20, 20, 0.9);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    color: var(--color-secondary-yellow);
    font-family: monospace;
    font-size: 0.9em;
}

.post-content pre {
    background-color: rgba(10, 10, 10, 0.9);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    overflow-x: auto;
    margin-bottom: 2rem;
}

.post-content pre code {
    background-color: transparent;
    border: none;
    padding: 0;
    color: var(--color-text-main);
}

.post-content blockquote {
    border-left: 4px solid var(--color-primary-blue);
    margin: 0 0 2rem 0;
    padding: 1rem 2rem;
    background-color: rgba(15, 73, 190, 0.05);
    border-radius: 0 8px 8px 0;
    font-style: italic;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 2rem 0;
    border: 1px solid var(--color-border);
}

/* =========================================
   5. RESPONSIVE (Telefony) DLA STAREGO UKŁADU
========================================= */
@media (max-width: 768px) {
    .post-header h1 { font-size: 1.8rem; }
    .post-content h2 { font-size: 1.5rem; }
    .post-content h3 { font-size: 1.2rem; }
}

/* =========================================
   6. STARA GALERIA I LIGHTBOX (Zostawiona z oryginału)
========================================= */
.post-gallery-section {
    margin-top: 5rem;
    border-top: 1px solid var(--color-border);
    padding-top: 3rem;
}

.post-gallery-section h3 {
    font-family: var(--font-pixel);
    color: var(--color-primary-blue);
    margin-bottom: 2rem;
    font-size: 1.5rem;
    text-shadow: 0 0 10px var(--color-primary-glow);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1 / 1; 
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--color-border);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.gallery-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 73, 190, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-overlay span {
    font-family: var(--font-pixel);
    color: white;
    font-size: 0.8rem;
    background: rgba(0,0,0,0.7);
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px); 
    z-index: 9999;
    display: none; 
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 85vh;
    border-radius: 8px;
    border: 1px solid var(--color-primary-blue);
    box-shadow: 0 0 30px var(--color-primary-glow);
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 40px;
    font-size: 3rem;
    color: white;
    cursor: pointer;
    transition: color 0.3s;
    font-family: sans-serif;
}

.lightbox-prev, .lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 4rem;
    cursor: pointer;
    padding: 1rem;
    transition: all 0.3s;
}

.lightbox-prev:hover, .lightbox-next:hover, .lightbox-close:hover {
    color: var(--color-primary-blue);
    text-shadow: 0 0 15px var(--color-primary-glow);
}

.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr); 
        gap: 1rem;
    }
    .lightbox-prev, .lightbox-next {
        font-size: 2.5rem;
        padding: 0.5rem;
    }
}

/* =========================================
   7. NOWA GALERIA W TEKŚCIE (MAX 2 ZDJĘCIA)
========================================= */
.custom-inline-gallery {
    display: grid !important;
    /* Sztywno 2 kolumny po równo, NIGDY nie zawija do nowej linii */
    grid-template-columns: repeat(2, 1fr) !important; 
    gap: 1.5rem !important;
    width: 100% !important;
    margin: 3rem 0;
}

/* Jeśli jest tylko 1 zdjęcie, wyśrodkuj i zajmij pełną szerokość */
.custom-inline-gallery.single-img {
    grid-template-columns: 1fr !important;
}

.custom-img-wrapper {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    background: rgba(10, 10, 10, 0.4);
    height: 100%;
}

/* Formatowanie obrazków */
.post-content .custom-inline-gallery img.custom-clickable-img {
    margin: 0 !important;
    border: none !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* Wypełnia równe kafelki */
    cursor: pointer;
    transition: transform 0.3s ease;
    display: block;
}

.custom-img-wrapper:hover .custom-clickable-img {
    transform: scale(1.03);
}

.custom-img-wrapper:hover {
    border-color: var(--color-primary-blue);
    box-shadow: 0 0 15px rgba(15, 73, 190, 0.3);
}

/* Zwykła podpowiedź powiększenia */
.custom-zoom-hint {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: var(--font-pixel, monospace);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.custom-img-wrapper:hover .custom-zoom-hint {
    opacity: 1;
}

/* NAKŁADKA "+X ZDJĘĆ" NA DRUGIM KAFELKU */
.more-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.65); /* Przyciemnienie zdjęcia */
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Pozwala kliknąć w zdjęcie pod spodem */
    transition: background 0.3s ease;
}

.more-overlay span {
    font-size: 2.5rem;
    font-family: var(--font-pixel, monospace);
    color: white;
    text-shadow: 0 0 15px rgba(15, 73, 190, 0.8);
}

.custom-img-wrapper:hover .more-overlay {
    background: rgba(0, 0, 0, 0.4); /* Lekkie rozjaśnienie po najechaniu */
}

.hidden-img {
    display: none !important;
}

/* NA TELEFONACH (Zostają obok siebie, tylko zmniejszamy odstęp) */
@media (max-width: 650px) {
    .custom-inline-gallery {
        gap: 0.5rem !important; /* Mniejsza szpara na małym ekranie */
    }
    .more-overlay span {
        font-size: 1.8rem;
    }
}

/* =========================================
   NOWY, GLOBALNY LIGHTBOX (STRZAŁKI)
========================================= */
.custom-lightbox-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.93);
    backdrop-filter: blur(6px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
}

.custom-lightbox-overlay.active {
    display: flex;
}

.custom-lightbox-image {
    max-width: 85%;
    max-height: 85vh;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    object-fit: contain;
}

.custom-lightbox-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 3.5rem;
    cursor: pointer;
    padding: 1.5rem;
    transition: all 0.2s ease;
    z-index: 100001;
}

.custom-lightbox-btn:hover {
    color: var(--color-primary-blue);
    text-shadow: 0 0 15px var(--color-primary-glow);
}

.custom-lightbox-prev { left: 20px; }
.custom-lightbox-next { right: 20px; }

.custom-lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    font-size: 3.5rem;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    line-height: 1;
    z-index: 100002;
}

.custom-lightbox-close:hover {
    color: var(--color-primary-blue);
}

/* RESPONSIVE: Na telefonach i tabletach zdjęcia spadają jedno pod drugie i odzyskują pełny rozmiar */
@media (max-width: 800px) {
    .custom-inline-gallery {
        flex-direction: column !important;
    }
    
    .custom-img-wrapper {
        flex: auto !important; /* KLUCZ: Resetuje ucięcie do 0 pikseli */
        width: 100% !important;
        margin-bottom: 1rem;
    }
}
/* =========================================
   ZABEZPIECZENIE PRZED MARKDOWNEM
========================================= */
.custom-inline-gallery > p,
.custom-inline-gallery > br {
    display: contents !important;
}

/* =========================================
   KARTY LINKÓW (GITHUB / PRINTABLES EMBED)
========================================= */
.embed-card {
    display: flex;
    flex-direction: column;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    max-width: 600px; 
    margin: 3rem auto !important; /* KLUCZ: auto wyśrodkowuje kartę w pionie i poziomie */
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.embed-card:hover {
    border-color: var(--color-primary-blue);
    box-shadow: 0 0 20px rgba(15, 73, 190, 0.25);
    transform: translateY(-2px);
}

.post-content .embed-card .embed-image img {
    width: 100% !important;
    height: auto !important;
    display: block !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    border-bottom: 1px solid var(--color-border) !important;
}

.embed-info {
    padding: 1.2rem;
}

.embed-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-pixel, monospace);
    font-size: 1.1rem;
    color: var(--color-text-main);
    margin-bottom: 0.5rem;
}

.post-content a.embed-card {
    text-decoration: none !important;
}

.embed-desc {
    font-size: 0.95rem;
    color: var(--color-text-muted);
    margin: 0 !important;
    line-height: 1.5;
}

/* --- Nowy układ specjalnie dla Printables (bez wielkiego zdjęcia) --- */
.printables-card {
    flex-direction: row; /* Elementy w poziomie zamiast w pionie */
    align-items: center;
    padding: 1.5rem;
    gap: 1.5rem;
}

.printables-icon {
    flex-shrink: 0;
    color: #fa6831; /* Pomarańczowy kolor Printables */
    display: flex;
    align-items: center;
    justify-content: center;
}

.printables-card .embed-info {
    padding: 0; /* Resetujemy padding, bo mamy go już na głównej karcie */
}