/* ═══════════════════════════════════════════════════════════════════
   MIA GAMES — Tic-Tac-Toe Game Styles
   File     : games/tic-tac-toe/tictactoe.css
   Inherits : ../../style.css (global tokens + layout)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Breadcrumb ─────────────────────────────────────────────────── */
.breadcrumb-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.625rem 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.breadcrumb li {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb a:hover { color: var(--accent-purple); }

.breadcrumb [aria-current="page"] {
  color: var(--text-secondary);
  font-weight: var(--fw-medium);
}

/* ── Screen-reader only utility ─────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── SEO Article Content ────────────────────────────────────────── */
.seo-content {
  padding: 2.5rem 0 1rem;
  border-top: 1px solid var(--border-subtle);
}

.seo-content h2 {
  font-size: clamp(var(--fs-xl), 2.5vw, var(--fs-2xl));
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.seo-content h3 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin-top: 1.75rem;
  margin-bottom: 0.6rem;
}

.seo-content p {
  font-size: var(--fs-base);
  color: var(--text-secondary);
  line-height: 1.85;
  max-width: none;
  margin-bottom: 1rem;
}

.seo-content ul {
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.seo-content ul li {
  list-style: disc;
  font-size: var(--fs-base);
  color: var(--text-secondary);
  line-height: 1.75;
}

/* ══════════════════════════════════════════════════════════════════
   TIC-TAC-TOE BOARD
   ══════════════════════════════════════════════════════════════════ */

.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1 / 1;
  position: relative;
}

/* Individual cell */
/* ── Individual cell ── */
.ttt-cell {
  position: relative;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  color: transparent;  /* symbol colour set by modifier classes */
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background   var(--transition-fast),
    border-color var(--transition-fast),
    transform    var(--transition-spring);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
  /* ── FIX: Ensure cells maintain consistent size ── */
  aspect-ratio: 1 / 1;
  width: 100%;
  height: 100%;
  min-height: 50px;
  min-width: 50px;
}

.ttt-cell:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 2px;
}

/* Hover — only on empty, enabled cells */
.ttt-cell:not(.ttt-cell--x):not(.ttt-cell--o):not(:disabled):hover {
  background: var(--bg-surface);
  border-color: var(--accent-purple);
  transform: scale(0.96);
}

/* X mark */
.ttt-cell--x {
  color: var(--accent-purple);
  border-color: var(--accent-purple);
  background: var(--accent-purple-dim);
  cursor: default;
}

.ttt-cell--x::before {
  content: 'X';
  animation: cellPop 0.22s var(--ease-spring) both;
}

/* O mark */
.ttt-cell--o {
  color: var(--accent-teal);
  border-color: var(--accent-teal);
  background: var(--accent-teal-dim);
  cursor: default;
}

.ttt-cell--o::before {
  content: 'O';
  animation: cellPop 0.22s var(--ease-spring) both;
}

/* Winning cells */
.ttt-cell--win {
  animation: winPulse 0.5s var(--ease-spring) both;
}

.ttt-cell--x.ttt-cell--win {
  background: rgba(124, 109, 250, 0.22);
  border-color: var(--accent-purple);
  box-shadow: 0 0 20px rgba(124, 109, 250, 0.35);
}

.ttt-cell--o.ttt-cell--win {
  background: rgba(62, 207, 207, 0.22);
  border-color: var(--accent-teal);
  box-shadow: 0 0 20px rgba(62, 207, 207, 0.35);
}

/* Disabled (game over) */
.ttt-cell:disabled {
  cursor: default;
  opacity: 1;
}

/* Loser cells dim slightly */
.ttt-board.game-over .ttt-cell:not(.ttt-cell--win) {
  opacity: 0.45;
}

/* Draw — all cells dim equally */
.ttt-board.draw .ttt-cell {
  opacity: 0.6;
}

/* Cell entry animation */
@keyframes cellPop {
  0%   { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  70%  { transform: scale(1.15) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg);    opacity: 1; }
}

@keyframes winPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.10); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* ── Win Overlay Line ────────────────────────────────────────────── */
/* SVG line is injected by JS and overlaid on the board */
.ttt-win-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.ttt-win-overlay svg {
  width: 100%;
  height: 100%;
}

/* ── AI Thinking Indicator ──────────────────────────────────────── */
.ttt-thinking {
  display: none;
  align-items: center;
  gap: 4px;
  height: 20px;
}

.ttt-thinking.is-visible {
  display: flex;
}

.thinking-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-purple);
  animation: thinkBounce 1.1s ease-in-out infinite;
}

.thinking-dot:nth-child(2) { animation-delay: 0.18s; }
.thinking-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes thinkBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%            { transform: scale(1.1); opacity: 1;   }
}

/* ── Game Status Message ─────────────────────────────────────────── */
.game-status {
  font-family: var(--font-display);
  font-size: clamp(var(--fs-base), 2vw, var(--fs-lg));
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.8em;
  letter-spacing: var(--ls-snug);
  transition: color var(--transition-base);
}

.game-status.status--win  { color: var(--accent-green); }
.game-status.status--lose { color: var(--accent-red);   }
.game-status.status--draw { color: var(--accent-amber);  }

/* ── Score values pop when updated ──────────────────────────────── */
.score-bump {
  animation: scoreBump 0.35s var(--ease-spring) both;
}

@keyframes scoreBump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.45); color: var(--accent-green); }
  100% { transform: scale(1); }
}

/* ── Responsive Adjustments ─────────────────────────────────────── */
@media (max-width: 768px) {
  .ttt-board {
    max-width: 300px;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .ttt-board {
    max-width: 270px;
    gap: 6px;
  }

  .ttt-cell {
    border-radius: var(--radius-md);
    border-width: 1.5px;
  }
}

@media (max-width: 360px) {
  .ttt-board {
    max-width: 240px;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   TIC-TAC-TOE GAME OVER MODAL
   ═══════════════════════════════════════════════════════════════════ */

.ttt-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: modalFadeIn 0.4s ease;
}

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

.ttt-modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--border-accent);
  animation: modalPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPopIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.ttt-modal-icon {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  display: block;
}

.ttt-modal-content h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.ttt-modal-content p {
  font-size: var(--fs-base);
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.ttt-modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.ttt-modal-stat {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.5rem;
}

.ttt-modal-stat-label {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  font-weight: var(--fw-medium);
}

.ttt-modal-stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  line-height: 1.2;
}

.ttt-modal-content .control-btn {
  padding: 0.75rem 2.5rem;
  font-size: var(--fs-base);
  background: var(--gradient-brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: transform var(--transition-spring), box-shadow var(--transition-base);
  box-shadow: 0 4px 18px rgba(124, 109, 250, 0.3);
}

.ttt-modal-content .control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124, 109, 250, 0.4);
}

/* Modal responsiveness */
@media (max-width: 480px) {
  .ttt-modal-content {
    padding: 1.5rem 1rem;
  }

  .ttt-modal-content h2 {
    font-size: 1.4rem;
  }

  .ttt-modal-icon {
    font-size: 2.5rem;
  }

  .ttt-modal-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3rem;
  }

  .ttt-modal-stat {
    padding: 0.5rem 0.3rem;
  }

  .ttt-modal-stat-value {
    font-size: var(--fs-lg);
  }

  .ttt-modal-content .control-btn {
    padding: 0.6rem 1.5rem;
    font-size: var(--fs-sm);
  }
}


/* ═══════════════════════════════════════════════════════════════════
   UNIVERSAL CONTROLS FIX — All Games
   Keeps game title and controls on one row on all screen sizes
   ═══════════════════════════════════════════════════════════════════ */

/* ── Game Controls Container ────────────────────────────────────── */
.game-controls {
  display: flex;
  align-items: center;
  flex-wrap: nowrap !important;
  gap: var(--space-2);
  width: 100%;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 44px;
}

.game-controls-title {
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-controls-title span {
  margin-right: 2px;
}

/* ── Right side controls wrapper ────────────────────────────────── */
.game-controls-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}

/* ── Controls inside the right wrapper ──────────────────────────── */
.game-controls-right .difficulty-select,
.game-controls-right select {
  flex: 0 1 auto;
  min-width: 60px;
  max-width: 120px;
  padding: var(--space-1) var(--space-6) var(--space-1) var(--space-2);
  font-size: var(--fs-xs);
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239898b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
}

.game-controls-right .difficulty-select:hover,
.game-controls-right select:hover {
  border-color: var(--border-strong);
}

.game-controls-right .difficulty-select:focus,
.game-controls-right select:focus {
  outline: 2px solid var(--accent-purple);
  outline-offset: 1px;
}

.game-controls-right .control-btn {
  flex: 0 0 auto;
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
  min-height: 32px;
  min-width: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}

.game-controls-right .control-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.game-controls-right .control-btn.control-btn--primary {
  background: var(--accent-purple-dim);
  color: var(--accent-purple);
  border-color: var(--border-accent);
}

.game-controls-right .control-btn.control-btn--primary:hover {
  background: var(--accent-purple);
  color: #fff;
}

.game-controls-right .control-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.game-controls-right .btn-text {
  display: inline;
  white-space: nowrap;
}

/* ── Game Stats Row ──────────────────────────────────────────────── */
.game-stats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  width: 100%;
  flex-wrap: wrap;
}

/* ── Mobile Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .game-controls {
    gap: var(--space-1);
    padding-bottom: var(--space-2);
    min-height: 40px;
  }

  .game-controls-title {
    font-size: var(--fs-sm);
    max-width: 45%;
  }

  .game-controls-right {
    gap: var(--space-1);
  }

  .game-controls-right .difficulty-select,
  .game-controls-right select {
    min-width: 50px;
    max-width: 80px;
    font-size: 0.65rem;
    height: 28px;
    padding: 0 var(--space-4) 0 var(--space-1);
    padding-right: 20px;
    background-size: 8px 5px;
    background-position: right 5px center;
  }

  .game-controls-right .control-btn {
    padding: var(--space-1) var(--space-2);
    font-size: 0.65rem;
    min-height: 28px;
    min-width: 28px;
  }

  .game-controls-right .control-btn svg {
    width: 12px;
    height: 12px;
  }

  .game-controls-right .btn-text {
    display: none;
  }

  .game-controls-right .control-btn.control-btn--primary .btn-text {
    display: inline;
    font-size: 0.65rem;
  }

  .game-stats-row {
    gap: var(--space-4);
  }

  .game-stat-item .game-stat-value {
    font-size: var(--fs-lg);
  }
}

@media (max-width: 400px) {
  .game-controls-title {
    font-size: 0.7rem;
    max-width: 35%;
  }

  .game-controls-right .difficulty-select,
  .game-controls-right select {
    min-width: 40px;
    max-width: 60px;
    font-size: 0.55rem;
    height: 24px;
    padding: 0 var(--space-3) 0 var(--space-1);
    padding-right: 16px;
    background-size: 6px 4px;
    background-position: right 4px center;
  }

  .game-controls-right .control-btn {
    padding: var(--space-1);
    min-height: 24px;
    min-width: 24px;
    font-size: 0.55rem;
  }

  .game-controls-right .control-btn svg {
    width: 10px;
    height: 10px;
  }

  .game-controls-right .control-btn.control-btn--primary .btn-text {
    display: none !important;
  }

  .game-stats-row {
    gap: var(--space-3);
  }

  .game-stat-item .game-stat-value {
    font-size: var(--fs-base);
  }

  .game-stat-item .game-stat-label {
    font-size: 0.6rem;
  }
}

@media (max-width: 340px) {
  .game-controls-title {
    font-size: 0.6rem;
    max-width: 30%;
  }

  .game-controls-right .difficulty-select,
  .game-controls-right select {
    min-width: 35px;
    max-width: 50px;
    font-size: 0.5rem;
    height: 22px;
    padding: 0 var(--space-2) 0 var(--space-1);
    padding-right: 14px;
  }

  .game-controls-right .control-btn {
    min-height: 22px;
    min-width: 22px;
  }

  .game-controls-right .control-btn svg {
    width: 8px;
    height: 8px;
  }
}