:root {
    --beige: #f4e8cf;
    --olive-dark: #544D0F;
    --accent: #8e4e28;
    --figure-accent: #DEC08F;
    --background: #fdf7ee;
    --header-footer-aside-bg: #ECD8B1;
    --main-bg: #F2E2C4;
    --link-green: #6B7D3C;
}

/* Base layout */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    font-family: 'Georgia', serif;
    background-color: var(--background);
    color: var(--olive-dark);
    min-height: 100vh;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: scroll;
    margin-right: 0;
}

/* Layout components */
.container {
    display: flex;
    flex: 1;
    margin: 0;
}

header {
    background-color: var(--header-footer-aside-bg);
    color: var(--olive-dark);
    text-align: center;
    border-bottom: 1px solid var(--olive-dark);
    z-index: 100;
    width: 100%;
}

.header-container {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
    width: 100%;
    padding: 0 1rem;
}

#header-logo.logo {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 1rem 0;
    transition: all 0.5s ease;
}

.logo img {
    max-width: 100%;
    height: auto;
    max-height: 200px;
    transition: all 0.3s ease;
    display: block;
    margin: 0 auto;
}

/* Navigation */
.top-nav {
    padding: 0.5rem;
    display: flex;
    justify-content: center;
    gap: 10rem;
    position: absolute;
    bottom: 0;
    left: 160px;
    right: 0;
    transition: all 0.3s ease;
}

.top-nav a {
    color: var(--olive-dark);
    text-decoration: none;
    font-weight: bold;
    font-size: large;
    padding: 0.3rem 0.8rem;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.top-nav a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 3px;
}

/* Sidebar */
.sidebar {
    width: 100%;
    max-width: 350px;
    background-color: var(--header-footer-aside-bg);
    padding: 1.5rem;
    border-right: 2px solid var(--figure-accent);
    position: relative;
    transition: all 0.3s ease;
}

.sidebar.sticky {
    position: fixed;
    top: 0px;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-placeholder {
    display: none;
    width: 400px;
    flex-shrink: 0;
}

.sidebar-placeholder.active {
    display: block;
}

.sidebar h2 {
    font-size: 1.6rem;
    border-bottom: 1px solid var(--olive-dark);
    padding-bottom: 0.8rem;
    margin-bottom: 1.2rem;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    margin: 0.8rem 0;
    line-height: 1.5;
}

.sidebar-post-link {
    display: block;
    padding: 0.5rem;
    border-radius: 4px;
    background-color: transparent;
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--accent);
    font-weight: 500;
    line-height: 1.2;
    transition: all 0.25s ease;
}

.sidebar-post-link:hover {
    text-decoration: none;
    transform: translateY(-2px) translateX(2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    background-color: rgba(255, 255, 255, 0.5);
    border-color: rgba(142, 78, 40, 0.15);
}

.sidebar-post-link .post-title {
    display: block;
    color: var(--accent);
    font-weight: 500;
    line-height: 1.2;
}

.post-date, .sidebar-post-link .post-date, .sidebar .post-date {
    display: block;
    font-size: 0.85rem;
    color: var(--olive-dark);
    margin-top: 0.3rem;
    font-style: italic;
    transition: all 0.25s ease;
}

.sidebar-post-link:hover .post-date {
    color: var(--accent);
}

/* Sidebar logo */
.sidebar-logo {
    text-align: center;
    margin-bottom: 1.5rem;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.5s ease;
}

.sidebar-logo img {
    max-width: 80%;
    height: auto;
}

.sidebar-logo.visible {
    opacity: 1;
    max-height: 300px;
}

/* Main content */
main {
    flex: 1;
    background-color: var(--main-bg);
    padding: 0;
    min-height: 60vh;
    min-width: 60vh;
}

/* Article styling */
article {
    margin-bottom: 2rem;
    padding: 0;
    border-bottom: 1px solid #ddd;
}

article:last-child {
    border-bottom: none;
}

article h2 {
    font-size: 2rem;
    color: var(--accent);
    margin-top: 0.5rem;
}

article:not(.post-preview) h2 {
    padding: 2rem 7rem 0;
}

article h2 a {
    color: var(--accent);
    text-decoration: none;
}

article h2 a:hover {
    text-decoration: underline;
}

/* Tytuł posta z featured image */
article .featured-image + h2 {
    margin-top: -1rem;
    position: relative;
    z-index: 1;
}

/* Post content styling */
article:not(.post-preview) p {
    font-size: 1.2rem;
    line-height: 1.9;
    margin: 1.5rem 0;
    padding: 0 7rem;
}

article:not(.post-preview) ul,
article:not(.post-preview) ol {
    font-size: 1.2rem;
    line-height: 1.9;
    margin: 1.5rem 0;
    padding-left: 9.5rem;
    padding-right: 7rem;
}

/* Zagnieżdżone listy - mniejszy padding */
article:not(.post-preview) ul ul,
article:not(.post-preview) ul ol,
article:not(.post-preview) ol ul,
article:not(.post-preview) ol ol {
    padding-left: 1rem;
    padding-right: 0;
    margin: 0.5rem 0;
}

article:not(.post-preview) li {
    margin: 0.8rem 0;
}

article:not(.post-preview) .meta {
    font-size: 0.9rem;
    color: #888;
    padding: 0 7rem 1rem;
}

/* Post preview specific meta styling */
.post-preview .meta {
    font-size: 0.9rem;
    color: #888;
}

/* Image styling */
article:not(.post-preview) img:not(.featured-image img) {
    max-width: calc(100% - 14rem);
    height: auto;
    display: block;
    margin: 1.5rem auto;
    padding: 0 7rem;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

article:not(.post-preview) figure {
    margin: 1.5rem 0;
    padding: 0 7rem;
}

figcaption {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}

/* Featured image */
.featured-image {
    position: relative;
    margin: 0;
    overflow: hidden;
    max-height: 500px;
}

.featured-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    background: linear-gradient(to bottom, transparent 0%, var(--main-bg) 100%);
    pointer-events: none;
}

.featured-image img {
    width: 100%;
    object-fit: cover;
    margin: 0;
    box-shadow: none;
    display: block;
}

/* Post preview link wrapper */
.post-preview-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* Post preview */
.post-preview {
    display: flex;
    flex-direction: column;
    margin: 2.5rem 3rem;
    padding: 1.5rem;
    border-radius: 8px;
    background-color: var(--main-bg);
    border: 1px solid transparent;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

.post-preview-link:hover .post-preview {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    border-color: rgba(142, 78, 40, 0.2);
    background-color: #f9f2e0;
}

.preview-image {
    margin-bottom: 1rem;
    border-radius: 5px;
    overflow: hidden;
    max-height: 250px;
}

.preview-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.post-preview-link:hover .preview-image img {
    transform: scale(1.03);
}

.preview-content h2 {
    margin-top: 0;
    color: var(--accent);
    transition: all 0.2s ease;
}

.abstract {
    margin: 1rem 0;
    line-height: 1.6;
}

/* Links */
article:not(.post-preview) a {
    color: var(--link-green);
    text-decoration: none;
    font-weight: bold;
    position: relative;
    padding: 0 2px;
    transition: all 0.2s ease;
    border-radius: 2px;
}

article:not(.post-preview) a:hover {
    background-color: rgba(107, 125, 60, 0.15);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Footer */
footer {
    background-color: var(--header-footer-aside-bg);
    color: var(--olive-dark);
    text-align: center;
    padding: 1rem;
    border-top: 1px solid var(--olive-dark);
    z-index: 100;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    margin: 2rem 3rem 0;
    padding-top: 1rem;
    border-top: 1px solid var(--olive-dark);
}

.pagination a {
    color: var(--accent);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px solid var(--accent);
    border-radius: 3px;
}

.pagination a:hover {
    background-color: var(--accent);
    color: white;
}

.page_number {
    align-self: center;
}

/* Mobile Menu Styles - hidden on desktop */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--header-footer-aside-bg);
    border-bottom: 1px solid var(--olive-dark);
    z-index: 1000;
    padding: 0.5rem 1rem;
}

.mobile-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.mobile-logo img {
    height: 45px;
    width: auto;
    display: block;
}

/* Hamburger button */
.mobile-menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 1001;
}

.hamburger-line {
    display: block;
    width: 28px;
    height: 3px;
    background-color: var(--olive-dark);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover .hamburger-line {
    background-color: var(--accent);
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--header-footer-aside-bg);
    z-index: 1100;
    overflow-y: auto;
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

.mobile-menu-overlay.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu-container {
    padding: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--figure-accent);
}

.mobile-menu-logo img {
    height: 80px;
    width: auto;
    transform: scale(0.7);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.2s, opacity 0.5s ease 0.2s;
}

.mobile-menu-overlay.active .mobile-menu-logo img {
    transform: scale(1);
    opacity: 1;
}

/* Close button */
.mobile-menu-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    opacity: 0;
    transform: rotate(-90deg) scale(0.8);
    transition: opacity 0.4s ease 0.25s, transform 0.4s ease 0.25s, color 0.2s ease;
}

.mobile-menu-overlay.active .mobile-menu-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.close-icon {
    font-size: 2.5rem;
    color: var(--olive-dark);
    font-weight: 300;
    display: block;
    line-height: 1;
    transition: color 0.2s ease;
}

.mobile-menu-close:hover .close-icon {
    color: var(--accent);
}

/* Mobile Navigation */
.mobile-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.mobile-nav-link {
    display: block;
    padding: 1rem;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--olive-dark);
    text-decoration: none;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    border: 1px solid transparent;
    text-align: center;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease, opacity 0.4s ease, transform 0.4s ease;
}

.mobile-menu-overlay.active .mobile-nav-link:nth-child(1) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.3s;
}

.mobile-menu-overlay.active .mobile-nav-link:nth-child(2) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.35s;
}

.mobile-menu-overlay.active .mobile-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.6);
    border-color: rgba(142, 78, 40, 0.15);
    transform: translateY(-2px) !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

/* Mobile Recent Posts */
.mobile-recent-posts {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--figure-accent);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease 0.4s, transform 0.5s ease 0.4s;
}

.mobile-menu-overlay.active .mobile-recent-posts {
    opacity: 1;
    transform: translateY(0);
}

.mobile-recent-posts h2 {
    font-size: 1.5rem;
    color: var(--olive-dark);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--olive-dark);
    padding-bottom: 0.5rem;
}

.mobile-recent-posts ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-recent-posts li {
    margin: 0.8rem 0;
}

.mobile-post-link {
    display: block;
    padding: 0.8rem;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.mobile-post-link:hover {
    background-color: rgba(255, 255, 255, 0.6);
    border-color: rgba(142, 78, 40, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.mobile-post-link .post-title {
    display: block;
    color: var(--accent);
    font-weight: 500;
    font-size: 1.05rem;
    line-height: 1.3;
    margin-bottom: 0.3rem;
}

.mobile-post-link .post-date {
    display: block;
    font-size: 0.85rem;
    color: var(--olive-dark);
    font-style: italic;
}

.mobile-post-link:hover .post-date {
    color: var(--accent);
}

/* Media queries */

/* Desktop and large tablets - post preview horizontal layout */
@media (min-width: 769px) {
    /* Hide mobile menu on desktop */
    .mobile-header,
    .mobile-menu-overlay {
        display: none !important;
    }
    
    .post-preview {
        flex-direction: row;
        gap: 2rem;
    }
    
    .preview-image {
        flex: 0 0 35%;
        margin-bottom: 0;
        max-height: 200px;
    }
    
    .preview-content {
        flex: 1;
    }
    
    .post-preview-link:hover .preview-image img {
        transform: scale(1.05);
    }
}

/* Tablets and smaller devices */
@media (max-width: 768px) {
    /* Hide desktop header and sidebar on mobile */
    header {
        display: none !important;
    }
    
    .sidebar {
        display: none !important;
    }
    
    /* Show mobile menu elements */
    .mobile-header {
        display: block;
    }
    
    /* Adjust body padding for fixed mobile header */
    body {
        padding-top: 60px;
    }
    
    .container {
        flex-direction: column;
    }
    
    main {
        order: 1;
        width: 100%;
    }
    
    /* Adjust navigation for tablets */
    .top-nav {
        position: static;
        gap: 3rem;
        padding: 1rem 0.5rem;
        left: auto;
        right: auto;
    }
    
    /* Smaller logo for tablets */
    .logo img {
        max-height: 150px;
    }
    
    article:not(.post-preview) h2 {
        padding: 1.5rem 2rem 0;
        font-size: 1.75rem;
    }
    
    article:not(.post-preview) p {
        padding: 0 2rem;
        font-size: 1.1rem;
    }
    
    article:not(.post-preview) ul,
    article:not(.post-preview) ol {
        padding-left: 4.5rem;
        padding-right: 2rem;
        font-size: 1.1rem;
    }
    
    article:not(.post-preview) .meta {
        padding: 0 2rem 1rem;
    }
    
    article:not(.post-preview) img:not(.featured-image img) {
        max-width: calc(100% - 4rem);
        padding: 0 2rem;
    }
    
    article:not(.post-preview) figure {
        padding: 0 2rem;
    }
    
    .post-preview-link .post-preview {
        margin: 2rem 1.5rem;
        padding: 1.25rem;
    }
    
    .pagination {
        margin: 2rem 1.5rem 0;
    }
}

/* Small tablets and large phones */
@media (max-width: 480px) {
    /* Header adjustments for small screens */
    .header-container {
        padding: 0 0.5rem;
    }
    
    #header-logo.logo {
        padding: 0.5rem 0.5rem 0;
    }
    
    .logo img {
        max-height: 120px;
    }
    
    /* Navigation stack vertically or very close together */
    .top-nav {
        position: static;
        gap: 1.5rem;
        padding: 0.75rem 0.5rem;
        left: auto;
        right: auto;
        flex-wrap: wrap;
    }
    
    .top-nav a {
        font-size: 1rem;
        padding: 0.4rem 0.8rem;
    }
    
    /* Sidebar adjustments */
    .sidebar {
        padding: 1rem;
    }
    
    .sidebar h2 {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }
    
    /* Main content with minimal padding */
    main {
        min-width: unset;
    }
    
    article:not(.post-preview) h2 {
        padding: 1rem 1rem 0;
        font-size: 1.5rem;
    }
    
    article:not(.post-preview) p {
        padding: 0 1rem;
        font-size: 1rem;
        line-height: 1.7;
    }
    
    article:not(.post-preview) ul,
    article:not(.post-preview) ol {
        padding-left: 2.5rem;
        padding-right: 1rem;
        font-size: 1rem;
        line-height: 1.7;
    }
    
    article:not(.post-preview) .meta {
        padding: 0 1rem 1rem;
        font-size: 0.85rem;
    }
    
    article:not(.post-preview) img:not(.featured-image img) {
        max-width: calc(100% - 2rem);
        padding: 0 1rem;
    }
    
    article:not(.post-preview) figure {
        padding: 0 1rem;
    }
    
    /* Post previews on small screens */
    .post-preview-link .post-preview {
        margin: 0 0.75rem 1.5rem;
        padding: 1rem;
    }
    
    .preview-content h2 {
        font-size: 1.35rem;
    }
    
    .abstract {
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    /* Featured image adjustments */
    .featured-image {
        max-height: 300px;
    }
    
    .featured-image::after {
        height: 100px;
    }
    
    /* Pagination */
    .pagination {
        margin: 2rem 0.75rem 0;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .pagination a {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .page_number {
        font-size: 0.9rem;
    }
    
    /* Footer */
    footer {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--main-bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background-color: var(--olive-dark);
    border-radius: 4px;
    border: 2px solid var(--main-bg);
}

::-webkit-scrollbar-thumb:hover {
    background-color: #3a350a;
}

html {
    scrollbar-width: thin;
    scrollbar-color: var(--olive-dark) var(--main-bg);
}

/* Mermaid diagrams - wycentrowanie */
.mermaid {
    text-align: center;
    margin: 2rem auto;
    max-width: 100%;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Mermaid w artykułach - dodatkowe marginesy */
article:not(.post-preview) .mermaid {
    margin: 2.5rem auto;
    padding: 0 4rem;
}

/* Responsywność dla diagramów Mermaid */
@media (max-width: 768px) {
    article:not(.post-preview) .mermaid {
        padding: 0 2rem;
        margin: 2rem auto;
    }
}

@media (max-width: 480px) {
    article:not(.post-preview) .mermaid {
        padding: 0 1rem;
        margin: 1.5rem auto;
    }
}

/* Zewnętrzne linki - ikonka */
.external-link-icon {
    font-size: 0.85em;
    opacity: 0.6;
    margin-left: 2px;
    display: inline-block;
    transition: opacity 0.2s ease;
}

/* Podświetlenie ikonki przy hover na linku */
a:hover .external-link-icon {
    opacity: 1;
}

/* Dostępność - ukryj ikonkę przed czytnikami ekranowymi
   (aria-label już opisuje że link otwiera się w nowym oknie) */
.external-link-icon[aria-label] {
    speak: none;
}

/* Code blocks styling */
code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    background-color: var(--olive-dark);
    color: var(--beige);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    border: 1px solid #3a350a;
}

pre {
    background-color: var(--olive-dark);
    border: 2px solid #3a350a;
    border-radius: 5px;
    padding: 1.5rem;
    overflow-x: auto;
    margin: 2rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

pre code {
    background-color: transparent;
    border: none;
    padding: 0;
    font-size: 0.95em;
    line-height: 1.6;
    color: var(--beige);
    display: block;
}

/* Code blocks w artykułach - dopasowanie do paddingu */
article:not(.post-preview) pre {
    margin: 2rem 7rem;
}

/* Scrollbar dla długich bloków kodu */
pre::-webkit-scrollbar {
    height: 8px;
}

pre::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

pre::-webkit-scrollbar-thumb {
    background-color: var(--accent);
    border-radius: 4px;
}

pre::-webkit-scrollbar-thumb:hover {
    background-color: #a05b30;
}

/* Responsywność dla bloków kodu */
@media (max-width: 768px) {
    article:not(.post-preview) pre {
        margin: 1.5rem 2rem;
    }
    
    pre {
        padding: 1rem;
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    article:not(.post-preview) pre {
        margin: 1rem 1rem;
    }
    
    pre {
        padding: 0.75rem;
        font-size: 0.85em;
    }
    
    code {
        font-size: 0.85em;
    }
}