/* ========================================================================
   KLONDIKE SOLITAIRE
   Kartengrafiken: wwwroot/images/cards (SVG, Vorder- und Rueckseiten)
   ======================================================================== */

/* --- CSS Custom Properties --- */
:root {
    /* Seitenverhaeltnis der Kartengrafiken: 58.60mm : 89.08mm = 0.658 */
    --sol-card-width: 92px;
    --sol-card-height: 140px;
    /* Eckenradius der Grafiken: 4.49% der Kartenbreite */
    --sol-card-radius: 4px;
    --sol-card-gap: 12px;
    --sol-tableau-face-down-offset: 8px;
    --sol-tableau-face-up-offset: 28px;
    --sol-felt-color: #1a6b3c;
    --sol-felt-dark: #145a30;
    --sol-card-bg: #fefefe;
    /* Erster Schatten = Haarlinien-Kontur (kein border, damit die Kartenmasse
       im content-box-Modell exakt bleiben). */
    --sol-card-shadow: 0 0 0 1px rgba(29, 29, 30, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
    --sol-card-shadow-hover: 0 0 0 1px rgba(29, 29, 30, 0.45), 0 4px 12px rgba(0, 0, 0, 0.4);
    --sol-gold: #c8a84e;
    --sol-gold-light: #e8c86e;
}

/* --- Game Board (Filz-Hintergrund) --- */
.sol-game-container {
    background:
        radial-gradient(ellipse at center, var(--sol-felt-color) 0%, var(--sol-felt-dark) 100%);
    background-color: var(--sol-felt-color);
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    font-family: 'Georgia', 'Times New Roman', 'Palatino Linotype', serif;
}

/* --- Game Board Layout --- */
.sol-board {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 820px;
    margin: 0 auto;
}

.sol-top-row {
    display: flex;
    gap: var(--sol-card-gap);
    align-items: flex-start;
}

.sol-stock-waste {
    display: flex;
    gap: var(--sol-card-gap);
    flex-shrink: 0;
}

.sol-spacer {
    flex: 1;
    min-width: 20px;
}

.sol-foundations {
    display: flex;
    gap: var(--sol-card-gap);
    flex-shrink: 0;
}

.sol-tableau-row {
    display: flex;
    gap: var(--sol-card-gap);
    align-items: flex-start;
}

/* --- Card Base --- */
.sol-card-slot {
    width: var(--sol-card-width);
    height: var(--sol-card-height);
    border-radius: var(--sol-card-radius);
    flex-shrink: 0;
}

.sol-card {
    width: var(--sol-card-width);
    height: var(--sol-card-height);
    border-radius: var(--sol-card-radius);
    position: relative;
    cursor: default;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
}

.sol-card.face-up {
    background: var(--sol-card-bg);
    box-shadow: var(--sol-card-shadow);
    cursor: grab;
}

/* --- Kartengrafik (SVG) ---
   Die SVGs sind transparent und bringen ihre eigene Kontur mit; die
   Kartenflaeche kommt aus dem Hintergrund des .sol-card-Containers. */
.sol-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

.sol-card.face-up:hover {
    box-shadow: var(--sol-card-shadow-hover);
    transform: translateY(-2px);
}

/* Waehrend eines Drags reagiert das Board nicht auf den Zeiger. Die
   Trefferpruefung laeuft ueber die zwischengespeicherten Rechtecke in
   solitaire.js, nicht ueber den DOM - :hover wird also nicht gebraucht.
   Ohne das startet jede ueberstrichene Karte eine 150ms-Transition und
   muss neu gezeichnet werden.

   Hinweis: Hover hier NICHT ueber "z-index: auto" neutralisieren - die
   Tableau-Karten tragen ein Inline-z-index, und positionierte Elemente mit
   positivem z-index werden nach denen mit auto gezeichnet. Die ueberfahrene
   Karte fiele damit hinter ihre eigene Saeule. */
.sol-is-dragging .sol-card,
.sol-is-dragging .sol-tableau-pile,
.sol-is-dragging .sol-foundation-slot {
    pointer-events: none;
    transition: none;
}

/* Gezogene Karten verschwinden an der Herkunftsstelle komplett - sie haengen
   ja am Zeiger. visibility statt display, damit die Saeule ihre Hoehe behaelt;
   unsichtbare Elemente werden gar nicht erst gezeichnet. */
.sol-card.dragging {
    visibility: hidden;
}

/* --- Card Back --- */
.sol-card.face-down {
    background: var(--sol-card-bg);
    box-shadow: var(--sol-card-shadow);
    overflow: hidden;
}

/* --- Stock (Talon) --- */
.sol-stock {
    position: relative;
    cursor: pointer;
}

.sol-stock:hover {
    transform: translateY(-2px);
}

.sol-stock-empty {
    width: var(--sol-card-width);
    height: var(--sol-card-height);
    border-radius: var(--sol-card-radius);
    border: 2px dashed rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.sol-stock-empty:hover {
    border-color: rgba(255, 255, 255, 0.5);
}

.sol-stock-refresh {
    font-size: 28px;
    color: rgba(255, 255, 255, 0.35);
}

/* --- Waste (Ablagestapel) --- */
.sol-waste {
    position: relative;
    width: var(--sol-card-width);
    height: var(--sol-card-height);
}

/* --- Foundation Slots --- */
.sol-foundation-slot {
    width: var(--sol-card-width);
    height: var(--sol-card-height);
    border-radius: var(--sol-card-radius);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.sol-foundation-slot .sol-foundation-suit {
    font-size: 32px;
    opacity: 0.2;
    color: #fff;
}

.sol-foundation-slot .sol-card {
    position: absolute;
    top: 0;
    left: 0;
}

/* Belegtes Ablagefeld: eigener Rahmen weicht der Karte, sonst stehen zwei
   Konturen uebereinander. Rahmenbreite auf 0 statt nur transparent - die
   Karte liegt absolut an der Innenkante, bliebe der Rahmen 2px breit, saesse
   sie um genau diese 2px versetzt. Das Aussenmass bleibt dank border-box
   unveraendert. */
.sol-foundation-slot.sol-slot-filled {
    border-width: 0;
}

.sol-foundation-slot.drop-target-hover {
    border-color: var(--sol-gold);
    background: rgba(200, 168, 78, 0.15);
}

/* --- Tableau Piles --- */
.sol-tableau-pile {
    width: var(--sol-card-width);
    min-height: var(--sol-card-height);
    position: relative;
    border-radius: var(--sol-card-radius);
    transition: background 0.2s ease, border-color 0.2s ease;
    border: 2px dashed transparent;
}

.sol-tableau-pile.empty-pile {
    border-color: rgba(255, 255, 255, 0.15);
}

.sol-tableau-pile .sol-card {
    position: absolute;
    left: 0;
}

.sol-tableau-pile.drop-target-hover {
    background: rgba(200, 168, 78, 0.12);
}

.sol-tableau-pile.drop-target-hover.empty-pile {
    border-color: var(--sol-gold);
    background: rgba(200, 168, 78, 0.15);
}

/* --- Drag Ghost ---
   Wird per transform bewegt (siehe solitaire.js) und liegt dadurch auf einer
   eigenen Compositor-Ebene: Verschieben kostet weder Layout noch Repaint. */
.sol-drag-ghost {
    width: var(--sol-card-width);
    pointer-events: none;
    z-index: 10000;
    transform-origin: top left;
    will-change: transform;
}

.sol-drag-ghost .sol-card {
    box-shadow: 0 0 0 1px rgba(29, 29, 30, 0.45), 0 8px 24px rgba(0, 0, 0, 0.5);
    transform: rotate(2deg);
    transition: none;
}

/* --- Win Screen --- */
.sol-win-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 20000;
    animation: solFadeIn 0.5s ease;
    backdrop-filter: blur(6px);
}

.sol-win-card {
    background: linear-gradient(135deg, #1a3a6b 0%, #2a5a8b 100%);
    border: 3px solid var(--sol-gold);
    border-radius: 16px;
    padding: 40px 60px;
    text-align: center;
    color: #e8e0d0;
    box-shadow: 0 0 60px rgba(200, 168, 78, 0.3);
    animation: solScaleIn 0.5s ease 0.2s both;
}

.sol-win-title {
    font-size: 36px;
    font-weight: 700;
    color: var(--sol-gold-light);
    margin-bottom: 16px;
    font-variant: small-caps;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.sol-win-stats {
    font-size: 16px;
    margin-bottom: 24px;
    line-height: 1.8;
}

.sol-win-stats strong {
    color: var(--sol-gold-light);
}

@keyframes solFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes solScaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* --- Firework Animation for Win --- */
.sol-firework {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: solFirework 1.5s ease-out infinite;
}

@keyframes solFirework {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--fw-x), var(--fw-y)) scale(0); opacity: 0; }
}

/* --- Responsive ---
   Breite immer aus der Hoehe abgeleitet, damit das Seitenverhaeltnis der
   Kartengrafiken erhalten bleibt (Hoehe x 0.658). */
@media (max-width: 900px) {
    :root {
        --sol-card-width: 74px;
        --sol-card-height: 112px;
        --sol-card-gap: 8px;
        --sol-tableau-face-down-offset: 6px;
        --sol-tableau-face-up-offset: 22px;
        --sol-card-radius: 3px;
    }
}

@media (max-width: 650px) {
    :root {
        --sol-card-width: 55px;
        --sol-card-height: 84px;
        --sol-card-gap: 5px;
        --sol-tableau-face-down-offset: 5px;
        --sol-tableau-face-up-offset: 18px;
        --sol-card-radius: 2px;
    }

    .sol-win-card { padding: 24px 32px; }
    .sol-win-title { font-size: 24px; }
}

/* --- Auto-Complete Button --- */
.sol-auto-complete-btn {
    animation: solPulse 2s ease-in-out infinite;
    border-color: var(--sol-gold) !important;
    background: rgba(200, 168, 78, 0.25) !important;
    color: var(--sol-gold-light) !important;
}

@keyframes solPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(200, 168, 78, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(200, 168, 78, 0); }
}

/* --- Card Flip Animation --- */
.sol-card-flip {
    animation: solCardFlip 0.3s ease;
}

@keyframes solCardFlip {
    0% { transform: scaleX(1); }
    50% { transform: scaleX(0); }
    100% { transform: scaleX(1); }
}
