/* --- БАЗА --- */
body { background: #000; overflow: hidden; margin: 0; padding: 0; }
.tarot-bg-glow { width: 100%; height: 100%; background: radial-gradient(circle at 50% 100%, rgba(204, 255, 0, 0.08) 0%, rgba(0,0,0,0) 60%); position: absolute; top: 0; left: 0; pointer-events: none; }
.spread-layout { position: relative; width: 100%; height: 100vh; display: flex; flex-direction: column; z-index: 10; }

/* ШАПКА */
.spread-header { height: 50px; flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; padding: 0 15px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); background: rgba(0,0,0,0.8); backdrop-filter: blur(10px); z-index: 20; }
.spread-logo { font-family: 'Unbounded'; font-size: 12px; color: #fff; letter-spacing: 1px; }
.spread-btn-icon { background: none; border: 1px solid rgba(255, 255, 255, 0.3); color: var(--accent); padding: 8px 16px; font-family: 'Unbounded'; font-size: 10px; text-decoration: none; border-radius: 4px; margin-left: 10px; cursor: pointer; }

/* МЕНЮ */
.spread-menu { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #050505; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.menu-title { font-family: 'Unbounded'; font-size: 16px; color: #fff; margin-bottom: 30px; }
.menu-grid { display: grid; grid-template-columns: 1fr; gap: 15px; width: 80%; max-width: 300px; }
.menu-item { background: #111; border: 1px solid #333; padding: 20px; border-radius: 12px; text-align: left; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; }
.menu-item:active { transform: scale(0.98); background: #1a1a1a; border-color: var(--accent); }
.mi-icon { font-size: 24px; color: var(--accent); margin-right: 15px; width: 30px; text-align: center; font-family: 'Unbounded'; }
.mi-name { font-family: 'Unbounded'; font-size: 12px; color: #fff; margin-bottom: 4px; }
.mi-desc { font-family: 'Manrope'; font-size: 10px; color: #888; }

/* СТОЛ */
.spread-workspace { flex: 1; position: relative; overflow-y: auto; overflow-x: hidden; padding-top: 10px; }

/* СЕТКИ */
.spread-grid { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding-bottom: 80px; width: 100%; padding-left: 10px; padding-right: 10px; align-items: flex-start; }
.spread-relations { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto; gap: 15px; width: 90%; max-width: 350px; margin: 0 auto; padding-bottom: 100px; justify-items: center; }
.slot-center { grid-column: 1 / -1; justify-self: center; margin-top: 5px; }
.spread-choice { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto; gap: 15px; width: 90%; max-width: 350px; margin: 0 auto; padding-bottom: 100px; justify-items: center; }
#slot-0 { grid-column: 1 / -1; grid-row: 1; }
#slot-1 { grid-column: 1; grid-row: 2; }
#slot-3 { grid-column: 2; grid-row: 2; }
#slot-2 { grid-column: 1; grid-row: 3; }
#slot-4 { grid-column: 2; grid-row: 3; }

/* СЛОТЫ */
.card-slot { width: 90px; height: 175px; display: flex; flex-direction: column; align-items: center; position: relative; background: rgba(255, 255, 255, 0.03); border: 1px dashed rgba(255, 255, 255, 0.2); border-radius: 8px; padding-top: 8px; overflow: visible; flex-shrink: 0; }
.card-slot-label { margin-bottom: 8px; font-family: 'Unbounded'; font-size: 8px; color: #666; text-align: center; width: 100%; text-transform: uppercase; height: 20px; display: flex; align-items: center; justify-content: center; }

/* КОНТЕЙНЕР ДЛЯ 3D КАРТЫ */
.cards-stack { 
    position: relative; width: 80px; height: 140px; flex-shrink: 0; 
    perspective: 1000px; /* Для 3D переворота */
    cursor: pointer;
}

/* КАРТА (ОБЩАЯ) */
.table-card { 
    width: 80px; height: 140px; position: absolute; top: 0; left: 0; 
    border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.5); 
    border: 1px solid #444; 
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d; /* Важно для сторон */
}

/* СКРЫВАЕМ НИЖНИЕ КАРТЫ (как и раньше) */
.cards-stack .table-card { display: none; }
.cards-stack .table-card:first-child { display: block; }

/* --- ЛИЦЕВАЯ СТОРОНА --- */
.card-face {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden; /* Скрываем задник */
    background-size: cover; background-position: center;
    border-radius: 8px;
    transform: rotateY(180deg); /* Изначально отвернута от нас */
}

/* --- РУБАШКА (BACK) --- */
.card-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    /* Генерируем красивый узор */
    background: #0a0a0a;
    background-image: 
        linear-gradient(45deg, #111 25%, transparent 25%, transparent 75%, #111 75%, #111),
        linear-gradient(45deg, #111 25%, transparent 25%, transparent 75%, #111 75%, #111);
    background-size: 10px 10px;
    background-position: 0 0, 5px 5px;
    border: 2px solid #333;
    display: flex; justify-content: center; align-items: center;
}
/* Логотип на рубашке */
.card-back::after {
    content: '✦'; color: #333; font-size: 24px;
}

/* --- СОСТОЯНИЯ --- */
/* Закрытая карта (по умолчанию) */
.table-card.is-hidden {
    transform: rotateY(0deg); /* Видим рубашку */
}

/* Открытая карта */
.table-card.is-revealed {
    transform: rotateY(180deg); /* Поворачиваемся лицом */
    box-shadow: 0 0 15px var(--accent-glow, rgba(204,255,0,0.3));
}

/* Пульсация для закрытой карты (призыв нажать) */
.table-card.is-hidden {
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% { border-color: #444; }
    50% { border-color: #666; box-shadow: 0 0 10px rgba(255,255,255,0.1); }
    100% { border-color: #444; }
}

/* БЕЙДЖ */
.stack-badge { position: absolute; top: -10px; right: -10px; width: 24px; height: 24px; background: var(--accent); color: #000; font-family: 'Unbounded'; font-weight: bold; font-size: 10px; border-radius: 50%; display: flex; justify-content: center; align-items: center; z-index: 20; box-shadow: 0 0 10px var(--accent); animation: popIn 0.3s; transform: translateZ(1px); /* Чтобы был поверх 3D */ }
.cards-stack.has-more::before { content: ''; position: absolute; top: 3px; left: 3px; width: 100%; height: 100%; background: #222; border: 1px solid #444; border-radius: 8px; z-index: -1; }

/* МОДАЛКА */
.focus-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 1000; display: none; flex-direction: column; }
.focus-overlay.active { display: flex; }
.focus-header { height: 50px; flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; padding: 0 15px; border-bottom: 1px solid #333; background: #0a0a0a; z-index: 1001; }
.close-focus-btn { background: rgba(255,255,255,0.05); border: 1px solid var(--accent); color: var(--accent); padding: 8px 16px; font-family: 'Unbounded'; font-size: 11px; cursor: pointer; border-radius: 6px; }
.focus-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.focus-cards-container { flex: 1; max-height: 55%; background: radial-gradient(circle at 50% 0%, rgba(255,255,255,0.05), #000 80%); overflow-y: auto; padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 30px; border-bottom: 1px solid #333; }
.layer-row { display: flex; justify-content: center; gap: 10px; position: relative; width: 100%; flex-shrink: 0; }
.layer-row:not(:first-child)::before { content: '↓'; color: #444; font-family: 'Unbounded'; font-size: 14px; position: absolute; top: -25px; left: 50%; transform: translateX(-50%); }
.focus-card { width: 90px; height: 150px; background-size: cover; background-position: center; border-radius: 8px; border: 1px solid #555; box-shadow: 0 5px 15px rgba(0,0,0,0.5); flex-shrink: 0; }
.focus-controls { height: 60px; flex-shrink: 0; display: flex; gap: 10px; justify-content: center; align-items: center; padding: 0 15px; background: #111; border-bottom: 1px solid #333; }
.add-btn { background: rgba(255,255,255,0.05); border: 1px dashed #666; color: #888; padding: 8px 0; width: 120px; border-radius: 8px; font-family: 'Unbounded'; font-size: 10px; cursor: pointer; text-align: center; transition: all 0.2s; }
.add-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(204, 255, 0, 0.05); }
.add-btn span { display: inline-block; font-size: 12px; margin-right: 5px; font-weight: bold; }
.focus-info-area { height: 35%; display: flex; flex-direction: column; padding: 20px; overflow-y: auto; background: #000; }
.smart-summary-box { margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid #222; }
.summary-label { font-family: 'Unbounded'; font-size: 10px; color: var(--accent); margin-bottom: 8px; }
.summary-text { font-family: 'Manrope'; font-size: 13px; color: #fff; line-height: 1.5; }
.spread-footer { height: 80px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(to top, #000 90%, transparent); position: fixed; bottom: 0; width: 100%; z-index: 50; }
.action-btn { background: var(--accent); color: #000; border: none; padding: 12px 30px; border-radius: 20px; font-family: 'Unbounded'; font-size: 10px; font-weight: 800; cursor: pointer; }

@keyframes popIn { 0% { transform: scale(0); } 100% { transform: scale(1); } }

/* --- ГЕНЕРАТОР ОТКРЫТОК (HIDDEN TEMPLATE) --- */
#share-template {
    position: fixed; left: -9999px; top: 0;
    width: 1080px; height: 1920px; /* Full HD Vertical */
    background: #050505;
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    padding: 100px 60px;
    box-sizing: border-box;
    font-family: 'Manrope', sans-serif;
    color: #fff;
    z-index: 9999;
}

/* Декоративная рамка */
#share-template::before {
    content: ''; position: absolute; top: 40px; left: 40px; right: 40px; bottom: 40px;
    border: 2px solid #222; border-radius: 30px; pointer-events: none;
}

/* Логотип сверху */
.st-header {
    text-align: center; margin-bottom: 60px;
}
.st-logo {
    font-family: 'Unbounded'; font-size: 32px; letter-spacing: 4px; color: #666;
    text-transform: uppercase; margin-bottom: 10px;
}
.st-date {
    font-family: 'Unbounded'; font-size: 20px; color: #333;
}

/* Центральная карта */
.st-card-container {
    width: 500px; height: 850px;
    position: relative;
    margin: 0 auto;
    box-shadow: 0 40px 100px rgba(0,0,0,0.8);
}
.st-card-img {
    width: 100%; height: 100%;
    background-size: cover; background-position: center;
    border-radius: 20px; border: 2px solid #444;
}
/* Неоновое свечение за картой */
.st-card-glow {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    opacity: 0.15; z-index: -1;
}

/* Блок текста снизу */
.st-content {
    text-align: center; width: 100%; margin-top: 60px;
}
.st-title {
    font-family: 'Unbounded'; font-size: 48px; color: var(--accent);
    margin-bottom: 30px; text-transform: uppercase;
    text-shadow: 0 0 20px rgba(204, 255, 0, 0.3);
}
.st-text {
    font-size: 28px; line-height: 1.5; color: #ccc;
    max-width: 800px; margin: 0 auto;
    border-top: 2px solid #333; padding-top: 30px;
}
.st-footer {
    margin-top: auto; font-family: 'Unbounded'; font-size: 24px; color: #444;
}

/* ИСПРАВЛЕНИЕ: Шаблон теперь виден, но спрятан за основным контентом */
/* Это гарантирует, что html2canvas его увидит */
#share-template {
    position: fixed; 
    top: 0; left: 0;
    width: 1080px; height: 1920px;
    background: #050505;
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    padding: 100px 60px;
    box-sizing: border-box;
    font-family: 'Manrope', sans-serif;
    color: #fff;
    z-index: -9999; /* Спрятан ПОД сайтом */
    opacity: 0;     /* И невидим */
    pointer-events: none;
    transform: scale(0.1); /* Уменьшен, чтобы не мешать скроллу */
    transform-origin: top left;
}

/* Класс для активации перед снимком */
#share-template.ready-to-shoot {
    opacity: 1;
    z-index: 9999; /* Выводим наверх на долю секунды */
    transform: scale(1); /* Восстанавливаем размер */
}
