/* ============================================
   SITE MODAL — Rich preview replacing tiny info panel
   Layers: scrim z-850, modal z-900
   ============================================ */

/* ── SCRIM ── */
.site-modal-scrim {
    position: fixed;
    inset: 0;
    z-index: 850;
    background: rgba(8, 12, 24, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.site-modal-scrim.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── SEARCH BAR ── */
.site-search-bar {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 860;
    width: min(420px, calc(100vw - 32px));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.site-modal-scrim.visible ~ .site-search-bar,
.site-search-bar.active {
    opacity: 1;
    pointer-events: auto;
}
.site-search-bar.always-visible {
    opacity: 1;
    pointer-events: auto;
}

.site-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.site-search-input-wrap svg {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: rgba(212, 175, 55, 0.6);
    pointer-events: none;
}
.site-search-input {
    width: 100%;
    padding: 12px 42px 12px 42px;
    background: rgba(10, 16, 32, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(180, 160, 120, 0.22);
    border-radius: 6px;
    color: #e8e0d0;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.site-search-input::placeholder {
    color: rgba(212, 175, 55, 0.4);
    font-style: italic;
}
.site-search-input:focus {
    border-color: rgba(180, 160, 120, 0.40);
    box-shadow: 0 0 20px rgba(180, 140, 40, 0.10);
}
.site-search-clear {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: rgba(212, 175, 55, 0.5);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    display: none;
}
.site-search-clear.visible {
    display: block;
}

/* Search Results Dropdown */
.site-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 360px;
    overflow-y: auto;
    background: rgba(10, 16, 32, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(180, 160, 120, 0.18);
    border-radius: 6px;
    display: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.site-search-results::-webkit-scrollbar {
    display: none;
}
.site-search-results.visible {
    display: block;
}
.site-search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(212, 175, 55, 0.08);
    transition: background 0.15s;
}
.site-search-result:last-child {
    border-bottom: none;
}
.site-search-result:hover,
.site-search-result.focused {
    background: rgba(212, 175, 55, 0.1);
}
.site-search-result-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.site-search-result-info {
    flex: 1;
    min-width: 0;
}
.site-search-result-name {
    color: #e8e0d0;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.site-search-result-meta {
    color: rgba(212, 175, 55, 0.5);
    font-size: 0.75rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
}
.site-search-no-results {
    padding: 16px;
    text-align: center;
    color: rgba(212, 175, 55, 0.4);
    font-style: italic;
    font-family: 'Cormorant Garamond', Georgia, serif;
}
.site-search-count {
    padding: 6px 14px;
    font-size: 0.7rem;
    color: rgba(212, 175, 55, 0.35);
    text-align: right;
    font-family: 'Cormorant Garamond', Georgia, serif;
}

/* ── MODAL CONTAINER ── */
.site-modal {
    position: fixed;
    z-index: 900;
    top: 56px;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(100vh);
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 72px);
    overflow-y: auto;
    background: rgba(10, 16, 32, 0.96);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid rgba(180, 160, 120, 0.14);
    border-radius: 6px;
    pointer-events: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6), 0 0 80px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.04);
}
.site-modal::-webkit-scrollbar {
    display: none;
}
.site-modal.visible {
    pointer-events: auto;
}

/* ── MODAL HEADER ── */
.site-modal-handle {
    width: 40px;
    height: 4px;
    background: rgba(180, 160, 120, 0.25);
    border-radius: 2px;
    margin: 10px auto 0;
}

.site-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: rgba(10, 16, 32, 0.6);
    border: 1px solid rgba(180, 160, 120, 0.18);
    border-radius: 4px;
    color: rgba(200, 185, 150, 0.7);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s, color 0.2s;
}
.site-modal-close:hover {
    background: rgba(180, 160, 120, 0.12);
    color: rgba(200, 185, 150, 0.95);
}

/* ── HERO BANNER ── */
.site-modal-hero {
    position: relative;
    height: 110px;
    display: flex;
    align-items: flex-end;
    padding: 16px 20px;
    overflow: hidden;
    border-radius: 6px 6px 0 0;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: height 0.3s ease;
}
.site-modal-hero.has-image {
    height: 200px;
}
.site-modal-hero-gradient {
    position: absolute;
    inset: 0;
    z-index: 0;
}
.site-modal-hero-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    font-size: 2.5rem;
    opacity: 0.12;
    z-index: 0;
}
.site-modal-hero-content {
    position: relative;
    z-index: 1;
    width: 100%;
}
.site-modal-hero h2 {
    font-family: 'Cinzel Decorative', 'Cinzel', serif;
    font-size: 1.3rem;
    color: #f0e6d3;
    margin: 0;
    text-shadow: 0 2px 10px rgba(0,0,0,0.6);
    letter-spacing: 0.02em;
}
.site-modal-hero-badges {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.site-modal-badge {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.72rem;
    padding: 2px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.35);
    color: #bbb;
}
.site-modal-badge.category-badge {
    border-color: rgba(212, 175, 55, 0.4);
    color: #d4af37;
}

/* ── TIER BADGES ── */
.site-modal-badge.tier-badge {
    font-weight: 600;
    letter-spacing: 0.8px;
    font-size: 0.68rem;
}
.site-modal-badge.tier-badge.tier-1 {
    border-color: rgba(255, 0, 255, 0.6);
    color: #ff44ff;
    background: rgba(255, 0, 255, 0.12);
    box-shadow: 0 0 8px rgba(255, 0, 255, 0.25), inset 0 0 6px rgba(255, 0, 255, 0.08);
    animation: tier1Pulse 2.5s ease-in-out infinite;
}
.site-modal-badge.tier-badge.tier-2 {
    border-color: rgba(0, 220, 255, 0.5);
    color: #00dcff;
    background: rgba(0, 220, 255, 0.1);
    box-shadow: 0 0 6px rgba(0, 220, 255, 0.2);
}
.site-modal-badge.tier-badge.tier-3 {
    border-color: rgba(80, 220, 120, 0.4);
    color: #50dc78;
    background: rgba(80, 220, 120, 0.08);
}
.site-modal-badge.tier-badge.tier-4 {
    border-color: rgba(150, 150, 150, 0.3);
    color: #999;
    background: rgba(150, 150, 150, 0.06);
}
@keyframes tier1Pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 0, 255, 0.25), inset 0 0 6px rgba(255, 0, 255, 0.08); }
    50%      { box-shadow: 0 0 14px rgba(255, 0, 255, 0.45), inset 0 0 10px rgba(255, 0, 255, 0.15); }
}

/* ── CONVERGENCE DETAIL CARD ── */
.site-modal-convergence {
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 0, 255, 0.2);
    background: rgba(255, 0, 255, 0.04);
}
.site-modal-convergence-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #ff44ff;
    margin-bottom: 10px;
}
.site-modal-convergence-layers {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.site-modal-layer-chip {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    font-family: 'Inter', sans-serif;
}
.site-modal-layer-chip .layer-label { color: #888; margin-right: 3px; }
.site-modal-layer-chip .layer-score { font-weight: 600; }
.site-modal-convergence-cultures {
    font-size: 0.75rem;
    color: #a090b0;
    line-height: 1.5;
}
.site-modal-convergence-cultures strong { color: #c8b0e0; }

/* ── MODAL BODY ── */
.site-modal-body {
    padding: 18px 20px 24px;
}

/* ── 1. DESCRIPTION — the star of the show ── */
.site-modal-description {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.7;
    color: #e0d8c8;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
}

/* ── 2. QUICK FACTS ROW ── */
.site-modal-facts {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.site-modal-fact {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.78rem;
    color: rgba(212, 175, 55, 0.55);
    padding: 3px 10px;
    border-radius: 4px;
    background: rgba(212, 175, 55, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.1);
    white-space: nowrap;
}

/* ── 3. ALIGNMENT TAGS ── */
.site-modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.site-modal-tag {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid rgba(204, 153, 255, 0.25);
    background: rgba(138, 43, 226, 0.08);
    color: rgba(204, 153, 255, 0.8);
}

/* ── 4. CONNECTION CARD (redesigned) ── */
.site-modal-connection {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    border: 1px solid;
}
.site-modal-connection-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
    box-shadow: 0 0 8px currentColor;
}
.site-modal-connection-body {
    flex: 1;
    min-width: 0;
}
.site-modal-connection-type {
    font-family: 'Cinzel', serif;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.site-modal-connection-reason {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.88rem;
    margin-top: 4px;
    color: rgba(220, 210, 190, 0.7);
    line-height: 1.5;
}

/* ── COLLAPSIBLE SECTIONS ── */
.site-modal-section {
    margin-bottom: 10px;
    border: 1px solid rgba(180, 160, 120, 0.08);
    border-radius: 4px;
    overflow: hidden;
}
.site-modal-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    background: rgba(212, 175, 55, 0.04);
    transition: background 0.2s;
    user-select: none;
}
.site-modal-section-header:hover {
    background: rgba(212, 175, 55, 0.08);
}
.site-modal-section-title {
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    color: rgba(212, 175, 55, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.site-modal-section-chevron {
    color: rgba(212, 175, 55, 0.4);
    transition: transform 0.25s;
    font-size: 0.9rem;
}
.site-modal-section.open .site-modal-section-chevron {
    transform: rotate(180deg);
}
.site-modal-section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.site-modal-section.open .site-modal-section-body {
    max-height: 600px;
}
.site-modal-section-content {
    padding: 10px 14px;
}

/* ── ALIGNMENTS TABLE ── */
.site-modal-alignment-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.8rem;
}
.site-modal-alignment-table th {
    text-align: left;
    color: rgba(212, 175, 55, 0.5);
    font-weight: 400;
    padding: 4px 8px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.12);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.site-modal-alignment-table td {
    padding: 5px 8px;
    color: #ccc;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.site-modal-alignment-table tr:hover td {
    background: rgba(212, 175, 55, 0.04);
}
.alignment-delta {
    font-weight: 600;
}
.alignment-delta.close {
    color: #33ff66;
}
.alignment-delta.medium {
    color: #ffaa33;
}
.alignment-delta.far {
    color: #666;
}

/* ── CONVERGENCE EVENTS ── */
.convergence-event {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-family: 'Cormorant Garamond', Georgia, serif;
}
.convergence-event:last-child {
    border-bottom: none;
}
.convergence-event-az {
    width: 50px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #d4af37;
}
.convergence-event-info {
    flex: 1;
}
.convergence-event-name {
    color: #e8e0d0;
    font-size: 0.85rem;
}
.convergence-event-tradition {
    color: rgba(212, 175, 55, 0.45);
    font-size: 0.75rem;
}
.convergence-event-delta {
    font-size: 0.78rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(51, 255, 102, 0.1);
    color: #33ff66;
    font-weight: 500;
}

/* ── LABYRINTH DETAILS ── */
.labyrinth-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.labyrinth-detail-label {
    color: rgba(204, 68, 255, 0.65);
}
.labyrinth-detail-value {
    color: #ddd;
}

/* ── WIKI LINK ── */
.site-modal-wiki-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.82rem;
    color: rgba(212, 175, 55, 0.7);
    text-decoration: none;
    padding: 4px 0;
    margin-bottom: 14px;
    transition: color 0.2s;
}
.site-modal-wiki-link:hover {
    color: #d4af37;
}
.site-modal-wiki-link svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ── CTA BUTTON ── */
.site-modal-cta {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 16px;
    background: linear-gradient(135deg, rgba(180, 140, 40, 0.12), rgba(180, 140, 40, 0.04));
    border: 1px solid rgba(180, 160, 120, 0.25);
    border-radius: 4px;
    color: rgba(200, 185, 150, 0.9);
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.site-modal-cta:hover {
    background: linear-gradient(135deg, rgba(180, 140, 40, 0.20), rgba(180, 140, 40, 0.10));
    border-color: rgba(180, 160, 120, 0.40);
    box-shadow: 0 0 20px rgba(180, 140, 40, 0.08);
}

/* ── MOBILE: Bottom-half sheet ── */
@media (max-width: 768px) {
    .site-modal {
        width: 100vw;
        top: 50vh;
        bottom: 0;
        left: 0;
        transform: translateY(100vh);
        max-height: 50vh;
        border-radius: 6px 6px 0 0;
    }

    .site-search-bar {
        top: 10px;
        width: calc(100vw - 24px);
    }

    .site-modal-hero {
        height: 70px;
    }
    .site-modal-hero.has-image {
        height: 120px;
    }

    .site-modal-hero h2 {
        font-size: 1rem;
    }

    .site-modal-body {
        padding: 12px 16px 20px;
    }

    .site-modal-description {
        font-size: 0.9rem;
        line-height: 1.5;
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .site-modal-facts {
        gap: 4px;
    }

    .site-modal-fact {
        font-size: 0.72rem;
        padding: 2px 8px;
    }

    .site-modal-cta {
        padding: 10px;
        font-size: 0.78rem;
        margin-top: 10px;
    }
}

/* ── LANDSCAPE MOBILE ── */
@media (max-height: 500px) and (orientation: landscape) {
    .site-modal {
        top: 8px;
        bottom: 8px;
        max-height: calc(100vh - 16px);
    }
    .site-modal-hero {
        height: 70px;
    }
}
