/* CSS DESIGN SYSTEM - STATIC CLEAN SPATIAL BOARD (SOOTWORLD) */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&family=Roboto+Mono:ital,wght@0,100..700;1,100..700&family=Inter:wght@300;400;500;700;800&family=Secular+One&display=swap');

@font-face {
    font-family: 'NarkisBlock';
    src: url('assets/FONT/VC_NarkisBlock-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'GretaSerif';
    src: url('assets/FONT/GretaSerifVF.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

@font-face {
    font-family: 'GretaSerifItalic';
    src: url('assets/FONT/GretaSerif-ItalicVF.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
}

@font-face {
    font-family: 'AlfaBravoBold';
    src: url('assets/FONT/AlfaBravo-Bold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'AlfaBravoNormal';
    src: url('assets/FONT/AlfaBravo-Normal.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'AlfaBravoRegularItalic';
    src: url('assets/FONT/AlfaBravo-RegularItalic.otf') format('opentype');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'GretaTextHL';
    src: url('assets/FONT/GretaTextPro_HL-LightItalic.otf') format('opentype'),
         url('assets/FONT/GretaTextPro_HL-LightItalic.ttf') format('truetype');
    font-weight: 300;
    font-style: italic;
}

@font-face {
    font-family: 'GretaTextHL';
    src: url('assets/FONT/GretaTextPro_HL-MediumItalic.otf') format('opentype'),
         url('assets/FONT/GretaTextPro_HL-MediumItalic.ttf') format('truetype');
    font-weight: 500;
    font-style: italic;
}

:root {
    /* Color Palette */
    --bg-base: #F4F4F5;
    --bg-elevated: #FFFFFF;
    --fg-primary: #020617;
    --fg-secondary: #52525C;
    --border-strong: #E4E4E7;
    --brand-base: #2C7FFF;
    --highlight-pink: #F4D2FB;
    --highlight-green: #DDF3CF;
    --highlight-purple: #F3E8FF;
    --highlight-blue: #DBEAFE;

    /* Legacy Map Aliases for Compatibility */
    --bg-color: var(--bg-base);
    --text-primary: var(--fg-primary);
    --text-secondary: var(--fg-secondary);
    --accent-color: var(--brand-base);
    --card-bg: var(--bg-elevated);
    
    --font-serif: 'Playfair Display', Georgia, serif;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}

p {
    text-wrap: pretty;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    /* Custom cursor everywhere — overrides every native state (default/pointer/grab/grabbing),
       including the canvas's own inline grab/grabbing styles set from three_scene.js. */
    cursor: url('assets/icons8-cursor-50.svg') 7 3, auto !important;
}

body {
    background-color: var(--bg-base);
    color: var(--fg-primary);
    font-family: var(--font-sans);
    overflow: hidden; /* Disable standard scrolling */
    width: 100vw;
    height: 100vh;
    direction: ltr; /* Coordinate canvas runs LTR */
    user-select: none;
    -webkit-user-select: none;
    
    
}

/* Background grid overlay */
.grid-overlay {
    display: none; /* Hide background grid per user request */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 1;
}

/* Header / Logo (Top-Left, Elegant, Multi-line like Mockup) */
header {
    position: fixed;
    top: 30px;
    left: 40px;
    right: 40px;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    text-align: left;
    transition: opacity 0.2s ease, filter 0.5s ease;

    /* No background box — just a soft white glow so the black mark still reads over dark photos */
    filter: drop-shadow(0px 0px 4px rgba(255, 255, 255, 0.8));
}

/* When an item is open: keep logo above backdrop blur layer */
body.is-item-opened header {
    pointer-events: none;
    z-index: 1100;
}
body.is-item-opened .category-menu {
    pointer-events: none;
}
body.is-item-opened .lang-toggle-btn {
    pointer-events: auto;
}
header:hover {
    opacity: 0.7;
}

#site-logo {
    pointer-events: auto;
    height: 94px;
    width: auto;
    display: block;
}


/* Spatial Physics & HTML Cards Container */
#world-container {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    z-index: 2;
    overflow: visible;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

#world-container:active {
    cursor: grabbing;
}

/* Background Persona Groups */
.persona-group {
    position: absolute;
    z-index: 10; /* Draw labels on top of items so they are never hidden */
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.persona-name {
    font-family: 'Secular One', var(--font-sans);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--fg-primary);
    white-space: nowrap;
    direction: rtl; /* RTL for Hebrew names */
    transition: opacity 0.3s ease;
}

.persona-count {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--brand-base);
    margin-top: 4px;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

/* Premium Visual Thumbnail Cards (Aspect Ratio Respected) */
.archive-item {
    position: absolute;
    left: 0;
    top: 0;
    margin: 0;
    height: 138px; /* Fixed height */
    width: auto;
    min-width: 60px;
    z-index: 5;
    cursor: pointer;
    will-change: transform, opacity;
    
    /* 3D perspective wrapper */
    perspective: 1200px;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
}

.archive-item.flipped .card-inner {
    transform: rotateY(180deg);
}

.archive-item.flipped {
    z-index: 99999 !important;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card-front {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.card-front img,
.card-front video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.archive-item:hover .card-front {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22), 0 4px 10px rgba(0, 0, 0, 0.12);
}

/* Card dismiss (X) button */
.card-dismiss-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    border: none;
    color: #fff;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.18s ease, background 0.18s ease;
    z-index: 20;
    pointer-events: all;
}
.archive-item:hover .card-dismiss-btn { opacity: 1; }
.card-dismiss-btn:hover { background: rgba(0,0,0,0.85); }

/* Aspect ratio helpers */
.archive-item.is-landscape { aspect-ratio: 16 / 9; }
.archive-item.is-portrait  { aspect-ratio: 3 / 4; }
.archive-item.is-square    { aspect-ratio: 1 / 1; }

/* Card Back - Structured with CSS Flexbox & Modern Typography */
.card-back {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    color: var(--fg-primary);
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 16px;
    box-sizing: border-box;
    overflow: hidden; /* Prevent overflow on container */
    direction: rtl; /* Default Hebrew direction */
}

.card-back-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    height: 100%;
    gap: 8px;
    font-family: var(--font-sans);
    direction: rtl;
    min-height: 0; /* Enable nested flex scrollability */
}

.card-back-name {
    font-family: 'GretaSerifItalic', serif;
    font-style: italic;
    font-size: 1.15rem;
    font-weight: 300;
    color: var(--brand-base);
    line-height: 1.25;
    text-align: center;
    margin-bottom: 4px;
}

.card-back-title {
    font-family: 'GretaSerifItalic', serif;
    font-style: italic;
    font-size: 1.6rem; /* 1.5rem to 1.8rem */
    font-weight: 600;
    line-height: 1.2;
    color: var(--fg-primary);
    text-align: center;
    margin-bottom: 8px; /* compact bottom margin */
}

.card-back-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px; /* clear visual separation */
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--fg-secondary);
    text-align: center;
}

.card-back-meta span {
    display: inline-block;
    white-space: nowrap;
}

.card-back-meta a {
    color: var(--brand-base);
    text-decoration: underline;
    display: inline-block;
    white-space: nowrap;
}

.card-back-meta a:hover {
    color: var(--fg-primary);
}

.card-back-meta .separator {
    color: var(--border-strong);
    margin: 0 4px;
}

.card-body-text {
    font-family: 'NarkisBlock', var(--font-sans);
    font-size: 1rem !important; /* exactly 1rem for legibility */
    line-height: 1.5;
    color: var(--fg-primary);
    text-align: justify;
    flex-grow: 1;
    overflow-y: auto; /* Scroll internally within exact bounding dimensions */
    overflow-x: hidden;
    padding-right: 6px;
    min-height: 0; /* Critical for scroll overflow inside flex container */
}

/* Sleek, minimal custom scrollbar track */
.card-body-text::-webkit-scrollbar {
    width: 4px;
}
.card-body-text::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}
.card-body-text::-webkit-scrollbar-thumb {
    background-color: var(--border-strong);
    border-radius: 4px;
}

/* Filtering States */
.archive-item.highlighted {
    opacity: 1 !important;
    --card-scale: 1.35;
}
.archive-item.highlighted .card-front {
    border-color: var(--fg-primary) !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15) !important;
}
.archive-item.highlighted:hover {
    --card-scale: 1.55;
    z-index: 99999 !important;
}

.archive-item.dimmed {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    transition: opacity 0.15s ease, 
                visibility 0.15s ease,
                left 0.15s ease, 
                top 0.15s ease;
}

.persona-group.dimmed {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

/* Removed inspecting state hiding logic, lightbox handles overlay */

/* Fixed Bottom Category Navigation (Horizontal Bar) - Collapsed by default */
.category-menu {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translate(-50%, 0);
    opacity: 1;
    pointer-events: auto;
    z-index: 1000;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-base);
    border: 1px solid #49057C;
    border-radius: 30px;
    height: 48px;
    padding: 0 24px;
    gap: 20px;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease, filter 0.5s ease;
    width: max-content;
    max-width: 90vw;
    overflow-x: auto;
}

/* Removed .menu-toggle-btn and .category-menu.open as menu is always visible */

/* Hide scrollbar for category menu */
.category-menu::-webkit-scrollbar {
    display: none;
}
.category-menu {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.category-pill {
    font-family: 'GretaTextHL', serif;
    font-size: 0.8rem;
    font-weight: 500;
    font-style: italic;
    padding: 10px 20px;
    background-color: transparent;
    color: #49057C;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 !important;
    flex: 0 0 auto;
}

.category-pill:hover {
    opacity: 0.85;
    transform: scale(1.05);
    text-shadow: 0 0 0.5px currentColor, 0 0 0.5px currentColor;
}

.category-pill.active {
    background-color: #49057C !important;
    color: var(--bg-elevated) !important;
    font-weight: 500;
}

/* Fullscreen Toggle Button at Bar End */
.category-pill.fullscreen-toggle {
    font-size: 1.15rem;
    padding: 8px 14px;
    border-radius: 50%;
    aspect-ratio: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #49057C;
    background-color: transparent;
    border: none;
}

.category-pill.fullscreen-toggle svg {
    width: 18px;
    height: 18px;
}

.category-pill.fullscreen-toggle:hover {
    background-color: rgba(27, 47, 245, 0.08);
}

/* 3D Card Inner & Faces */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
}

.archive-item.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.45);
}

/* Old card-back styles removed for new Lightbox modal */

#world-container.smooth-transition {
    transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Language Toggle Button (Premium Minimalist) */
.lang-toggle-btn {
    pointer-events: auto;
    z-index: 1000;
    background-color: var(--bg-base);
    border: 1px solid #49057C;
    border-radius: 20px;
    color: #49057C;
    font-family: 'GretaTextHL', serif;
    font-weight: 300;
    font-style: italic;
    font-size: 0.78rem;
    padding: 6px 14px;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease, filter 0.5s ease;
    outline: none;
}

.lang-toggle-btn:hover {
    opacity: 0.7;
    transform: scale(1.05);
}

/* Adjust layout rules for LTR English mode */
/* Adjust layout rules for LTR English mode on card back */
body[dir="ltr"] .card-back-close {
    left: auto;
    right: 15px;
}

body[dir="ltr"] .card-back-content {
    direction: ltr;
    text-align: left;
}

body[dir="ltr"] .card-back-quote {
    border-right: none;
    border-left: 2px solid var(--fg-primary);
    padding-right: 0;
    padding-left: 10px;
}

body[dir="ltr"] .card-back-footer {
    direction: ltr;
}

/* Card number label at bottom-right corner */
.card-number {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--fg-primary);
    background-color: rgba(255, 255, 255, 0.8);
    padding: 1px 4px;
    border-radius: 3px;
    z-index: 10;
    pointer-events: none;
    line-height: 1;
}

#world-container.smooth-transition .archive-item {
    transition: left 0.8s cubic-bezier(0.2, 0.8, 0.2, 1),
                top 0.8s cubic-bezier(0.2, 0.8, 0.2, 1),
                transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1),
                opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

/* Zoom Controls (Minimalist Premium Glassmorphism) */
.zoom-controls {
    position: fixed;
    bottom: 30px;
    right: 40px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zoom-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-strong);
    color: var(--fg-primary);
    font-family: var(--font-sans);
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    outline: none;
}

.zoom-btn:hover {
    background-color: var(--fg-primary);
    color: var(--bg-elevated);
    border-color: var(--fg-primary);
    transform: scale(1.05);
}



/* ====================================================
   ITEM MODAL — DUAL-STATE MASTER SPECIFICATION
   ==================================================== */

/* ── MULTI-MODAL SYSTEM ─────────────────────────────── */
#modals-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2000;
}

/* RULE 3: Backdrop scrolls — zero internal scrollbars anywhere */
.item-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5vh 0;
    pointer-events: all;
    background-color: transparent;
    backdrop-filter: blur(0.7px);
    -webkit-backdrop-filter: blur(0.7px);
}

/* Modal base — layout direction driven by state class below */
.item-modal {
    position: relative;
    margin: auto;
    width: fit-content;
    height: fit-content;
    max-width: 95vw;
    max-height: 90vh;   /* hard ceiling — JS scales media to keep total within this */
    background: #E8E8EA;
    border-radius: 12px;
    box-shadow: 20px 20px 0px #49057C;
    overflow: hidden;
    pointer-events: all;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.item-modal--visible { opacity: 1; transform: translateY(0); }

/* STATE 1: Portrait/Tall — side-by-side, image LEFT text RIGHT */
.item-modal.is-portrait {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

/* STATE 2: Landscape/Wide — side-by-side, image LEFT text RIGHT */
.item-modal.is-landscape {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

/* Close button */
.item-modal-close {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    background: var(--bg-base);
    border: 1px solid #49057C;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.78rem;
    line-height: 1;
    cursor: pointer;
    color: #49057C;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease;
}
.item-modal-close:hover { opacity: 0.7; }

/* RULE 1: Image panel — never cropped, never stretched */
.item-modal-image-panel {
    position: relative;
    flex-shrink: 0;
}

.item-modal-video-panel {
    position: relative;
    flex-shrink: 0;
    width: 420px;
    aspect-ratio: 9 / 16;
    background: #000;
    border-radius: 12px 0 0 12px;
    overflow: hidden;
}

.item-modal-video-panel iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Portrait: image panel fills full modal height; image centers vertically — no empty gap */
.item-modal.is-portrait .item-modal-image-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 280px;
}

/* Portrait: tall image — constrain on height */
.item-modal.is-portrait .item-modal-image-panel img,
.item-modal.is-portrait .item-modal-image-panel video {
    display: block;
    width: auto;
    height: auto;
    max-height: 80vh;
    max-width: 65vw;
    object-fit: contain !important;
}

/* Landscape: image panel fills remaining width, centers image */
.item-modal.is-landscape .item-modal-image-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 280px;
}

/* Landscape: image constrained by panel width and viewport height */
.item-modal.is-landscape .item-modal-image-panel img {
    display: block;
    width: auto;
    height: auto;
    max-height: 90vh;
    max-width: 100%;
    object-fit: contain !important;
}
.item-modal.is-landscape .item-modal-image-panel video {
    display: block;
    width: 100%;
    height: auto;
    max-height: 90vh;
    object-fit: cover;
}


.item-modal-image-panel.is-loading img { opacity: 0; }
.item-modal-image-panel video { background: #000; }

.item-modal-media-loader {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    min-width: 260px;
    min-height: 200px;
}

.item-modal-image-panel.is-loading .item-modal-media-loader { display: flex; }

.item-modal-media-loader::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0,43,250,0.15);
    border-top-color: #002bfa;
    border-radius: 50%;
    animation: modal-spin 0.7s linear infinite;
}

@keyframes modal-spin { to { transform: rotate(360deg); } }

/* Sound toggle */
.modal-sound-btn {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 10;
    background: rgba(0,0,0,0.35);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.item-modal-image-panel:hover .modal-sound-btn { opacity: 1; }
.modal-sound-btn svg { width: 14px; height: 14px; fill: #fff; }

/* RULE 4: Text panel base */
.item-modal-body {
    flex-shrink: 0;
    background: var(--bg-base);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    direction: rtl;
    box-sizing: border-box;
}

body[dir="ltr"] .item-modal-body {
    direction: ltr;
}

body[dir="ltr"] .item-modal-title,
body[dir="ltr"] .item-modal-headline,
body[dir="ltr"] .item-modal-meta,
body[dir="ltr"] .item-modal-columns {
    text-align: left;
}

/* Portrait: text column, height set by JS */
.item-modal.is-portrait .item-modal-body {
    width: 360px;
    overflow: hidden;
    padding-top: 2.8rem;
}

/* Landscape: same text panel as portrait */
.item-modal.is-landscape .item-modal-body {
    width: 360px;
    overflow: hidden;
    padding-top: 2.8rem;
}

/* Upper group: persona + headline + meta + analysis */
.item-modal-top {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}


/* Persona name */
.item-modal-title {
    font-family: 'GretaSerif', serif;
    font-size: 2rem;
    font-weight: 700;
    color: #49057C;
    line-height: 1.2;
    margin: 0 0 6px;
    text-align: right;
}

/* Headline */
.item-modal-headline {
    font-family: 'GretaTextHL', serif;
    font-size: 1rem;
    font-weight: 300;
    font-style: italic;
    color: #111;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 16px;
    text-align: right;
}

/* Meta row */
.item-modal-meta {
    font-family: 'GretaTextHL', serif;
    font-size: 0.82rem;
    font-weight: 300;
    font-style: italic;
    letter-spacing: 0.03em;
    color: #555;
    padding: 10px 0;
    border-top: 1px solid rgba(0,0,0,0.18);
    border-bottom: 1px solid rgba(0,0,0,0.18);
    margin-bottom: 16px;
    text-align: right;
}

/* Analysis text — standard block flow, no CSS columns */
.item-modal-columns {
    font-family: 'NarkisBlock', var(--font-sans);
    font-size: 0.875rem;
    line-height: 1.6;
    color: #111;
    text-align: right;
    text-wrap: pretty;
}

/* Portrait: fills remaining panel height, clips if text is longer than image */
.item-modal.is-portrait .item-modal-columns {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Landscape: flows freely downward — backdrop scrolls if total modal exceeds viewport */
.item-modal.is-landscape .item-modal-columns {
    overflow: hidden;
}

/* RULE 4: Footer anchored at absolute bottom of text panel */
.item-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    margin-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.item-modal-nav {
    background: var(--bg-base);
    border: 1px solid #49057C;
    border-radius: 20px;
    padding: 3px 12px;
    cursor: pointer;
    font-family: 'GretaTextHL', serif;
    font-weight: 300;
    font-style: italic;
    font-size: 0.8rem;
    color: #49057C;
    transition: opacity 0.15s ease;
}
.item-modal-nav:hover { opacity: 0.7; }

.item-modal-counter {
    font-family: 'GretaTextHL', serif;
    font-weight: 300;
    font-style: italic;
    font-size: 0.9rem;
    color: #333;
}

.modal-source-link { color: #49057C; text-decoration: underline; font-weight: bold; }
/* ──────────────────────────────────────────────────── */

#lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

#lightbox-modal.lightbox-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.lightbox-content-wrapper {
    position: relative;
    background-color: #ffffff;
    border-radius: 30px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 90vw;
    max-width: 650px;
    height: 80vh;
    max-height: 80vh;
    padding: 40px;
    box-sizing: border-box;
}

.modal-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    width: 100%;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    background: transparent;
    border: none;
    font-size: 2.2rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #002bfa;
    transition: transform 0.2s ease;
    line-height: 1;
}

.lightbox-close:hover {
    transform: scale(1.15) rotate(90deg);
}

body[dir="ltr"] .lightbox-close {
    left: 20px;
    right: auto;
}

body[dir="rtl"] .lightbox-close {
    right: 20px;
    left: auto;
}

.modal-title {
    font-family: 'GretaSerif', serif;
    font-size: 2rem;
    font-weight: 700;
    color: #002bfa;
    margin-top: 15px;
    margin-bottom: 10px;
    line-height: 1.2;
}

body[dir="ltr"] .modal-title {
    text-align: left;
}

body[dir="rtl"] .modal-title {
    text-align: right;
}

.modal-meta {
    font-family: 'GretaSerifItalic', serif;
    font-style: italic;
    font-size: 1.1rem;
    color: #002bfa;
    margin-bottom: 25px;
    opacity: 0.8;
    border-bottom: 1px solid rgba(0, 43, 250, 0.2);
    padding-bottom: 15px;
}

body[dir="ltr"] .modal-meta {
    text-align: left;
}

body[dir="rtl"] .modal-meta {
    text-align: right;
}

.modal-source-link {
    color: #49057C;
    font-weight: bold;
    text-decoration: underline;
    font-family: 'GretaSerifItalic', serif;
}
.modal-source-meta {
    color: #555;
}

.modal-source-link:hover {
    opacity: 0.8;
}

.modal-body-text {
    font-family: 'NarkisBlock', var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    color: #002bfa;
    flex: 1 1 auto;
    overflow-y: auto;
    padding-bottom: 20px;
    text-wrap: pretty;
}

body[dir="ltr"] .modal-body-text {
    text-align: left;
    padding-right: 15px;
}

body[dir="rtl"] .modal-body-text {
    text-align: right;
    padding-left: 15px;
}

.modal-body-text::-webkit-scrollbar {
    width: 6px;
}

.modal-body-text::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body-text::-webkit-scrollbar-thumb {
    background-color: rgba(0, 43, 250, 0.2);
    border-radius: 3px;
}

.modal-body-text::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 43, 250, 0.4);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 43, 250, 0.2);
    margin-top: auto;
}

.modal-nav-btn {
    background: transparent;
    border: 1px solid #333;
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'GretaSerifItalic', serif;
    font-weight: normal;
    font-style: italic;
    font-size: 0.85rem;
    color: #333;
    transition: all 0.2s ease;
}

.modal-nav-btn:hover {
    background: #eee;
    color: #000;
}

.modal-counter {
    font-family: 'GretaSerifItalic', serif;
    font-weight: normal;
    font-style: italic;
    font-size: 1rem;
    color: #333;
    opacity: 0.8;
}

@media (max-width: 600px) {
    .lightbox-content-wrapper {
        width: 95vw;
        height: 85vh;
        max-height: 85vh;
        padding: 30px 20px;
        border-radius: 20px;
    }
    .modal-title {
        font-size: 1.6rem;
    }
    .modal-meta {
        font-size: 1rem;
        margin-bottom: 15px;
        padding-bottom: 10px;
    }
    .modal-nav-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}



/* Fullscreen Toggle Button */
.fullscreen-toggle {
    font-size: 1.2rem;
    padding: 6px 16px;
    font-weight: bold;
}

/* ── DEBUG GRID MODE ─────────────────────────────────── */

.debug-grid-btn {
    position: fixed;
    top: 80px;
    right: 40px;
    z-index: 1003;
    background: transparent;
    border: 1px solid var(--fg-primary);
    border-radius: 20px;
    color: var(--fg-primary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 6px 14px;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    outline: none;
}
.debug-grid-btn:hover,
.debug-grid-btn.active {
    background: var(--fg-primary);
    color: var(--bg-elevated);
}

/* Grid mode: restore normal body scroll */
body.debug-grid-mode {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Grid mode: world container becomes a flat CSS grid */
body.debug-grid-mode #world-container {
    position: static !important;
    top: auto !important;
    left: auto !important;
    width: 100% !important;
    height: auto !important;
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
    gap: 20px !important;
    padding: 80px 50px 50px !important;
    overflow: visible !important;
    transform: none !important;
    opacity: 1 !important;
    cursor: default !important;
    transition: none !important;
}

/* Grid mode: cards sit naturally in the grid, all visible */
body.debug-grid-mode .archive-item,
body.debug-grid-mode .archive-item.dimmed,
body.debug-grid-mode .archive-item.highlighted {
    position: static !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    width: 100% !important;
    height: 150px !important;
    margin: 0 !important;
    transition: none !important;
}

/* Mobile Landscape Prompt */
#rotate-device-prompt {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-base);
    z-index: 999999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

#rotate-device-prompt svg {
    width: 60px;
    height: 60px;
    margin-bottom: 20px;
    color: var(--brand-base);
    animation: rotatePhone 2s infinite ease-in-out;
}

@keyframes rotatePhone {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(-90deg); }
    100% { transform: rotate(-90deg); }
}

#rotate-device-prompt p {
    font-family: var(--font-sans);
    font-size: 1.2rem;
    line-height: 1.5;
    color: var(--fg-primary);
    direction: rtl;
}

@media (max-width: 899px) and (orientation: portrait) {
    #rotate-device-prompt {
        display: flex;
    }
    #world-container, .category-menu, header, .lang-toggle-btn, .menu-toggle-btn, canvas#three-canvas {
        display: none !important;
    }
}

/* ── About Panel ─────────────────────────────────────────── */
.header-right-btns {
    display: flex;
    gap: 8px;
    align-items: center;
    pointer-events: auto;
}

.about-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
}
.about-overlay.open { display: block; }

.about-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background: #2d1f5e;
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.42s cubic-bezier(0.4,0,0.2,1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.about-panel.open { transform: translateX(0); }

@media (max-width: 768px) {
    .about-panel { width: 100%; }
}

.about-close {
    position: absolute;
    top: 18px;
    left: 20px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
    padding: 4px;
    transition: color 0.15s;
}
.about-close:hover { color: #fff; }

/* Content — no scroll, fits viewport */
.about-content {
    flex: 1;
    overflow: hidden;
    padding: 36px 56px 28px;
    direction: rtl;
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.about-title {
    font-family: 'GretaSerifItalic', serif;
    font-style: italic;
    font-size: clamp(28px, 3.8vw, 54px);
    font-weight: 400;
    color: #fff;
    margin: 0 0 18px;
    line-height: 1.05;
    white-space: nowrap;
    text-align: right;
}

.about-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.about-content p {
    font-family: 'NarkisBlock', sans-serif;
    font-size: clamp(12px, 1.15vw, 14px);
    line-height: 1.65;
    color: rgba(255,255,255,0.9);
    margin: 0 0 8px;
    text-align: justify;
    text-align-last: right;
}

.about-credits {
    margin-top: 4px;
}
.about-credits p {
    font-family: 'NarkisBlock', sans-serif;
    font-size: clamp(10px, 0.95vw, 12px);
    line-height: 1.8;
    color: rgba(255,255,255,0.9);
    margin: 0 0 16px;
    text-align: right;
}

.about-contact {
    margin-top: 0;
}
.about-contact p {
    font-family: 'NarkisBlock', sans-serif;
    font-size: clamp(10px, 0.95vw, 12px);
    line-height: 1.8;
    margin: 0 0 0;
    color: rgba(255,255,255,0.9);
    text-align: right;
}
.about-contact a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.about-contact a:hover { opacity: 0.8; }

.about-logo {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}
.about-logo img {
    height: 120px;
    width: auto;
    opacity: 0.9;
}
