/* ==========================================================================
   CROSSWORD PLAYER - DESKTOP STYLES
   ========================================================================== */

/* Desktop Layout - Page Container
   ========================================================================== */

/**
 * Prevent page scrolling on desktop - only clue lists should scroll
 * The entire crossword player should fit within the viewport
 */
body:has(.gcc__shell) {
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Desktop Layout - Main Container
   ========================================================================== */

/**
 * Desktop: 3-column grid layout (Across | Grid | Down)
 * Mobile: Will be replaced with vertical stack layout
 */
.gcc__shell {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    box-sizing: border-box;
    gap: 2rem;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}


/* Desktop Layout - Crossword Grid
   ========================================================================== */

/**
 * Grid container structure
 * Shared between desktop and mobile
 */
.gcc__g {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.gcc__g-header {
    flex-shrink: 0;
}

.gcc__g-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/**
 * Crossword table element
 */
.gcc__g table {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
    container-type: inline-size;
    border: 2px solid rgba(74, 158, 255, 0.3);
    border-radius: 3px;
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3),
        inset 2px 0 4px rgba(0, 0, 0, 0.25),
        inset -2px 0 4px rgba(0, 0, 0, 0.25),
        0 0 20px rgba(74, 158, 255, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.gcc__g tbody,
.gcc__g tr {
    width: 100%;
}

/**
 * Grid cells - Base styles
 */
.gcc__g td {
    position: relative;
    width: calc(100% / var(--grid-size));
    height: 0;
    padding-bottom: calc(100% / var(--grid-size));
    border: 1px solid rgba(217, 218, 219, 0.25);
    background: linear-gradient(180deg,
        #f8fbff 0%,
        #f0f6ff 100%);
}

/**
 * Grid cells - Block/Empty cells
 */
.gcc__g td.block {
    background: #202020;
    pointer-events: none;
}

.gcc__g td.block .cell {
    display: none;
}

/**
 * Grid cells - Cell modifiers (states)
 */

/* Selected cell - Vibrant blue highlight */
.gcc__g td.cell--selected {
    background: linear-gradient(180deg,
        #5ab0ff 0%,
        #4a9eff 50%,
        #3680d8 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        inset 0 -1px 0 rgba(40, 104, 184, 0.6),
        0 0 12px rgba(74, 158, 255, 0.9),
        0 0 20px rgba(90, 176, 255, 0.5);
}

/* Word cells - Light blue for current word */
.gcc__g td.cell--word {
    background: linear-gradient(180deg,
        #d0e5ff 0%,
        #bcdaff 50%,
        #a8d0ff 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -1px 0 rgba(74, 158, 255, 0.3);
}

/* Cross cells - Very subtle highlight for crossing word */
.gcc__g td.cell--cross {
    background: linear-gradient(180deg,
        #f5f9ff 0%,
        #f0f7ff 100%);
}

/**
 * Grid cells - Cell content (input)
 */
.gcc__g .cell {
    position: absolute;
    inset: 0;
    border: 0;
    background: transparent;
    text-align: center;
    text-transform: uppercase;
    font: 700 clamp(0.5rem, 2cqi, 1.9rem) var(--font-gcc-cell);
    display: flex;
    align-items: center;
    justify-content: center;
    caret-color: transparent;
    user-select: none;
}

.gcc__g .cell::selection {
    background: transparent;
}

/**
 * Grid cells - Clue numbers
 */
.gcc__g .clue-number {
    position: absolute;
    top: 0;
    left: 0;
    font: bold clamp(0.35rem, 1cqi, 1rem) sans-serif;
    color: #000000;
    pointer-events: none;
}

/**
 * Desktop only: Current clue display below grid
 */
.gcc__g-current-clue {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(180deg,
        rgba(74, 158, 255, 0.15) 0%,
        rgba(54, 128, 216, 0.1) 100%);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 6px;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gcc__g-current-clue-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    line-height: 1.4;
}


/* Desktop Layout - Clue Panels (Across & Down)
   ========================================================================== */

/**
 * Clue column containers (gcc__c1 = Across, gcc__c2 = Down)
 * Desktop only: Side panels with clue lists
 */
.gcc__c1,
.gcc__c2 {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/**
 * Clue panel headers
 */
.gcc__c1-header,
.gcc__c2-header {
    flex-shrink: 0;
}

/**
 * Clue panel content areas (scrollable)
 */
.gcc__c1-content,
.gcc__c2-content {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/**
 * Custom scrollbar styling for clue panels
 */
.gcc__c1-content::-webkit-scrollbar,
.gcc__c2-content::-webkit-scrollbar {
    width: 12px;
}

.gcc__c1-content::-webkit-scrollbar-track,
.gcc__c2-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    margin: 4px 0;
}

.gcc__c1-content::-webkit-scrollbar-thumb,
.gcc__c2-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg,
        rgba(107, 182, 255, 0.25) 0%,
        rgba(74, 158, 255, 0.2) 50%,
        rgba(54, 128, 216, 0.22) 100%);
    border-radius: 10px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    box-shadow:
        inset 0 1px 0 rgba(150, 210, 255, 0.3),
        inset 0 -1px 0 rgba(30, 80, 150, 0.2);
}

.gcc__c1-content::-webkit-scrollbar-thumb:hover,
.gcc__c2-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg,
        rgba(107, 182, 255, 0.35) 0%,
        rgba(74, 158, 255, 0.3) 50%,
        rgba(54, 128, 216, 0.32) 100%);
}

/**
 * Clue lists
 */
.gcc__c1-content ol,
.gcc__c2-content ol {
    list-style: none;
    margin: 0;
    padding: 0 0 2rem 0;
}

/**
 * Individual clue items - Base styles
 */
.gcc__c1-content ol li,
.gcc__c2-content ol li {
    cursor: pointer;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    border-radius: 4px;
    transition: background-color 0.15s ease;
    font: 500 clamp(0.8rem, 1.4cqi, 1.5rem) var(--font-gcc-c1-c2);
}

/**
 * Individual clue items - Hover state
 */
.gcc__c1-content ol li:hover,
.gcc__c2-content ol li:hover {
    background: linear-gradient(180deg,
        rgba(107, 182, 255, 0.5) 0%,
        rgba(74, 158, 255, 0.42) 50%,
        rgba(46, 112, 196, 0.35) 100%);
    box-shadow:
        inset 0 1px 0 rgba(150, 210, 255, 0.6),
        inset 0 -1px 0 rgba(30, 80, 150, 0.5),
        0 3px 12px rgba(74, 158, 255, 0.5),
        0 0 20px rgba(107, 182, 255, 0.3);
}

/**
 * Individual clue items - Active/Selected state
 */
.gcc__c1-content ol li.clue--active,
.gcc__c2-content ol li.clue--active {
    color: #E8F4FF;
    font-weight: 600;
    background: linear-gradient(180deg,
        rgba(90, 175, 255, 0.6) 0%,
        rgba(74, 158, 255, 0.5) 50%,
        rgba(54, 128, 216, 0.45) 100%);
    box-shadow:
        inset 0 1px 0 rgba(160, 215, 255, 0.7),
        inset 0 -1px 0 rgba(40, 90, 160, 0.6),
        0 2px 10px rgba(74, 158, 255, 0.4);
}


/* Visibility Utilities (Desktop/Mobile)
   ========================================================================== */

/**
 * Mobile-only elements (hidden on desktop)
 * Mobile styles will be added in a separate section
 */
.gcc__mobile-only {
    display: none;
}

/**
 * Desktop-only elements (will be hidden on mobile)
 * Mobile styles will add: @media (max-width: 767px) { display: none; }
 */
/* .gcc__desktop-only - No styles needed for desktop, visible by default */


/* ==========================================================================
   MOBILE STYLES
   ========================================================================== */

@media (max-width: 767px) {

    /* Hide desktop-only elements
       ====================================================================== */

    .gcc__desktop-only {
        display: none;
    }

    /* Show mobile-only elements
       ====================================================================== */

    .gcc__mobile-only {
        display: flex;
    }


    /* Mobile Layout - Reset desktop body constraints
       ====================================================================== */

    /**
     * On mobile, we need scrolling and different layout
     * Reset the desktop fixed body styles
     */
    html, body:has(.gcc__shell) {
        overflow: visible;
        height: auto;
        display: block;
        background-color: #0f1215;
    }


    /* Mobile Layout - 4 rows perfectly stacked
       ====================================================================== */

    /**
     * Main container: Vertical stack instead of 3-column grid
     * Contains 3 rows: row1 (grid), row2 (clue), row3 (keyboard)
     */
    .gcc__shell {
        display: flex;
        flex-direction: column;
        grid-template-columns: unset;
        gap: 0;
        height: calc(100vh - 3rem);
        width: 100vw;
        max-width: 100vw;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom);
        margin: 0;
    }


    /* Row 1: Crossword Grid
       ====================================================================== */

    .gcc__mobile__row1 {
        min-height: 0;
        overflow: hidden;
        padding: 0.5rem;
    }

    .gcc__g-header {
        display: none;
    }

    .gcc__g table {
        max-height: 100%;
        max-width: 100%;
    }

    .gcc__g td {
        padding-bottom: calc(90% / var(--grid-size));
    }

    .gcc__g .cell {
        font-size: 1.1rem;
        padding: 0;
        box-sizing: border-box;
    }

    .gcc__g .clue-number {
        color: #133997;
        font-style: italic;
        font-size: 0.5rem;
    }


    /* Row 2: Current Clue Display
       ====================================================================== */

    .gcc__mobile__row2 {
        flex-shrink: 0;
        height: 4rem;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
        align-items: center;
        justify-content: space-between;
    }

    .gcc__current-clue-text {
        flex: 1;
        font-size: 0.9rem;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .gcc__clue-nav {
        flex-shrink: 0;
        width: 3.5rem;
        height: 3.5rem;
        background: linear-gradient(180deg,
            rgba(107, 182, 255, 0.45) 0%,
            rgba(74, 158, 255, 0.35) 50%,
            rgba(54, 128, 216, 0.3) 100%);
        border-top: 2px solid rgba(150, 210, 255, 0.6);
        border-left: 1px solid rgba(120, 190, 255, 0.5);
        border-right: 1px solid rgba(30, 80, 150, 0.5);
        border-bottom: 2px solid rgba(30, 80, 150, 0.6);
        border-radius: 6px;
        color: rgba(255, 255, 255, 0.95);
        font-size: 1.8rem;
        cursor: pointer;
        box-shadow:
            inset 0 2px 3px rgba(200, 230, 255, 0.5),
            inset 0 -3px 4px rgba(20, 60, 120, 0.4),
            inset 2px 0 2px rgba(150, 210, 255, 0.3),
            inset -2px 0 2px rgba(30, 80, 150, 0.3),
            0 3px 6px rgba(0, 0, 0, 0.4),
            0 6px 12px rgba(0, 0, 0, 0.3);
        transition: all 0.15s ease;
    }

    .gcc__clue-nav:active {
        background: linear-gradient(180deg,
            rgba(54, 128, 216, 0.5) 0%,
            rgba(74, 158, 255, 0.4) 50%,
            rgba(107, 182, 255, 0.35) 100%);
        border-top: 2px solid rgba(30, 80, 150, 0.7);
        border-left: 1px solid rgba(30, 80, 150, 0.6);
        border-right: 1px solid rgba(120, 190, 255, 0.4);
        border-bottom: 2px solid rgba(150, 210, 255, 0.5);
        box-shadow:
            inset 0 3px 6px rgba(0, 0, 0, 0.5),
            inset 0 -2px 3px rgba(150, 210, 255, 0.2),
            inset 3px 0 4px rgba(0, 0, 0, 0.3),
            inset -3px 0 4px rgba(0, 0, 0, 0.3),
            0 1px 2px rgba(0, 0, 0, 0.3);
        transform: translateY(2px);
    }


    /* Row 3: Keyboard
       ====================================================================== */

    .gcc__mobile__row3 {
        flex-shrink: 0;
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.5rem;
        background: rgba(0, 0, 0, 0.2);
    }

    .gcc__keyboard-row {
        display: flex;
        justify-content: center;
        gap: 0.25rem;
    }

    .gcc__key {
        flex: 1;
        max-width: 2.5rem;
        height: 2.5rem;
        background: linear-gradient(180deg,
            rgba(107, 182, 255, 0.3) 0%,
            rgba(74, 158, 255, 0.25) 50%,
            rgba(54, 128, 216, 0.2) 100%);
        border-top: 1px solid rgba(150, 210, 255, 0.4);
        border-left: 1px solid rgba(120, 190, 255, 0.35);
        border-right: 1px solid rgba(30, 80, 150, 0.35);
        border-bottom: 1px solid rgba(30, 80, 150, 0.4);
        border-radius: 4px;
        color: rgba(255, 255, 255, 0.9);
        font-weight: 600;
        font-size: 1rem;
        cursor: pointer;
        box-shadow:
            inset 0 1px 2px rgba(200, 230, 255, 0.3),
            inset 0 -1px 2px rgba(20, 60, 120, 0.25),
            0 2px 4px rgba(0, 0, 0, 0.25);
        transition: all 0.12s ease;
    }

    .gcc__key:active {
        background: linear-gradient(180deg,
            rgba(54, 128, 216, 0.35) 0%,
            rgba(74, 158, 255, 0.3) 50%,
            rgba(107, 182, 255, 0.25) 100%);
        border-top: 1px solid rgba(30, 80, 150, 0.45);
        border-left: 1px solid rgba(30, 80, 150, 0.4);
        border-right: 1px solid rgba(120, 190, 255, 0.3);
        border-bottom: 1px solid rgba(150, 210, 255, 0.35);
        box-shadow:
            inset 0 2px 3px rgba(0, 0, 0, 0.3),
            inset 0 -1px 2px rgba(150, 210, 255, 0.15),
            0 1px 2px rgba(0, 0, 0, 0.2);
        transform: translateY(1px);
    }

    .gcc__key--backspace,
    .gcc__key--space {
        max-width: 3rem;
    }

}


/* ==========================================================================
   LARGER MOBILE DEVICES (iPhone 15 Plus, 16 Pro Max, 17 Air/Pro Max)
   ========================================================================== */

/**
 * Media query for larger iPhones:
 * - iPhone 15 Plus (428px viewport)
 * - iPhone 16 Pro Max (430px viewport)
 * - iPhone 17 Air (428px viewport)
 * - iPhone 17 Pro Max (430px viewport)
 */
@media (max-width: 767px) and (min-width: 404px) {

    /* Row 2: Increase clue display height for better readability */
    .gcc__mobile__row2 {
        height: 5.5rem;
    }

    /* Row 3: Increase keyboard key height for easier tapping */
    .gcc__key {
        font-size: 1.2rem;
        height: 3.5rem;
    }

}


/* ==========================================================================
   SAVE STATUS INDICATOR
   ========================================================================== */

/**
 * Save status indicator for pro users
 * Shows: Saved | Saving... | Retrying... | Error
 * Positioned in navbar top right on desktop, hidden on mobile
 */
.save-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

/* Icon - pulsing dot indicator */
.save-status__icon {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

/* States */
.save-status--saved {
    color: #059669;
    background-color: #d1fae5;
}

.save-status--saved .save-status__icon {
    background-color: #059669;
}

.save-status--saving,
.save-status--pending {
    color: #0284c7;
    background-color: #dbeafe;
}

.save-status--saving .save-status__icon,
.save-status--pending .save-status__icon {
    background-color: #0284c7;
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.save-status--retrying {
    color: #d97706;
    background-color: #fef3c7;
}

.save-status--retrying .save-status__icon {
    background-color: #d97706;
    animation: pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.save-status--error {
    color: #dc2626;
    background-color: #fee2e2;
}

.save-status--error .save-status__icon {
    background-color: #dc2626;
}

.save-status--hidden {
    opacity: 0;
    pointer-events: none;
}

/* Pulse animation for saving/retrying states */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* Mobile: hide completely */
@media (max-width: 767px) {
    .save-status {
        display: none;
    }
}


/* ==========================================================================
   ANONYMOUS USER BANNER
   ========================================================================== */

/**
 * Banner shown to anonymous users instead of breadcrumb navigation
 * Provides branding and CTA to sign up
 * Hidden on mobile (login button in mobile nav instead)
 */
.gcc__anon-banner {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    font-family: var(--font-brand), sans-serif;
    font-size: 0.65rem;
}

.gcc__anon-banner__title {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    margin-right: 0.5rem;
}

.gcc__anon-banner__edition {
    color: rgba(255, 255, 255, 0.7);
    margin-right: 0.5rem;
}

.gcc__anon-banner__cta {
    color: rgba(255, 255, 255, 0.7);
    margin-left: auto;
}

.gcc__anon-banner__cta a {
    color: rgba(130, 170, 215, 1);
    /*text-decoration: underline;*/
    transition: color 0.15s ease;
}

.gcc__anon-banner__cta a:hover {
    color: rgba(150, 190, 235, 1);
}

/* Mobile: hide banner (login button in mobile nav instead) */
@media (max-width: 767px) {
    .gcc__anon-banner {
        display: none;
    }
}
