/* ==========================================================================
   CARD COUNTING - EXPLANATION SINGLE-PAGE CHEATSHEET CSS
   Stimuludo Design System & Responsive Mobile Layout
   ========================================================================== */

:root {
    --red-suit: var(--accent-color-secondary, #FF4545);
    --black-suit: #1e293b;
    --card-bg-front: #ffffff;
    --card-width: 48px;
    --card-height: 68px;
    --card-gap: 6px;
    --card-radius: calc(var(--card-width) * 0.08);
}

/* Page Layout - Strictly Single Screen / No Scroll */
html, body.explanation-single-page {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body, 'Rubik', sans-serif);
    touch-action: none;
}

#bg-pattern {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* Main Container below fixed site header */
.explanation-main {
    position: fixed;
    inset: 0;
    top: 76px;
    bottom: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    z-index: 1;
    overflow: hidden;
    padding: 8px 0 16px 0;
}

.explanation-layout {
    width: 100%;
    max-width: 860px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0 1rem;
}

.rows-board {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    gap: clamp(8px, 1.8vh, 18px);
    box-sizing: border-box;
    overflow: hidden;
}

/* Row Containers - Card Style with Theme Variables */
.count-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(8px, 2vw, 20px);
    width: 100%;
    max-width: 100%;
    flex: 1;
    min-height: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 8px);
    padding: clamp(6px, 1.2vh, 12px) clamp(8px, 1.8vw, 16px);
    box-sizing: border-box;
    box-shadow: var(--shadow-card, 0 4px 6px -1px rgba(0,0,0,0.08));
    overflow: hidden;
    transition: background-color 0.4s ease, border-color 0.4s ease, transform 0.15s ease;
}

.count-row:hover {
    border-color: color-mix(in srgb, var(--accent-color), var(--border-color) 50%);
}

/* Left Accent Borders according to Stimuludo Theme */
.row-plus {
    border-left: 5px solid var(--accent-color);
}

.row-zero {
    border-left: 5px solid var(--border-color);
}

.row-minus {
    border-left: 5px solid var(--accent-color-secondary, #FF4545);
}

/* Increment Badges using Site Accent Colors */
.count-badge {
    flex-shrink: 0;
    width: clamp(40px, 9vw, 76px);
    height: 100%;
    max-height: clamp(48px, 10vh, 76px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md, 8px);
    font-family: var(--font-heading, 'Rubik', sans-serif);
    font-weight: 700;
    font-size: clamp(1.2rem, 3.8vw, 2.4rem);
    line-height: 1;
    user-select: none;
    box-sizing: border-box;
    transition: all var(--transition-fast);
}

.badge-plus {
    background: color-mix(in srgb, var(--accent-color), transparent 85%);
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 16px var(--accent-glow, rgba(114, 222, 95, 0.25));
}

.badge-zero {
    background: color-mix(in srgb, var(--text-secondary), transparent 88%);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.badge-minus {
    background: color-mix(in srgb, var(--accent-color-secondary, #FF4545), transparent 85%);
    color: var(--accent-color-secondary, #FF4545);
    border: 2px solid var(--accent-color-secondary, #FF4545);
    box-shadow: 0 0 16px var(--accent-glow-secondary, rgba(255, 69, 69, 0.25));
}

/* Cards Row Container - Guaranteed No Overflow */
.row-cards {
    flex: 1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--card-gap, 6px);
    overflow: hidden;
    box-sizing: border-box;
}

/* Playing Card Component */
.playing-card {
    width: var(--card-width);
    height: var(--card-height);
    max-width: calc((100% - (var(--card-gap, 6px) * 4)) / 5);
    max-height: 100%;
    aspect-ratio: 5 / 7;
    position: relative;
    border-radius: var(--card-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    flex-shrink: 0;
    user-select: none;
    box-sizing: border-box;
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease;
}

.playing-card:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    z-index: 5;
}

.card-front {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: var(--card-bg-front, #ffffff);
    border-radius: var(--card-radius);
    overflow: hidden;
    box-sizing: border-box;
    font-family: 'Space Grotesk', var(--font-heading), sans-serif;
    color: var(--black-suit);
    border: 1px solid #cbd5e1;
}

.card-front.red-suit { color: var(--red-suit); }
.card-front.black-suit { color: var(--black-suit); }

.card-front.face-card-mode {
    border: none;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #ffffff;
}

/* Corners */
.card-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-weight: 700;
    width: calc(var(--card-width) * 0.22);
    padding-top: calc(var(--card-width) * 0.05);
    z-index: 2;
}

.card-corner .corner-val {
    font-size: calc(var(--card-width) * 0.22);
    letter-spacing: -1px;
    font-family: 'Space Grotesk', var(--font-heading), sans-serif;
    line-height: 1;
}

.card-corner .corner-val.is-ten {
    letter-spacing: -1.5px;
}

.narrow-zero {
    letter-spacing: -2px;
}

.card-corner .corner-suit {
    font-size: calc(var(--card-width) * 0.11);
    margin-top: 0;
    line-height: 1;
}

.corner-top-left {
    top: 0;
    left: 0;
}

.corner-bottom-right {
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}

/* Face Card SVG */
.face-card-wrapper {
    position: absolute;
    inset: 6%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.face-card-wrapper svg {
    width: 100%;
    height: 100%;
}

/* Pip Layouts */
.card-inner-layout {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--card-width) * 0.15);
    bottom: calc(var(--card-width) * 0.15);
    padding: 0 calc(var(--card-width) * 0.16);
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    box-sizing: border-box;
}

.pip-col {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    flex: 1 1 0px;
    width: 0;
}

.pip-col.mid-col {
    justify-content: center;
    gap: 15%;
}

.pip-symbol {
    font-size: calc(var(--card-width) * 0.22);
    line-height: 1;
}

.pip-symbol.inverted {
    transform: rotate(180deg);
}

.pip-symbol.transparent {
    opacity: 0;
}

/* Ace Layout */
.layout-ace {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.big-ace-symbol {
    font-size: calc(var(--card-width) * 0.58);
    line-height: 1;
}

/* Mobile Screens Adjustments */
@media (max-width: 700px) {
    .explanation-main {
        top: 60px;
        padding: 4px 0 10px 0;
    }
    .explanation-layout {
        padding: 0 8px;
    }
    .rows-board {
        gap: 6px;
    }
    .count-row {
        gap: 6px;
        padding: 4px 6px;
    }
    .count-badge {
        width: 36px;
        font-size: 1.15rem;
    }
}

@media (max-width: 380px) {
    .explanation-layout {
        padding: 0 4px;
    }
    .count-row {
        gap: 4px;
        padding: 4px;
    }
    .count-badge {
        width: 32px;
        font-size: 1rem;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .explanation-main {
        top: 48px;
        padding: 2px 0 4px 0;
    }
    .count-row {
        padding: 2px 6px;
    }
    .count-badge {
        width: 34px;
        max-height: 38px;
        font-size: 1rem;
    }
}
