/* Interactive cronograma: modal with one section per month
   (calendar + timeline). Loaded after styles.css and academic.css. */

.bimester-label {
  margin-top: 6px;
  color: var(--accent);
  font-weight: 600;
}

.bimester-label:empty { display: none; }

.document-row[data-turma] .document-action .ph-arrow-right { transition: transform .28s var(--ease-out); }
.document-row[data-turma]:hover .document-action .ph-arrow-right { transform: translateX(3px); }

/* Activity type colors (design system support colors) */
.type-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--logo-blue-light);
}

.type-dot[data-type="Avaliação"] { background: #e8dd64; }
.type-dot[data-type="Avaliação Bimestral"] { background: #a67af1; }
.type-dot[data-type="Provão"] { background: var(--logo-navy); }

/* Modal */
.schedule-modal {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--white);
  color: var(--body);
  overflow: hidden;
}

.schedule-modal::backdrop {
  background: rgba(23, 25, 28, .45);
  backdrop-filter: blur(2px);
}

.schedule-modal[open] { animation: modal-in .32s var(--ease-out); }
.schedule-modal[open]::backdrop { animation: backdrop-in .24s ease; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.schedule-sheet {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 48px);
}

.schedule-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 12px;
}

.schedule-kicker {
  display: block;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

.schedule-head h2 {
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -.01em;
}

.schedule-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.schedule-pdf { min-height: 40px; padding: 0 14px; }

.schedule-close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--title);
  font-size: 20px;
  transition: border-color .18s ease, background-color .18s ease;
}

.schedule-close:hover { border-color: var(--border-strong); background: var(--surface); }

.schedule-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 0 24px 16px;
  list-style: none;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.schedule-legend li { display: inline-flex; align-items: center; gap: 8px; }

.schedule-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 24px 32px;
  scroll-behavior: smooth;
}

/* Month section */
.month-section { padding: 0; }
.month-section + .month-section { margin-top: 32px; }

.month-section h3 {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -24px;
  padding: 14px 24px 8px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(6px);
  font-size: 18px;
}

/* Calendar */
.month-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin: 4px 0 20px;
  text-align: center;
}

.month-calendar .weekday {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding-bottom: 4px;
}

.cal-day {
  position: relative;
  aspect-ratio: 1 / 1;
  max-height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 15px;
}

button.cal-day {
  border: 0;
  background: var(--icon-box-bg);
  color: var(--title);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  transition: transform .28s var(--ease-out), background-color .18s ease, box-shadow .18s ease;
}

button.cal-day:hover { transform: translateY(-2px); background: #e6eefa; }
button.cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cal-day[data-type="Trabalho"] { background: #e3f5fd; }
.cal-day[data-type="Avaliação"] { background: #f8f5d6; }
.cal-day[data-type="Avaliação Bimestral"] { background: #ede4fc; }
.cal-day[data-type="Provão"] { background: var(--logo-navy); color: var(--white); }

.cal-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5px;
  display: flex;
  justify-content: center;
  gap: 3px;
}

.cal-dots .type-dot { width: 5px; height: 5px; flex-basis: 5px; }
.cal-day[data-type="Provão"] .cal-dots .type-dot[data-type="Provão"] { background: var(--white); }
.cal-day.is-today::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  pointer-events: none;
}

/* Timeline */
.timeline { margin: 0; padding: 0; list-style: none; }

.timeline-day {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: 56px;
  border-radius: var(--radius);
  transition: background-color .6s ease;
}

.timeline-day.is-flash { background: var(--icon-box-bg); }
.timeline-day.is-past .timeline-date,
.timeline-day.is-past .timeline-event > * { opacity: .55; }

.timeline-date strong {
  display: block;
  color: var(--logo-navy);
  font-size: 24px;
  line-height: 1.1;
}

.timeline-date span {
  color: var(--muted);
  font-size: 14px;
}

.timeline-events { display: flex; flex-direction: column; gap: 10px; }

.timeline-event {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.timeline-event .type-dot { margin-top: 10px; }
.timeline-event strong { color: var(--title); font-weight: 600; }
.timeline-event .event-type { color: var(--muted); }
.timeline-event p { margin: 0; line-height: 1.45; }

/* Tabs */
.schedule-tabs {
  display: flex;
  gap: 4px;
  margin: 0 24px 12px;
  padding: 4px;
  width: max-content;
  max-width: calc(100% - 48px);
  border-radius: 999px;
  background: var(--surface);
}

.schedule-tabs[hidden] { display: none; }

.schedule-tabs button {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--body);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}

.schedule-tabs button:hover { color: var(--title); }

.schedule-tabs button[aria-selected="true"] {
  background: var(--white);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(23, 25, 28, .08), 0 0 0 1px var(--border);
}

/* Expandable activity in the month timeline */
.timeline-event-wrap { display: flex; flex-direction: column; }

.event-toggle {
  width: 100%;
  margin: -6px -8px;
  padding: 6px 36px 6px 8px;
  position: relative;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  transition: background-color .18s ease;
}

.event-toggle:hover { background: var(--surface); }
.event-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }

.event-caret {
  position: absolute;
  right: 10px;
  top: 12px;
  color: var(--muted);
  transition: transform .28s var(--ease-out);
}

.event-toggle[aria-expanded="true"] .event-caret { transform: rotate(180deg); }

.event-detail {
  margin: 10px 0 6px 20px;
  padding: 0 0 4px 14px;
  border-left: 2px solid var(--border);
  animation: detail-in .28s var(--ease-out);
}

@keyframes detail-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.event-detail-item + .event-detail-item { margin-top: 18px; }

.event-detail-subject {
  margin: 0 0 6px;
  color: var(--title);
  font-weight: 600;
}

.detail-teacher {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* Keep context while reading long activities: the date and the activity
   header stick under the month title until their content scrolls away. */
.schedule-body { --month-head: 48px; }

.timeline-day > .timeline-date {
  position: sticky;
  top: calc(var(--month-head) + 6px);
  align-self: start;
}

.event-toggle {
  position: sticky;
  top: var(--month-head);
  z-index: 1;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.event-toggle:hover { background: var(--surface); }

/* Per-subject view: subject name stays on top while its entries scroll. */
.subject-head {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -24px 18px;
  padding: 12px 24px 10px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid transparent;
}

.subject-entry > .subject-date {
  position: sticky;
  top: 96px;
  align-self: start;
}

/* Shared detail content (timeline + per-subject view) */
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.type-badge, .tag-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.type-badge { background: #e3f5fd; color: var(--logo-navy); }
.type-badge[data-type="Avaliação"] { background: #f8f5d6; color: #6b5f00; }
.type-badge[data-type="Avaliação Bimestral"] { background: #ede4fc; color: #5b2bad; }
.type-badge[data-type="Provão"] { background: #e6ecf6; color: var(--logo-navy); }

.tag-badge { border: 1px solid var(--border); color: var(--body); font-weight: 500; }

.detail-title {
  margin: 0 0 8px;
  color: var(--logo-navy);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
}

.event-detail p, .subject-content p { margin: 0 0 10px; line-height: 1.55; }
.event-detail h5, .subject-content h5 {
  margin: 14px 0 6px;
  color: var(--logo-navy);
  font-size: 15px;
  font-weight: 700;
}

.event-detail ul, .subject-content ul {
  margin: 0 0 10px;
  padding-left: 20px;
}

.event-detail li, .subject-content li { margin: 2px 0; line-height: 1.5; }
.event-detail li::marker, .subject-content li::marker { color: var(--muted); }

.detail-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin: 4px 0 12px;
}

.detail-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15px;
}

.detail-card-title {
  color: var(--title);
  font-weight: 600;
  line-height: 1.35 !important;
}

.detail-card ul { margin-bottom: 0 !important; }

.detail-images { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }

.detail-images img {
  height: 160px;
  width: auto;
  max-width: 100%;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* Per-subject view */
.subject-section {
  padding: 24px 0 8px;
  border-bottom: 1px solid var(--border);
}

.subject-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 18px;
}

.subject-kicker { color: var(--muted); font-size: 15px; }

.subject-head h3 {
  color: var(--logo-navy);
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -.01em;
}

.subject-meta { display: flex; gap: 24px; margin: 0; }
.subject-meta dt { color: var(--muted); font-size: 14px; }
.subject-meta dd { margin: 0; color: var(--title); font-weight: 600; }

.subject-timeline { margin: 0; padding: 0; list-style: none; }

.subject-entry {
  position: relative;
  display: grid;
  grid-template-columns: 76px 16px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 24px;
}

.subject-entry::before {
  content: "";
  position: absolute;
  left: calc(76px + 12px + 7px);
  top: 18px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.subject-entry:last-child::before { display: none; }
.subject-entry.is-past { opacity: .6; }
.subject-entry > .type-dot { width: 12px; height: 12px; flex-basis: 12px; margin: 6px 2px 0; position: relative; z-index: 1; }

.subject-date strong { display: block; color: var(--logo-navy); font-size: 17px; line-height: 1.3; }
.subject-date span { color: var(--muted); font-size: 14px; }

.schedule-empty, .schedule-error { padding: 24px 0; }

body.modal-open { overflow: hidden; }

@media (max-width: 720px) {
  .schedule-modal {
    width: 100%;
    max-width: none;
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .schedule-sheet { max-height: 100dvh; height: 100%; }
  .schedule-head { padding: 16px 16px 10px; }
  .schedule-head h2 { font-size: 20px; }
  .schedule-legend { padding: 0 16px 12px; font-size: 13px; gap: 4px 14px; }
  .schedule-body { padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
  .month-section h3 { margin: 0 -16px; padding: 14px 16px 8px; }
  .schedule-pdf span { display: none; }
  .timeline-day { grid-template-columns: 44px minmax(0, 1fr); gap: 10px; }
  .timeline-date strong { font-size: 20px; }
  .cal-day, button.cal-day { font-size: 14px; }
  .schedule-tabs { margin: 0 16px 10px; max-width: calc(100% - 32px); }
  .subject-head h3 { font-size: 22px; }
  .subject-head { margin: 0 -16px 14px; padding: 10px 16px 8px; }
  .subject-entry > .subject-date { top: 86px; }
  .subject-entry { grid-template-columns: 56px 12px minmax(0, 1fr); gap: 10px; }
  .subject-entry::before { left: calc(56px + 10px + 5px); }
  .subject-entry > .type-dot { width: 10px; height: 10px; flex-basis: 10px; margin: 6px 1px 0; }
  .detail-title { font-size: 17px; }
  .detail-images img { height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .schedule-modal[open], .schedule-modal[open]::backdrop { animation: none; }
  .schedule-body { scroll-behavior: auto; }
}
