/**
 * Additional custom styles for Griddle
 * (Main styling is handled by Tailwind CSS)
 */

/* Ensure proper emoji rendering */
.emoji-large {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-size: 2rem;
    line-height: 1;
}

/* Mobile interaction: prevent iOS double-tap to zoom while preserving pinch-zoom */
html, body,
button, a, [role="button"],
input, select, textarea {
    touch-action: manipulation;
}

/* Force main header onto its own compositing layer to prevent rendering issues */
header.bg-white\/80.backdrop-blur-sm.shadow-lg.border-b.border-gray-200\/50 {
    transform: translateZ(0);
    will-change: transform;
}

/* Force other key UI elements onto their own compositing layers */
/* Date display container */
.text-center.bg-white\/60.backdrop-blur-sm.rounded-2xl.px-8.py-4.shadow-md {
    transform: translateZ(0);
    will-change: transform;
}

/* Difficulty selector container */
.bg-white\/60.backdrop-blur-sm.rounded-lg.p-0\.5.shadow-md.w-full.max-w-xs {
    transform: translateZ(0);
    will-change: transform;
}

/* Clue panel - use contain instead of translateZ to avoid overriding Tailwind's centering transform */
.clue-panel {
    contain: layout paint;
}

/* Limit layer promotion to top-level containers only (avoid promoting thousands of children) */
#fullView,
#gameGrid {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Prevent emoji headers (non-floating) from dropping out on fast scroll */
/* Keep headers simple to reduce GPU layer count on mobile */
.column-item-header,
.row-item-header,
.column-category-header,
.row-category-header {
    backface-visibility: hidden;
}

/* Loading state */
#loadingState {
    transform: translateZ(0);
    will-change: transform;
}

/* Error state */
#errorState {
    transform: translateZ(0);
    will-change: transform;
}

/* Grid cell animations */
.grid-cell {
    /* Avoid animating layout-affecting properties to prevent flicker */
    transition: background-color 120ms ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    border-radius: 0.5rem;
    /* Isolate paints to the cell to reduce neighbor flicker */
    contain: paint;
}

.grid-cell:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.grid-cell:active {
    transform: scale(0.98);
}

/* Cell states defined in index.html <style> using CSS variables for theme support.
   Duplicate hardcoded values were here previously — removed to avoid cascade conflicts. */

/* Logic grid specific styling */
.grid-cell {
    transition: background-color 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
    font-size: 18px;
    font-weight: bold;
}

.grid-cell:hover {
    transform: none !important; /* override inline head style */
}

/* Do not show hover ring for positive/negative states */
.state-positive:hover,
.state-negative:hover {
    box-shadow: none !important;
}

/* Header cells */
.header-cell {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 2px solid #d1d5db;
    font-weight: 600;
    min-height: 4rem;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Row category headers with -90 degree rotation */
.row-category-header {
    transform: rotate(-90deg);
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

.corner-cell {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    text-transform: uppercase;
}

/* Modal animations */
.modal {
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(0.95) translateY(-10px);
}

.modal.show {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

/* Progress bar animation */
#progressBar {
    transition: width 0.3s ease-in-out;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  /*   .emoji-large {
        font-size: 1.5rem;
    } */
    
  /* .grid-cell {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
        border-radius: 0.375rem;
    } */
    
  /*  .header-cell {
        min-height: 3rem;
        font-size: 0.875rem;
        border-radius: 0.375rem;
    } */
    

    
    /* Mobile modal adjustments */
    .modal > div {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    /* Smaller clue text and emojis on mobile */
    #currentClue,
    #currentClue span {
        font-size: 0.9rem !important;
    }
    
    /* Make emojis in clues bigger on mobile (softer scaling) */
    #currentClue .text-3xl {
        font-size: 2rem !important;
    }
    
    #currentClue .emoji-large {
        font-size: 1.5rem !important;
    }
    
    /* Remove main margins on mobile but preserve bottom padding for clue panel */
    main {
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-top: 0 !important;
        /* Keep bottom padding for clue panel space */
    }
    
    /* Remove fullView rounded border on mobile */
    #fullView {
        border-radius: 0 !important;
    }
    
    /* Remove simpleView rounded border on mobile */
    #simpleView {
        border-radius: 0 !important;
    }
    
    /* Disable costly backdrop blur on mobile to reduce GPU load */
    .clue-panel {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }

    /* On touch devices, disable hover rings to reduce repaints */
    .grid-cell:hover {
        box-shadow: none;
    }
}

/* Prefer no hover effects on non-hover pointers (touch) */
@media (hover: none) {
  .grid-cell:hover {
    box-shadow: none !important;
    transform: none !important;
  }
}

/* Desktop-only hover ring for blank cells in both themes */
@media (hover: hover) and (pointer: fine) {
  .grid-cell.state-blank:hover {
    box-shadow: 0 0 0 2px #3b82f6; /* light */
  }
  .dark .grid-cell.state-blank:hover {
    box-shadow: 0 0 0 2px #60a5fa; /* dark contrast */
  }
}

@media (max-width: 640px) {
  /*   .emoji-large {
        font-size: 1.25rem;
    } */
    
  /*  .grid-cell {
        width: 2rem;
        height: 2rem;
        font-size: 0.875rem;
        border-radius: 0.25rem;
    } */
    
  /*  .header-cell {
        min-height: 2.5rem;
        font-size: 0.75rem;
        padding: 0.25rem;
        border-radius: 0.25rem;
    } */
    
    /* Small screen optimizations */
  /*    .grid {
        gap: 0.125rem;
    } */
    
    /* Compact spacing for small screens */
    .space-y-6 > * + * {
        margin-top: 1rem;
    }
    
    .space-y-8 > * + * {
        margin-top: 1.5rem;
    }
    
    /* Better text wrapping for narrow screens */
    #currentClue,
    #currentClue span {
        flex-wrap: wrap;
        gap: 0.125rem;
        font-size: 0.875rem !important;
    }
    
    .clue-type-xor,
    .clue-type-group,
    .clue-type-biconditional,
    .clue-type-double-negative,
    .clue-type-simple {
        flex-wrap: wrap;
        gap: 0.125rem;
        font-size: 0.875rem !important;
    }
    
    /* Make emojis in clues bigger on small mobile (softer scaling) */
    #currentClue .text-3xl {
        font-size: 1.75rem !important;
    }
    
    #currentClue .emoji-large {
        font-size: 1.25rem !important;
    }
}

/* Loading animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Tailwind's .hidden (display:none) handles visibility.
   The previous custom .hidden override broke layout after switching from CDN to build. */

/* Button hover/active transforms removed — Tailwind utilities (hover:-translate-y-1 etc.)
   handle per-button transforms. The blanket button:hover was overriding them. */

/* Enhanced focus styles */
button:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 0.5rem;
}

/* Disabled button styles */
button:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

button:disabled:hover {
    transform: none !important;
}

/* Focus styles for accessibility */
.grid-cell:focus,
button:focus,
select:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Clue navigation styling */
#currentClue {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 5rem;
    border-radius: 1rem;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    max-width: 100%;
}



/* New clue type styling */
.clue-type-xor {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    max-width: 100%;
}

.clue-type-group {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    max-width: 100%;
}

.clue-type-biconditional {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    max-width: 100%;
}

.clue-type-double-negative {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    max-width: 100%;
}

.clue-type-simple {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    max-width: 100%;
}

/* Dark mode: lighten saturated utility text colors for legibility */
.dark .text-blue-400 { color: #b3d0ff !important; }
.dark .text-purple-400 { color: #dacfff !important; }
.dark .text-green-400 { color: #c0f0d1 !important; }
.dark .text-emerald-400 { color: #b9f2e2 !important; }
.dark .text-cyan-400 { color: #b8f3ff !important; }
.dark .text-sky-400 { color: #c7e2ff !important; }
.dark .text-orange-400 { color: #ffdba8 !important; }
.dark .text-amber-400 { color: #ffe6a8 !important; }
.dark .text-red-400 { color: #ffb5b5 !important; }

/* Clue navigation button animations */
#prevClueBtn:hover,
#nextClueBtn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Dark mode override for clue navigation button hover - tone down brightness */
.dark #prevClueBtn:hover,
.dark #nextClueBtn:hover {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#prevClueBtn:active,
#nextClueBtn:active {
    transform: scale(0.98);
}

/* Print styles */
@media print {
    .no-print {
        display: none;
    }
    
    .modal {
        display: none !important;
    }
}

/* Modern scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Font family defaults */
body {
    font-family: 'Public Sans', sans-serif;
}

.font-jetbrains {
    font-family: 'JetBrains Mono', monospace;
}

.font-public-sans {
    font-family: 'Public Sans', sans-serif;
}

.font-roboto {
    font-family: 'Roboto', sans-serif;
}

/* Selection styling */
::selection {
    background-color: #3b82f6;
    color: white;
}

::-moz-selection {
    background-color: #3b82f6;
    color: white;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .animate-bounce,
    .animate-pulse {
        animation: none !important;
    }
}

/* Gradient text with solid-color fallback for older Safari */
.gradient-text {
  /* Fallback solid colors when text clipping isn't supported */
  color: #1f2937; /* slate-800 */
}
.dark .gradient-text {
  color: #f1f5f9; /* lighten for better contrast on dark */
}
@supports (-webkit-background-clip: text) {
  .gradient-text {
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    /* Apply gradient background only when clipping is supported to avoid blocks */
    background-image: linear-gradient(to right, #2563eb, #7c3aed); /* blue-600 to purple-600 */
  }
  .dark .gradient-text {
    /* Lighten the gradient stops in dark mode for readability (one level lighter) */
    background-image: linear-gradient(to right, #b3d0ff, #dacfff);
  }
}

/* Category dividing lines */
.grid-with-dividers {
    position: relative;
}

.dividing-line {
    position: absolute;
    pointer-events: none;
    z-index: 10;
}

/* Stabilize alternating background overlays to prevent neighbor flicker */
.alternating-bg {
    contain: paint;
    transform: translateZ(0);
    backface-visibility: hidden;
}

@media (hover: none) {
  /* On touch devices, eliminate transitions to reduce flicker during taps */
  .grid-cell {
    transition: none !important;
  }
}