/* ==========================================================================
           STYLE.CSS - WSPÓLNY ARKUSZ STYLÓW ARCHIWUM WŁADYSŁAWA BRONIEWSKIEGO
           Klimat: Stary Pergamin, Archiwalia z Epoki, Teczka Personalna Nr 1897
           ========================================================================== */
        :root {
            --bg-primary: #f3ebd7;
            --bg-secondary: #e9dcbe;
            --bg-card: #efe4ca;
            --bg-elevated: #e2d2ae;
            --text-main: #221e1a;
            --text-muted: #574c3f;
            --gold-faded: #b89047;
            --gold-dark: #8c6826;
            --stamp-red: #8b2522;
            --stamp-red-light: rgba(139, 37, 34, 0.12);
            --border-ink: #baa682;
            --border-dark: #4a3f35;
            --shadow-paper: 0 4px 20px rgba(34, 30, 26, 0.12), inset 0 0 45px rgba(184, 144, 71, 0.14);
            --watermark-opacity: 0.045;
        }

        [data-theme="night"] {
            --bg-primary: #161412;
            --bg-secondary: #1f1c18;
            --bg-card: #24201b;
            --bg-elevated: #2d2721;
            --text-main: #e6c89c;
            --text-muted: #b09774;
            --gold-faded: #d4a857;
            --gold-dark: #b89047;
            --stamp-red: #cc4440;
            --stamp-red-light: rgba(204, 68, 64, 0.16);
            --border-ink: #463c30;
            --border-dark: #786650;
            --shadow-paper: 0 6px 28px rgba(0, 0, 0, 0.65), inset 0 0 35px rgba(212, 168, 87, 0.05);
            --watermark-opacity: 0.03;
        }

        * {
            box-sizing: border-box;
            scroll-behavior: smooth;
        }

        body {
            background-color: var(--bg-primary);
            color: var(--text-main);
            font-family: 'Lora', Georgia, serif;
            line-height: 1.75;
            margin: 0;
            padding: 0;
            transition: background-color 0.35s ease, color 0.35s ease;
            background-image: 
                radial-gradient(rgba(184, 144, 71, 0.08) 1px, transparent 0),
                radial-gradient(rgba(139, 37, 34, 0.04) 1px, transparent 0);
            background-size: 28px 28px;
            background-position: 0 0, 14px 14px;
            overflow-x: hidden;
        }

        /* Typografia specjalistyczna */
        .font-headline {
            font-family: 'Playfair Display', Georgia, serif;
        }
        .font-monumental {
            font-family: 'Cinzel', serif;
        }
        .font-typewriter {
            font-family: 'Special Elite', 'Courier Prime', monospace;
        }
        .font-courier {
            font-family: 'Courier Prime', monospace;
        }

        /* Znak wodny w tle */
        .archive-watermark {
            position: fixed;
            top: 52%;
            left: 50%;
            transform: translate(-50%, -50%) rotate(-24deg);
            font-family: 'Cinzel', serif;
            font-size: clamp(3rem, 9vw, 8.5rem);
            font-weight: 800;
            color: var(--text-main);
            opacity: var(--watermark-opacity);
            pointer-events: none;
            z-index: 0;
            white-space: nowrap;
            letter-spacing: 0.15em;
            user-select: none;
        }

        /* Ramki i winiety gazetowe */
        .paper-sheet {
            background-color: var(--bg-card);
            border: 1px solid var(--border-ink);
            box-shadow: var(--shadow-paper);
            position: relative;
        }

        .double-vintage-border {
            border: 3px double var(--border-dark);
        }

        /* Pieczęcie archiwalne */
        .stamp-badge {
            display: inline-block;
            border: 2px solid var(--stamp-red);
            color: var(--stamp-red);
            font-family: 'Special Elite', monospace;
            text-transform: uppercase;
            padding: 0.18rem 0.6rem;
            letter-spacing: 0.09em;
            font-size: 0.72rem;
            transform: rotate(-2deg);
            background-color: var(--stamp-red-light);
            box-shadow: inset 0 0 0 1px rgba(139, 37, 34, 0.25);
            user-select: none;
            white-space: nowrap;
        }

        .stamp-badge-tilted {
            transform: rotate(3deg);
        }

        /* Inicjał (Drop cap) w stylu druku przedwojennego */
        .drop-cap::first-letter {
            float: left;
            font-family: 'Cinzel', serif;
            font-size: 3.6rem;
            line-height: 0.82;
            padding-top: 4px;
            padding-right: 12px;
            padding-bottom: 4px;
            color: var(--stamp-red);
            font-weight: 700;
        }

        /* Nawigacja boczna (Sticky TOC) */
        .toc-link {
            display: block;
            padding: 0.45rem 0.75rem;
            border-left: 3px solid transparent;
            color: var(--text-muted);
            font-size: 0.88rem;
            transition: all 0.2s ease;
            text-decoration: none;
        }

        .toc-link:hover {
            color: var(--text-main);
            border-left-color: var(--gold-faded);
            background-color: rgba(184, 144, 71, 0.08);
        }

        .toc-link.active {
            color: var(--stamp-red);
            border-left-color: var(--stamp-red);
            font-weight: 700;
            background-color: var(--stamp-red-light);
        }

        /* Przypisy w stylu Wikipedii */
        .footnote-ref {
            font-family: 'Courier Prime', monospace;
            font-size: 0.78em;
            vertical-align: super;
            color: var(--stamp-red);
            font-weight: 700;
            cursor: pointer;
            padding: 0 2px;
            text-decoration: none;
            border-bottom: 1px dotted var(--stamp-red);
            transition: background-color 0.2s;
        }

        .footnote-ref:hover {
            background-color: var(--stamp-red);
            color: #fff;
        }

        /* Stylizacja maszynopisu wiersza */
        .typewriter-page {
            background-color: var(--bg-primary);
            border: 1px solid var(--border-ink);
            box-shadow: 4px 6px 18px rgba(0, 0, 0, 0.16), inset 0 0 60px rgba(184, 144, 71, 0.18);
            position: relative;
        }

        .typewriter-page::before {
            content: "";
            position: absolute;
            top: 0;
            bottom: 0;
            left: 2.2rem;
            width: 1px;
            background-color: rgba(139, 37, 34, 0.25);
            pointer-events: none;
        }

        /* Ozdobny separator sekcji */
        .vintage-divider {
            display: flex;
            align-items: center;
            text-align: center;
            margin: 2.5rem 0;
            color: var(--gold-dark);
        }
        .vintage-divider::before,
        .vintage-divider::after {
            content: '';
            flex: 1;
            border-bottom: 1px solid var(--border-ink);
        }
        .vintage-divider span {
            padding: 0 1rem;
            font-family: 'Cinzel', serif;
            font-size: 0.9rem;
            letter-spacing: 0.2em;
        }

        /* Karty fotograficzne w archiwum i narożniki albumowe */
        .photo-frame {
            position: relative;
            background-color: #d6c5a3;
            padding: 0.65rem;
            border: 1px solid var(--border-dark);
            box-shadow: inset 0 0 18px rgba(34, 30, 26, 0.25);
        }

        .photo-sepia {
            filter: sepia(0.42) contrast(1.06) brightness(0.96);
            transition: filter 0.35s ease, transform 0.35s ease;
        }
        .group:hover .photo-sepia {
            filter: sepia(0.14) contrast(1.04) brightness(1);
        }

        /* Narożniki fotograficzne w starym albumie */
        .album-corner {
            width: 16px;
            height: 16px;
            border-color: var(--border-dark);
            position: absolute;
            z-index: 10;
            pointer-events: none;
        }
        .corner-tl { top: 4px; left: 4px; border-top: 2px solid var(--border-dark); border-left: 2px solid var(--border-dark); }
        .corner-tr { top: 4px; right: 4px; border-top: 2px solid var(--border-dark); border-right: 2px solid var(--border-dark); }
        .corner-bl { bottom: 4px; left: 4px; border-bottom: 2px solid var(--border-dark); border-left: 2px solid var(--border-dark); }
        .corner-br { bottom: 4px; right: 4px; border-bottom: 2px solid var(--border-dark); border-right: 2px solid var(--border-dark); }

        /* Kursor maszyny do pisania */
        .typewriter-cursor {
            display: inline-block;
            width: 9px;
            height: 1.15em;
            background-color: var(--stamp-red);
            vertical-align: text-bottom;
            margin-left: 3px;
            animation: blinkCursor 0.85s infinite;
        }

        @keyframes blinkCursor {
            0%, 49% { opacity: 1; }
            50%, 100% { opacity: 0; }
        }

        /* ==========================================================================
           NAGŁÓWEK I ZAKŁADKI NAWIGACYJNE (1 RZĄD, 4 KARTY, BRAK ŁAMANIA WIERSZY)
           ========================================================================== */
        .header-tabs-nav {
            display: flex;
            flex-wrap: nowrap;
            gap: 0.4rem;
            white-space: nowrap;
            align-items: flex-end;
            overflow-x: auto;
            scrollbar-width: none;
        }
        .header-tabs-nav::-webkit-scrollbar {
            display: none;
        }

        .file-tab {
            border: 1px solid var(--border-ink);
            border-bottom: none;
            background-color: var(--bg-secondary);
            color: var(--text-muted);
            transition: all 0.2s ease;
            white-space: nowrap;
            flex-shrink: 0;
            cursor: pointer;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
        }
        .file-tab:hover {
            color: var(--text-main);
            background-color: var(--bg-elevated);
        }
        .file-tab.active {
            background-color: var(--bg-card);
            color: var(--text-main);
            border-top: 3px solid var(--stamp-red);
            font-weight: 700;
            transform: translateY(1px);
        }

        .hero-title-wrap {
            line-height: 1.15;
        }
        .hero-dates {
            white-space: nowrap;
            display: inline-block;
        }

        /* Ikony wektorowe SVG w stylu archiwalnej ryciny */
        .icon-svg {
            width: 1rem;
            height: 1rem;
            stroke: currentColor;
            stroke-width: 1.85;
            stroke-linecap: round;
            stroke-linejoin: round;
            fill: none;
            flex-shrink: 0;
            display: inline-block;
            vertical-align: middle;
        }
        .icon-svg-sm {
            width: 0.875rem;
            height: 0.875rem;
        }
        .icon-svg-lg {
            width: 1.25rem;
            height: 1.25rem;
        }

        /* ==========================================================================
           STÓŁ PODŚWIETLANY LUPY BADACZA (DRAG & PAN)
           ========================================================================== */
        .magnifier-viewport {
            position: relative;
            overflow: hidden;
            user-select: none;
            background-color: #161310;
            background-image: 
                linear-gradient(rgba(233, 220, 190, 0.04) 1px, transparent 1px),
                linear-gradient(90deg, rgba(233, 220, 190, 0.04) 1px, transparent 1px);
            background-size: 24px 24px;
        }
        .magnifier-viewport.can-grab {
            cursor: grab;
        }
        .magnifier-viewport.is-grabbing {
            cursor: grabbing !important;
        }
        .magnifier-target-smooth {
            transition: transform 0.14s ease-out;
        }
        .magnifier-target-dragging {
            transition: none !important;
        }

        /* ==========================================================================
           MODUŁ PREZENTACJI: RZUTNIK DIAPOZYTYWÓW (PROJEKTOR RETRO)
           ========================================================================== */
        .projector-frame {
            background: linear-gradient(145deg, var(--bg-secondary), var(--bg-card));
            border: 3px double var(--border-dark);
            box-shadow: 0 12px 34px rgba(24, 20, 16, 0.25), inset 0 0 60px rgba(184, 144, 71, 0.16);
            position: relative;
        }
        .slide-perforation {
            height: 14px;
            background-image: repeating-linear-gradient(
                90deg,
                var(--border-dark) 0px,
                var(--border-dark) 12px,
                transparent 12px,
                transparent 24px
            );
            opacity: 0.28;
        }
        .slide-pill {
            transition: all 0.2s ease;
        }
        .slide-pill.active {
            background-color: var(--stamp-red);
            color: #f3ebd7;
            border-color: var(--stamp-red);
            font-weight: 700;
            transform: translateY(-1px);
        }

        /* Dostosowanie paska przewijania */
        ::-webkit-scrollbar {
            width: 10px;
            height: 10px;
        }
        ::-webkit-scrollbar-track {
            background: var(--bg-secondary);
        }
        ::-webkit-scrollbar-thumb {
            background: var(--gold-faded);
            border: 2px solid var(--bg-secondary);
        }
        ::-webkit-scrollbar-thumb:hover {
            background: var(--stamp-red);
        }