/* =====================================================================
 * Calendário acadêmico — reprodução do calendário oficial (A4, 5 meses por linha).
 * Medidas em "pontos do PDF": 1 unidade (--u) = 1/550 da largura do calendário.
 * Em telas estreitas os meses se reorganizam (1 ou 2 por linha).
 * ===================================================================== */
.acal-wrap { container-type: inline-size; width: 100%; }
.acal { --u: calc(100cqi / 550); --line: #000; --grey: #d9d9d9; --band: #a6a6a6;
  font-family: "Aptos", "Segoe UI", "Open Sans", Calibri, Arial, sans-serif; color: #000; background: #fff;
  font-size: calc(7 * var(--u)); line-height: 1.2; padding: calc(10 * var(--u)) 0 calc(14 * var(--u)); }
.acal *, .acal *::before, .acal *::after { box-sizing: border-box; }

/* Cabeçalho */
.acal-head { text-align: center; margin-bottom: calc(10 * var(--u)); }
.ah1 { font-weight: 700; font-size: calc(9.2 * var(--u)); letter-spacing: .01em; }
.ah2 { font-weight: 700; font-size: calc(10.7 * var(--u)); color: #0070c0; margin-top: calc(1 * var(--u)); }
.ah3 { font-style: italic; font-size: calc(7.7 * var(--u)); color: #c00000; margin-top: calc(1.5 * var(--u)); }
.ah4 { font-size: calc(7.7 * var(--u)); color: #c00000; margin-top: calc(2 * var(--u)); }

/* Linhas de 5 meses e faixas de semestre */
.acal-row { margin-bottom: calc(10 * var(--u)); }
.acal-bands, .acal-months { display: grid; grid-template-columns: repeat(5, 1fr); column-gap: calc(6 * var(--u)); }
.acal-bands { margin-bottom: calc(6 * var(--u)); }
.acal-band { background: var(--band); text-align: center; font-weight: 700; font-size: calc(7.6 * var(--u)); height: calc(10.5 * var(--u)); line-height: calc(10.5 * var(--u)); }
.acal-band.ab-empty { background: transparent; }

/* Mês */
.am { min-width: 0; }
.am-theme { background: var(--grey); text-align: center; font-weight: 700; font-size: calc(5.6 * var(--u)); height: calc(10 * var(--u)); line-height: calc(10 * var(--u));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: calc(14 * var(--u)); position: relative; }
.am-sem { display: none; }
.am-body { display: flex; align-items: stretch; }
.am-side { width: calc(14 * var(--u)); flex: none; background: var(--grey); display: flex; align-items: center; justify-content: center; }
.am-side span { writing-mode: vertical-rl; transform: rotate(180deg); font-weight: 700; font-size: calc(7.2 * var(--u)); white-space: nowrap; }
.am-grid { border-collapse: collapse; table-layout: fixed; width: calc(100% - 14 * var(--u)); background: #fff; }
.am-grid th, .am-grid td { border: calc(.8 * var(--u)) solid var(--line); text-align: center; padding: 0; height: calc(9.6 * var(--u)); font-weight: 700; }
.am-grid th { font-size: calc(6.4 * var(--u)); background: #fff; }
.am-grid td { font-size: calc(7.1 * var(--u)); }
.am-grid td.x { border: 0; background: transparent; }
.am-grid tbody tr:last-child td.x { border-top: calc(.8 * var(--u)) solid var(--line); }
.am-grid tbody tr:first-child td.x { border-bottom: calc(.8 * var(--u)) solid var(--line); }
.am-grid td.diag { background: linear-gradient(to top right, #fff calc(50% - .6px), #000 calc(50% - .6px), #000 calc(50% + .6px), #fff calc(50% + .6px)); }
.am-grid td.today { outline: calc(1.8 * var(--u)) solid #e00; outline-offset: calc(-1.8 * var(--u)); position: relative; z-index: 1; }
.am-ev { list-style: none; margin: calc(5 * var(--u)) 0 0; padding: 0 0 0 calc(2 * var(--u)); font-size: calc(5.2 * var(--u)); line-height: calc(8.5 * var(--u)); letter-spacing: -.01em; }
.am-ev li { padding: 0; }
.am-empty { visibility: hidden; }

/* Rodapé: legenda e tabelas */
.acal-foot { display: grid; grid-template-columns: 1.25fr 1fr 1fr .8fr; gap: calc(10 * var(--u)); margin-top: calc(14 * var(--u)); align-items: start; font-size: calc(5.6 * var(--u)); }
.af-t { text-align: center; font-weight: 700; font-size: calc(5.8 * var(--u)); margin: calc(2 * var(--u)) 0 calc(3 * var(--u)); }
.af-legend { padding-left: calc(18 * var(--u)); }
.af-li { display: flex; align-items: center; height: calc(12.5 * var(--u)); }
.af-sw { width: calc(20 * var(--u)); height: calc(12.5 * var(--u)); border: calc(.7 * var(--u)) solid #000; margin-right: calc(2 * var(--u)); flex: none; margin-top: calc(-.7 * var(--u)); }
.af-sw.diag { background: linear-gradient(to top right, #fff calc(50% - .7px), #000 calc(50% - .7px), #000 calc(50% + .7px), #fff calc(50% + .7px)); }
.af-note { margin: calc(3.5 * var(--u)) 0 0 calc(-8 * var(--u)); }
.af-tb { border-collapse: collapse; width: 100%; table-layout: fixed; }
.af-tb th, .af-tb td { border: calc(.6 * var(--u)) solid #444; text-align: center; height: calc(9.6 * var(--u)); padding: 0; }
.af-tb th { font-weight: 700; border-color: #000; border-width: calc(.9 * var(--u)); }
.af-tot { display: flex; justify-content: center; gap: calc(26 * var(--u)); margin: calc(2 * var(--u)) 0 calc(14 * var(--u)); }
.af-tb2 { border-collapse: collapse; width: 100%; }
.af-tb2 th, .af-tb2 td { border: calc(.5 * var(--u)) solid #bbb; padding: calc(1.6 * var(--u)) calc(2.5 * var(--u)); text-align: center; }
.af-tb2 th:first-child, .af-tb2 td:first-child { text-align: left; }
.af-tb2 th { font-weight: 700; }
.af-tb2 tr.tot td { font-weight: 700; }
.af-tb2 tr.pct td { border: 0; }

/* Telas estreitas: meses 2 por linha / 1 por linha, com o semestre no próprio mês */
@container (max-width: 820px) {
  .acal { --u: 2.45px; padding: 10px 0; }
  .acal-head { padding: 0 8px; }
  .acal-bands { display: none; }
  .acal-row { margin: 0; }
  .acal-months { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px 14px; margin-bottom: 18px; }
  .am-empty { display: none; }
  .am-sem { display: inline-block; position: absolute; right: 4px; top: 0; font-size: 1.1em; color: #444; }
  .acal-foot { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
  .af-legend { padding-left: 0; }
  .af-note { margin-left: 0; }
}

/* Painel: dias clicáveis */
.acal-edit .am-grid td.d { cursor: pointer; user-select: none; }
.acal-edit .am-grid td.d:hover { box-shadow: inset 0 0 0 2px #1f6fb2; }
.acal-edit .am-grid td.sel { box-shadow: inset 0 0 0 3px #1f6fb2 !important; filter: brightness(1.08); }
.acal-edit .am-ev li { cursor: pointer; border-radius: 3px; }
.acal-edit .am-ev li:hover { background: #eef4fb; }

@media print {
  @page { size: A4 portrait; margin: 8mm; }
  .no-print { display: none !important; }
  .acal { padding: 0; }
  .acal-wrap { width: 194mm; }
  .am-grid td.today { outline: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
