:root {
    --bg: #0c0c0e; --surface: #141418; --border: rgba(255,255,255,0.07);
    --text: #e8e4dc; --muted: rgba(232,228,220,0.45);
    --accent: #c9a96e; --accent2: #7a9e8e;
    --glass-bg: rgba(10,10,14,0.72); --glass-border: rgba(255,255,255,0.10);
    --radius: 3px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: 'Jost', sans-serif;
       font-weight: 300; min-height: 100vh; overflow-x: hidden; }

/* Tło strony — aktywne gdy admin ustawi obrazek */
body.has-bg {
    background-image: var(--body-bg-img);
    background-size: cover;
    background-position: top center;
    background-attachment: fixed;
}
/* Konkretne sekcje nad nakładką — nie kafle */

/* HEADER — trzy kolumny: motto | filtry | admin */
header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 10px 32px;
    background: linear-gradient(to bottom, rgba(12,12,14,0.97) 0%, rgba(12,12,14,0.0) 100%);
    gap: 16px;
}
.header-brand { display: flex; align-items: center; }
.header-tagline {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(0.95rem, 1.6vw, 1.3rem);
    font-weight: 300; color: var(--text);
    white-space: nowrap; line-height: 1;
    text-decoration: none;
}
/* Filtry — środkowa kolumna */
.header-filters {
    display: flex; gap: 6px; align-items: center; flex-wrap: nowrap;
}
/* Admin — prawa kolumna, wyrównany do prawej */
nav { display: flex; gap: 16px; align-items: center; justify-content: flex-end; }
nav a { font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase;
        color: var(--muted); text-decoration: none; transition: color 0.2s; }
nav a:hover { color: var(--accent); }
.nav-admin { background: transparent; border: 1px solid var(--border); padding: 5px 13px;
             color: var(--muted) !important; border-radius: var(--radius);
             transition: border-color 0.2s, color 0.2s !important; }
.nav-admin:hover { border-color: var(--accent); color: var(--accent) !important; }

/* FILTER — używane w headerze i footerze */
.filter-bar { padding: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn { background: transparent; border: 1px solid var(--border); color: var(--muted);
              font-family: 'Jost', sans-serif; font-size: 0.65rem; font-weight: 300;
              letter-spacing: 0.12em; text-transform: uppercase; padding: 5px 13px;
              border-radius: 50px; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.filter-btn:hover, .filter-btn.active { background: var(--accent); border-color: var(--accent); color: #0c0c0e; }

/* GRID */
.grid-section { padding: 0 32px 80px; margin-top: 72px; }
.poems-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px; }
.poem-card { position: relative; aspect-ratio: 1; overflow: hidden; cursor: pointer;
             background: var(--surface); border-radius: var(--radius); }
.poem-card img {
    width: 100%; height: 100%; object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.25,0.46,0.45,0.94);
}
.poem-card img.loaded { opacity: 1; }
.poem-card:hover img { transform: scale(1.04); }
.card-overlay { position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(12,12,14,0.88) 0%, rgba(12,12,14,0.1) 55%, transparent 100%);
    display: flex; flex-direction: column; justify-content: flex-end; padding: 24px 22px;
    transition: background 0.3s; }
.poem-card:hover .card-overlay {
    background: linear-gradient(to top, rgba(12,12,14,0.92) 0%, rgba(12,12,14,0.35) 55%, transparent 100%); }
.card-date { font-size: 0.64rem; letter-spacing: 0.2em; text-transform: uppercase;
             color: var(--accent); margin-bottom: 6px; opacity: 0.8; }
.card-title { font-family: 'Cormorant Garamond', serif; font-size: 1.45rem; font-weight: 400;
              line-height: 1.2; color: var(--text); margin-bottom: 8px; }
.poem-card:first-child .card-title { font-size: 2rem; }
.card-excerpt { font-size: 0.78rem; color: var(--muted); line-height: 1.6;
                max-height: 0; overflow: hidden; transition: max-height 0.4s, opacity 0.3s; opacity: 0; }
.poem-card:hover .card-excerpt { max-height: 80px; opacity: 1; }
.card-read { margin-top: 14px; display: flex; align-items: center; gap: 8px;
             font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase;
             color: var(--accent); opacity: 0; transform: translateY(6px);
             transition: opacity 0.3s, transform 0.3s; }
.card-read::after { content: '→'; }
.poem-card:hover .card-read { opacity: 1; transform: translateY(0); }

/* no-image placeholder */
.card-no-img { width: 100%; height: 100%; background: linear-gradient(135deg, #1a1820 0%, #0e1218 100%);
               display: flex; align-items: center; justify-content: center;
               font-size: 2.5rem; color: rgba(201,169,110,0.2); }

/* READER */
#reader-overlay {
    position: fixed; inset: 0; z-index: 200;
    display: none; opacity: 0; transition: opacity 0.4s ease;
    background: rgba(0,0,0,0.96);
    align-items: center; justify-content: center;
    padding: 24px;
}
#reader-close {
    position: absolute; top: 10px; right: 14px; z-index: 20;
    background: transparent; border: none; color: var(--muted);
    font-size: 1.2rem; cursor: pointer; transition: color 0.2s; line-height: 1;
}
#reader-close:hover { color: var(--text); }

/* Kontener split */
#reader-content {
    position: relative; z-index: 5;
    display: grid;
    grid-template-columns: 320px 1fr;
    width: min(900px, 100%);
    height: auto;
    max-height: 100%;          /* rosnie do tresci, max = overlay minus padding */
    background: rgba(20,20,24,0.96);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    align-items: stretch;
    box-shadow: 0 32px 64px rgba(0,0,0,0.5);
}

/* Lewa kolumna — obrazek */
#reader-img-col {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 28px;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    overflow: hidden;
}
#reader-img-frame {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid rgba(232,228,220,0.85);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.45);
    flex-shrink: 0;
}
#reader-img-frame img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    opacity: 0;
    transition: opacity 0.4s ease;
}
#reader-img-frame img.loaded { opacity: 1; }
#reader-no-img {
    display: none;
    font-size: 3rem;
    color: rgba(201,169,110,0.18);
}

/* Prawa kolumna — nagłówek stały + scrollowany tekst */
#reader-text-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    max-height: calc(100vh - 48px);  /* 48px = 2x padding overlaya */
    overflow: hidden;
}
#reader-header {
    padding: 28px 30px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;          /* nagłówek nie scrolluje */
}
#reader-date {
    font-size: 0.62rem; letter-spacing: 0.24em; text-transform: uppercase;
    color: var(--accent); margin-bottom: 8px;
}
#reader-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.3rem, 2.2vw, 1.9rem);
    font-weight: 400; line-height: 1.15; color: var(--text);
    text-transform: uppercase; letter-spacing: 0.06em;
}
#reader-body {
    padding: 22px 30px 28px;
    overflow-y: auto;        /* TYLKO tu scrolluje */
    flex: 1;
    min-height: 0;           /* kluczowe — bez tego flex ignoruje overflow */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
#reader-body::-webkit-scrollbar { width: 3px; }
#reader-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
#reader-poem {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.35rem; font-weight: 300;
    line-height: 2; color: var(--text);
    white-space: pre-wrap;
}


/* MOBILE — stack pionowy */
@media (max-width: 640px) {
    #reader-overlay { align-items: flex-start; padding: 0; }
    #reader-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        width: 100vw;
        height: 100svh;
        border-radius: 0; border: none;
    }
    #reader-img-col {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 18px; background: rgba(0,0,0,0.25);
    }
    #reader-img-frame { width: min(180px, 55vw); margin: 0 auto; }
    #reader-header { padding: 18px 20px 14px; }
    #reader-body { padding: 14px 20px 24px; }
    #reader-close { top: 14px; right: 16px; }
}

/* FOOTER */
footer { padding: 28px 40px; border-top: 1px solid var(--border);
         display: flex; justify-content: space-between; align-items: center;
         flex-wrap: wrap; gap: 16px; }
.footer-brand { font-family: 'Cormorant Garamond', serif; font-size: 1rem; color: var(--muted); font-style: italic; }
.footer-note { font-size: 0.68rem; color: rgba(232,228,220,0.25); letter-spacing: 0.1em; }

/* MOBILE */
@media (max-width: 700px) {
    header { padding: 8px 18px; grid-template-columns: 1fr auto; }
    .header-tagline { font-size: 0.9rem; }
    .header-filters { display: none; }

    .grid-section { padding: 0 0 60px; }
    .poems-grid { grid-template-columns: 1fr 1fr; gap: 2px; }
    .card-title { font-size: 1.05rem; }
    .card-excerpt, .card-read { display: none; }
    .card-overlay { padding: 14px; }
    footer { flex-direction: column; text-align: center; padding: 28px 18px; }
}
@media (max-width: 480px) {
    .poems-grid { grid-template-columns: 1fr 1fr; gap: 1px; }
}

@keyframes fadeUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
.poem-card { animation: fadeUp 0.5s ease both; }
.poem-card:nth-child(1) { animation-delay: 0.05s; }
.poem-card:nth-child(2) { animation-delay: 0.12s; }
.poem-card:nth-child(3) { animation-delay: 0.18s; }
.poem-card:nth-child(4) { animation-delay: 0.24s; }
.poem-card:nth-child(5) { animation-delay: 0.30s; }
.poem-card:nth-child(6) { animation-delay: 0.36s; }
.poem-card:nth-child(7) { animation-delay: 0.42s; }
