/* ============================================================
   Cheat-sheet page — A4 landscape print-friendly single-page summary
   ============================================================ */

.cs-body {
  margin: 0;
  background: #ECEEF2;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
}

/* ============================================================
   Top toolbar (screen only)
   ============================================================ */
.cs-toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.cs-toolbar-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-800);
  text-decoration: none;
  background: var(--blue-50);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}
.cs-toolbar-home:hover { background: var(--blue-100); }
.cs-toolbar-role-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: var(--radius-md);
}
.cs-role-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}
.cs-role-tab:hover { background: #fff; color: var(--blue-800); }
.cs-role-tab.is-active { background: var(--blue-700); color: #fff; }

.cs-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cs-toolbar-print {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--blue-700);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}
.cs-toolbar-print:hover { background: var(--blue-900); }
.cs-toolbar-print i { font-size: 16px; }

/* ============================================================
   The A4 sheet (landscape: 297mm × 210mm)
   ============================================================ */
.cs-page {
  padding: 24px 16px 64px;
  display: flex;
  justify-content: center;
}
.cs-sheet {
  background: #fff;
  width: 297mm;
  min-height: 210mm;
  box-shadow: 0 8px 32px rgba(0,0,0,0.10);
  padding: 10mm 12mm;
  display: flex;
  flex-direction: column;
  gap: 6mm;
  box-sizing: border-box;
  /* Slight zoom-down so it fits typical screens better */
}
/* On smaller screens, allow the sheet to scale */
@media (max-width: 1200px) {
  .cs-sheet { width: 100%; min-width: 0; padding: 6mm 6mm; }
}

/* Header strip */
.cs-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--blue-700);
}
.cs-header-left { line-height: 1.25; }
.cs-eyebrow {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue-600);
}
.cs-role-name {
  font-size: 24px;
  font-weight: 800;
  color: var(--blue-900);
  margin: 2px 0 1px;
  letter-spacing: -0.01em;
}
.cs-tagline {
  font-size: 11px;
  font-style: italic;
  color: var(--text-secondary);
}
.cs-header-right { text-align: right; font-size: 9.5px; color: var(--text-tertiary); }
.cs-version {
  display: inline-block;
  padding: 1px 8px;
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 700;
  border-radius: 99px;
  letter-spacing: 0.05em;
}
.cs-print-hint { margin-top: 4px; }

/* Progression ladder */
.cs-ladder {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.cs-ladder-cell {
  padding: 5px 8px;
  border-radius: 4px;
  text-align: center;
  line-height: 1.2;
}
.cs-ladder-cell.cs-lvl-1 { background: #F1EFE8; color: #2C2C2A; }
.cs-ladder-cell.cs-lvl-2 { background: #E6F1FB; color: #042C53; }
.cs-ladder-cell.cs-lvl-3 { background: #E1F5EE; color: #04342C; border: 2px solid #1D9E75; padding: 3px 8px; }
.cs-ladder-cell.cs-lvl-4 { background: #FAEEDA; color: #412402; }
.cs-ladder-cell.cs-lvl-5 { background: #EEEDFE; color: #26215C; }
.cs-ladder-cell .cs-ladder-name {
  font-size: 10.5px;
  font-weight: 700;
}
.cs-ladder-cell .cs-ladder-time {
  font-size: 9px;
  font-weight: 600;
  opacity: 0.75;
  margin-top: 1px;
}
.cs-hire-bar-badge {
  display: inline-block;
  font-size: 8px;
  font-weight: 800;
  padding: 1px 5px;
  background: #fff;
  color: #1D9E75;
  border-radius: 99px;
  margin-left: 4px;
  letter-spacing: 0.05em;
}

/* Competency grid */
.cs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4mm;
  flex: 1;
}
/* For roles with 9 comps (PM), it's 3×3. For 8 comps (BA/QA/SE), it's 3×3 with one slot empty,
   or 4×2. We dynamically pick at JS time. Default to 3 cols. */
.cs-grid.cs-cols-4 { grid-template-columns: repeat(4, 1fr); }
.cs-grid.cs-cols-3 { grid-template-columns: repeat(3, 1fr); }

.cs-comp {
  background: #fff;
  border: 1px solid #DDE4EE;
  border-radius: 4px;
  padding: 6px 9px 7px;
  display: flex;
  flex-direction: column;
}
.cs-comp-head {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-bottom: 3px;
  border-bottom: 1px dashed #DDE4EE;
  margin-bottom: 3px;
}
.cs-comp-head .ti {
  font-size: 14px;
  color: var(--blue-700);
}
.cs-comp-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--blue-900);
}
.cs-comp-rungs {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-primary);
}
.cs-comp-rung {
  padding: 1px 4px;
  border-radius: 3px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.cs-comp-rung-lbl {
  font-weight: 800;
  flex-shrink: 0;
  min-width: 14px;
}
.cs-comp-rung-text { flex: 1; }
.cs-comp-rung.cs-rung-1 .cs-comp-rung-lbl { color: #5F5E5A; }
.cs-comp-rung.cs-rung-2 .cs-comp-rung-lbl { color: #185FA5; }
.cs-comp-rung.cs-rung-3 {
  background: #E1F5EE;
  color: #04342C;
}
.cs-comp-rung.cs-rung-3 .cs-comp-rung-lbl { color: #0F6E56; }
.cs-comp-rung.cs-rung-3::before {
  content: "★";
  color: #1D9E75;
  font-size: 9px;
  font-weight: 800;
  margin-right: 2px;
}
.cs-comp-rung.cs-rung-4 .cs-comp-rung-lbl { color: #854F0B; }
.cs-comp-rung.cs-rung-5 .cs-comp-rung-lbl { color: #3C3489; }

/* Anti-signals strip */
.cs-anti {
  background: #FCEBEB;
  border: 1px solid #F09595;
  border-radius: 4px;
  padding: 6px 10px 7px;
}
.cs-anti-head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}
.cs-anti-head .ti {
  font-size: 12px;
  color: #791F1F;
}
.cs-anti-label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #791F1F;
}
.cs-anti-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px 10px;
  font-size: 9.5px;
  line-height: 1.4;
  color: #791F1F;
}
.cs-anti-item::before {
  content: "·";
  font-weight: 800;
  margin-right: 4px;
}

/* Footer */
.cs-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid #DDE4EE;
  font-size: 9.5px;
  color: var(--text-secondary);
}
.cs-source { color: var(--text-tertiary); }

/* ============================================================
   Print rules — fits perfectly on A4 landscape
   ============================================================ */
@media print {
  .no-print { display: none !important; }
  @page {
    size: A4 landscape;
    margin: 0;
  }
  body { background: #fff; }
  .cs-page { padding: 0; }
  .cs-sheet {
    box-shadow: none;
    width: 297mm;
    min-height: 210mm;
    padding: 8mm 10mm;
    page-break-after: avoid;
    page-break-inside: avoid;
  }
  /* Force backgrounds to print */
  * {
    -webkit-print-color-adjust: exact !important;
    color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* ============================================================
   Mỗi dòng là một deep link vào trang role (in ra vẫn y nguyên)
   ============================================================ */
.cs-comp-rung,
.cs-comp-head,
.cs-anti-item {
  color: inherit;
  text-decoration: none;
}
.cs-comp-rung:hover,
.cs-comp-head:hover,
.cs-anti-item:hover { color: inherit; }

.cs-comp-head { cursor: pointer; }
.cs-comp-head:hover .cs-comp-name { text-decoration: underline; text-decoration-color: var(--blue-300); }

.cs-comp-rung { cursor: pointer; transition: background .12s ease; }
.cs-comp-rung-go {
  flex-shrink: 0;
  font-size: 10px;
  opacity: 0;
  color: var(--blue-600);
  transition: opacity .12s ease;
}
.cs-comp-rung:hover { background: var(--blue-50); }
.cs-comp-rung.cs-rung-3:hover { background: #CDEDE1; }
.cs-comp-rung:hover .cs-comp-rung-go { opacity: 1; }
.cs-comp-rung:focus-visible,
.cs-comp-head:focus-visible,
.cs-anti-item:focus-visible { outline: 2px solid var(--blue-400); outline-offset: 1px; }

.cs-anti-item { cursor: pointer; display: block; }
.cs-anti-item:hover { text-decoration: underline; text-decoration-color: #F09595; }

.cs-tap-hint {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--blue-600);
  margin-top: 3px;
}
.cs-tap-hint::before {
  content: "\2192";
  margin-right: 4px;
}

/* ============================================================
   Màn hình nhỏ — tờ A4 co lại cho đọc được trên điện thoại.
   Chỉ áp cho screen: bản in vẫn giữ nguyên A4 landscape.
   ============================================================ */
/* Chặn ô grid phình theo min-content — từ dài như CODEOWNERS từng làm tràn ngang. */
.cs-grid > *, .cs-ladder > *, .cs-anti-grid > * { min-width: 0; }

@media screen and (max-width: 1000px) {
  .cs-grid.cs-cols-3, .cs-grid.cs-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cs-anti-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 760px) {
  .cs-toolbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .cs-toolbar-home { padding: 8px 10px; }
  .cs-toolbar-home span { display: none; }
  .cs-toolbar-actions { margin-left: auto; }
  .cs-toolbar-print span { display: none; }
  .cs-toolbar-role-tabs { order: 3; width: 100%; justify-content: space-between; }
  .cs-role-tab { flex: 1; justify-content: center; }
}

@media screen and (max-width: 620px) {
  .cs-page { padding: 12px 10px 48px; }
  .cs-sheet { padding: 16px 14px; gap: 14px; min-height: 0; }

  .cs-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .cs-header-right { text-align: left; }
  .cs-role-name { font-size: 22px; }
  .cs-tagline { font-size: 12.5px; }
  .cs-tap-hint { font-size: 11.5px; }

  /* thang cấp độ xếp dọc, đọc rõ hơn 5 ô chen ngang */
  .cs-ladder { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .cs-ladder-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 9px 12px;
  }
  .cs-ladder-cell.cs-lvl-3 { padding: 7px 12px; }
  .cs-ladder-cell .cs-ladder-name { font-size: 13px; }
  .cs-ladder-cell .cs-ladder-time { font-size: 11.5px; margin-top: 0; white-space: nowrap; }
  .cs-hire-bar-badge { font-size: 9.5px; }

  .cs-grid.cs-cols-3, .cs-grid.cs-cols-4 { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .cs-comp { padding: 10px 12px 11px; border-radius: 6px; }
  .cs-comp-head .ti { font-size: 17px; }
  .cs-comp-name { font-size: 14px; }
  .cs-comp-rungs { font-size: 12.5px; gap: 2px; }
  .cs-comp-rung { padding: 5px 6px; gap: 7px; }
  .cs-comp-rung-lbl { min-width: 18px; }
  .cs-comp-rung-go { opacity: 0.45; font-size: 13px; }

  .cs-anti { padding: 10px 12px 11px; border-radius: 6px; }
  .cs-anti-label { font-size: 11px; }
  .cs-anti-grid { grid-template-columns: minmax(0, 1fr); gap: 5px; font-size: 12px; }
  .cs-anti-item { padding: 2px 0; }

  .cs-footer { flex-direction: column; align-items: flex-start; gap: 4px; font-size: 11.5px; }
}

/* ============================================================
   Gỡ chặn in cho riêng trang này.

   style.css có một "anti-print deterrent" dùng chung:
     @media print { body::before { content: "… Printing is discouraged." } }
   Trang cheat sheet cũng nạp style.css, nên dòng chặn đó chiếm 70px ở đầu
   bản in và đẩy toàn bộ tờ A4 sang trang 2 — tức là bấm "In / Lưu PDF" ra
   2 trang: trang 1 là lời nhắc đừng in, trang 2 mới là cheat sheet.
   Đây đúng là trang sinh ra để in, nên vô hiệu hoá dòng đó ở đây.
   ============================================================ */
@media print {
  body.cs-body::before {
    content: none !important;
    display: none !important;
    padding: 0 !important;
  }
  /* chừa vài mm để làm tròn pixel không đẩy sang trang thứ hai */
  .cs-sheet { min-height: 203mm; }
}
