* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: Georgia, 'Palatino Linotype', serif;
    background: #f4e8c1;
    color: #3b2f1e;
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}
.bg-layer {
    position: fixed; inset: 0; z-index: 0;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(139,109,56,0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(139,109,56,0.12) 0%, transparent 50%),
        linear-gradient(180deg, #f0e0b8 0%, #f4e8c1 30%, #efe0b0 100%);
    pointer-events: none;
}
.bg-layer::after {
    content: '';
    position: absolute; inset: 0;
    background:
        repeating-linear-gradient(0deg, transparent, transparent 28px, rgba(139,109,56,0.03) 28px, rgba(139,109,56,0.03) 29px);
}
.container { position: relative; z-index: 1; max-width: 100vw; margin: 0 auto; padding: 20px; }
header { text-align: center; padding: 40px 20px 20px; }
header h1 {
    font-size: 3.2rem;
    color: #5a3e28;
    text-shadow: 1px 1px 2px rgba(90,62,40,0.2);
    margin-bottom: 10px;
    letter-spacing: 2px;
}
.subtitle {
    font-size: 1.2rem;
    color: #7a6545;
    font-style: italic;
}
.tabs { display: flex; justify-content: center; gap: 10px; margin: 20px 0; flex-wrap: wrap; }
.tab {
    padding: 10px 24px; border: 1px solid #a08c6a; border-radius: 30px;
    background: rgba(244,232,193,0.6); color: #5a3e28; cursor: pointer;
    font-family: Georgia, serif; font-size: 1rem; transition: all 0.3s;
    text-decoration: none; display: inline-block;
}
.tab:hover { border-color: #8b6d47; background: rgba(212,175,55,0.15); text-decoration: none; }
.tab.active { background: #5a3e28; color: #f4e8c1; border-color: #5a3e28; font-weight: bold; }
.donate-tab { background: rgba(212,175,55,0.2); border-color: #d4af37; color: #8b6914; font-weight: bold; }
.donate-tab:hover { background: rgba(212,175,55,0.4); border-color: #b8962e; transform: scale(1.05); }

/* Timeline wrapper with sliders */
.timeline-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 3px solid #8b6d47;
    border-radius: 6px;
    background: rgba(255,250,235,0.6);
    box-shadow: inset 0 0 40px rgba(139,109,56,0.15), 0 4px 20px rgba(90,62,40,0.2);
    overflow: hidden;
    height: 90vh;
    min-height: 700px;
}
.timeline-main {
    flex: 1;
    min-height: 0;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Bottom pan slider */
.timeline-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 15px;
    background: linear-gradient(180deg, #e8d9b8 0%, #dcc9a5 100%);
    border-top: 1px solid #a08c6a;
}
.slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 500px;
}
.slider-group label {
    font-size: 0.85rem;
    color: #5a3e28;
    font-family: Georgia, serif;
    white-space: nowrap;
    min-width: 50px;
}
.slider-group input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #c4a265;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}
.slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #5a3e28;
    border: 2px solid #f4e8c1;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.slider-group input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.1);
}
.slider-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #5a3e28;
    border: 2px solid #f4e8c1;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

footer { text-align: center; padding: 30px; color: #7a6545; font-size: 0.9rem; font-style: italic; }

/* D3 Timeline styles */
#timeline svg {
    display: block;
}

/* Grid lines */
.grid-line {
    pointer-events: none;
}
.grid-line.major {
    stroke: rgba(139,109,56,0.15) !important;
}
.grid-line:not(.major) {
    stroke: rgba(139,109,56,0.06) !important;
}

/* Timeline bars */
.timeline-bar {
    cursor: pointer;
}
.timeline-bar .bar-bg {
    filter: drop-shadow(2px 3px 4px rgba(90,62,40,0.25));
    transition: filter 0.2s;
}
.timeline-bar:hover .bar-bg {
    filter: drop-shadow(2px 3px 8px rgba(90,62,40,0.4));
}

/* Bar type colors */
.bar-timeline .bar-bg { fill: #ffffff; stroke: #8b7355; }
.bar-pope .bar-bg { fill: #d4af37; stroke: #8b7355; }
.bar-saint .bar-bg { fill: #2e8b57; stroke: #8b7355; }
.bar-document .bar-bg { fill: #4169e1; stroke: #8b7355; }
.bar-marian .bar-bg { fill: #8e44ad; stroke: #8b7355; }

/* Text colors per type */
.bar-timeline .item-title,
.bar-timeline .item-sub,
.bar-timeline .item-icon { fill: #1a1a1a; }
.bar-pope .item-title,
.bar-pope .item-sub,
.bar-pope .item-icon { fill: #1a1a2e; }
.bar-saint .item-title,
.bar-saint .item-sub,
.bar-saint .item-icon { fill: #ffffff; }
.bar-document .item-title,
.bar-document .item-sub,
.bar-document .item-icon { fill: #ffffff; }
.bar-marian .item-title,
.bar-marian .item-sub,
.bar-marian .item-icon { fill: #ffffff; }

/* Group labels */
.group-label {
    font-family: Georgia, serif;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 3px;
    fill: #4a2e18;
}

/* Time axis */
.time-axis text {
    font-family: Georgia, serif;
    fill: #5a3e28;
}

/* Year markers */
.year-marker line {
    stroke: rgba(139,0,0,0.5);
    stroke-width: 3;
}
.year-marker text {
    font-family: Georgia, serif;
    font-size: 0.7rem;
    fill: #8b0000;
    font-weight: bold;
}

/* Category tags */
.item-category-tag {
    display: inline-block;
    font-size: 0.6em;
    font-weight: 700;
    font-family: Georgia, serif;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-top: 3px;
    text-transform: uppercase;
}
.item-category-tag.biblical { background: rgba(107,54,154,0.2); color: #6b369a; border: 1px solid rgba(107,54,154,0.3); }
.item-category-tag.church { background: rgba(41,128,185,0.15); color: #2171a6; border: 1px solid rgba(41,128,185,0.3); }
.item-category-tag.persecution { background: rgba(192,57,43,0.15); color: #922b21; border: 1px solid rgba(192,57,43,0.3); }
.item-category-tag.document { background: rgba(211,84,0,0.12); color: #a04000; border: 1px solid rgba(211,84,0,0.25); }
.item-category-tag.war { background: rgba(142,36,17,0.15); color: #7b241c; border: 1px solid rgba(142,36,17,0.3); }
.item-category-tag.crusade { background: rgba(142,68,173,0.15); color: #7d3c98; border: 1px solid rgba(142,68,173,0.3); }
.item-category-tag.empire { background: rgba(212,165,11,0.15); color: #9a7d0a; border: 1px solid rgba(212,165,11,0.3); }
.item-category-tag.saint { background: rgba(39,174,96,0.15); color: #1e8449; border: 1px solid rgba(39,174,96,0.3); }
.item-category-tag.pope { background: rgba(212,165,11,0.2); color: #7d6608; border: 1px solid rgba(212,165,11,0.35); }
.item-category-tag.inquisition { background: rgba(142,36,17,0.18); color: #641e16; border: 1px solid rgba(142,36,17,0.35); }
.item-category-tag.plague { background: rgba(78,78,78,0.15); color: #4d4d4d; border: 1px solid rgba(78,78,78,0.3); }
.item-category-tag.colonial { background: rgba(42,157,143,0.12); color: #1a7a6d; border: 1px solid rgba(42,157,143,0.25); }
.item-category-tag.reformation { background: rgba(230,126,34,0.15); color: #a04000; border: 1px solid rgba(230,126,34,0.3); }
.item-category-tag.revolution { background: rgba(192,57,43,0.18); color: #7b241c; border: 1px solid rgba(192,57,43,0.35); }
.item-category-tag.world { background: rgba(52,73,94,0.15); color: #2c3e50; border: 1px solid rgba(52,73,94,0.3); }
.item-category-tag.marian { background: rgba(142,68,173,0.15); color: #6c3483; border: 1px solid rgba(142,68,173,0.35); }

/* Detail pages */
.detail-container { max-width: 800px; margin: 0 auto; padding: 40px 20px; }
.detail-header { text-align: center; margin-bottom: 40px; }
.detail-icon { font-size: 4rem; margin-bottom: 20px; }
.detail-title { font-size: 2.5rem; color: #5a3e28; margin-bottom: 10px; }
.detail-sub { font-size: 1.1rem; color: #7a6545; font-style: italic; }
.detail-body { line-height: 1.8; font-size: 1.1rem; color: #3b2f1e; }
.detail-body p { margin-bottom: 1em; }
.detail-nav { display: flex; justify-content: center; gap: 20px; margin-top: 40px; flex-wrap: wrap; }
.detail-nav a {
    padding: 10px 20px; border: 1px solid #a08c6a; border-radius: 30px;
    color: #5a3e28; text-decoration: none; transition: all 0.3s;
}
.detail-nav a:hover { background: #5a3e28; color: #f4e8c1; }
.back-link {
    display: inline-block; margin-bottom: 20px; color: #7a6545; text-decoration: none;
}
.back-link:hover { color: #5a3e28; }

/* Language toggle bar */
#ct-lang-bar {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 9999;
    display: flex;
    gap: 6px;
    background: rgba(90, 62, 40, 0.9);
    border-radius: 20px;
    padding: 6px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.ct-lang-btn {
    padding: 6px 14px;
    border: 1px solid rgba(244, 232, 193, 0.3);
    border-radius: 16px;
    background: transparent;
    color: #f4e8c1;
    font-family: Georgia, serif;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.25s;
    font-weight: bold;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.ct-lang-btn:hover {
    background: rgba(212, 175, 55, 0.3);
    border-color: #d4af37;
}
.ct-lang-btn.ct-lang-active {
    background: #d4af37;
    color: #3b2f1e;
    border-color: #d4af37;
}
