/* ==============================================================================
   ClassKit Global - Secret Ciphers & Cryptography Studio Stylesheet
   Pure Vanilla CSS | A4 210mm x 297mm Vector Print Engine
   Full-Page Scissors-Free One-Paper Design | Crisp Pigpen, Caesar & Polybius Ciphers
   Curricular Alignment: CSTA 1A-DA-06, 1B-AP-10, 2-CS-01
   Strict Rule 4 Compliance: Under 600 lines
   ============================================================================== */

:root {
  --cipher-border-thick: 2px solid #0F172A;
  --cipher-border-thin: 1px solid #CBD5E1;
  --cipher-green: #16A34A;
  --cipher-green-bg: rgba(22, 163, 74, 0.12);
}

/* ------------------------------------------------------------------------------
   1. Left Control Panel Options & Form Elements
   ------------------------------------------------------------------------------ */
.form-group-wb { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-label-wb { font-size: 12px; font-weight: 800; color: var(--text-main, #0F172A); }
.form-input-wb {
  height: 38px; padding: 0 12px; border: 1.5px solid var(--border-medium, #CBD5E1);
  border-radius: var(--radius-sm, 6px); font-size: 13px; font-weight: 700;
  color: var(--text-main, #0F172A); outline: none; background: #FFFFFF;
  box-sizing: border-box; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input-wb:focus { border-color: var(--primary, #4F46E5); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
.form-row-checkboxes { display: flex; flex-direction: column; gap: 8px; }
.checkbox-label-wb { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-main, #1E293B); cursor: pointer; user-select: none; }
.checkbox-label-wb input[type="checkbox"] { accent-color: var(--primary, #4F46E5); width: 16px; height: 16px; cursor: pointer; }

.option-label-sub { font-size: 11.5px; font-weight: 700; color: var(--text-muted, #64748B); margin-bottom: 6px; letter-spacing: -0.2px; }
.segmented-control { display: flex; gap: 4px; background: #EDF2F7; padding: 4px; border-radius: 8px; }
.seg-btn {
  flex: 1; padding: 8px 4px; font-size: 11.5px; font-weight: 700; color: #64748B;
  background: transparent; border: none; border-radius: 6px; cursor: pointer;
  transition: all 0.15s ease; text-align: center; user-select: none; white-space: nowrap;
}
.seg-btn:hover { color: #0F172A; }
.seg-btn.active { background: #FFFFFF; color: #0F172A; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.layout-hint-text { font-size: 11.5px; color: #64748B; line-height: 1.4; margin-top: 8px; padding: 4px 6px; }

.btn-secondary-action {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 700; background: #FFFFFF; color: #334155; border: 1px solid #CBD5E1;
  cursor: pointer; transition: all 0.15s ease;
}
.btn-secondary-action:hover { background: #F8FAFC; border-color: #94A3B8; color: #0F172A; }

.btn-sidebar-generate {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px;
  border-radius: 10px; font-size: 13.5px; font-weight: 800; background: #F1F5F9; border: 1.5px solid #CBD5E1;
  color: #1E293B; cursor: pointer; transition: all 0.18s ease;
}
.btn-sidebar-generate:hover { background: #E2E8F0; border-color: #94A3B8; color: #0F172A; transform: translateY(-1px); }

/* ------------------------------------------------------------------------------
   2. A4 Printable Sheet Engine (Portrait 210mm x 297mm)
   ------------------------------------------------------------------------------ */
.print-pages-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
}

.crypto-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);
  border-radius: 2px;
}

/* Standardized Worksheet Header Block */
.sheet-header-block {
  display: flex;
  flex-direction: column;
  gap: 2mm;
  border-bottom: 2px solid #0F172A;
  padding-bottom: 2mm;
  margin-bottom: 3mm;
}

.sheet-meta-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6mm;
  font-size: 8.5pt;
  font-weight: 700;
  color: #334155;
}

.sheet-name-field {
  display: inline-block;
  min-width: 26mm;
  border-bottom: 1.5px solid #0F172A;
}

.sheet-answer-tag {
  font-size: 9pt;
  font-weight: 900;
  color: #166534;
  background: #DCFCE7;
  padding: 1mm 3mm;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.sheet-main-title {
  font-size: 16pt;
  font-weight: 900;
  color: #0F172A;
  margin: 0;
  line-height: 1.2;
}

/* ------------------------------------------------------------------------------
   3. Story Mission Hero Banner & Visual Example Card
   ------------------------------------------------------------------------------ */
.crypto-hero-banner {
  background: #F8FAFC;
  border: 1.5px solid #E2E8F0;
  border-radius: 7px;
  padding: 2.5mm 4mm;
  margin-bottom: 3mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
}

.crypto-mission-story {
  font-size: 8.2pt;
  color: #334155;
  line-height: 1.4;
  flex: 1;
  padding-right: 4mm;
}

.crypto-mission-story strong {
  color: #0F172A;
}

.crypto-example-card {
  display: flex;
  align-items: center;
  gap: 2mm;
  background: #FFFFFF;
  border: 1.5px solid #CBD5E1;
  border-radius: 6px;
  padding: 1.5mm 3.5mm;
  font-size: 8pt;
  font-weight: 700;
  color: #475569;
  white-space: nowrap;
}

.crypto-answer-banner {
  width: 100%;
  background: #F0FDF4;
  border: 1.5px solid #86EFAC;
  border-radius: 7px;
  padding: 2.5mm 4mm;
  margin-bottom: 3mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
}

.ans-banner-title {
  font-size: 8.5pt;
  color: #166534;
  font-weight: 700;
}

.ans-banner-badge {
  font-size: 11pt;
  font-weight: 900;
  color: #15803D;
  background: #FFFFFF;
  border: 1.5px solid #16A34A;
  border-radius: 6px;
  padding: 1mm 4mm;
}

/* ------------------------------------------------------------------------------
   4. Reference Table Containers
   ------------------------------------------------------------------------------ */
.crypto-puzzle-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.crypto-reference-box {
  background: #F8FAFC;
  border: 1.5px solid #CBD5E1;
  border-radius: 8px;
  padding: 2.5mm 3.5mm;
}

.reference-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2mm;
  font-size: 8pt;
  color: #334155;
}

.reference-badge {
  font-size: 7pt;
  font-weight: 800;
  padding: 0.5mm 2mm;
  border-radius: 4px;
  background: #EEF2FF;
  color: #4338CA;
  border: 0.5px solid #C7D2FE;
}

/* Pigpen Grid */
.pigpen-ref-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2.5mm;
}

.pigpen-section-card {
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 5px;
  padding: 2mm;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pigpen-section-title {
  font-size: 7.2pt;
  font-weight: 900;
  color: #475569;
  margin-bottom: 1.5mm;
}

/* Caesar Strip */
.caesar-strip-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Inter', monospace;
  font-size: 7.5pt;
  text-align: center;
  background: #FFFFFF;
}

.caesar-strip-table th,
.caesar-strip-table td {
  border: 1px solid #CBD5E1;
  padding: 1.5mm 0.5mm;
  font-weight: 700;
}

.caesar-strip-table th {
  background: #F1F5F9;
  color: #334155;
  width: 12mm;
}

.caesar-strip-table .cipher-row td {
  background: #F8FAFC;
  color: #4338CA;
  font-weight: 900;
}

/* Polybius Table */
.polybius-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 8pt;
  font-weight: 800;
  background: #FFFFFF;
}

.polybius-table th,
.polybius-table td {
  border: 1px solid #CBD5E1;
  padding: 1.5mm 1mm;
}

.polybius-table th {
  background: #F1F5F9;
  color: #475569;
}

.polybius-table td {
  color: #0F172A;
}

/* ------------------------------------------------------------------------------
   5. Puzzle Cards & Escape Vault Pad
   ------------------------------------------------------------------------------ */
.puzzle-cards-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3.5mm;
  margin: 4mm 0;
  flex-wrap: wrap;
}

.cipher-char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #FFFFFF;
  border: 2px solid #0F172A;
  border-radius: 8px;
  width: 22mm;
  padding: 2mm;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
  box-sizing: border-box;
}

.char-card-idx {
  font-size: 7.2pt;
  font-weight: 800;
  color: #64748B;
  margin-bottom: 1.5mm;
}

.char-cipher-symbol {
  height: 12mm;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16pt;
  font-weight: 900;
}

.char-pencil-box {
  width: 14mm;
  height: 14mm;
  border: 2px dashed #0F172A;
  border-radius: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 15pt;
  font-weight: 900;
  color: #15803D;
  background: #FFFFFF;
}

.is-answer-key-page .char-pencil-box {
  background: #DCFCE7;
  border-style: solid;
  border-color: #16A34A;
}

.escape-vault-box {
  background: #F8FAFC;
  border: 2px solid #0F172A;
  border-radius: 10px;
  padding: 3mm 4mm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  box-sizing: border-box;
}

.vault-label-group {
  flex: 1;
}

.vault-title {
  font-size: 8.8pt;
  font-weight: 900;
  color: #0F172A;
}

.vault-desc {
  font-size: 7.2pt;
  color: #64748B;
}

.vault-dials-wrap {
  display: flex;
  gap: 2mm;
  margin: 0 4mm;
}

.vault-dial-cell {
  width: 11mm;
  height: 13mm;
  border: 2px solid #0F172A;
  border-radius: 4px;
  background: #FFFFFF;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 13pt;
  font-weight: 900;
  color: #0F172A;
}

.is-answer-key-page .vault-dial-cell {
  background: #DCFCE7;
  color: #166534;
  border-color: #16A34A;
}

.vault-stamp-box {
  border: 1.5px dashed #94A3B8;
  border-radius: 6px;
  padding: 1.5mm 3mm;
  text-align: center;
  font-size: 7pt;
  font-weight: 800;
  color: #64748B;
  min-width: 16mm;
}

.teacher-hint-card {
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-radius: 6px;
  padding: 2mm 3.5mm;
  margin-top: 2.5mm;
  font-size: 7.5pt;
  color: #92400E;
  display: flex;
  gap: 2mm;
  align-items: center;
}

/* ------------------------------------------------------------------------------
   6. Footer Meta Information
   ------------------------------------------------------------------------------ */
.sheet-footer-block {
  border-top: 1px solid #E2E8F0;
  padding-top: 2mm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 7.2pt;
  color: #94A3B8;
}

.footer-meta-brand {
  font-weight: 700;
  color: #64748B;
}

.footer-brand-tag {
  font-weight: 800;
  color: #4F46E5;
}

/* ------------------------------------------------------------------------------
   7. Native Print Optimization (@media print)
   ------------------------------------------------------------------------------ */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #FFFFFF !important;
  }

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

  .studio-body {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .studio-viewport {
    background: transparent !important;
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
  }

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

  .print-pages-container {
    gap: 0 !important;
  }

  .crypto-sheet {
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    page-break-after: always !important;
    break-after: page !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .crypto-sheet:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }
}
