/* ============================================================
   Academic Calendar — page-scoped styles
   Loaded only on the page-academic-calendar.php template.
   Uses the theme's existing brand tokens defined in main.css:
     --mc-purple, --mc-purple-light, --mc-gold, --mc-grey,
     --ink, --cream, --display, --ease.
   ============================================================ */

.academic-calendar-page {
  --ac-purple:        var(--mc-purple, #52247F);
  --ac-purple-light:  var(--mc-purple-light, #6E3FA4);
  --ac-gold:          var(--mc-gold, #BC9B6A);
  --ac-grey:          var(--mc-grey, #5F6062);
  --ac-line:          rgba(82, 36, 127, 0.10);
  --ac-line-strong:   rgba(82, 36, 127, 0.20);
  --ac-bg-soft:       rgba(82, 36, 127, 0.03);
  --ac-bg-active:     rgba(188, 155, 106, 0.10);
  --ac-radius:        12px;
  --ac-radius-sm:     8px;
}

/* ------------------------------------------------------------
   Toolbar (year + actions)
   ------------------------------------------------------------ */
.ac-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  margin-bottom: 24px;
  background: var(--ac-bg-soft);
  border: 1px solid var(--ac-line);
  border-radius: var(--ac-radius);
}
.ac-toolbar__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ac-toolbar__year {
  font-family: var(--display, "Cormorant Garamond", serif);
  font-size: clamp(22px, 2.4vw, 28px);
  color: var(--ac-purple);
  font-weight: 600;
  line-height: 1.15;
}
.ac-toolbar__faculty {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ac-grey);
}
.ac-toolbar__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.ac-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.25s var(--ease, ease);
  text-decoration: none;
  line-height: 1;
}
.ac-btn--primary {
  background: linear-gradient(135deg, var(--ac-purple), var(--ac-purple-light));
  color: #fff;
}
.ac-btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(82, 36, 127, 0.25);
  color: #fff;
}
.ac-btn--ghost {
  background: transparent;
  color: var(--ac-purple);
  border-color: var(--ac-line-strong);
}
.ac-btn--ghost:hover {
  background: var(--ac-bg-soft);
}

/* ------------------------------------------------------------
   "Currently in" banner
   ------------------------------------------------------------ */
.ac-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 22px;
  margin-bottom: 32px;
  background: linear-gradient(135deg, rgba(82, 36, 127, 0.06), rgba(188, 155, 106, 0.08));
  border-left: 4px solid var(--ac-gold);
  border-radius: var(--ac-radius);
}
.ac-banner__pulse {
  width: 14px;
  height: 14px;
  position: relative;
  flex: 0 0 14px;
}
.ac-banner__pulse span {
  position: absolute;
  inset: 0;
  background: var(--ac-gold);
  border-radius: 50%;
  animation: ac-pulse 2s ease-out infinite;
}
.ac-banner__pulse::before {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--ac-gold);
  border-radius: 50%;
}
@keyframes ac-pulse {
  0%   { transform: scale(1);   opacity: 0.6; }
  70%  { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}
.ac-banner__label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ac-grey);
  font-weight: 600;
  margin-bottom: 4px;
}
.ac-banner__title {
  font-family: var(--display, "Cormorant Garamond", serif);
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 600;
  color: var(--ac-purple);
  line-height: 1.2;
  margin-bottom: 6px;
}
.ac-banner__meta {
  font-size: 13px;
  color: var(--ac-grey);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ac-banner__meta span {
  opacity: 0.45;
}

/* ------------------------------------------------------------
   Layout (main + sidebar)
   ------------------------------------------------------------ */
.ac-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 48px;
  align-items: start;
}
@media (max-width: 960px) {
  .ac-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

/* ------------------------------------------------------------
   Intro & legend
   ------------------------------------------------------------ */
.ac-intro {
  margin-bottom: 32px;
}
.ac-intro h2 {
  font-family: var(--display, "Cormorant Garamond", serif);
  font-size: clamp(22px, 2.6vw, 30px);
  color: var(--ac-purple);
  margin: 0 0 12px;
  line-height: 1.2;
}
.ac-intro p {
  color: var(--ac-grey);
  line-height: 1.65;
  max-width: 68ch;
  margin: 0 0 18px;
}
.ac-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.ac-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--ac-bg-soft);
  border: 1px solid var(--ac-line);
  color: var(--ac-grey);
}
.ac-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
}
.ac-chip--registration .ac-chip__dot { background: var(--ac-purple); }
.ac-chip--lectures     .ac-chip__dot { background: #2E7D6F; }
.ac-chip--exams        .ac-chip__dot { background: #B23E3E; }
.ac-chip--break        .ac-chip__dot { background: var(--ac-gold); }

/* ------------------------------------------------------------
   Cohort jump nav
   ------------------------------------------------------------ */
.ac-cohort-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  margin: 0 0 32px;
  background: #fff;
  border: 1px solid var(--ac-line);
  border-radius: var(--ac-radius);
  position: sticky;
  top: 90px;
  z-index: 5;
  backdrop-filter: blur(6px);
}
.ac-cohort-nav__label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ac-grey);
  font-weight: 600;
}
.ac-cohort-nav a {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--ac-purple);
  text-decoration: none;
  background: var(--ac-bg-soft);
  transition: all 0.2s var(--ease, ease);
}
.ac-cohort-nav a:hover {
  background: var(--ac-purple);
  color: #fff;
}

/* ------------------------------------------------------------
   Cohort & semester
   ------------------------------------------------------------ */
.ac-cohort {
  margin-bottom: 56px;
  scroll-margin-top: 140px;
}
.ac-cohort__head {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ac-line-strong);
}
.ac-cohort__title {
  font-family: var(--display, "Cormorant Garamond", serif);
  font-size: clamp(26px, 3.2vw, 36px);
  color: var(--ac-purple);
  margin: 0 0 8px;
  line-height: 1.15;
}
.ac-cohort__desc {
  color: var(--ac-grey);
  margin: 0;
  line-height: 1.6;
  max-width: 68ch;
}
.ac-cohort__note {
  margin: 10px 0 0;
  padding: 10px 14px;
  background: rgba(188, 155, 106, 0.12);
  border-left: 3px solid var(--ac-gold);
  border-radius: var(--ac-radius-sm);
  font-size: 14px;
  color: #6b4f23;
}

.ac-semester {
  margin-bottom: 32px;
}
.ac-semester__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.ac-semester__title {
  font-family: var(--display, "Cormorant Garamond", serif);
  font-size: clamp(20px, 2.4vw, 26px);
  color: var(--ac-purple);
  margin: 0;
  line-height: 1.2;
}
.ac-semester__period {
  font-size: 13px;
  color: var(--ac-grey);
  padding: 4px 10px;
  background: var(--ac-bg-soft);
  border-radius: 999px;
}

/* ------------------------------------------------------------
   Groups & tables
   ------------------------------------------------------------ */
.ac-group {
  margin-bottom: 20px;
}
.ac-group__label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ac-grey);
  font-weight: 600;
  margin: 0 0 8px;
  padding-left: 14px;
  border-left: 3px solid var(--ac-gold);
}
.ac-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--ac-line);
  border-radius: var(--ac-radius);
  background: #fff;
}
.ac-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  min-width: 480px;
}
.screen-reader-text {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.ac-row {
  border-bottom: 1px solid var(--ac-line);
  transition: background 0.2s var(--ease, ease);
}
.ac-row:last-child {
  border-bottom: none;
}
.ac-row__date,
.ac-row__event {
  padding: 14px 18px;
  vertical-align: top;
  line-height: 1.5;
}
.ac-row__date {
  width: 38%;
  min-width: 200px;
  font-weight: 500;
  color: var(--ac-purple);
  background: var(--ac-bg-soft);
  position: relative;
}
.ac-row__event {
  color: #2a1f3a;
}
.ac-row__event strong {
  color: var(--ac-purple);
  font-weight: 600;
}
.ac-row__note {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  color: var(--ac-gold);
  font-style: italic;
  font-weight: 500;
}
.ac-row__now {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--ac-gold);
  color: #fff;
  border-radius: 999px;
}

/* Active row */
.ac-row--active {
  background: var(--ac-bg-active);
}
.ac-row--active .ac-row__date {
  background: rgba(188, 155, 106, 0.18);
}

/* Cancelled row */
.ac-row--cancelled .ac-row__date,
.ac-row--cancelled .ac-row__event {
  text-decoration: line-through;
  opacity: 0.5;
}
.ac-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  vertical-align: middle;
}
.ac-tag--cancelled {
  background: #fdecec;
  color: #b23e3e;
  border: 1px solid #f4c4c4;
}

/* Category accent on the left edge of the date cell */
.ac-row__date::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: transparent;
}
.ac-row--registration .ac-row__date::before { background: var(--ac-purple); }
.ac-row--lectures     .ac-row__date::before { background: #2E7D6F; }
.ac-row--exams        .ac-row__date::before { background: #B23E3E; }
.ac-row--break        .ac-row__date::before { background: var(--ac-gold); }

/* ------------------------------------------------------------
   Footnote
   ------------------------------------------------------------ */
.ac-footnote {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--ac-line);
  font-size: 13px;
  color: var(--ac-grey);
}
.ac-footnote p {
  margin: 0 0 6px;
}
.ac-footnote__caveat {
  font-style: italic;
  opacity: 0.85;
}

/* ------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------ */
.ac-layout__side {
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (max-width: 960px) {
  .ac-layout__side {
    position: static;
  }
}
.ac-side-card {
  padding: 22px;
  background: #fff;
  border: 1px solid var(--ac-line);
  border-radius: var(--ac-radius);
}
.ac-side-card__title {
  font-family: var(--display, "Cormorant Garamond", serif);
  font-size: 18px;
  color: var(--ac-purple);
  margin: 0 0 14px;
  line-height: 1.2;
  font-weight: 600;
}
.ac-event-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ac-event {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--ac-line);
}
.ac-event:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.ac-event__date {
  flex: 0 0 44px;
  text-align: center;
  padding: 6px 4px;
  background: var(--ac-bg-soft);
  border-radius: var(--ac-radius-sm);
  line-height: 1;
}
.ac-event__month {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ac-purple);
  font-weight: 600;
}
.ac-event__day {
  display: block;
  font-family: var(--display, "Cormorant Garamond", serif);
  font-size: 20px;
  color: var(--ac-purple);
  font-weight: 600;
  margin-top: 2px;
}
.ac-event__title {
  font-size: 14px;
  color: #2a1f3a;
  text-decoration: none;
  line-height: 1.4;
  flex: 1 1 auto;
  padding-top: 4px;
}
.ac-event__title:hover {
  color: var(--ac-purple);
  text-decoration: underline;
}
.ac-side-card__more {
  display: inline-block;
  font-size: 13px;
  color: var(--ac-purple);
  text-decoration: none;
  font-weight: 500;
}
.ac-side-card__more:hover {
  text-decoration: underline;
}
.ac-link-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ac-link-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--ac-line);
}
.ac-link-list li:last-child {
  border-bottom: none;
}
.ac-link-list a {
  font-size: 14px;
  color: var(--ac-purple);
  text-decoration: none;
}
.ac-link-list a:hover {
  text-decoration: underline;
}
.ac-side-card__rich {
  font-size: 14px;
  color: var(--ac-grey);
  line-height: 1.55;
}
.ac-side-card__rich p {
  margin: 0 0 10px;
}
.ac-side-card__rich p:last-child {
  margin-bottom: 0;
}

/* ------------------------------------------------------------
   Notice
   ------------------------------------------------------------ */
.ac-notice {
  padding: 18px 22px;
  border-radius: var(--ac-radius);
  margin-bottom: 24px;
}
.ac-notice--error {
  background: #fdecec;
  border: 1px solid #f4c4c4;
  color: #8a2828;
}
.ac-notice p {
  margin: 0;
}

/* ------------------------------------------------------------
   Mobile refinements
   ------------------------------------------------------------ */
@media (max-width: 600px) {
  .ac-toolbar {
    padding: 14px 16px;
  }
  .ac-toolbar__actions {
    width: 100%;
  }
  .ac-btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  .ac-banner {
    padding: 16px 18px;
    gap: 14px;
  }
  .ac-row__date,
  .ac-row__event {
    padding: 12px 14px;
    font-size: 14px;
  }
  .ac-cohort-nav {
    position: static; /* avoid sticky overlap on small screens */
  }
}

/* ------------------------------------------------------------
   Print
   ------------------------------------------------------------ */
@media print {
  /* Hide chrome */
  .site-header,
  .site-footer,
  .programme-archive-hero,
  .ac-toolbar,
  .ac-cohort-nav,
  .ac-layout__side,
  .ac-banner__pulse {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
  }

  .academic-calendar-page {
    padding: 0 !important;
  }

  .ac-layout {
    display: block;
  }

  .ac-cohort {
    page-break-inside: avoid;
    margin-bottom: 24px;
  }

  .ac-cohort__title,
  .ac-semester__title,
  .ac-intro h2 {
    color: #000 !important;
  }

  .ac-table-wrap {
    border: 1px solid #999;
    border-radius: 0;
    overflow: visible;
  }

  .ac-row {
    page-break-inside: avoid;
  }

  .ac-row__date {
    background: #f5f5f5 !important;
    color: #000 !important;
  }

  .ac-banner {
    border: 1px solid #999;
    background: #f9f9f9 !important;
    page-break-inside: avoid;
  }

  .ac-row__now,
  .ac-tag {
    border: 1px solid #999;
    background: #fff !important;
    color: #000 !important;
  }

  /* URL hints after links */
  .ac-side-card a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #555;
  }
}

/* ------------------------------------------------------------
   v2.7.6 Mobile academic calendar containment fix
   Prevents intro text, legend chips, jump links and tables from
   being clipped on narrow mobile screens.
   ------------------------------------------------------------ */
@media (max-width: 680px) {
  .academic-calendar-page,
  .academic-calendar-page * {
    box-sizing: border-box;
  }

  .academic-calendar-page {
    overflow-x: hidden;
  }

  .academic-calendar-page .container,
  .academic-calendar-page .wrap,
  .academic-calendar-page .entry-content,
  .ac-layout,
  .ac-layout__main,
  .ac-layout__side,
  .ac-intro,
  .ac-cohort,
  .ac-semester,
  .ac-table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .ac-intro p,
  .ac-cohort__desc,
  .ac-cohort__note,
  .ac-row__event,
  .ac-side-card__rich {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .ac-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .ac-chip {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
    white-space: normal;
  }

  .ac-cohort-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 14px 14px;
    scroll-snap-type: x proximity;
  }

  .ac-cohort-nav__label,
  .ac-cohort-nav a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .ac-cohort-nav a {
    scroll-snap-align: start;
  }

  .ac-cohort__title {
    font-size: clamp(24px, 8vw, 32px);
    overflow-wrap: anywhere;
  }

  .ac-semester__head {
    align-items: flex-start;
  }

  .ac-semester__period {
    max-width: 100%;
    white-space: normal;
  }

  .ac-table-wrap {
    overflow-x: visible;
  }

  .ac-table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .ac-table tbody,
  .ac-row,
  .ac-row__date,
  .ac-row__event {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .ac-row {
    padding: 0;
  }

  .ac-row__date {
    border-bottom: 1px solid var(--ac-line);
  }

  .ac-row__event {
    padding-top: 12px;
  }
}

@media (max-width: 380px) {
  .ac-legend {
    grid-template-columns: 1fr;
  }

  .ac-cohort-nav {
    margin-left: 0;
    margin-right: 0;
  }
}

/* ------------------------------------------------------------
   v2.7.7 Mobile first-load render fix
   Some mobile browsers can fail to paint lower calendar sections on an
   initial narrow viewport until a resize occurs. Keep the calendar in a
   normal document flow and force all major sections visible on first load.
   ------------------------------------------------------------ */
@media (max-width: 680px) {
  html,
  body {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .academic-calendar-page {
    display: block !important;
    min-height: auto !important;
    height: auto !important;
    overflow-x: clip;
    overflow-y: visible !important;
    contain: none !important;
    content-visibility: visible !important;
  }

  .academic-calendar-page .container,
  .academic-calendar-page .section-inner,
  .ac-layout,
  .ac-layout__main,
  .ac-layout__side,
  .ac-intro,
  .ac-legend,
  .ac-cohort-nav,
  .ac-cohort,
  .ac-cohort__head,
  .ac-semester,
  .ac-semester__head,
  .ac-group,
  .ac-table-wrap,
  .ac-table,
  .ac-table tbody,
  .ac-row,
  .ac-row__date,
  .ac-row__event,
  .ac-side-card {
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    contain: none !important;
    content-visibility: visible !important;
  }

  .ac-layout {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .ac-layout__main,
  .ac-layout__side {
    display: block !important;
  }

  .ac-intro,
  .ac-cohort-nav,
  .ac-cohort,
  .ac-side-card {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .ac-cohort + .ac-cohort,
  .ac-side-card + .ac-side-card {
    margin-top: 28px;
  }

  .ac-table,
  .ac-table tbody,
  .ac-row,
  .ac-row__date,
  .ac-row__event {
    display: block !important;
  }

  .ac-table-wrap {
    overflow: visible !important;
  }

  .ac-row {
    margin-bottom: 12px;
  }
}
