/* ==========================================================================
   KARTY - WYGLĄD, KOLORYSTYKA I REWERSY
   ========================================================================== */

.card { 
    width: 180px; 
    height: 250px; 
    background-color: #ecf0f1; 
    border-radius: 12px; 
    padding: 10px; 
    cursor: pointer; 
    display: flex; 
    flex-direction: column; 
    font-size: 0.85em; 
    transition: transform 0.2s, box-shadow 0.2s; 
    border: 4px solid #bdc3c7; 
    position: relative; 
    box-sizing: border-box; 
    user-select: none;
    color: #2c3e50; /* Ciemny tekst na jasnym tle kart */
}

.card:hover { 
    transform: translateY(-15px) scale(1.05); 
    box-shadow: 0 15px 30px rgba(0,0,0,0.5); 
    z-index: 100;
}

/* --- KOLORY KART (BORDER & BG) --- */
.card-green { border-color: var(--green); background: linear-gradient(135deg, #fff, #e8f8f5); }
.card-red   { border-color: var(--red);   background: linear-gradient(135deg, #fff, #fdecea); }
.card-blue  { border-color: var(--blue);  background: linear-gradient(135deg, #fff, #ebf5fb); }

/* Karta Hybrydowa (Zielono-Czerwona) - NAPRAWIONE KOLORY */
.card-greenred { 
    border-top-color: var(--green);
    border-left-color: var(--green);
    border-bottom-color: var(--red);
    border-right-color: var(--red);
    background: linear-gradient(135deg, #e8f8f5 0%, #fff 50%, #fdecea 100%); 
}

/* ==========================================================================
   STRUKTURA KARTY (ZGODNA Z UICardRenderer.js)
   ========================================================================== */

.card-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
}

/* --- NAGŁÓWEK KARTY --- */
.card-header-physical {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid rgba(0,0,0,0.1);
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.category-circle {
    width: 24px;
    height: 24px;
    background: #34495e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8em;
    box-shadow: inset 0 0 4px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

.card-title-text {
    font-weight: bold;
    font-size: 1em;
    line-height: 1.1;
    text-transform: uppercase;
    color: #111;
}

/* --- MIEJSCE NA ART / ZNACZNIKI CZASU --- */
.card-art-placeholder {
    flex-grow: 1;
    background: rgba(0,0,0,0.03);
    border-radius: 4px;
    border: 1px inset rgba(0,0,0,0.1);
    margin-bottom: 8px;
    position: relative;
    min-height: 40px;
}

.badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 0.7em;
    padding: 2px 5px;
    border-radius: 3px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    letter-spacing: 0.5px;
}
.badge.delayed { background: #8e44ad; color: #fff; border: 1px solid #9b59b6; }
.badge.instant { background: #f39c12; color: #fff; border: 1px solid #f1c40f; }

/* --- DOLNA CZĘŚĆ (FLAVOR I OPIS EFEKTU) --- */
.card-bottom-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-flavor-box {
    font-style: italic;
    font-size: 0.75em;
    color: #7f8c8d;
    text-align: center;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
    padding-bottom: 5px;
    line-height: 1.2;
}

.card-description-list {
    font-size: 0.78em;
    color: #222;
    line-height: 1.3;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.desc-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.desc-icon-container {
    flex-shrink: 0;
    margin-top: 1px;
}

.desc-icon {
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.8em;
    color: white;
}
.triangle-up { background: var(--green-dark); }
.triangle-down { background: var(--red-dark); }
.icon-discard { background: #555; }
.desc-bullet { color: #34495e; font-weight: bold; }

/* Linia oddzielająca (zgodnie ze specyfikacją '----') */
.card-divider {
    width: 90%;
    height: 1px;
    background: rgba(0,0,0,0.2);
    margin: 2px auto;
}

/* ==========================================================================
   STANY KART I REWERSY
   ========================================================================== */

.card-back { 
    background-color: #2c3e50; 
    background-image: url('../grafiki/backside6.jpg'); 
    background-size: cover; 
    border: 4px solid var(--gold-dim); 
}

.card.selected { 
    box-shadow: 0 0 20px var(--gold); 
    transform: translateY(-25px); 
    border-style: dashed;
}

/* --- KARTY NA STOSIE I W ANIMACJI --- */
.animating-card { 
    position: fixed; 
    z-index: 10000; 
    pointer-events: none; 
    transition: all 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); 
}

.card-on-pile { 
    width: 150px; 
    height: 210px; 
    font-size: 0.75em; 
    margin-bottom: -160px; /* Efekt wachlarza na stosie */
    box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
}
/* karta zakryta (używana w animacjach dobierania) */
.card-none { border-color: #555; background: linear-gradient(135deg, #2c2c2c, #444); }

/* ==========================================================================
   SQ-CARD SYSTEM (CardDOMBuilder v5)
   ========================================================================== */

.sq-card-wrapper {
    display: inline-block;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    margin: 0 6px;
    vertical-align: top;
    width: 175px;
    flex-shrink: 0;
}

.sq-card-wrapper:hover {
    transform: translateY(-18px) scale(1.08) !important;
    z-index: 100;
    box-shadow: 0 20px 40px rgba(0,0,0,0.7), 0 0 15px rgba(255,255,255,0.1);
}

.sq-card {
    width: 175px;
    height: 260px;
    perspective: 1000px;
    position: relative;
    box-sizing: border-box;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Wewnętrzny kontener obracany w 3D */
.sq-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform-style: preserve-3d;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.08);
    border-radius: 12px;
}

/* Stan odwrócony (rewers do widza) */
.sq-card.sq-card-is-flipped .sq-card-inner {
    transform: rotateY(180deg);
}

/* Obie strony karty (awers/rewers) */
.sq-card-front, .sq-card-back {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 12px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Front (awers) */
.sq-card-front {
    background: transparent;
    border: 3px solid #bdc3c7;
    color: #2c3e50;
    font-family: 'Segoe UI', 'Crimson Text', serif;
    transform: translateZ(1px);
}

/* Tył (rewers) */
.sq-card-back {
    background: #2c3e50;
    border: 3px solid var(--gold-dim, #b8860b);
    transform: rotateY(180deg) translateZ(1px);
}

.sq-card-back-bg {
    width: 100%;
    height: 100%;
    background: url('../grafiki/backside6.jpg') center/cover;
}

/* Kolory frontu per klasa koloru — tylko border (tło pokrywa .sq-card-bg) */
.sq-card-red .sq-card-front     { border-color: #c0392b; }
.sq-card-green .sq-card-front   { border-color: #27ae60; }
.sq-card-blue .sq-card-front    { border-color: #2980b9; }
.sq-card-greenred .sq-card-front {
    border-image: linear-gradient(135deg, #27ae60, #c0392b) 1;
}

/* Card background image layer */
.sq-card-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
    opacity: 1;
    pointer-events: none;
}

.sq-card-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
 /*   padding: 7px 8px; */
    overflow: hidden;
    font-size: 0.82em;
}

/* Header */
.sq-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
    border-bottom: 5px solid #77d800;
    padding: 5px;
    background: rgba(103,103,103,0.7);
}

.sq-header-top {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
}

.sq-cat-icon { font-size: 1.1em; }
.sq-card-name {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.82em;
    text-transform: uppercase;
    line-height: 1.1;
    color: #fff;
}

.sq-header-badges {
    display: flex;
    gap: 3px;
}

.sq-badge {
    width: 20px; height: 20px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65em; font-weight: bold;
    background: #34495e; color: #fff;
    box-shadow: inset 0 0 3px rgba(0,0,0,0.4);
}
.sq-badge-id { background: #7f8c8d; font-size: 0.5em; }

/* Middle section (art area) */
.sq-section-middle {
    flex: 1;
    min-height: 35px;
    position: relative;
    margin-bottom: 4px;
}

/* Footer */
.sq-section-footer { 
    display: flex;
    flex-direction: column; 
    gap: 4px;     
    padding: 7px;
    background: rgba(65,65,65,0.7);
    border-top: 3px solid #77d800;
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

/* === HEADER & FOOTER COLOR GRADIENTS (per card color) === */

/* RED cards */
.sq-card-red .sq-section-header {
    background: linear-gradient(-68deg, rgba(210,0,0,0.7), rgba(81,0,0,0.7));
}
.sq-card-red .sq-section-footer {
    background: linear-gradient(-68deg, rgba(119,0,0,0.7), rgba(35,16,16,0.7), rgba(119,0,0,0.7));
}

/* GREEN cards */
.sq-card-green .sq-section-header {
    background: linear-gradient(-68deg, rgba(170,140,210,0.7), rgba(0,81,16,0.7));
}
.sq-card-green .sq-section-footer {
    background: linear-gradient(-68deg, rgba(0,119,12,0.7), rgba(16,35,18,0.7), rgba(0,119,12,0.7));
}

/* BLUE cards */
.sq-card-blue .sq-section-header {
    background: linear-gradient(-68deg, rgba(96,150,219,0.7), rgba(0,6,252,0.7));
}
.sq-card-blue .sq-section-footer {
    background: linear-gradient(-68deg, rgba(28,0,119,0.7), rgba(48,58,98,0.7), rgba(28,0,119,0.7));
}

/* GREEN-RED (hybrid) cards — uses RED color scheme for now */
.sq-card-greenred .sq-section-header {
    background: linear-gradient(-68deg, rgba(210,0,0,0.7), rgba(81,0,0,0.7));
}
.sq-card-greenred .sq-section-footer {
    background: linear-gradient(-68deg, rgba(119,0,0,0.7), rgba(35,16,16,0.7), rgba(119,0,0,0.7));
}

.sq-flavor-text {
    font-style: italic;
    font-size: 0.65em;
    color: #f8ee96;
    text-align: center;
    line-height: 1.15;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
    padding-bottom: 2px;
    margin-bottom: 2px;
    max-height: 24px;
    overflow: hidden;
}

.sq-actions-container {
    display: flex;
    gap: 3px;
    font-size: 0.68em;
    line-height: 1.2;
    overflow: hidden;
    flex: 1;
}

.sq-actions-col-icons {
    display: flex; flex-direction: column; gap: 2px;
    align-items: center; width: 18px; flex-shrink: 0;
}
.sq-actions-col-texts { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sq-action-icon { font-size: 0.9em; color: #34495e; }
.sq-action-text { color: #fff; }

/* === SELECTION & ACTIVE STATES === */

/* Wrapper: obsługuje tylko uniesienie i blask (bez border-radius gap) */
.sq-card-selected {
    transform: translateY(-20px) !important;
}

/* Blask i obramowanie na wewnętrznym .sq-card – ma border-radius 12px,
   więc box-shadow ściśle obrysowuje zaokrąglone rogi bez luki */
.sq-card-selected .sq-card {
    box-shadow:
        0 0 0 3px #f1c40f,
        0 0 18px 6px rgba(241, 196, 15, 0.75),
        0 8px 20px rgba(0,0,0,0.6) !important;
    animation: sq-pulse-gold 1.5s infinite;
}

@keyframes sq-pulse-gold {
    0%, 100% {
        box-shadow:
            0 0 0 2px #f1c40f,
            0 0 10px 3px rgba(241, 196, 15, 0.5),
            0 8px 20px rgba(0,0,0,0.6);
    }
    50% {
        box-shadow:
            0 0 0 3px #ffe066,
            0 0 26px 8px rgba(241, 196, 15, 0.9),
            0 8px 20px rgba(0,0,0,0.6);
    }
}

.sq-active-player {
    border-color: #f1c40f !important;
    box-shadow: 0 0 12px rgba(241, 196, 15, 0.4);
}

.sq-eliminated {
    opacity: 0.4;
    filter: grayscale(0.8);
}

/* === ACTION SEPARATOR (multi-payload cards) === */
.sq-action-sep {
    width: 100%;
    height: 1px;
    background: rgba(255,255,255,0.15);
    margin: 2px 0;
    opacity: 0.6;
}

.sq-actions-col-icons .sq-action-sep {
    width: 16px;
    height: 1px;
}

/* Self-effect sub-row (dimmed, italic) */
.sq-self-effect {
    color: rgba(255,255,255,0.55) !important;
    font-style: italic;
    font-size: 0.9em;
}

/* === VALIDATION BADGE on card === */
.sq-validation-errors {
    position: absolute;
    top: 4px; right: 4px;
    background: rgba(231,76,60,0.9);
    color: white;
    font-size: 0.55em;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 3px;
    z-index: 10;
}


/* ==========================================================================
   v5.3 PATCHES — Ikony trybu, kompozycje, stos odrzuconych
   ========================================================================== */

/* --- IKONA TRYBU WYKONANIA (INSTANT ⚡ / DELAYED ⏳) --- */

.sq-cat-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.sq-timing-icon {
    font-size: 0.7em;
    line-height: 1;
    background: rgba(0,0,0,0.45);
    border-radius: 3px;
    padding: 1px 3px;
    letter-spacing: 0;
}

/* Kolor tła ikony zależny od trybu */
.sq-card-greenred .sq-timing-icon,
.sq-card-blue .sq-timing-icon { color: #f1c40f; }
.sq-card-red   .sq-timing-icon { color: #f39c12; }
.sq-card-green .sq-timing-icon { color: #2ecc71; }

/* INSTANT — wyróżnienie pomarańczowe na wrapperze (wąska kreska na górze) */
.sq-card-wrapper[data-timing="INSTANT"] .sq-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #f39c12, #f1c40f, #f39c12);
    border-radius: 12px 12px 0 0;
    z-index: 10;
}

/* DELAYED — fioletowe */
.sq-card-wrapper[data-timing="DELAYED"] .sq-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #8e44ad, #9b59b6, #8e44ad);
    border-radius: 12px 12px 0 0;
    z-index: 10;
}

/* --- KOMPOZYCJE IKON ATOMOWYCH --- */

.sq-icon-composition {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1px;
    flex-wrap: nowrap;
    line-height: 1;
}

.sq-icon-atom {
    font-size: 0.75em;
    line-height: 1;
    display: inline-block;
    cursor: default;
}

/* Ikony w kolumnie ikon są teraz flexboxem złożeń */
.sq-actions-col-icons {
    width: auto;
    min-width: 20px;
    max-width: 52px;
}

/* --- FIZYCZNY STOS ODRZUCONYCH KART --- */

#discard-pile {
    position: relative;
    min-height: 60px;
    overflow: visible;
    display: flex;
    align-items: flex-end;
}

/* Wachlarze kart na stosie odrzuconych */
#discard-pile .sq-card-wrapper {
    position: absolute !important;
    /* Konkretne wartości nadaje JS (bottom, left, z-index, rotate) */
    transform-origin: bottom left !important;
    margin: 0 !important;
    cursor: default;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

/* Karta na wierzchu stosu — hover z podglądem */
#discard-pile .sq-card-wrapper:last-child {
    cursor: pointer !important;
}

#discard-pile .sq-card-wrapper:last-child:hover {
    transform: scale(0.7) rotate(0deg) translateY(-10px) !important;
    z-index: 999 !important;
    opacity: 1 !important;
}

/* Placeholder ukryty gdy są karty */
.discard-placeholder {
    font-size: 1.8em;
    color: #444;
    margin: auto;
    pointer-events: none;
}

/* Legenda miniaturki na wierzchu stosu */
#discard-pile::after {
    content: attr(data-top-card);
    position: absolute;
    bottom: -18px;
    left: 0; right: 0;
    text-align: center;
    font-size: 0.6em;
    color: #666;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

