/**
 * Noos Network — Unified Card System v1.2.5
 * assets/css/cards.css
 */

/* ─── 1. Design Tokens ─────────────────────────────────────────── */
:root {
    --gold-foil:      #c5a059;
    --gold-light:     #e8c97a;
    --gold-dark:      #9a7a3a;
    --card-bg:        #fdfcf8;
    --card-back-top:  #b45309;
    --card-back-bot:  #8b4513;
    --card-border:    rgba(0, 0, 0, 0.08);
    --card-shadow:    0 4px 15px rgba(0, 0, 0, 0.08);
    --slate:          #334155;
    --amber:          #b45309;
    --radius-card:    10px;
    --radius-inner:   7px;
    --card-w:         100px;
    --card-h:         calc(var(--card-w) * 1.4);
}

/* ─── 2. Card Shell & Flip Mechanics ───────────────────────────── */
.noos-card {
    width:  var(--card-w);
    height: var(--card-h);
    position: relative;
    cursor: pointer;
    perspective: 1000px;
    font-family: 'Quicksand', sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.noos-card.is-flipped .card-inner {
    transform: rotateY(180deg);
}
.noos-card.face-down .card-inner {
    transform: rotateY(0deg);
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-card);
    box-sizing: border-box;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ─── 3. Card Back (Intricate Geometric Engraving Style) ────────── */
.card-back {
    background: radial-gradient(ellipse at center, var(--card-back-top) 0%, var(--card-back-bot) 100%);
    border: 2px solid var(--gold-foil);
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.4), inset 0 0 6px rgba(197, 160, 89, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transform: rotateY(0deg);
}

/* Container layer for tracking premium back corner filigrees */
.card-back-swirls {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    border-radius: var(--radius-card);
    overflow: hidden;
}

/* Intricate, highly detailed architectural vector frame corners */
.card-back::before,
.card-back::after,
.card-back-swirls::before,
.card-back-swirls::after {
    content: "";
    position: absolute;
    width:  44%;
    height: 44%;
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    opacity: 0.95;
    z-index: 2;
}

/* High-detail nested line patterns mimicking luxury stamped banknote frames */
.card-back::before { top: 4%; left: 4%; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50' fill='none' stroke='%23e8c97a' stroke-width='1'%3E%3Cpath d='M2,2 H45 M2,2 V45 M6,6 H38 M6,6 V38 M10,10 H31 M10,10 V31' stroke-opacity='0.35'/%3E%3Cpath d='M2,2 L14,14 M6,6 L14,14 M45,2 L25,22 M2,45 L22,25' stroke-width='0.75' stroke-opacity='0.5'/%3E%3Cpath d='M2,2 Q20,2 20,20 Q2,20 2,2 Z M6,6 Q16,6 16,16 Q6,16 6,6 Z' stroke='%23c5a059' stroke-width='0.75'/%3E%3Ccircle cx='14' cy='14' r='1.5' fill='%23e8c97a'/%3E%3Ccircle cx='3' cy='3' r='1' fill='%239a7a3a'/%3E%3C/svg%3E"); }
.card-back::after  { bottom: 4%; right: 4%; transform: rotate(180deg); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50' fill='none' stroke='%23e8c97a' stroke-width='1'%3E%3Cpath d='M2,2 H45 M2,2 V45 M6,6 H38 M6,6 V38 M10,10 H31 M10,10 V31' stroke-opacity='0.35'/%3E%3Cpath d='M2,2 L14,14 M6,6 L14,14 M45,2 L25,22 M2,45 L22,25' stroke-width='0.75' stroke-opacity='0.5'/%3E%3Cpath d='M2,2 Q20,2 20,20 Q2,20 2,2 Z M6,6 Q16,6 16,16 Q6,16 6,6 Z' stroke='%23c5a059' stroke-width='0.75'/%3E%3Ccircle cx='14' cy='14' r='1.5' fill='%23e8c97a'/%3E%3Ccircle cx='3' cy='3' r='1' fill='%239a7a3a'/%3E%3C/svg%3E"); }
.card-back-swirls::before { top: 4%; right: 4%; transform: scaleX(-1); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50' fill='none' stroke='%23e8c97a' stroke-width='1'%3E%3Cpath d='M2,2 H45 M2,2 V45 M6,6 H38 M6,6 V38 M10,10 H31 M10,10 V31' stroke-opacity='0.35'/%3E%3Cpath d='M2,2 L14,14 M6,6 L14,14 M45,2 L25,22 M2,45 L22,25' stroke-width='0.75' stroke-opacity='0.5'/%3E%3Cpath d='M2,2 Q20,2 20,20 Q2,20 2,2 Z M6,6 Q16,6 16,16 Q6,16 6,6 Z' stroke='%23c5a059' stroke-width='0.75'/%3E%3Ccircle cx='14' cy='14' r='1.5' fill='%23e8c97a'/%3E%3Ccircle cx='3' cy='3' r='1' fill='%239a7a3a'/%3E%3C/svg%3E"); }
.card-back-swirls::after  { bottom: 4%; left: 4%; transform: scaleX(-1) rotate(180deg); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50' fill='none' stroke='%23e8c97a' stroke-width='1'%3E%3Cpath d='M2,2 H45 M2,2 V45 M6,6 H38 M6,6 V38 M10,10 H31 M10,10 V31' stroke-opacity='0.35'/%3E%3Cpath d='M2,2 L14,14 M6,6 L14,14 M45,2 L25,22 M2,45 L22,25' stroke-width='0.75' stroke-opacity='0.5'/%3E%3Cpath d='M2,2 Q20,2 20,20 Q2,20 2,2 Z M6,6 Q16,6 16,16 Q6,16 6,6 Z' stroke='%23c5a059' stroke-width='0.75'/%3E%3Ccircle cx='14' cy='14' r='1.5' fill='%23e8c97a'/%3E%3Ccircle cx='3' cy='3' r='1' fill='%239a7a3a'/%3E%3C/svg%3E"); }

.back-logo-container {
    position: absolute;
    inset: 0;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    pointer-events: none;
}

.card-back-logo {
    width:  52%;
    height: auto;
    max-height: 52%;
    object-fit: contain;
    opacity: 0.95;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.4));
}

/* REMOVED: .logo-fallback-icon circle definition to clear the middle area entirely */

.card-back-border {
    position: absolute;
    inset: 5px;
    border: 1px solid var(--gold-foil);
    border-radius: calc(var(--radius-card) - 3px);
    opacity: 0.45;
    pointer-events: none;
    z-index: 4;
}

/* ─── 4. Card Front Layouts (With Embossed Gold Border) ────────── */
.card-front {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotateY(180deg);
    z-index: 1;
}

.card-front::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("https://www.transparenttextures.com/patterns/natural-paper.png");
    opacity: 0.12;
    pointer-events: none;
    border-radius: inherit;
}

/* PREMIUM: Embossed metallic border framing the card interior */
.card-edge {
    position: absolute;
    inset: 5px; /* Sits exactly between the index text and the card edge */
    border: 1.5px solid var(--gold-foil);
    border-radius: var(--radius-inner);
    pointer-events: none;
    z-index: 5;
    opacity: 0.85;
    
    /* Creates the physical 'stamped/embossed' inset ridge depth effect */
    box-shadow: 
        inset 0 1px 1px rgba(0, 0, 0, 0.15),
        0 1px 0px rgba(255, 255, 255, 0.8);
}

/* Adding a secondary ultra-faint inner gold pin-stripe for a luxury finish */
.card-edge::after {
    content: "";
    position: absolute;
    inset: 2px;
    border: 0.5px solid var(--gold-light);
    border-radius: calc(var(--radius-inner) - 2px);
    opacity: 0.4;
}

.corner-info {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.0;
    z-index: 10;
    width: clamp(12px, 2vw, 18px);
}

/* Adjusted corner tracking to sit comfortably alongside the new frame line */
.corner-info.top-left     { top: 5.5%; left: 5.5%; }
.corner-info.bottom-right { bottom: 5.5%; right: 5.5%; transform: rotate(180deg); }

.rank-text {
    font-size:   clamp(0.68rem, 1.3vw, 0.92rem); 
    font-weight: 800;
    letter-spacing: -0.2px;
    margin-bottom: 2px;
}

.mini-suit {
    width:  clamp(8px, 1.2vw, 12px);
    height: clamp(8px, 1.2vw, 12px);
    overflow: visible;
}

.center-piece {
    position: absolute;
    inset: 16% 26%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    pointer-events: none;
}

/* ─── 5. Precise Pip Grid Framework ───────────────────────────── */
.pip-container {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    box-sizing: border-box;
}

.pip {
    width: 100%;
    height: 100%;
    max-width: clamp(11px, 1.6vw, 15px);
    max-height: clamp(11px, 1.6vw, 15px);
    overflow: visible;
}

/* 1 to 4 Layouts */
.count-1 .pip { max-width: 26px; max-height: 26px; }
.count-2, .count-3 { grid-template-columns: 1fr; padding: 10% 0; }
.count-4 { grid-template-columns: repeat(2, 1fr); padding: 10% 4%; gap: 20% 0; }

/* 5 Pip Layout */
.count-5 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 6% 4%;
}
.count-5 .pip:nth-child(1) { grid-column: 1; grid-row: 1; }
.count-5 .pip:nth-child(2) { grid-column: 3; grid-row: 1; }
.count-5 .pip:nth-child(3) { grid-column: 2; grid-row: 2; justify-self: center; align-self: center; } 
.count-5 .pip:nth-child(4) { grid-column: 1; grid-row: 3; }
.count-5 .pip:nth-child(5) { grid-column: 3; grid-row: 3; }


/* 6 Pip Layout */
.count-6 { grid-template-columns: repeat(2, 1fr); padding: 4% 4%; gap: 8% 0; }

/* 7 Pip Layout */
.count-7 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    padding: 4% 4%;
}
.count-7 .pip:nth-child(1) { grid-column: 1; grid-row: 1; }
.count-7 .pip:nth-child(2) { grid-column: 3; grid-row: 1; }
.count-7 .pip:nth-child(3) { grid-column: 1; grid-row: 2; }
.count-7 .pip:nth-child(4) { grid-column: 3; grid-row: 2; }
.count-7 .pip:nth-child(5) { grid-column: 2; grid-row: 3; justify-self: center; align-self: center; } 
.count-7 .pip:nth-child(6) { grid-column: 1; grid-row: 4; }
.count-7 .pip:nth-child(7) { grid-column: 3; grid-row: 4; }


/* 8 Pip Layout */
.count-8 { grid-template-columns: repeat(2, 1fr); padding: 2% 4%; gap: 4% 0; }

/* 9 Pip Layout */
.count-9 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(5, 1fr);
    padding: 4% 3%;
}
.count-9 .pip:nth-child(1) { grid-column: 1; grid-row: 1; }
.count-9 .pip:nth-child(2) { grid-column: 3; grid-row: 1; }
.count-9 .pip:nth-child(3) { grid-column: 1; grid-row: 2; }
.count-9 .pip:nth-child(4) { grid-column: 3; grid-row: 2; }
.count-9 .pip:nth-child(5) { grid-column: 2; grid-row: 3; justify-self: center; align-self: center; } 
.count-9 .pip:nth-child(6) { grid-column: 1; grid-row: 4; }
.count-9 .pip:nth-child(7) { grid-column: 3; grid-row: 4; }
.count-9 .pip:nth-child(8) { grid-column: 1; grid-row: 5; }
.count-9 .pip:nth-child(9) { grid-column: 3; grid-row: 5; }

/* 10 Pip Layout */
.count-10 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    padding: 4% 3%;
    gap: 2% 0;
}
.count-10 .pip:nth-child(1) { grid-column: 1; grid-row: 1; }
.count-10 .pip:nth-child(2) { grid-column: 3; grid-row: 1; }
.count-10 .pip:nth-child(3) { grid-column: 1; grid-row: 2; }
.count-10 .pip:nth-child(4) { grid-column: 2; grid-row: 2; justify-self: center; align-self: center; } 
.count-10 .pip:nth-child(5) { grid-column: 3; grid-row: 2; }
.count-10 .pip:nth-child(6) { grid-column: 1; grid-row: 3; }
.count-10 .pip:nth-child(7) { grid-column: 2; grid-row: 3; justify-self: center; align-self: center; } 
.count-10 .pip:nth-child(8) { grid-column: 3; grid-row: 3; }
.count-10 .pip:nth-child(9) { grid-column: 1; grid-row: 4; }
.count-10 .pip:nth-child(10) { grid-column: 3; grid-row: 4; }

/* ─── 6. Royal Card Layouts ────────────────────────────────────── */
.royal-wrapper {
    position: relative;
    width:  100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4%;
}

/* FIX: Ensure watermark is visible and positioned properly under the court frame */
.suit-watermark {
    position: absolute;
    width:  125%;
    height: 125%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.14 !important; /* Brought visibility back safely */
    z-index: 1;
    display: block !important;
}

.master-suit.royal-icon {
    width:  85%;
    height: auto;
    z-index: 3;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.05));
    margin-top: 5%;
    position: relative;
}

.royal-badge-container {
    position: relative;
    z-index: 4;
    background: var(--card-bg);
    border-radius: 50%;
    padding: 3px; 
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.royal-suit-badge {
    width:  13px;
    height: 13px;
    display: block;
}

/* ─── 7. Petal Ace Special Animation ───────────────────────────── */
.petal-ring {
    width:  65%;
    height: auto;
    animation: rotateZen 40s linear infinite;
}
@keyframes rotateZen {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ─── 8. Suit-specific Overrides ───────────────────────────────── */
.suit-reeds .pip, .suit-reeds .mini-suit, .suit-reeds .suit-watermark, .suit-reeds .royal-suit-badge { fill: none; }

/* ─── 9. Deck & Pile Visuals ───────────────────────────────────── */
.deck-card-slice {
    position: absolute;
    width:  var(--card-w);
    height: var(--card-h);
    background: radial-gradient(ellipse at center, var(--card-back-top) 0%, var(--card-back-bot) 100%);
    border-radius: var(--radius-card);
    border: 2px solid var(--gold-foil);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.25);
}

/* ─── 10. Interaction States ────────────────────────────────────── */
.noos-card.selected-card {
    outline: 2px solid #10b981;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.7);
    z-index: 5000 !important;
}
.noos-card.child-selected {
    outline: 2px solid #34d399;
    box-shadow: 0 2px 8px rgba(52, 211, 153, 0.3);
    z-index: 5001 !important;
}

/* ─── 11. Responsive Overrides ──────────────────────────────────── */
@media (max-width: 768px) {
    .rank-text { font-size: 0.65rem; }
    .mini-suit { width: 7px; height: 7px; }
    .center-piece { inset: 15% 22%; }
}