/* Shared shell styles for layouts/game.blade.php (Quran games: topbar, share modal,
   results modal, toast). The encouragement panel and celebration overlay live in
   encouragement-v1.css, so pages outside this layout can reuse them.
   System: "الكوفي المربّع" — every value comes from tokens.css. The stage is deep teal,
   controls are square-ish blocks, orange marks the one thing to press. */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: var(--font-ui);
    background: var(--c-teal-900);
    color: var(--c-cream);
    -webkit-font-smoothing: antialiased;
}

/* Quran text font class - use in any game */
.ayah-text, .quran-text, .stone-text, .balloon-text, .match-card,
.card-back-name, .card-label, .ing-text, .option-btn, .word-option,
.ayah-line, .blank-input, .surah-name, .ayah-bubble {
    font-family: var(--font-quran) !important;
}

.game-layout {
    width: 100%; height: 100vh;
    display: flex; flex-direction: column;
    overflow: hidden; position: relative;
}

/* ========================================
   GAME TOP BAR — a solid teal-950 band; the stage below owns the color.
   ======================================== */
.game-topbar {
    position: fixed; top: 0; left: 0; right: 0;
    background: var(--c-teal-950);
    border-bottom: 1px solid rgba(240, 234, 222, .08);
    padding: 8px 16px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: nowrap;
    min-height: 60px; z-index: 9999;
}
.game-topbar-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.game-topbar-center { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.game-topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.game-stat {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: var(--r-cell);
    background: var(--c-teal-800);
    font-size: .9rem; font-weight: 700; white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.game-stat .stat-icon { font-size: 1rem; }
.game-stat .stat-value { color: var(--c-orange-soft); font-weight: 800; }

.game-btn {
    width: 44px; height: 44px; border-radius: var(--r-block);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s var(--ease), color .2s var(--ease), transform .15s var(--ease);
    font-size: .95rem;
    background: var(--c-teal-800); color: var(--c-cream);
}
.game-btn:hover { background: var(--c-teal-700); }
.game-btn:active { transform: translateY(2px); }
.game-btn:focus-visible { outline: 3px solid var(--c-orange-soft); outline-offset: 2px; }
.game-btn.btn-danger { background: var(--c-teal-800); color: var(--c-orange-soft); }
.game-btn.btn-danger:hover { background: var(--c-wrong); color: var(--c-white); }
.game-btn.active { background: var(--c-orange); color: var(--c-teal-950); }

.game-title {
    font-family: var(--font-kufi);
    font-size: 1.05rem; font-weight: 600;
    color: var(--c-cream);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: none;
}

/* ========================================
   GAME CONTENT
   ======================================== */
.game-content {
    flex: 1; margin-top: 60px;
    display: flex; flex-direction: column;
    min-height: 0; overflow: hidden; position: relative;
    padding-bottom: 60px;
}

/* ========================================
   SHARE MODAL
   ======================================== */
.share-modal {
    display: none; position: fixed; inset: 0; z-index: 100000;
    align-items: center; justify-content: center;
    background: rgba(7, 43, 37, .78);
}
.share-modal.show { display: flex; animation: fadeIn .25s ease; }
.share-content {
    background: var(--c-paper-raised); color: var(--c-ink);
    padding: 28px; border-radius: var(--r-tile); text-align: center;
    max-width: 400px; width: 90%;
    box-shadow: var(--shadow-float);
}
.share-title { font-family: var(--font-kufi); font-size: 1.35rem; font-weight: 700; color: var(--c-ink); margin-bottom: 4px; }
.share-subtitle { color: var(--c-ink-soft); margin-bottom: 22px; font-size: .9rem; }
.share-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.share-btn {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 14px 12px; border-radius: var(--r-block);
    border: 1px solid var(--c-line);
    background: var(--c-white);
    cursor: pointer; transition: border-color .2s, background .2s; color: var(--c-ink);
    font-family: inherit;
}
.share-btn:hover { border-color: var(--c-teal-700); background: var(--c-teal-50); }
.share-btn i { font-size: 1.4rem; color: var(--c-teal-700); }
.share-btn span { font-size: .8rem; font-weight: 700; color: var(--c-ink-soft); }
.share-link-box { display: flex; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--c-line); }
.share-link-input {
    flex: 1; min-width: 0; padding: 10px 12px;
    border: 1px solid var(--c-line); border-radius: var(--r-block);
    background: var(--c-white); color: var(--c-ink);
    font-size: .8rem; direction: ltr; text-align: left;
}
.share-link-copy {
    padding: 10px 16px;
    background: var(--c-teal-700);
    color: var(--c-white); border: none; border-radius: var(--r-block);
    cursor: pointer; font-weight: 800; font-family: inherit;
}
.share-link-copy:hover { background: var(--c-teal-800); }
.share-close {
    margin-top: 16px; padding: 10px 24px;
    background: transparent; color: var(--c-ink-soft);
    border: 1px solid var(--c-line); border-radius: var(--r-block); cursor: pointer;
    font-weight: 700; font-family: inherit;
}
.share-close:hover { border-color: var(--c-teal-700); color: var(--c-teal-700); }

/* ========================================
   RESULTS MODAL (Unified Game Over)
   The reward moment: a teal tile, the Kufic square assembling above the title,
   one orange action.
   ======================================== */
.results-modal {
    display: none; position: fixed; inset: 0; z-index: 200000;
    align-items: center; justify-content: center;
    background: rgba(7, 43, 37, .82);
}
.results-modal.show { display: flex; animation: fadeIn .3s ease; }
.results-content {
    background: var(--c-teal-900);
    border: 1px solid rgba(240, 234, 222, .12);
    border-radius: var(--r-tile); padding: 36px 32px 32px; text-align: center;
    max-width: 420px; width: 90%;
    box-shadow: var(--shadow-float);
    animation: modalPop .45s var(--ease);
    position: relative;
}
/* Kufic square: nine cells assemble into the logo's orange block */
.results-content::before {
    content: "";
    display: block;
    width: 56px; height: 56px;
    margin: 0 auto 14px;
    border-radius: var(--r-cell);
    background: var(--c-orange);
    box-shadow: 0 5px 0 var(--c-orange-edge);
    animation: kufiSquare .6s var(--ease) both;
}
@keyframes kufiSquare { from { transform: scale(.2) rotate(-45deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes modalPop { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.results-close {
    position: absolute; top: 12px; left: 12px;
    width: 40px; height: 40px; border-radius: var(--r-block);
    border: none; background: var(--c-teal-800);
    color: var(--c-cream); font-size: 1.2rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 2;
}
.results-close:hover { background: var(--c-teal-700); }
.results-trophy {
    font-size: 3rem; line-height: 1; margin-bottom: 8px;
}
.results-title {
    font-family: var(--font-kufi);
    font-size: 1.8rem; font-weight: 700; color: var(--c-cream);
    margin-bottom: 4px;
}
.results-subtitle {
    color: var(--c-on-teal-soft); margin-bottom: 18px; font-size: 1rem; font-weight: 600;
}
.results-stars {
    display: flex; justify-content: center; gap: 10px; margin-bottom: 24px;
}
.results-star {
    font-size: 2.2rem;
    animation: starPop .45s var(--ease) forwards;
    opacity: 0; transform: scale(0);
}
.results-star:nth-child(1) { animation-delay: .25s; }
.results-star:nth-child(2) { animation-delay: .4s; }
.results-star:nth-child(3) { animation-delay: .55s; }
@keyframes starPop { to { opacity: 1; transform: scale(1); } }
.results-star.empty { filter: grayscale(1) opacity(.3); }
.results-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.results-btn {
    min-height: 56px; padding: 12px 28px; border-radius: var(--r-tile); border: none;
    font-size: 1.1rem; font-weight: 800; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    font-family: var(--font-ui);
    transition: background .2s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
}
.results-btn.primary {
    background: var(--c-orange); color: var(--c-teal-950);
    box-shadow: 0 5px 0 var(--c-orange-edge);
}
.results-btn.primary:hover { background: var(--c-orange-soft); }
.results-btn.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--c-orange-edge); }
.results-btn.secondary,
.results-btn.home {
    background: var(--c-teal-800); color: var(--c-cream);
    box-shadow: 0 5px 0 var(--c-teal-950);
}
.results-btn.secondary:hover,
.results-btn.home:hover { background: var(--c-teal-700); }
.results-btn.secondary:active,
.results-btn.home:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--c-teal-950); }

@media (max-width: 480px) {
    .results-content { padding: 28px 18px 22px; }
    .results-title { font-size: 1.45rem; }
    .results-star { font-size: 1.8rem; }
    .results-actions { flex-direction: column; }
    .results-btn { width: 100%; justify-content: center; }
}

/* ========================================
   TOAST
   ======================================== */
.game-toast {
    position: fixed; bottom: 80px; left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--c-paper-raised); color: var(--c-ink);
    border: 1px solid var(--c-line);
    padding: 12px 22px; border-radius: var(--r-block);
    font-weight: 700; font-size: .95rem;
    box-shadow: var(--shadow-float);
    z-index: 100001; opacity: 0; transition: transform .3s var(--ease), opacity .3s;
}
.game-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ========================================
   FULLSCREEN FIXES
   ======================================== */
.game-layout:fullscreen .share-modal { z-index: 2147483647 !important; }
.game-layout:fullscreen .results-modal { z-index: 2147483647 !important; }
.game-layout:fullscreen .game-toast { z-index: 2147483647 !important; }
.game-layout:fullscreen .game-topbar { top: 0 !important; }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .game-topbar { padding: 6px 10px; min-height: 52px; }
    .game-stat { padding: 4px 8px; font-size: .8rem; }
    .game-btn { width: 40px; height: 40px; font-size: .85rem; }
    .game-title { font-size: .95rem; }
    .game-content { margin-top: 52px; }
}
@media (max-width: 480px) {
    .game-stat { padding: 3px 6px; font-size: .72rem; gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
    .results-content, .results-content::before, .results-star, .game-toast { animation: none !important; transition: none !important; }
    .results-star { opacity: 1; transform: none; }
}
