/* ============================================
   CYOA ENGINE - ОСНОВНЫЕ СТИЛИ v2.3
   ============================================ */

   /* ============================================
   ПОДКЛЮЧЕНИЕ ШРИФТОВ
   ============================================ */

@font-face {
    font-family: 'FF Kaytek Rounded';
    src: url('../fonts/KaytekRounded-Medium.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap; /* Показывает fallback пока шрифт грузится */
}

@font-face {
    font-family: 'FF Kaytek Rounded';
    src: url('../fonts/KaytekRounded-Medium.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ============================================
   ПЕРЕМЕННЫЕ CSS
   ============================================ */
:root {
    --bg-color: #6bb1e0;
    --card-bg: #1E382F;
    --card-border: #D1D1D1;
    --gold: #D4BA61;
    --gold-light: #F5E297;
    --gold-dark: #B1864C;
    --cyan: #4ffefd;
    --text-main: #cddfdf;
    --text-muted: #999;

    --card-glow: rgba(224, 250, 164, 0.5);
    --card-glow-selected: rgba(197, 194, 30, 0.856);
    --card-glow-locked: rgba(0, 0, 0, 0.4);
    
    --transition-speed: 0.4s;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-color);
    font-family: 'Segoe UI', 'Arial', sans-serif;
    margin: 0;
    padding: 40px;
    padding-bottom: 120px;
    min-height: 100vh;
}



/* ============================================
   СЕКЦИИ
   ============================================ */

.cyoa-section {
    max-width: 1600px;
    margin: 0 auto 60px auto;
}

.cyoa-section.hidden { display: none; }

.section-header {
    margin-bottom: 40px;
    text-align: center;
}

.section-title {
    font-size: 2.5rem;
    color: var(--cyan);
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(79, 254, 253, 0.5);
    margin: 0 0 10px 0;
}

.section-description {
    font-size: 1.1rem;
    color: var(--text-main);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
}

.section-limit-info {
    font-size: 0.9rem;
    color: var(--gold);
    margin-top: 10px;
    font-style: italic;
}

.section-story {
    background: linear-gradient(135deg, var(--card-bg), #152820);
    border: 2px solid var(--gold);
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 40px;
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.section-story.image-left { flex-direction: row; }
.section-story.image-right { flex-direction: row-reverse; }
.section-story.image-top { flex-direction: column; }

.section-story-image {
    flex-shrink: 0;
    width: 300px;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--gold-dark);
}

.section-story.image-top .section-story-image {
    width: 100%;
    height: 300px;
}

.section-story-text {
    color: var(--text-main);
    font-size: 1.1rem;
    line-height: 1.8;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 40px 30px;
    padding-bottom: 20px;
}

/* ============================================
   КАРТОЧКИ
   ============================================ */

.card-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: visible;
    container-type: inline-size;
    cursor: pointer;
    will-change: transform;
    contain: layout style;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    /* Плавный переход тени и других эффектов */
    filter: drop-shadow(0 0 20px var(--card-glow));
    transition: 
        filter var(--transition-speed) ease,
        transform 0.3s ease;
}

.card-wrapper:hover .card-inner {
    transform: translateY(-5px);
}

.card-wrapper.selected .card-inner {
    filter: drop-shadow(0 0 30px var(--card-glow-selected));
}

.card-wrapper.selected .card-svg-layer .card-bg-path {
    fill: #0d4a40;
}

/* ============================================
   ЗАТЕМНЕНИЕ ЗАБЛОКИРОВАННЫХ КАРТОЧЕК
   Тень и blur переходят плавно
   ============================================ */

.card-wrapper.locked {
    cursor: not-allowed;
}

/* Плавный переход тени от светлой к тёмной + blur */
.card-wrapper.locked .card-inner {
    transform: none;
    filter: 
        drop-shadow(0 0 15px var(--card-glow-locked))
        blur(1px);
    /* transition унаследован - всё плавно */
}

/* ============================================
   ЗАТЕМНЯЮЩИЙ СЛОЙ - SVG ПОВЕРХ КОНТЕНТА
   ============================================ */

.card-darken-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    pointer-events: none;
    overflow: visible;
}

.card-darken-path {
    fill: rgba(0, 0, 0, 0);
    transition: fill var(--transition-speed) ease;
}

.card-wrapper.locked .card-darken-path {
    fill: rgba(0, 0, 0, 0.55);
}

/* ============================================
   ОВЕРЛЕЙ БЛОКИРОВКИ (текст причины)
   ============================================ */

.lock-overlay {
    display: flex;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    padding: 0 10px;
    z-index: 200;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    background: transparent;
    border: none;
    transition: opacity var(--transition-speed) ease;
}

.card-wrapper.locked .lock-overlay {
    opacity: 1;
}

.lock-reason {
    font-size: 0.9rem; 
    font-weight: 900;
    color: #ffffff;
    text-transform: uppercase;
    line-height: 1.2;
    letter-spacing: 2px;
    text-shadow: 
        0 2px 4px #000000, 
        0 2px 8px #000000,
        0 0 20px rgba(255, 215, 0, 0.9),
        0 0 40px rgba(255, 165, 0, 0.6);
    white-space: pre-line;
    word-wrap: break-word;
}

/* ============================================
   ИНДИКАТОР ВЫБОРА - МАГИЧЕСКИЙ КРИСТАЛЛ
   ============================================ */

.corner-diamond-default {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.selection-crystal {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-wrapper.selected .corner-diamond-default {
    opacity: 0;
}

.card-wrapper.selected .selection-crystal {
    opacity: 1;
}

.card-bg-path {
    stroke: #D1D1D1;
    transition: stroke var(--transition-speed) ease, fill var(--transition-speed) ease;
}

.card-wrapper.selected .card-bg-path {
    stroke: #D4BA61;
    fill: #0d4a40;
}

.card-wrapper.selected:hover .card-bg-path {
    stroke: #e4c04a;
}

/* SVG слой */
.card-svg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: visible;
    pointer-events: none;
}

.card-body {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 158cqw;
}

.image-spacer {
    width: 100%;
    padding-top: 86%;
    flex-shrink: 0;
}

.text-container {
    padding: 0 8cqw 8cqw 8cqw;
    text-align: center;
    color: var(--text-main);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

/* Заголовок */
.card-header {
    margin-top: 0;
    margin-bottom: 0;
    position: relative;
    z-index: 10;
}

.card-title {
    margin: 0 0 1cqw 0;
    color: var(--cyan);
    font-size: 9cqw;
    font-family: 'FF Kaytek Rounded', 'Arial', sans-serif;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(79, 254, 253, 0.3);
    line-height: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-speed) ease, text-shadow var(--transition-speed) ease;
}

.card-wrapper.selected .card-title {
    color: #7fffba;
    text-shadow: 0 0 15px rgba(127, 255, 186, 0.5);
}

/* ============================================
   ОЧКИ КАРТОЧКИ - ЛИНИЯ С ПРОЁМОМ
   ============================================ */

.card-points {
    color: #ccc;
    font-style: italic;
    font-size: 4.5cqw;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3cqw;
    margin-left: 10cqw;
    margin-right: 10cqw;
    width: calc(100% - 20cqw);
    box-sizing: border-box;
}

.card-points.cost-positive { color: #7fffba; }
.card-points.cost-negative { color: #ff9999; }

.card-points::before,
.card-points::after {
    content: "";
    display: block;
    flex: 1 1 0;
    min-width: 1cqw;
    height: 0.5cqw;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--gold-dark));
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(212, 186, 97, 0.5);
}

.card-points:empty::before,
.card-points:empty::after {
    display: none;
}

/* Текст */
.card-text {
    font-size: 4cqw;
    line-height: 1.4;
    margin-bottom: 2cqw;
    margin-top: 0;
}

.card-text::before {
    content: "";
    float: left;
    width: 4cqw;
    height: 1.3em;
}

.text-span::before {
    content: "";
    float: right;
    width: 4cqw;
    height: 1.3em;
}

.text-span::after {
    content: "";
    float: left;
    width: 4cqw;
    height: 2.3em;
}

/* ============================================
   ПЛАВНОЕ ПОЯВЛЕНИЕ ИЗОБРАЖЕНИЙ
   ============================================ */

.card-image {
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

.card-image.loaded {
    opacity: 1;
}

/* ============================================
   КЛАСС КАРТОЧКИ - SVG TEXT
   ============================================ */

.card-class-svg {
    font-family: 'FF Kaytek Rounded', 'Arial', sans-serif;
    font-size: 28px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
    fill: var(--gold);
    pointer-events: none;
}

.card-class-svg.legendary { fill: #ff9900; }
.card-class-svg.epic { fill: #a855f7; }
.card-class-svg.rare { fill: #3b82f6; }
.card-class-svg.common { fill: #9ca3af; }
.card-class-svg.origin { fill: #22c55e; }

/* ============================================
   ПАНЕЛЬ ОЧКОВ - АДАПТИВНАЯ
   ============================================ */

#point-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 20, 20, 0.98), rgba(0, 30, 30, 0.95));
    border-top: 2px solid var(--gold);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.bar-button {
    background: rgba(212, 186, 97, 0.2);
    border: 2px solid var(--gold);
    color: var(--gold);
    font-size: 1.5rem;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bar-button:hover {
    background: rgba(212, 186, 97, 0.4);
    transform: scale(1.05);
}

/* Кнопка музыки - состояние muted */
.bar-button.muted {
    border-color: #ff6b6b;
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
}

.bar-button.muted:hover {
    background: rgba(255, 107, 107, 0.3);
}

#points-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    flex-grow: 1;
}

.point-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    font-size: 1.1rem;
}

.point-icon { font-size: 1.3rem; }
.point-name { color: var(--text-muted); font-size: 0.85rem; }

.point-value {
    font-weight: bold;
    font-size: 1.3rem;
    color: var(--cyan);
    min-width: 40px;
    text-align: right;
    transition: color 0.3s ease;
}

.point-value.negative { color: #ff6b6b; }
.point-value.positive { color: #7fffba; }

/* ============================================
   МОДАЛЬНОЕ ОКНО
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: linear-gradient(135deg, #1a2f2a, #0d1f1a);
    border: 2px solid var(--gold);
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #ff6b6b;
}

.modal-title {
    color: var(--cyan);
    text-align: center;
    margin: 0 0 25px 0;
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.modal-section {
    margin-bottom: 25px;
}

.modal-section h3 {
    color: var(--gold);
    font-size: 1rem;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0 0 10px 0;
}

.modal-section textarea {
    width: 100%;
    height: 120px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--gold-dark);
    border-radius: 8px;
    color: var(--text-main);
    font-family: monospace;
    font-size: 0.85rem;
    padding: 12px;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.modal-section textarea:focus {
    outline: none;
    border-color: var(--gold);
}

.modal-section textarea[readonly] {
    background: rgba(0, 0, 0, 0.6);
    cursor: default;
}

.modal-btn {
    width: 100%;
    padding: 12px 20px;
    background: rgba(212, 186, 97, 0.2);
    border: 2px solid var(--gold);
    border-radius: 8px;
    color: var(--gold);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
}

.modal-btn:hover {
    background: rgba(212, 186, 97, 0.4);
    transform: translateY(-2px);
}

.modal-btn-danger {
    border-color: #ff6b6b;
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
}

.modal-btn-danger:hover {
    background: rgba(255, 107, 107, 0.3);
}

.modal-actions {
    border-top: 1px solid rgba(212, 186, 97, 0.3);
    padding-top: 20px;
}

.modal-message {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    margin-top: 15px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-message.visible {
    opacity: 1;
}

.modal-message.success {
    background: rgba(127, 255, 186, 0.2);
    color: #7fffba;
}

.modal-message.error {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */

@media (max-width: 768px) {
    body {
        padding: 15px;
        padding-bottom: 90px;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .section-title {
        font-size: 1.8rem;
    }

    .section-story {
        flex-direction: column !important;
        padding: 20px;
    }

    .section-story-image {
        width: 100% !important;
        height: 180px;
    }

    #point-bar {
        padding: 10px 15px;
        gap: 10px;
    }

    .bar-button {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
    }

    #points-container {
        gap: 15px;
    }

    .point-item {
        font-size: 0.9rem;
        gap: 5px;
    }

    .point-icon { font-size: 1.1rem; }
    .point-name { 
        display: none;
    }
    .point-value {
        font-size: 1.1rem;
        min-width: 35px;
    }

    .modal-content {
        padding: 20px;
        margin: 10px;
    }

    .modal-title {
        font-size: 1.2rem;
    }

    .lock-reason { 
        font-size: 0.75rem; 
        letter-spacing: 1px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
        padding-bottom: 80px;
    }

    #point-bar {
        padding: 8px 10px;
    }

    .bar-button {
        width: 35px;
        height: 35px;
        font-size: 1.1rem;
    }

    #points-container {
        gap: 10px;
    }

    .point-item {
        flex-direction: column;
        gap: 2px;
    }

    .point-value {
        font-size: 1rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    body {
        background: white;
        padding: 20px;
    }

    #point-bar,
    .modal-overlay,
    .lock-overlay,
    .card-darken-layer {
        display: none !important;
    }

    .card-wrapper {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .card-wrapper.locked {
        opacity: 0.5;
    }
}