/**
 * Chess Clock Timer Styles
 * Professional timing for chess and turn-based games
 */

/* Chess Clock Wrapper */
.chess-clock-wrapper {
    width: 100%;
    max-width: 1600px;
}

/* Override the landing page hero wrapper constraint */
.hero-counter-wrapper.chess-clock-wrapper {
    max-width: 1200px;
}

.chess-clocks-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    width: 100%;
    margin-bottom: 1.5rem;
}

/* Toolbar above the grid */
.chess-clock-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

.grid-fullscreen-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.grid-fullscreen-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.add-clock-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-clock-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary-color);
    background: var(--bg-hover);
}

/* Individual Chess Clock Card */
.chess-clock-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    overflow: hidden;
    position: relative;
}

/* Per-card accent color overlay */
.chess-clock-card[data-accent-color] {
    border-color: var(--card-accent, var(--border-color));
}

.chess-clock-card .card-accent-overlay {
    display: none;
}

.chess-clock-card[data-accent-color] .card-accent-overlay {
    display: block;
    position: absolute;
    inset: 0;
    background: var(--card-accent, transparent);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

.chess-clock-card > * {
    position: relative;
    z-index: 1;
}

/* Color picker in settings */
.color-picker-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.color-swatches {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--text-primary);
}

.color-swatch.no-color {
    background: var(--bg-tertiary);
    position: relative;
}

.color-swatch.no-color::after {
    content: '\00d7';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* Alternating card colors (fallback when no accent) */
.chess-clock-card.shade-alt {
    background: var(--bg-tertiary);
}

.chess-clock-card.shade-alt .clock-header {
    background: var(--bg-secondary);
}

.chess-clock-card.shade-alt .player-side.player-1 {
    background: var(--bg-hover);
}

.chess-clock-card.shade-alt .player-side.player-2 {
    background: var(--bg-tertiary);
}

.chess-clock-card.shade-alt .clock-controls {
    background: var(--bg-secondary);
}

/* Single card fullscreen */
.chess-clock-card.fullscreen {
    position: fixed;
    inset: 0;
    border-radius: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

.chess-clock-card.fullscreen .clock-players {
    flex: 1;
}

.chess-clock-card.fullscreen .player-time {
    font-size: 6rem;
}

/* ============================================
   Grid Fullscreen Mode (tournament TV view)
   ============================================ */
.chess-clock-wrapper.grid-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9998;
    max-width: none;
    padding: 0.75rem;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    overflow: auto;
}

.chess-clock-wrapper.grid-fullscreen .chess-clocks-grid {
    flex: 1;
    margin-bottom: 0;
}

/* Hide controls in grid fullscreen */
.chess-clock-wrapper.grid-fullscreen .clock-controls {
    display: none;
}

.chess-clock-wrapper.grid-fullscreen .clock-actions {
    display: none;
}

.chess-clock-wrapper.grid-fullscreen .clock-header {
    padding: 0.375rem 0.75rem;
}

.chess-clock-wrapper.grid-fullscreen .add-clock-btn {
    display: none;
}

/* Make cards fill height better in grid fullscreen */
.chess-clock-wrapper.grid-fullscreen .chess-clock-card {
    min-height: 0;
}

.chess-clock-wrapper.grid-fullscreen .player-side {
    padding: 1rem 0.5rem;
    min-height: 80px;
}

.chess-clock-wrapper.grid-fullscreen .player-time {
    font-size: 2rem;
}

/* Auto-fit rows in grid fullscreen */
.chess-clock-wrapper.grid-fullscreen .chess-clocks-grid {
    grid-auto-rows: 1fr;
}

/* Clock Header */
.clock-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.clock-title-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.clock-title-input {
    width: 100%;
    min-width: 0;
    padding: 0.25rem 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    text-overflow: ellipsis;
    overflow: hidden;
    color: var(--text-primary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.clock-title-input:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
}

.clock-title-input:focus {
    outline: none;
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.clock-title-input::placeholder {
    color: var(--text-tertiary);
    font-weight: 500;
}

.clock-type-label {
    padding-left: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

.clock-actions {
    display: flex;
    gap: 0.25rem;
}

.clock-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clock-action-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.clock-action-btn.delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Clock Players */
.clock-players {
    display: flex;
    flex-direction: row;
}

.player-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 120px;
    min-width: 0;
    overflow: hidden;
}

.player-side.player-1 {
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border-color);
}

.player-side.player-2 {
    background: var(--bg-secondary);
}

.player-side.active {
    background: rgba(59, 130, 246, 0.15);
}

.player-side.active.player-1 {
    background: rgba(59, 130, 246, 0.15);
}

.player-side.active.player-2 {
    background: rgba(139, 92, 246, 0.15);
}

.player-side.expired {
    background: rgba(239, 68, 68, 0.15);
}

.player-side.expired .player-time {
    color: #ef4444;
}

.player-name-input {
    width: 100%;
    max-width: 120px;
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-tertiary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.player-name-input:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
}

.player-name-input:focus {
    outline: none;
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.player-time {
    font-size: 2.5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    line-height: 1;
    user-select: none;
}

.player-side.active .player-time {
    color: #3b82f6;
}

.player-side.active.player-2 .player-time {
    color: #8b5cf6;
}

/* Clock Controls */
.clock-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.clock-control-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clock-control-btn:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.clock-control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.clock-control-btn.start {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
    color: white;
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.clock-control-btn.start:hover {
    filter: brightness(1.1);
}

/* Settings Modal */
.clock-settings-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.clock-settings-modal.open {
    display: flex;
}

.clock-settings-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    width: 100%;
    max-width: 360px;
    overflow: hidden;
}

.clock-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.clock-settings-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.clock-settings-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.setting-label {
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.setting-input {
    width: 80px;
    padding: 0.625rem 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
}

.setting-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.clock-settings-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.apply-clock-settings-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apply-clock-settings-btn:hover {
    filter: brightness(1.1);
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Responsive */
@media (max-width: 1024px) {
    .chess-clocks-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .chess-clocks-grid {
        grid-template-columns: 1fr;
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .player-time {
        font-size: 2rem;
    }

    .chess-clock-card.fullscreen .player-time {
        font-size: 4rem;
    }

    .clock-players {
        flex-direction: column;
    }

    .player-side.player-1 {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}
