/* 
 * काव्यकुतूहलम् - Layout Styles
 * Grid layouts, responsive design, and structural components
 */

/* ==========================================
   Main Layout
   ========================================== */
.main-content {
  margin-bottom: var(--spacing-xxl);
}

.main-layout {
  display: grid;
  gap: var(--spacing-xl);
  align-items: start;
  transition: grid-template-columns 0.8s ease-in-out;
}

/* Single column on mobile/tablet */
.main-layout {
  grid-template-columns: 1fr;
}

/* Two columns on desktop */
@media (min-width: 769px) {
  .main-layout {
    grid-template-columns: 2fr 1fr;
  }
  
  .main-layout.single-pane {
    grid-template-columns: 1fr;
  }
}

/* ==========================================
   Verse Canvas
   ========================================== */
.verse-canvas {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 500px;
  background-color: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  border: 2px solid var(--grid-border);
  box-shadow: var(--shadow-md);
}

.verse-display {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ==========================================
   Grid Layout Variations
   ========================================== */

/* Standard 4x8 grid */
.verse-grid {
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(4, 1fr);
}

/* Module 3: Indented layout */
.verse-grid.indented-pairs .row-1,
.verse-grid.indented-pairs .row-3 {
  margin-left: 4rem;
}

/* ==========================================
   Reference Pane Layout
   ========================================== */
.reference-pane {
  position: sticky;
  top: var(--spacing-lg);
  transition: width 0.8s ease-in-out, opacity 0.8s ease-in-out;
  overflow: hidden;
}

.reference-pane.hidden {
  width: 0 !important;
  opacity: 0 !important;
  overflow: hidden;
}

/* Vowel Grid (Module 2) */
.vowel-reference-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: var(--spacing-lg);
}

/* Center the vowel count title */
.reference-pane h3 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--accent-gold);
}

.vowel-grid-row {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: var(--spacing-xs);
  align-items: stretch;
  margin: var(--spacing-xs);
}

/* Match verse grid row height for alignment */
.vowel-grid-row:not(.header) {
  min-height: 80px;
  height: 80px;
}

.vowel-grid-row.header {
  font-weight: 700;
  border-bottom: 2px solid var(--grid-border);
  padding-bottom: var(--spacing-xs);
  margin-bottom: var(--spacing-sm);
  min-height: auto;
  height: auto;
}

.vowel-grid-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xs);
  border: 1px solid var(--grid-border);
  border-radius: var(--radius-sm);
  background-color: var(--grid-cell-bg);
  transition: all var(--transition-normal);
  font-size: 1rem;
  position: relative;
}

.vowel-grid-cell.header {
  background-color: rgba(201, 169, 97, 0.15);
  font-weight: 700;
  border: 1px solid var(--grid-border);
  padding: 0.4rem;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.vowel-grid-cell.count-cell {
  font-size: 1.3rem;
  font-weight: 700;
  border-width: 2px;
}

/* Fade out zero counts */
.vowel-grid-cell.count-cell.zero {
  opacity: 0.25;
  color: #999;
  background-color: rgba(0, 0, 0, 0.02);
}

/* Violation styling */
.vowel-grid-cell.violation {
  border-color: #D32F2F;
  border-width: 3px;
  box-shadow: 0 0 8px rgba(211, 47, 47, 0.3);
}

.violation-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.7em;
  line-height: 1;
}

/* Split cell styling */
.split-cell {
  display: flex;
  flex-direction: column;
  gap: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.vowel-half {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
  border-bottom: 1px solid var(--grid-border);
  padding: var(--spacing-xs);
  box-sizing: border-box;
  margin-top: 10px;
}

.consonant-half {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  /* font-size: 0.7em; */
  padding: var(--spacing-xs);
  font-weight: 700; 
  /* opacity: 0.8; */
  margin-top: -10px;
}

/* Varṇamālā Grid (Module 3) */
.varnamala-grid {
  display: grid;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-md);
}

.varnamala-row {
  display: flex;
  gap: var(--spacing-xs);
}

.varnamala-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  /* width: 50px; */
  /* height: 50px; */
  width: auto;  /* Let grid control it */
  aspect-ratio: 1;
  background-color: var(--grid-cell-bg);
  border: 1px solid var(--grid-border);
  border-radius: var(--radius-sm);
  font-size: 1.5rem;
  transition: all var(--transition-normal);
}

/* ==========================================
   Module-Specific Layouts
   ========================================== */

/* Module 2: Cell splitting for vowel/consonant */
.verse-grid.split-cells .grid-cell {
  flex-direction: column;
  padding: var(--spacing-xs);
}

/* Module 3: Keep grid layout, use margin-left for indentation */
.verse-grid.module-3 {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--grid-gap);
}

/* No special row handling needed - grid flows left to right automatically */

/* ==========================================
   Loading & Empty States
   ========================================== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--tab-text-inactive);
}

.loading-state .spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--tab-inactive);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--tab-text-inactive);
  font-size: 1.2rem;
}

/* ==========================================
   Responsive Layout Adjustments
   ========================================== */

/* Mobile - Stack reference pane below */
@media (max-width: 768px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  
  .reference-pane {
    position: static;
    margin-top: var(--spacing-lg);
    max-height: 400px;
  }
  
  .verse-canvas {
    min-height: 400px;
  }
  
  .verse-grid {
    gap: var(--spacing-xs);
  }
  
  /* Module 3: Indentation already handled in JS via first cell margin-left */
  
  .varnamala-cell {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
  .verse-canvas {
    min-height: 450px;
  }
  
  .grid-cell {
    width: 80px;
    height: 80px;
  }
}

/* Large Desktop */
@media (min-width: 1200px) {
  .verse-canvas {
    min-height: 600px;
  }
  
  .reference-pane {
    max-height: 700px;
  }
}

/* ==========================================
   Print Styles
   ========================================== */
@media print {
  .tab-navigation,
  .controls-container {
    display: none;
  }
  
  .verse-canvas {
    box-shadow: none;
    border: 1px solid #000;
  }
  
  .reference-pane {
    break-inside: avoid;
  }
}
