/* =====================================================================
   ESAForum — Cases / Lootbox CSS  v5
   Created by ESAGAMES HOSTING SHIELD SRL
   Uses CSS custom properties from theme.css: --primary, --surface,
   --border, --text, --text-mute, --radius, etc.
   ===================================================================== */

/* ---- Page wrapper ---- */
.cases-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px 60px;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* ---- Hero header ---- */
.cases-hero {
    text-align: center;
    padding: 48px 16px 32px;
}
.cases-hero-inner {
    max-width: 560px;
    margin: 0 auto;
}
.cases-hero-title {
    font-size: clamp(24px, 5vw, 44px);
    font-weight: 800;
    margin: 0 0 8px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 55%, var(--accent-2) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.cases-hero-sub {
    color: var(--text-mute);
    margin: 0 0 16px;
    font-size: 15px;
    line-height: 1.55;
}
.cases-balance {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 22px;
    font-weight: 700;
    font-size: 15px;
    color: var(--amber);
    box-shadow: 0 2px 12px rgba(245,179,1,.12);
}
.cases-guest {
    margin-bottom: 24px;
}

/* ---- Case grid ---- */
.cases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 48px;
}

/* ---- Case card ---- */
.case-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius, 12px) + 4px);
    padding: 32px 24px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    min-width: 0;
    box-sizing: border-box;
}
.case-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(0,0,0,.4);
    border-color: rgba(var(--primary-rgb,124,92,255),.28);
}

/* Glow overlays */
.case-glow {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    height: 240px;
    border-radius: 50%;
    opacity: 0.13;
    pointer-events: none;
    filter: blur(60px);
    transition: opacity 0.3s;
}
.case-card:hover .case-glow { opacity: 0.2; }
.case-glow--daily   { background: var(--primary); }
.case-glow--premium { background: #f5b301; }

/* Premium card accent border */
.case-card--premium {
    border-color: rgba(245, 179, 1, 0.3);
    background: linear-gradient(160deg, var(--surface) 75%, rgba(245,179,1,0.05));
}
.case-card--premium:hover {
    border-color: rgba(245,179,1,.55);
    box-shadow: 0 16px 48px rgba(245,179,1,.12);
}

/* ---- Case icon ---- */
.case-icon-wrap {
    margin-bottom: 22px;
}
.case-icon {
    width: 96px;
    height: 96px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 46px;
    position: relative;
    transition: box-shadow 0.3s, transform 0.3s;
}
.case-card:hover .case-icon {
    transform: scale(1.06);
}
.case-icon--daily {
    background: linear-gradient(135deg, rgba(var(--primary-rgb),0.22), rgba(var(--primary-rgb),0.05));
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb),0.3), 0 8px 24px rgba(var(--primary-rgb),0.15);
}
.case-card:hover .case-icon--daily {
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb),0.55), 0 12px 32px rgba(var(--primary-rgb),0.25);
}
.case-icon--premium {
    background: linear-gradient(135deg, rgba(245,179,1,0.25), rgba(245,179,1,0.06));
    box-shadow: 0 0 0 2px rgba(245,179,1,0.35), 0 8px 24px rgba(245,179,1,0.15);
}
.case-card:hover .case-icon--premium {
    box-shadow: 0 0 0 2px rgba(245,179,1,0.6), 0 12px 32px rgba(245,179,1,0.25);
}
.case-icon-inner {
    display: block;
    line-height: 1;
}

/* Spin animation — more dramatic for feedback */
@keyframes case-spin-anim {
    0%   { transform: scale(1)    rotate(0deg); }
    15%  { transform: scale(1.22) rotate(-12deg); }
    35%  { transform: scale(1.28) rotate(14deg); }
    55%  { transform: scale(1.18) rotate(-8deg); }
    75%  { transform: scale(1.1)  rotate(5deg); }
    90%  { transform: scale(1.04) rotate(-2deg); }
    100% { transform: scale(1)    rotate(0deg); }
}
.case-spin {
    animation: case-spin-anim 0.75s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

/* ---- Case info text ---- */
.case-info {
    flex: 1;
    margin-bottom: 22px;
    min-width: 0;
    width: 100%;
}
.case-name {
    font-size: 21px;
    font-weight: 800;
    margin: 0 0 8px;
    color: var(--text);
    letter-spacing: -.02em;
    overflow-wrap: break-word;
    word-break: break-word;
}
.case-desc {
    font-size: 14px;
    color: var(--text-mute);
    margin: 0 0 14px;
    line-height: 1.55;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Odds pills */
.case-odds {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.odds-pill {
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    padding: 3px 10px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.odds-pts  { background: rgba(74,158,255,0.15); color: #4a9eff; border: 1px solid rgba(74,158,255,0.3); }
.odds-item { background: rgba(245,179,1,0.15); color: #f5b301; border: 1px solid rgba(245,179,1,0.3); }

/* ---- Open button ---- */
.case-open-btn {
    width: 100%;
    font-size: 15px;
    font-weight: 700;
    padding: 13px 0;
    border-radius: var(--radius, 10px);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
}
.case-open-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}
.case-open-btn:active:not(:disabled) { transform: scale(0.97); }
.case-open-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Daily/login open buttons render as .btn-primary on the solid accent fill —
   keep the label legible on light accents (e.g. gold). */
.case-open-btn.btn-primary { color: var(--on-accent, #fff); }

/* Premium button special gradient */
.btn-premium {
    background: linear-gradient(135deg, #e6a800, #f5b301 50%, #ffd454);
    color: #1a1200;
    border: none;
    font-weight: 800;
    box-shadow: 0 4px 18px rgba(245,179,1,.35);
}
.btn-premium:hover:not(:disabled) {
    opacity: 0.92;
    box-shadow: 0 6px 28px rgba(245,179,1,.55);
}

/* ---- Cooldown block ---- */
.case-cooldown {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    font-size: 14px;
    color: var(--text-mute);
    margin-bottom: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 8px 14px;
    width: 100%;
    box-sizing: border-box;
}
.cooldown-icon { font-size: 18px; }

/* =====================================================================
   RESULT MODAL
   ===================================================================== */
.case-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    padding: 16px;
}
.case-modal-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

.case-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    width: min(430px, 100%);
    padding: 38px 30px 28px;
    position: relative;
    text-align: center;
    box-shadow: 0 28px 90px rgba(0,0,0,.65);
    transform: scale(0.88) translateY(20px);
    transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1);
    max-height: 90dvh;
    overflow-y: auto;
    box-sizing: border-box;
    overflow-x: hidden;
}
.case-modal-backdrop.active .case-modal {
    transform: scale(1) translateY(0);
}
.case-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-mute);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 6px 9px;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
}
.case-modal-close:hover { color: var(--text); background: var(--surface-2); }

/* Decorative top shimmer on modal */
.case-modal::before {
    content: '';
    position: absolute;
    top: 0; left: 10%; right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(var(--primary-rgb,124,92,255),.6), transparent);
    border-radius: 0 0 2px 2px;
}

/* ---- Modal animation area ---- */
.case-modal-anim {
    position: relative;
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}
.modal-burst {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.modal-reward-icon {
    font-size: 68px;
    z-index: 1;
    animation: modal-pop 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
    filter: drop-shadow(0 4px 16px rgba(0,0,0,.4));
}
@keyframes modal-pop {
    0%   { transform: scale(0) rotate(-25deg); opacity: 0; }
    65%  { transform: scale(1.12) rotate(5deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Burst particles */
.burst-particle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: burst-fly 0.7s ease-out both;
}
@keyframes burst-fly {
    0%   { transform: translate(-50%,-50%) rotate(var(--angle)) translateX(0) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%,-50%) rotate(var(--angle)) translateX(var(--dist)) scale(0); opacity: 0; }
}

/* ---- Modal text ---- */
.case-modal-body { margin-bottom: 22px; }
.modal-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--primary-2, #9d7bff);
    margin-bottom: 8px;
}
.modal-reward-name {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    word-break: break-word;
    overflow-wrap: break-word;
    letter-spacing: -.02em;
    line-height: 1.25;
}
.modal-balance {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text-mute);
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 4px 14px;
    margin-top: 4px;
}

/* =====================================================================
   SECTION HEADING
   ===================================================================== */
.cases-feed-section {
    margin-top: 8px;
}

.cases-section-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 14px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.cases-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
    border-radius: 1px;
}

/* =====================================================================
   RECENT WINS FEED
   ===================================================================== */
.cases-feed {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius, 12px);
    overflow: hidden;
}
.feed-row {
    display: grid;
    grid-template-columns: 1fr 80px 1fr 100px;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-soft);
    transition: background 0.2s;
}
.feed-row:last-child { border-bottom: none; }
.feed-row--item { background: rgba(245,179,1,.04); }
.feed-row:hover { background: var(--surface-2); }
.feed-row--new {
    animation: feed-slide-in 0.35s ease both;
}
@keyframes feed-slide-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.feed-user  { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.feed-case  { text-align: center; font-size: 11px; text-transform: uppercase; font-weight: 700; letter-spacing: 0.04em; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.feed-reward { text-align: right; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-reward--pts  { color: #4a9eff; }
.feed-reward--item { color: #f5b301; }
.feed-time  { text-align: right; color: var(--text-mute); font-size: 11px; white-space: nowrap; }

/* =====================================================================
   DESKTOP ENHANCEMENTS (≥1024px)
   ===================================================================== */
@media (min-width: 1024px) {
    .cases-hero { padding: 60px 16px 44px; }
    .cases-hero-sub { font-size: 16px; }
    .cases-balance { font-size: 16px; padding: 8px 26px; }
    .cases-grid { grid-template-columns: repeat(2, 1fr); gap: 32px; margin-bottom: 56px; }
    .case-card { padding: 42px 32px 32px; }
    .case-icon { width: 104px; height: 104px; font-size: 52px; border-radius: 28px; }
    .case-icon-wrap { margin-bottom: 24px; }
    .case-name { font-size: 23px; }
    .case-desc { font-size: 15px; }
    .case-open-btn { font-size: 16px; padding: 14px 0; }
    .odds-pill { font-size: 12px; padding: 4px 12px; }
    /* Feed: wider columns */
    .feed-row { grid-template-columns: 1fr 100px 1fr 120px; padding: 13px 20px; font-size: 14px; }
    .feed-time { font-size: 12px; }
    .case-modal { padding: 42px 36px 32px; }
    .modal-reward-icon { font-size: 72px; }
    .modal-reward-name { font-size: 26px; }
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

@media (max-width: 640px) {
    .cases-hero { padding: 32px 8px 22px; }
    .cases-grid { grid-template-columns: 1fr; gap: 16px; }
    .case-card  { padding: 26px 18px 22px; }
    .case-icon  { width: 76px; height: 76px; font-size: 38px; }
}

@media (max-width: 540px) {
    /* Feed: 2 rows, hide time column */
    .feed-row {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 4px 8px;
        padding: 10px 12px;
    }
    .feed-user  { grid-column: 1; grid-row: 1; }
    .feed-reward { grid-column: 2; grid-row: 1; }
    .feed-case  { grid-column: 1; grid-row: 2; text-align: left; }
    .feed-time  { display: none; }
    /* Larger touch target on open button */
    .case-open-btn { min-height: 48px; }
}

/* 480px — phones */
@media (max-width: 480px) {
    .cases-hero { padding: 24px 8px 16px; }
    .cases-hero-sub { font-size: 14px; }
    /* Case modal: edge-to-edge on narrow phones */
    .case-modal {
        padding: 30px 18px 22px;
        border-radius: 18px;
        width: min(420px, 100%);
        box-sizing: border-box;
    }
    .modal-reward-icon { font-size: 54px; }
    .modal-reward-name { font-size: 20px; }
    .case-modal-anim   { height: 110px; }
    /* Odds pills: smaller */
    .odds-pill { font-size: 10px; padding: 2px 8px; }
}

@media (max-width: 400px) {
    .cases-wrap { padding: 0 10px 48px; }
    .case-card  { padding: 22px 14px 18px; }
    .case-open-btn { font-size: 14px; padding: 11px 0; min-height: 46px; }
    .cases-hero-title { font-size: 22px; }
    /* Cooldown: wrap if needed */
    .case-cooldown { flex-wrap: wrap; justify-content: center; text-align: center; gap: 6px; }
}

/* 390px */
@media (max-width: 390px) {
    .case-card { padding: 20px 12px 16px; }
    .case-icon { width: 68px; height: 68px; font-size: 32px; border-radius: 20px; }
    .case-name { font-size: 18px; }
    .case-desc { font-size: 13px; }
    .case-modal { padding: 26px 14px 18px; }
    .modal-reward-name { font-size: 18px; }
}

/* 360px */
@media (max-width: 360px) {
    .cases-wrap { padding: 0 8px 40px; }
    .case-card { padding: 18px 10px 14px; }
    .case-icon { width: 60px; height: 60px; font-size: 28px; border-radius: 16px; }
    .case-name { font-size: 16px; }
    .case-modal { padding: 22px 12px 16px; border-radius: 16px; }
    .cases-balance { font-size: 13px; padding: 5px 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .case-spin,
    .feed-row--new,
    .modal-reward-icon { animation: none; }
    .case-card { transition: none; }
    .case-glow { transition: none; }
    .case-icon { transition: none; }
}
