/* Course calendar — static week-grid table + legend + deadline tables.
 *
 * Each row = one week (Sat → Fri).  The final column (visual left in RTL)
 * is the Jalali month label.  All day cells have identical fixed dimensions.
 *
 * Visual identity — two axes:
 *   type  ∈ {theory, practical, exam}       → color
 *   phase ∈ {release, deadline, hard, exam} → chip style / border
 */

/* ── Color tokens ──────────────────────────────────────────────────── */
:root {
  --cal-theory-fg:    #0d9488;
  --cal-theory-bg:    #ccfbf1;

  --cal-practical-fg: #4f46e5;
  --cal-practical-bg: #eef2ff;

  --cal-exam-fg:      #dc2626;
  --cal-exam-bg:      #fee2e2;
}
[data-md-color-scheme="slate"] {
  --cal-theory-bg:    #042f2e;
  --cal-practical-bg: #1e1b4b;
  --cal-exam-bg:      #450a0a;
}

/* ── Wrapper + table ────────────────────────────────────────────────── */
.dasut-cal-wrap {
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--md-default-fg-color--lightest);
}

.dasut-cal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  table-layout: fixed;
  display: table;
  margin: 0 !important;
}

/* ── Column widths ─────────────────────────────────────────────────── */
.dasut-cal-table col.cal-col-month { width: 2.8rem; }

/* ── Header row ────────────────────────────────────────────────────── */
.dasut-cal-table thead th {
  padding: .35rem .25rem;
  text-align: center;
  font-size: .8em;
  font-weight: 700;
  color: var(--md-default-fg-color--light);
  background: var(--md-code-bg-color);
  border-bottom: 2px solid var(--md-default-fg-color--lightest);
  border-left: 1px solid var(--md-default-fg-color--lightest);
  white-space: nowrap;
}
.dasut-cal-table thead th.cal-m-hdr {
  border-left: none;
  border-right: 2px solid var(--md-default-fg-color--lightest);
}

/* ── Day cells ──────────────────────────────────────────────────────── */
.cal-day {
  padding: 0;
  vertical-align: top;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-top: none;
  border-right: none;
}
/* Inner wrapper: flex column, fixed height, overflow visible so chip
 * outlines (which extend outside the border box) are not clipped. */
.cal-day-inner {
  height: 4.3rem;
  padding: .22rem .28rem .35rem; /* extra bottom for outline clearance */
  display: flex;
  flex-direction: column;
  gap: .15rem;          /* between day-num and event list */
  overflow: visible;
}

.cal-day--other .cal-day-inner { opacity: .35; }
.cal-day--today {
  outline: 2px solid var(--cal-theory-fg);
  outline-offset: -2px;
}

/* Jalali day number — pinned top-right in RTL */
.cal-day-num {
  display: block;
  font-size: .72em;
  font-weight: 500;
  color: var(--md-default-fg-color--light);
  line-height: 1;
  text-align: right;
  flex-shrink: 0;
}

/* Event stack — natural height, top-aligned */
.cal-day-evts {
  display: flex;
  flex-direction: column;
  /* Gap must exceed 2 × outline-reach (1.5px offset + 2px = 3.5px each side)
   * to prevent hard-deadline outlines from touching each other. */
  gap: .55rem;
}

/* ── Month label column ─────────────────────────────────────────────── */
.cal-m-hdr,
.cal-m-cell {
  text-align: center;
  vertical-align: middle;
  font-size: .8em;
  font-weight: 700;
  color: var(--md-default-fg-color--light);
  background: var(--md-code-bg-color);
  white-space: nowrap;
  padding: .3rem .4rem;
  border-right: 2px solid var(--md-default-fg-color--lightest);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.cal-m-cell {
  border-top: 1px solid var(--md-default-fg-color--lightest);
}

/* ── Event chip (.cal-evt × type × phase) ───────────────────────────── */
.cal-evt {
  display: inline-flex;
  align-items: center;
  gap: .22rem;
  padding: .07rem .28rem;
  border-radius: 999px;
  font-size: .75em;
  line-height: 1.35;
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: default;
  overflow: hidden;
  flex-shrink: 0;
}
.cal-evt__dot {
  display: inline-block;
  width: .45em;
  height: .45em;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}
.cal-evt__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── type → color ────────────────────────────────────────────────── */
.cal-evt--theory    { color: var(--cal-theory-fg);    background: var(--cal-theory-bg);    border-color: var(--cal-theory-fg); }
.cal-evt--practical { color: var(--cal-practical-fg); background: var(--cal-practical-bg); border-color: var(--cal-practical-fg); }
.cal-evt--exam      { color: var(--cal-exam-fg);      background: var(--cal-exam-bg);      border-color: var(--cal-exam-fg); font-weight: 700; }

/* ── phase → fill / border ──────────────────────────────────────── */

/* release: transparent chip, dashed border, hollow dot */
.cal-evt--release { background: transparent; border-style: dashed; font-weight: 500; }
.cal-evt--release .cal-evt__dot { background: transparent; border: 1.5px solid currentColor; }

/* deadline: solid chip */
.cal-evt--deadline { font-weight: 700; }

/* hard: same solid fill + DOUBLE border via outline ring */
.cal-evt--hard {
  font-weight: 700;
  border-width: 1.5px;
  outline: 1.5px solid currentColor;
  outline-offset: 2px;
}

/* ── Legend block ───────────────────────────────────────────────────── */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .8rem;
  padding: .6rem .8rem;
  margin: .8rem 0 1rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  background: var(--md-default-bg-color);
  font-size: .9em;
}
.cal-legend__item {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--md-default-fg-color);
}
.cal-legend .cal-evt__label { display: none; }
.cal-legend .cal-evt { padding: .1rem .3rem; }

/* ── Deadline tables ────────────────────────────────────────────────── */
.md-content table th,
.md-content table td { vertical-align: middle; }

.md-content table td:nth-child(2),
.md-content table td:nth-child(3),
.md-content table td:nth-child(4),
.md-content table th:nth-child(2),
.md-content table th:nth-child(3),
.md-content table th:nth-child(4) {
  white-space: nowrap;
  text-align: center;
}
