/* --- MAIN CONTENT AREA --- */
.main-content {
    flex-grow: 1;
    padding: 1.5rem;
    max-width: 1080px;
    min-height: 0px;
    margin: auto;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.parchment-box::before {
    content: '';
    position: absolute;
    inset: 0;

    border-image: url('../assets/ucp3/ornament_border_shadow.png');
    border-image-slice: 16;
    border-image-repeat: round;
    border-style: solid;
    border-width: 12px;
    border-color: transparent;

    /* Put the border layer behind the scrollbar but in front of content */
    z-index: 5; 
    pointer-events: none; 
}

.parchment-box {
    background-image: url('../assets/ucp3/parchment_bg_smooth.png');
    background-color: var(--ucp-parchment);
    color: var(--ucp-text);

    position: relative; /* For positioning the scrollbar inside */
    display: flex;
    flex-grow: 1;
    min-height: 0;
    overflow: hidden; /* Hide anything that spills out */
    padding: 0; /* Padding is now on the inner wrapper */
}
.parchment-box::-webkit-scrollbar {
    display: none;
}

.parchment-box a {
    color: var(--ucp-link-color);
    font-weight: bold;
    text-decoration: underline;
}
.parchment-box a:hover {
    color: var(--ucp-text);
}

.parchment-content-wrapper {
    flex-grow: 1;
    min-height: 0;
    overflow-y: scroll; 
    padding: 0 1rem;

    /* Hide native scrollbar */
    scrollbar-width: none; /* Firefox */
}
.parchment-content-wrapper::-webkit-scrollbar {
    display: none; /* Webkit */
}

/* --- MODAL --- */
.modal-overlay { 
    position: fixed; 
    inset: 0; 
    background-color: rgba(0,0,0,0.75); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 50; 
}

/* The .modal-content class now only defines size and inherits parchment styling */
.modal-content { 
    max-width: 42rem; 
    width: 100%; 
    max-height: 80vh; 
    /* All border, background, and padding are handled by .parchment-box */
}

.modal-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 1rem; 
}

.modal-close-btn { 
    background: none; 
    border: none; 
    font-size: 2rem; 
    line-height: 1; 
    cursor: pointer; 
    color: var(--ucp-brown); 
}

.hidden { 
    display: none; 
}


/* --- Store Tab Layout Styles --- */
.store-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 0.5rem;
    width: 100%
}

.store-headers-and-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    flex-shrink: 0;
}

.store-headers-and-controls .ucp-header-font {
    color: var(--ucp-button-text);
}

.store-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.store-content-split {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) 2fr;
    gap: 1rem;
    flex-grow: 1;
    min-height: 0;
}

.ucp-store-row {
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ucp-store-row:hover { background:rgba(0,0,0,.1); }
.ucp-store-row.sel { background: rgba(255,255,0,.25); }

.ucp-store-list-items {
    padding: 1rem 0px;
}

.ucp-tag-menu {
    position: absolute;
    background: var(--ucp-brown);
    color: var(--ucp-parchment);
    border: 1px solid var(--ucp-gold);
    padding: 10px;
    border-radius: 4px;
    z-index: 20;
    margin-top: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.ucp-tag-menu label { display: block; }

/* --- Description Header & Metadata --- */
.description-header {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}
.meta-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--ucp-text-muted);
    margin-top: 0.25rem;
}

/* --- VIDEO FACADE STYLES --- */
.video-facade {
    position: relative;
    cursor: pointer;
    background-color: #000;
    border-radius: 4px;
    overflow: hidden;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
}
.video-facade img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.7;
    transition: opacity 0.2s ease-in-out;
}
.video-facade:hover img {
    opacity: 1;
}
.video-facade .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68px;
    height: 48px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 68 48"><path d="M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.55C3.97,2.33,2.26,4.81,1.48,7.74,0.06,13.05,0,24,0,24s0.06,10.95,1.48,16.26c0.78,2.93,2.49,5.41,5.42,6.19C12.21,47.87,34,48,34,48s21.79-0.13,27.1-1.55c2.93-0.78,4.64-3.26,5.42-6.19C67.94,34.95,68,24,68,24S67.94,13.05,66.52,7.74z" fill="%23f00"></path><path d="M 45,24 27,14 27,34" fill="%23fff"></path></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
    transition: transform 0.2s ease-in-out;
    filter: drop-shadow(0 0 5px rgba(0,0,0,0.5));
}
.video-facade:hover .play-icon {
    transform: translate(-50%, -50%) scale(1.1);
}

.parchment-box .prose img {
    max-width: 100%;
    height: auto;
    border-radius: 4px; /* Optional: for a nicer look */
}

/* --- ADDED WIKI STYLES --- */
.wiki-split {
    display: grid;
    grid-template-columns: 220px 1fr; /* Sidebar width and main content */
    gap: 1.5rem;
    align-items: start;
}

.wiki-sidebar {
    position: sticky;
    top: 1rem; /* Stick to top while scrolling */
    max-height: calc(100vh - 250px); /* Adjust height based on your layout */
    overflow-y: auto;
    padding-right: 1rem;
    border-right: 2px solid rgba(0,0,0,0.1);
}

/* General styling for markdown-generated content */
.prose h1, .prose h2, .prose h3 {
    font-family: 'RiverAvenue', cursive;
    margin-top: 1.2em;
    margin-bottom: 0.5em;
}

.prose ul {
    list-style-type: disc;
    padding-left: 1.5rem;
}

.prose a {
    text-decoration: underline;
    font-weight: bold;
    color: var(--ucp-link-color);
}
.prose a:hover {
    color: var(--ucp-text);
}

.prose code {
    background-color: rgba(0,0,0,0.08);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
}

/* --- CUSTOM CHAIN SCROLLBAR V3 (FINAL) --- */
.custom-scrollbar {
    position: absolute;
    top: 8px;
    right: 11px;
    bottom: 8px;
    width: 7px; /* YOUR EXACT WIDTH */
    display: flex;
    flex-direction: column;
    z-index: 10; /* Raise it ABOVE the parchment border image */
}

.scrollbar-top {
    width: 100%;
    height: 0px; /* YOUR EXACT HEIGHT */
    background-image: url('../assets/ucp3/scroll_bar_top.png');
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.scrollbar-track {
    position: relative;
    width: 100%;
    flex-grow: 1;
    cursor: pointer;
}

.chain-visuals {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    min-height: 18px; /* Correct: Height of your bottom cap */
    cursor: grab;
    
    /* NEW: Create a dedicated 18px space at the bottom for the cap */
    padding-bottom: 18px; 
    
    /* --- The Multi-Background Setup --- */
    background-image: 
        url('../assets/ucp3/scroll_bar_bottom_hook.png'), /* Layer 2: The Cap */
        url('../assets/ucp3/scroll_bar_middle.png');      /* Layer 1: The repeating chain */
    
    background-repeat: 
        no-repeat,
        repeat-y;
        
    background-position: 
        bottom center, /* Position cap at the bottom */
        bottom center; /* Also align the repeating grid to the bottom */

    /* THIS IS THE KEY TO THE FIX: Clip backgrounds to different areas */
    background-clip: 
        padding-box,   /* The cap will ONLY render in the padding area */
        content-box;   /* The repeating chain will ONLY render in the content area (above the padding) */

    background-size: 
        7px 18px,   /* Size of bottom cap image */
        100% 8px;   /* Size of one middle link */
}

.chain-visuals:active {
    cursor: grabbing;
}

/* DELETE these old rules as they are no longer needed */
.chain-middle,
.chain-bottom-cap {
    display: none;
}