/* ============================================
   Chess Clock - Hidden Panel Feature (home page bottom)
   ============================================ */

.chess-clock-section {
  padding: var(--space-8) 0 var(--space-6);
  background: var(--color-bg-primary);
}

.chess-clock-toggle {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

/* Trigger = the <summary> element styled as a discreet outline button */
.chess-clock-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-gold);
  background: transparent;
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  list-style: none;
  user-select: none;
}

.chess-clock-trigger::-webkit-details-marker { display: none; }
.chess-clock-trigger::marker { display: none; }

.chess-clock-trigger:hover {
  background: rgba(201, 168, 76, 0.1);
  box-shadow: var(--shadow-gold);
}

.chess-clock-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-gold-glow);
}

.chess-clock-trigger-icon {
  font-size: var(--text-lg);
  color: var(--color-gold);
  line-height: 1;
}

.chess-clock-trigger-chevron {
  font-size: var(--text-base);
  transition: transform var(--transition-base);
  line-height: 1;
}

.chess-clock-toggle[open] .chess-clock-trigger-chevron {
  transform: rotate(180deg);
}

/* Panel = the body that appears when <details> is open */
.chess-clock-panel {
  margin-top: var(--space-5);
  text-align: left;
  background: var(--color-bg-card);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  animation: chessClockSlideIn var(--transition-base) ease;
}

@keyframes chessClockSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== SETUP VIEW ===== */
.chess-clock-setup {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* The HTML `hidden` attribute would normally apply display:none, but
   `display: flex` above wins the cascade. Restore the expected behavior. */
.chess-clock-setup[hidden] {
  display: none;
}

.chess-clock-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

@media (min-width: 600px) {
  .chess-clock-presets {
    grid-template-columns: repeat(6, 1fr);
  }
}

.chess-clock-preset {
  padding: var(--space-3) var(--space-2);
  background: var(--color-bg-secondary);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--color-cream);
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chess-clock-preset:hover {
  border-color: var(--color-gold);
  color: var(--color-gold);
  background: rgba(201, 168, 76, 0.05);
  transform: translateY(-1px);
}

.chess-clock-preset:focus-visible {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px var(--color-gold-glow);
}

.chess-clock-preset.selected {
  border-color: var(--color-gold);
  background: rgba(201, 168, 76, 0.12);
  color: var(--color-gold);
  box-shadow: var(--shadow-gold);
}

.chess-clock-launch {
  align-self: stretch;
}

/* ===== GAME VIEW ===== */
/* The game view is only ever shown in fullscreen mode — no inline rendering.
   This also dodges the [hidden] vs display:flex cascade issue. */
.chess-clock-game {
  display: none;
}

.chess-clock-game.fullscreen {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.chess-clock-board {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.chess-clock-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  background: var(--color-bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  min-height: 140px;
  font-family: inherit;
  color: inherit;
}

.chess-clock-side:hover {
  background: var(--color-bg-card-hover);
}

.chess-clock-side:focus-visible {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px var(--color-gold-glow);
}

.chess-clock-side.active {
  border-color: var(--color-gold);
  background: rgba(201, 168, 76, 0.08);
  box-shadow: var(--shadow-gold);
}

.chess-clock-side.low-time {
  background: rgba(168, 50, 50, 0.15);
}

.chess-clock-side.low-time .chess-clock-time {
  color: var(--color-danger);
}

.chess-clock-side.flagged {
  border-color: var(--color-danger);
  background: rgba(168, 50, 50, 0.12);
  cursor: default;
}

.chess-clock-side.flagged .chess-clock-time {
  color: var(--color-danger);
  font-size: var(--text-2xl);
  letter-spacing: var(--tracking-wide);
}

.chess-clock-side-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-cream-dim);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.chess-clock-time {
  font-family: var(--font-heading);
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--color-cream);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  transition: color var(--transition-fast);
}

.chess-clock-moves {
  font-size: var(--text-xs);
  color: var(--color-gray);
}

.chess-clock-controls {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Floating Pause button — sits between the two timer cards */
.chess-clock-pause {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 90px;
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-gold);
  color: var(--color-gold);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  z-index: 1;
  opacity: 0.7;
  transition: opacity var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.chess-clock-pause:hover {
  opacity: 1;
  background: var(--color-bg-card-hover);
}

.chess-clock-pause:focus-visible {
  outline: none;
  opacity: 1;
  box-shadow: 0 0 0 3px var(--color-gold-glow);
}

/* Mobile tweaks */
@media (max-width: 599px) {
  .chess-clock-panel {
    padding: var(--space-4);
  }

  .chess-clock-time {
    font-size: var(--text-3xl);
  }

  .chess-clock-side {
    min-height: 120px;
    padding: var(--space-4) var(--space-2);
  }

  .chess-clock-controls .btn {
    flex: 1;
    min-width: 130px;
  }
}

/* ===== FULLSCREEN MODE (active during a game) ===== */
body.chess-clock-fullscreen-active {
  overflow: hidden;
}

.chess-clock-game.fullscreen {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--color-bg-primary);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: chessClockFsIn 250ms ease;
}

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

.chess-clock-game.fullscreen .chess-clock-board {
  flex: 1;
  min-height: 0;
}

@media (max-width: 767px) {
  .chess-clock-game.fullscreen .chess-clock-board {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

.chess-clock-game.fullscreen .chess-clock-side {
  min-height: 0;
  padding: var(--space-6);
  border-width: 3px;
}

.chess-clock-game.fullscreen .chess-clock-side-label {
  font-size: var(--text-base);
  margin-bottom: var(--space-3);
}

.chess-clock-game.fullscreen .chess-clock-time {
  font-size: clamp(3.5rem, 14vw, 9rem);
}

.chess-clock-game.fullscreen .chess-clock-side.flagged .chess-clock-time {
  font-size: clamp(2.5rem, 10vw, 6rem);
}

.chess-clock-game.fullscreen .chess-clock-moves {
  font-size: var(--text-base);
  margin-top: var(--space-3);
}

.chess-clock-game.fullscreen .chess-clock-controls {
  flex-shrink: 0;
}

.chess-clock-game.fullscreen .chess-clock-controls .btn {
  min-width: 140px;
}

.chess-clock-game.fullscreen .chess-clock-pause {
  min-width: 110px;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
}
