/**
 * layout.css
 *
 * Purpose: Game layout structures including the main game content area,
 * control panel, card panel, and flexbox/grid arrangements.
 *
 * Dependencies: base.css (must load first)
 *
 * Key Styles:
 * - Game content wrapper
 * - Game layout structure
 * - Control panel (reference card area)
 * - Card panel and cards section
 * - Stats pills
 */

/* ==================== GAME LAYOUT ==================== */

.game-content {
  padding: 0 20px 20px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Prevent scrolling - cards must fit */
  min-height: 0; /* Allow flex children to shrink below content size */
  position: relative; /* For absolute positioned child pages (stats, etc.) */
}

#gameArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* UNIFIED LAYOUT: Vertical column layout for ALL screen sizes */
.game-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.control-panel {
  /* Compact vertical layout with label on top, 3-column row below */
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 20px 14px 20px;
  background: #f9f9ff;
  border-bottom: 1px solid #e0e0e0;
  gap: 8px;
  width: 100%;
  min-height: auto;
  border-radius: 0;
  position: relative;
  flex-shrink: 0;
}

/* "Can you find it?" label centered at top */
.control-label {
  text-align: center;
  margin-bottom: 0;
}

/* 3-column horizontal row: Level badge | Reference card | Streak badge */
.control-row {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding: 0 5px;
}

/* Ensure badges take equal space on sides */
.control-row .stat-pill.left,
.control-row .stat-pill.right {
  flex: 0 0 auto;
  min-width: 95px;
}

/* Reference card centered in the middle */
.control-row #referenceCard {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Reference card - prominent display (~25% larger) */
.control-panel .card.reference {
  width: 100px;
  height: 140px;
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}

.card-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 12px 15px;
  min-height: 0;
  overflow: hidden; /* Prevent overflow */
  /* MOBILE: Use dynamic viewport height for proper mobile sizing */
  max-height: calc(100dvh - 200px); /* Approximate space for header + controls */
}

/* Mobile-specific card panel adjustments */
@media (max-width: 768px) {
  .card-panel {
    max-height: calc(100dvh - 180px);
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .card-panel {
    max-height: calc(100dvh - 160px);
  }
}

/* ==================== STATS PILLS ==================== */

.stats-pills {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-bottom: 40px;
}

.stat-pill {
  background: white;
  border: 1px solid #ececec;
  border-radius: 50px;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2em;
}

.stat-pill.left {
  /* Center positioning - no auto margins */
}

.stat-pill.right {
  flex-direction: column;
  gap: 5px;
  padding: 10px 18px;
}

.stat-pill.right .pill-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill-emoji {
  font-size: 1.4em;
}

.pill-label {
  color: #666;
  font-weight: 600;
  font-size: 1.1em;
}

.pill-value {
  color: #667eea;
  font-weight: 700;
  font-size: 1.3em;
}

.pill-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.pill-dots .progress-dot {
  width: 10px;
  height: 10px;
  border-width: 2px;
}

/* Keep old styles for backwards compatibility but hide them */
.game-stats {
  display: none;
}

.stat {
  text-align: center;
}

.stat-label {
  color: #666;
  font-size: 0.9em;
  font-weight: 600;
}

.stat-value {
  font-weight: 700;
  color: #667eea;
  font-size: 1.3em;
}

.progress-dots {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.progress-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #667eea;
  background: transparent;
  transition: background 0.3s ease;
}

.progress-dot.filled {
  background: #667eea;
}

/* Reference card container in control-row is styled above */

.section-label {
  font-size: 0.9em;
  color: #999;
  margin-bottom: 15px;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ==================== CARDS SECTION ==================== */

.cards-section {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Level 12 Scroll Support - enables vertical scrolling only for level 12 (13 cards) */
.allow-scroll .card-panel {
  overflow-y: auto;
  overflow-x: hidden;
}

.allow-scroll .cards-section {
  overflow-y: visible;
  overflow-x: hidden;
}

.cards-section .section-label {
  font-size: 0.85em;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.face-down-cards {
  --face-card-width: 120px;
  --face-card-height: 168px;
  --card-gap: 12px;

  display: grid;
  justify-content: center;
  justify-items: center;
  align-content: start;
  gap: var(--card-gap);
  width: 100%;
  max-width: 500px;
  flex: 0 1 auto; /* Don't grow, can shrink, auto basis */
  min-height: 0;
  max-height: 100%; /* Don't exceed parent */
  /* JS dynamically sets grid-template-columns and CSS variables */

  /*
   * ZOOM TARGET: This is the ONLY element affected by zoom.
   * Card sizes are calculated by JavaScript based on currentZoomLevel
   * and set via CSS custom properties (--face-card-width, --face-card-height).
   * Lower zoom = smaller cards = all cards fit in viewport.
   */
}

/* Message styling */
.message {
  margin-top: 8px;
  font-size: 1em;
  flex-shrink: 0;
  min-height: 24px;
}
