/* ==============================================================================
   ClassKit Global - Bug Hunter Debugging Challenge Stylesheet
   Pure Vanilla CSS | A4 210mm x 297mm Vector Print Engine
   Supports 6x6, 8x8, 10x10 Exploration Grids & Algorithmic Bug Code Blocks
   1-Up Wide & 2-Up Paper-Saving Layouts + Automated 2-Page Answer Keys
   Strict Rule 4 Compliance: Under 600 lines
   ============================================================================== */

:root {
  --bug-border-thick: 2px solid #0F172A;
  --bug-border-thin: 0.8px solid #CBD5E1;
  --bug-red: #DC2626;
  --bug-red-bg: #FEF2F2;
  --bug-green: #059669;
  --bug-green-bg: #ECFDF5;
  --bug-blue: #2563EB;
}

/* ------------------------------------------------------------------------------
   1. A4 Printable Sheet Engine (Portrait 210mm x 297mm)
   ------------------------------------------------------------------------------ */
.bug-sheet {
  width: 210mm;
  height: 297mm;
  min-height: 297mm;
  max-height: 297mm;
  box-sizing: border-box;
  padding: 10mm 14mm 8mm 14mm;
  background: #FFFFFF;
  color: #0F172A;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
  margin-bottom: 24px;
}

.bug-sheet.answer-sheet {
  border-top: 4px solid #2563EB;
}

/* ------------------------------------------------------------------------------
   2. Map Grid Coordinate System
   ------------------------------------------------------------------------------ */
.map-board-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.map-coordinate-table {
  border-collapse: collapse;
  background: #FFFFFF;
  border: var(--bug-border-thick);
  user-select: none;
  box-sizing: border-box;
}

.coord-header-cell {
  background: #F1F5F9;
  color: #475569;
  font-size: 7.2pt;
  font-weight: 800;
  text-align: center;
  padding: 1.5mm 0;
  border: var(--bug-border-thin);
  line-height: 1;
}

.map-grid-cell {
  position: relative;
  text-align: center;
  vertical-align: middle;
  border: var(--bug-border-thin);
  background: #FFFFFF;
  box-sizing: border-box;
  transition: background 0.15s ease;
}

.cell-symbol-icon {
  font-size: 1.4em;
  line-height: 1;
  display: block;
  z-index: 2;
  position: relative;
}

.cell-sub-tag {
  position: absolute;
  bottom: 0.5mm;
  left: 0;
  right: 0;
  font-size: 5pt;
  font-weight: 900;
  letter-spacing: -0.2px;
  text-transform: uppercase;
  line-height: 1;
}

.cell-start { background: rgba(16, 185, 129, 0.12); }
.cell-start .cell-sub-tag { color: #047857; }

.cell-goal { background: rgba(245, 158, 11, 0.16); }
.cell-goal .cell-sub-tag { color: #B45309; }

.cell-obstacle { background: #F8FAFC; }
.cell-obstacle .cell-sub-tag { color: #64748B; }

.cell-trap { background: #FEF2F2; }
.cell-trap .cell-sub-tag { color: #DC2626; }

/* Grid Dimensions for 1-Up Layout */
.layout-content-1up .map-size-6 .map-grid-cell { width: 17mm; height: 17mm; }
.layout-content-1up .map-size-8 .map-grid-cell { width: 14.5mm; height: 14.5mm; }
.layout-content-1up .map-size-10 .map-grid-cell { width: 12.2mm; height: 12.2mm; }

/* Grid Dimensions for 2-Up Layout */
.layout-content-2up .map-size-6 .map-grid-cell { width: 11.5mm; height: 11.5mm; }
.layout-content-2up .map-size-8 .map-grid-cell { width: 9.8mm; height: 9.8mm; }
.layout-content-2up .map-size-10 .map-grid-cell { width: 8.2mm; height: 8.2mm; }

/* Solutions Overlay */
.show-solutions .map-grid-cell.in-valid-path,
.bug-sheet.answer-sheet .map-grid-cell.in-valid-path {
  background: rgba(37, 99, 235, 0.12) !important;
}

.show-solutions .map-grid-cell.in-valid-path::after,
.bug-sheet.answer-sheet .map-grid-cell.in-valid-path::after {
  content: '';
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: #2563EB;
  opacity: 0.85;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.show-solutions .map-grid-cell.cell-start::after,
.show-solutions .map-grid-cell.cell-goal::after,
.bug-sheet.answer-sheet .map-grid-cell.cell-start::after,
.bug-sheet.answer-sheet .map-grid-cell.cell-goal::after {
  display: none;
}

.show-solutions .map-grid-cell.is-crash-cell,
.bug-sheet.answer-sheet .map-grid-cell.is-crash-cell {
  background: #FEE2E2 !important;
  box-shadow: inset 0 0 0 2px #DC2626;
}

/* ------------------------------------------------------------------------------
   3. Program Code Sequence (Command Slots)
   ------------------------------------------------------------------------------ */
.code-section-wrap {
  width: 100%;
  margin-top: 2.5mm;
}

.code-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5mm;
}

.code-section-title {
  font-size: 8.5pt;
  font-weight: 900;
  color: #0F172A;
  display: flex;
  align-items: center;
  gap: 1.5mm;
}

.code-section-badge {
  font-size: 7pt;
  font-weight: 800;
  color: #DC2626;
  background: #FEF2F2;
  padding: 0.4mm 1.8mm;
  border-radius: 1mm;
  border: 0.5px solid #FECACA;
}

.code-slots-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6mm;
  align-items: center;
}

.code-slot-box {
  position: relative;
  width: 8.5mm;
  height: 9.5mm;
  border: 1.2px solid #94A3B8;
  border-radius: 1.5mm;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.slot-step-badge {
  position: absolute;
  top: -1.8mm;
  left: 1.2mm;
  background: #F1F5F9;
  color: #475569;
  font-size: 5.5pt;
  font-weight: 900;
  padding: 0.2mm 1mm;
  border-radius: 0.6mm;
  border: 0.5px solid #CBD5E1;
  line-height: 1;
}

.slot-arrow-char {
  font-size: 11pt;
  font-weight: 900;
  color: #0F172A;
  line-height: 1;
  margin-top: 1mm;
}

.code-slot-box.is-bug-slot {
  background: #FEF2F2 !important;
  border-color: #DC2626 !important;
  box-shadow: 0 0 0 1px #DC2626;
}

.code-slot-box.is-bug-slot .slot-arrow-char {
  color: #DC2626 !important;
  text-decoration: line-through;
}

/* ------------------------------------------------------------------------------
   4. Debugging Report Form (Student Worksheet)
   ------------------------------------------------------------------------------ */
.debugging-report-section {
  background: #F8FAFC;
  border: 1.5px solid #0F172A;
  border-radius: 2mm;
  padding: 2.2mm 3.5mm;
  margin-top: 2.5mm;
  box-sizing: border-box;
}

.report-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2mm;
  border-bottom: 1px solid #CBD5E1;
  padding-bottom: 1.2mm;
}

.report-main-title {
  font-size: 8.5pt;
  font-weight: 900;
  color: #0F172A;
}

.report-guidance {
  font-size: 6.8pt;
  color: #64748B;
  font-weight: 600;
}

.report-fields-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr 1.3fr;
  gap: 3mm;
  align-items: center;
}

.report-field-box {
  display: flex;
  flex-direction: column;
  gap: 1mm;
}

.field-label {
  font-size: 7.2pt;
  font-weight: 800;
  color: #334155;
}

.field-input-area {
  display: flex;
  align-items: center;
  gap: 1.5mm;
  font-size: 8pt;
  font-weight: 700;
  color: #0F172A;
  min-height: 5.5mm;
}

.blank-box-line {
  display: inline-block;
  border-bottom: 1.2px solid #64748B;
  height: 4mm;
  vertical-align: bottom;
}

/* ------------------------------------------------------------------------------
   5. Layout Specifics (1-Up vs 2-Up)
   ------------------------------------------------------------------------------ */
.layout-content-1up {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.layout-content-2up {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.puzzle-unit-2up {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 124mm;
}

.puzzle-unit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1.2mm;
  border-bottom: 1.2px solid #0F172A;
  margin-bottom: 1.5mm;
}

.puzzle-unit-title { font-size: 9.5pt; font-weight: 800; color: #0F172A; }
.puzzle-unit-meta { font-size: 7.5pt; color: #64748B; font-weight: 600; }

.puzzle-unit-body-2up {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4mm;
  align-items: center;
}

.cut-line-horizontal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2mm;
  color: #94A3B8;
  font-size: 7.5pt;
  font-weight: 700;
  margin: 2mm 0;
  user-select: none;
}

.cut-line-horizontal::before,
.cut-line-horizontal::after {
  content: '';
  flex: 1;
  border-bottom: 1px dashed #CBD5E1;
}

/* ------------------------------------------------------------------------------
   6. Print Media Queries (@media print)
   ------------------------------------------------------------------------------ */
@media print {
  body {
    background: #FFFFFF !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .studio-header,
  .studio-sidebar,
  .pro-modal-backdrop {
    display: none !important;
  }

  .studio-body {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .studio-viewport {
    padding: 0 !important;
    margin: 0 !important;
    background: #FFFFFF !important;
  }

  .a4-wrapper {
    transform: none !important;
  }

  .bug-sheet {
    box-shadow: none !important;
    margin: 0 !important;
    page-break-after: always !important;
    break-after: page !important;
  }
}
