/* ==================================================
   Tafsiri.ai - Custom Styles
   ================================================== */

/* ==================================================
   0. Brand Palette & Dark/Light Mode Fallbacks
   ================================================== */
:root {
    --tafsiri-black: #0B0B0B;
    --tafsiri-dark: #141414;
    --tafsiri-crimson: #C8102E;
    --tafsiri-crimson-hover: #A30822;
}

/* Fallback color utilities (in case CDN compilation delays) */
.bg-tafsiri-black { background-color: var(--tafsiri-black); }
.bg-tafsiri-dark { background-color: var(--tafsiri-dark); }
.text-tafsiri-crimson { color: var(--tafsiri-crimson); }
.bg-tafsiri-crimson { background-color: var(--tafsiri-crimson); }
.hover\:bg-tafsiri-crimson-hover:hover { background-color: var(--tafsiri-crimson-hover); }

/* System OS Dark Mode Overrides */
@media (prefers-color-scheme: dark) {
    .dark\:bg-tafsiri-black { background-color: var(--tafsiri-black) !important; }
    .dark\:bg-tafsiri-dark { background-color: var(--tafsiri-dark) !important; }
    .dark\:text-white { color: #ffffff !important; }
    .dark\:text-gray-100 { color: #f3f4f6 !important; }
    .dark\:text-gray-400 { color: #9ca3af !important; }
    .dark\:border-neutral-900 { border-color: #171717 !important; }
    .dark\:border-neutral-800 { border-color: #262626 !important; }
    .dark\:border-neutral-700 { border-color: #404040 !important; }
}

/* Class-based Dark Mode Fallback */
html.dark .dark\:bg-tafsiri-black { background-color: var(--tafsiri-black) !important; }
html.dark .dark\:bg-tafsiri-dark { background-color: var(--tafsiri-dark) !important; }
html.dark .dark\:text-white { color: #ffffff !important; }
html.dark .dark\:text-gray-100 { color: #f3f4f6 !important; }
html.dark .dark\:text-gray-400 { color: #9ca3af !important; }
html.dark .dark\:border-neutral-900 { border-color: #171717 !important; }
html.dark .dark\:border-neutral-800 { border-color: #262626 !important; }
html.dark .dark\:border-neutral-700 { border-color: #404040 !important; }

/* ==================================================
   1. Full-Page Interactive Dotted Grid (Top to Bottom)
   ================================================== */

/* Full-Page Fixed Dot Canvas */
#page-background {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    background-color: #F9FAFB;
    transition: background-color 0.3s ease;
}

@media (prefers-color-scheme: dark) {
    #page-background {
        background-color: var(--tafsiri-black);
    }
}

html.dark #page-background {
    background-color: var(--tafsiri-black) !important;
}

/* Base dots:
   - Light theme: subtle black dots on light background
   - Dark theme: subtle white dots on black background */
.page-base-dots,
.base-dots {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, #0B0B0B 1.2px, transparent 1.2px);
    background-size: 32px 32px;
    opacity: 0.12;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

@media (prefers-color-scheme: dark) {
    .page-base-dots,
    .base-dots {
        background-image: radial-gradient(circle, #ffffff 1.2px, transparent 1.2px);
        opacity: 0.16;
    }
}

html.dark .page-base-dots,
html.dark .base-dots {
    background-image: radial-gradient(circle, #ffffff 1.2px, transparent 1.2px) !important;
    opacity: 0.16 !important;
}

/* Red dots: Outer Crimson Halo around mouse cursor */
.page-hover-dots-red,
.hover-dots-red {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, #C8102E 1.8px, transparent 1.8px);
    background-size: 32px 32px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    -webkit-mask-image: radial-gradient(circle 160px at var(--mouse-x, -100%) var(--mouse-y, -100%), black 0%, transparent 100%);
    mask-image: radial-gradient(circle 160px at var(--mouse-x, -100%) var(--mouse-y, -100%), black 0%, transparent 100%);
}

/* Core dots directly under cursor:
   - Light theme: bold black dots (#0B0B0B 2.2px)
   - Dark theme: bright glowing white dots (#FFFFFF 2.2px) */
.page-hover-dots-white,
.page-hover-dots-core,
.hover-dots-white,
.hover-dots-black {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, #0B0B0B 2.2px, transparent 2.2px);
    background-size: 32px 32px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    -webkit-mask-image: radial-gradient(circle 55px at var(--mouse-x, -100%) var(--mouse-y, -100%), black 0%, transparent 100%);
    mask-image: radial-gradient(circle 55px at var(--mouse-x, -100%) var(--mouse-y, -100%), black 0%, transparent 100%);
}

@media (prefers-color-scheme: dark) {
    .page-hover-dots-white,
    .page-hover-dots-core,
    .hover-dots-white,
    .hover-dots-black {
        background-image: radial-gradient(circle, #ffffff 2.2px, transparent 2.2px);
    }
}

html.dark .page-hover-dots-white,
html.dark .page-hover-dots-core,
html.dark .hover-dots-white,
html.dark .hover-dots-black {
    background-image: radial-gradient(circle, #ffffff 2.2px, transparent 2.2px) !important;
}

.page-hover-dots-red.active,
.page-hover-dots-white.active,
.page-hover-dots-core.active,
.hover-dots-red.active,
.hover-dots-white.active,
.hover-dots-black.active {
    opacity: 1;
}

/* Page body and transparent sections */
body {
    background-color: transparent !important;
    min-height: 100vh;
}

header {
    background-color: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}

html.dark header {
    background-color: rgba(11, 11, 11, 0.85) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

#interactive-hero,
.bg-cultural-section,
.bg-countdown-section,
.bg-beta-section,
footer {
    background-color: transparent !important;
}

/* Card glassmorphism overlays */
.countdown-box {
    background-color: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: #0B0B0B !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

html.dark .countdown-box {
    background-color: rgba(22, 22, 22, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

#signup input {
    background-color: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    color: #0B0B0B !important;
}

html.dark #signup input {
    background-color: rgba(22, 22, 22, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

/* ==================================================
   2. 4-Face 3D Kinetic Cube Spinner
   ================================================== */
:root {
    --cube-width: 11ch;
    --cube-height: 1.25em;
    --face-translateZ: 28px;
    --anim-duration: 10s;
}

.hero-cubespinner {
    display: inline-flex;
    position: relative;
    width: var(--cube-width);
    height: var(--cube-height);
    vertical-align: bottom;
    transform-style: preserve-3d;
    animation: spinCube4 var(--anim-duration) cubic-bezier(0.77, 0, 0.175, 1) infinite;
}

.hero-face1,
.hero-face2,
.hero-face3,
.hero-face4 {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    backface-visibility: hidden;
    color: #C8102E;
}

.hero-face1 { transform: rotateX(0deg) translateZ(var(--face-translateZ)); }
.hero-face2 { transform: rotateX(90deg) translateZ(var(--face-translateZ)); }
.hero-face3 { transform: rotateX(180deg) translateZ(var(--face-translateZ)); }
.hero-face4 { transform: rotateX(270deg) translateZ(var(--face-translateZ)); }

@keyframes spinCube4 {
    0%, 20%   { transform: rotateX(0deg); }
    25%, 45%  { transform: rotateX(-90deg); }
    50%, 70%  { transform: rotateX(-180deg); }
    75%, 95%  { transform: rotateX(-270deg); }
    100%      { transform: rotateX(-360deg); }
}

/* ==================================================
   3. Interactive Showcase & Game Styles
   ================================================== */
.showcase-container {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.tab-btn {
    transition: all 0.2s ease;
}

.tab-btn.active {
    background-color: #C8102E;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.25);
}

.lang-pill {
    transition: all 0.2s ease;
}

.lang-pill.active {
    background-color: #0B0B0B;
    color: #ffffff;
}

@media (prefers-color-scheme: dark) {
    .lang-pill.active {
        background-color: #ffffff;
        color: #0B0B0B;
    }
}

html.dark .lang-pill.active {
    background-color: #ffffff;
    color: #0B0B0B;
}

/* Word Sprint Game Styles */
.game-option-btn {
    transition: all 0.15s ease-out;
}

.game-option-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.game-option-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.game-option-btn.correct {
    background-color: #10B981 !important;
    border-color: #059669 !important;
    color: #ffffff !important;
    animation: pulseCorrect 0.4s ease;
}

.game-option-btn.wrong {
    background-color: #EF4444 !important;
    border-color: #DC2626 !important;
    color: #ffffff !important;
    animation: shakeWrong 0.3s ease;
}

@keyframes pulseCorrect {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes shakeWrong {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* Sentence Builder Tile Styles */
.word-tile {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.word-tile:hover {
    transform: translateY(-2px);
    border-color: #C8102E;
}

.word-tile:active {
    transform: scale(0.96);
}

.word-tile.placed {
    opacity: 0.35;
    pointer-events: none;
}

.slot-tile {
    cursor: pointer;
    transition: all 0.2s ease;
}

.slot-tile:hover {
    border-color: #EF4444;
}

/* ==================================================
   4. Floating Bubbles
   ================================================== */
.speech-bubble {
    position: absolute;
    border-radius: .45em;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 1.05rem;
    display: inline-block;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    animation: float 3s ease-in-out infinite;
    z-index: 30;
}

.speech-bubble:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    border-bottom: 0;
    margin-left: -10px;
    margin-bottom: -10px;
}

.speech-bubble-black {
    background: #0B0B0B;
    color: #ffffff;
}

.speech-bubble-black:after {
    border-top-color: #0B0B0B;
}

.speech-bubble-crimson {
    background: #C8102E;
    color: #ffffff;
}

.speech-bubble-crimson:after {
    border-top-color: #C8102E;
}

.speech-bubble-white {
    background: #ffffff;
    color: #0B0B0B;
    border: 2px solid #0B0B0B;
}

.speech-bubble-white:after {
    border-top-color: #ffffff;
}

.bubble-1 { top: 55%; left: 5%; animation-delay: 0s; }
.bubble-2 { top: 30%; left: 18%; animation-delay: 0.5s; }
.bubble-3 { top: 14%; left: 35%; animation-delay: 1s; }
.bubble-4 { top: 37%; right: 15%; animation-delay: 1.5s; }
.bubble-5 { top: 60%; right: 5%; animation-delay: 2s; }

@keyframes float {
    0%   { transform: translateY(0px); }
    50%  { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

/* ==================================================
   5. Countdown Boxes
   ================================================== */
.countdown-box {
    font-weight: 700;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 640px) {
    .countdown-box {
        width: 52px;
        height: 52px;
        font-size: 1.25rem;
    }
}

/* ==================================================
   6. Mobile Browser Responsiveness & Utilities
   ================================================== */

/* Hide native scrollbar while retaining momentum touch scroll */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Smooth Touch Interactions */
button, a, input, textarea, .tab-btn, .lang-pill, .game-option-btn, .sentence-tile {
    -webkit-tap-highlight-color: transparent;
}

/* Mobile Slide-in Drawer */
#mobile-nav-drawer {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#mobile-nav-backdrop {
    transition: opacity 0.3s ease;
}

body.drawer-open {
    overflow: hidden !important;
    touch-action: none;
}

/* Mobile 3D Cube Spinner Responsiveness */
@media (max-width: 640px) {
    :root {
        --cube-width: 10ch;
        --cube-height: 1.25em;
        --face-translateZ: 20px;
    }
}

/* Mobile Tablet Mockup & Speech Bubbles */
@media (max-width: 640px) {
    .speech-bubble {
        font-size: 0.75rem;
        padding: 5px 10px;
        border-radius: 12px;
    }
    .speech-bubble:after {
        border-width: 7px;
        margin-left: -7px;
        margin-bottom: -7px;
    }
    .bubble-1 { top: 58%; left: 4%; }
    .bubble-2 { top: 32%; left: 8%; }
    .bubble-3 { top: 16%; left: 28%; }
    .bubble-4 { top: 38%; right: 8%; }
    .bubble-5 { top: 62%; right: 4%; }
}

