/* Calendar styles for createcal output. Loaded after ../site.css,
   so it reuses the site's color tokens. createcal -gencals keeps this
   file; `createcal -writecss` would reset it to the default. */

:root {
  --ev-lecture: #ece6f6;
  --ev-section: #e3eef9;
  --ev-exam: #fbe1dc;
  --ev-hw: #f6efdc;
  --ev-oh: #e2f3e6;
  --ev-other: #f1e4f1;
  --ev-holiday: #ececec;
  --ev-fg: #1c1c1c;
  --cal-off: #f3f3f3;
  --today: #b7a57a;
}

/* Dark colors apply when the system is dark and the visitor has not chosen
   light, or whenever the visitor chooses dark (see theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ev-lecture: #342a4d;
    --ev-section: #1f3347;
    --ev-exam: #4a2621;
    --ev-hw: #3f3520;
    --ev-oh: #1f3a28;
    --ev-other: #3c2640;
    --ev-holiday: #2d2d2d;
    --ev-fg: #eeeaf4;
    --cal-off: #1e1a26;
  }
}
:root[data-theme="dark"] {
  --ev-lecture: #342a4d;
  --ev-section: #1f3347;
  --ev-exam: #4a2621;
  --ev-hw: #3f3520;
  --ev-oh: #1f3a28;
  --ev-other: #3c2640;
  --ev-holiday: #2d2d2d;
  --ev-fg: #eeeaf4;
  --cal-off: #1e1a26;
}

/* The intro line under the page title keeps the normal text size here */
.muted-note { font-size: inherit; }

/* Color key */
details.colorkey { margin-bottom: 1.5rem; }
details.colorkey summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
#color-key {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
#color-key li { margin: 0; }
#color-key div { margin: 0; }

/* Month tables */
table.monthtable {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
}
table.monthtable td,
table.monthtable th {
  vertical-align: top;
  border: 1px solid var(--rule);
  padding: 0.35rem;
}
.month-header {
  text-align: left;
  font-size: 1.25rem;
  background: var(--purple);
  color: #ffffff;
  padding: 0.5rem 0.75rem !important;
}
.day-header {
  background: var(--panel);
  text-align: center;
  font-size: 0.9rem;
}
td.eventtd, td.noevent { font-size: 0.85rem; line-height: 1.4; }
td.notinquarter { background: var(--cal-off); }
table.monthtable td.today { outline: 4px solid var(--today); outline-offset: -4px; }

span.datespan {
  display: block;
  text-align: right;
  font-weight: 700;
  color: var(--muted);
}

/* Events */
div.lecture, div.section, div.lab, div.exam,
div.hw, div.oh, div.holiday, div.other {
  color: var(--ev-fg);
  padding: 0.3rem 0.4rem;
  margin: 0.25rem 0;
  border-radius: 4px;
  border-left: 4px solid transparent;
  overflow-wrap: anywhere;
}
div.lecture { background: var(--ev-lecture); border-left-color: #4b2e83; }
div.section { background: var(--ev-section); border-left-color: #2d6aa3; }
div.lab     { background: var(--ev-section); border-left-color: #2d6aa3; }
div.exam    { background: var(--ev-exam);    border-left-color: #b3372a; }
div.hw      { background: var(--ev-hw);      border-left-color: #8a6d1f; }
div.oh      { background: var(--ev-oh);      border-left-color: #2e7d4a; }
div.other   { background: var(--ev-other);   border-left-color: #8e3f8e; }
div.holiday { background: var(--ev-holiday); border-left-color: #6b6b6b; }

span.summary { font-weight: 600; }
span.description { font-style: italic; }
div.lecture a, div.section a, div.hw a, div.other a { color: inherit; font-weight: 600; }

/* List pages (lecture, section, homework lists) */
table.listtable {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}
table.listtable thead { background: var(--panel); }
table.listtable th,
table.listtable td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}
span.list_description { font-style: italic; }

/* Subscribe page: long URLs wrap instead of widening the page */
table.subscribe td:nth-child(2) { white-space: nowrap; }
table.subscribe code.url {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* Screen-reader-only text */
.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  height: 1px;
  width: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  border: 0;
}

/* Phones: stack each week's days vertically instead of a 5-column grid */
@media (max-width: 40rem) {
  table.monthtable,
  table.monthtable tbody,
  table.monthtable tr,
  table.monthtable td { display: block; width: 100%; }
  table.monthtable thead tr:last-child { display: none; }
  table.monthtable thead,
  table.monthtable thead tr,
  table.monthtable thead th { display: block; width: 100%; }
  table.monthtable td { border-top: 0; }
  table.monthtable td.notinquarter,
  table.monthtable td.noevent { display: none; }
  span.datespan { display: none; }
  table.monthtable td.eventtd::before {
    content: attr(aria-label);
    display: block;
    font-weight: 700;
    color: var(--muted);
  }
}

@media print {
  /* Light event colors on paper, even if the reader chose dark mode */
  :root[data-theme],
  :root:not([data-theme]) {
    --ev-lecture: #ece6f6;
    --ev-section: #e3eef9;
    --ev-exam: #fbe1dc;
    --ev-hw: #f6efdc;
    --ev-oh: #e2f3e6;
    --ev-other: #f1e4f1;
    --ev-holiday: #ececec;
    --ev-fg: #1c1c1c;
    --cal-off: #f3f3f3;
  }
  table.monthtable { page-break-inside: avoid; }
}
