/* Uses the theme's own CSS variables where available, with fallbacks
   so the calendar still looks right if dropped on a page outside the
   ACE theme. */
.rc-calendar{
  --rc-bg: var(--color-bg-alt, #30302e);
  --rc-bg-deep: var(--color-secondary, #1a1918);
  --rc-surface: var(--color-bg, #262624);
  --rc-text: var(--color-text, #e8e6dc);
  --rc-heading: var(--color-heading, #f5f4ef);
  --rc-muted: var(--color-text-muted, #a39e93);
  --rc-primary: var(--color-primary, #008a81);
  --rc-primary-dark: var(--color-primary-dark, #006c65);
  --rc-accent: var(--color-accent, #61b6b1);

  /* The accent as a bare triple. CSS cannot build an rgba() out of a hex
     variable, which is why the soft tints below were written as literals
     and stayed terracotta when the site moved to teal. ace-palette sets
     --ace-primary-rgb site-wide; the fallback keeps this file correct on
     its own. */
  --rc-primary-rgb: var(--ace-primary-rgb, 0,138,129);
  --rc-line: rgba(255,255,255,.08);
  --rc-line-strong: rgba(255,255,255,.14);

  width: 100%;
  max-width: 100%;
  background: var(--rc-bg);
  border: 1px solid var(--rc-line);
  border-radius: 14px;
  padding: 26px 30px 30px;
  color: var(--rc-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  box-sizing: border-box;
}

/* =========================================
   HEADER: title, zoom switch, navigation
   ========================================= */
.rc-cal-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}
.rc-cal-title{
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--rc-heading);
  letter-spacing: -.01em;
}
.rc-cal-controls{
  display: flex;
  align-items: center;
  gap: 10px;
}

.rc-cal-zoom{
  display: inline-flex;
  background: rgba(255,255,255,.05);
  border-radius: 999px;
  padding: 3px;
}
.rc-cal-zoom button{
  border: none;
  background: transparent;
  color: var(--rc-muted);
  font-size: .8rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.rc-cal-zoom button:hover{ color: var(--rc-text); }
/* The selected pill carries small bold text, which needs 4.5:1 to be
   readable. The accent with near-black on it reached only 4.14:1, and
   plain white on the accent only 4.24:1 -- both short. Taking the accent
   a little deeper and putting white on it reaches 5.36:1 while looking
   almost identical, and it is derived from the token so it still follows
   if the site's accent ever changes. */
.rc-cal-zoom button.is-active{
  background: color-mix(in srgb, var(--rc-primary) 87%, #000);
  color: #fff;
}

@supports not (background: color-mix(in srgb, red 50%, #000)){
  .rc-cal-zoom button.is-active{ background: var(--rc-primary-dark, #006c65); }
}

.rc-cal-nav{
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,.05);
  border-radius: 999px;
  padding: 3px;
}
.rc-cal-nav button{
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--rc-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
}
.rc-cal-nav button:hover{
  background: rgba(255,255,255,.08);
  color: var(--rc-primary);
}

/* =========================================
   GRID
   ========================================= */
.rc-cal-grid{
  display: grid;
  border: 1px solid var(--rc-line);
  border-radius: 10px;
  /* visible so a hovered event's full-text bubble isn't clipped */
  overflow: visible;
}
.rc-cal-grid.is-month,
.rc-cal-grid.is-week{ grid-template-columns: repeat(7, 1fr); }
.rc-cal-grid.is-day{ grid-template-columns: 1fr; }

/* Weekday header bar — single deep tone rather than the multicolor
   reference, which would clash with the site's restrained palette. */
.rc-cal-weekday{
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--rc-muted);
  background: var(--rc-bg-deep);
  padding: 12px 4px;
  border-bottom: 1px solid var(--rc-line);
}
/* Weekend columns get a subtle warm tint to break up the row */
.rc-cal-weekday:nth-child(1),
.rc-cal-weekday:nth-child(7){ color: var(--rc-accent); }

.rc-cal-day{
  position: relative;
  min-height: 108px;
  border-right: 1px solid var(--rc-line);
  border-bottom: 1px solid var(--rc-line);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--rc-surface);
  overflow: visible;
}
.rc-cal-grid.is-month .rc-cal-day:nth-child(7n+7),
.rc-cal-grid.is-week .rc-cal-day:nth-child(7n+7){ border-right: none; }

/* With overflow:visible on the grid (so hover bubbles aren't clipped),
   the rounded corners have to come from the corner cells instead. */
.rc-cal-grid.is-month .rc-cal-weekday:first-child,
.rc-cal-grid.is-week .rc-cal-weekday:first-child{ border-top-left-radius: 9px; }
.rc-cal-grid.is-month .rc-cal-weekday:nth-child(7),
.rc-cal-grid.is-week .rc-cal-weekday:nth-child(7){ border-top-right-radius: 9px; }
.rc-cal-grid.is-day .rc-cal-day:only-child{ border-radius: 9px; }
.rc-cal-day:last-child{ border-bottom-right-radius: 9px; }

.rc-cal-day.is-empty{ background: rgba(0,0,0,.15); }
.rc-cal-day.is-empty .rc-cal-day-number{ color: rgba(255,255,255,.2); }

/* Review timeline shading — warm tint using the accent color */
.rc-cal-day.in-timeline{ background: rgba(var(--rc-primary-rgb), .09); }
.rc-cal-day.in-timeline.is-timeline-start{ box-shadow: inset 3px 0 0 var(--rc-accent); }
.rc-cal-day.in-timeline.is-timeline-end{ box-shadow: inset -3px 0 0 var(--rc-accent); }

.rc-cal-day.is-today{ background: rgba(var(--rc-primary-rgb), .1); }
.rc-cal-day.is-today .rc-cal-day-number{
  background: var(--rc-primary);
  color: var(--rc-bg-deep);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Whole cell shaded when it holds an event */
.rc-cal-day.has-event{
  cursor: pointer;
  background: rgba(var(--rc-primary-rgb), .05);
}
.rc-cal-day.has-event:hover{ background: rgba(var(--rc-primary-rgb), .1); z-index: 10; }
/* Event days inside the review timeline blend both tints */
.rc-cal-day.has-event.in-timeline{ background: rgba(var(--rc-primary-rgb), .11); }
/* Today + event: keep today readable rather than double-shading */
.rc-cal-day.is-today.has-event{ background: rgba(var(--rc-primary-rgb), .14); }

.rc-cal-day-number{
  font-size: .85rem;
  font-weight: 600;
  color: var(--rc-text);
  flex-shrink: 0;
}

.rc-cal-day-events{
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
}
/* An event reads as a label, not a button.
   A solid block of colour behind dark text is loud at this size, and it
   fought with the tint on the cell behind it -- two shades of the same
   colour arguing over the same square. A quiet tint with a coloured spine
   down the left says the same thing more calmly, keeps the type's colour
   legible at a glance, and lets the day number stay the brightest thing
   in the cell.
   The colour arrives from the script as --rc-ev. */
.rc-cal-day-event{
  position: relative;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.4;
  padding: 3px 8px;
  border-radius: 4px;
  border-left: 4px solid var(--rc-ev, var(--rc-primary));
  background: color-mix(in srgb, var(--rc-ev, var(--rc-primary)) 18%, transparent);
  color: var(--rc-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .14s ease;
}

.rc-cal-day-event:hover{
  background: color-mix(in srgb, var(--rc-ev, var(--rc-primary)) 30%, transparent);
}

/* color-mix is recent enough to be worth a floor: without it the two
   declarations above are dropped and the chip would have a spine and no
   fill at all, which still reads correctly but flatly. */
@supports not (background: color-mix(in srgb, red 50%, transparent)){
  .rc-cal-day-event{ background: rgba(var(--rc-primary-rgb), .16); }
  .rc-cal-day-event:hover{ background: rgba(var(--rc-primary-rgb), .26); }
}

/* Hovering a truncated event reveals its full text in a floating
   bubble, so long names stay readable without stretching the cell. */
.rc-cal-day-event[data-full]:hover::after{
  content: attr(data-full);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 30;
  background: var(--rc-bg-deep);
  color: var(--rc-text);
  border: 1px solid var(--rc-line-strong);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: normal;
  width: max-content;
  max-width: 240px;
  box-shadow: 0 10px 24px rgba(0,0,0,.45);
  pointer-events: none;
}

.rc-cal-grid.is-week .rc-cal-day{ min-height: 200px; }
.rc-cal-grid.is-week .rc-cal-day-event{ white-space: normal; }

.rc-cal-grid.is-day .rc-cal-day{
  min-height: 260px;
  border-right: none;
  padding: 22px;
  gap: 12px;
}
.rc-cal-grid.is-day .rc-cal-day-number{ font-size: 1.1rem; color: var(--rc-heading); }
.rc-cal-grid.is-day .rc-cal-day-event{
  font-size: .9rem;
  padding: 10px 14px;
  border-radius: 8px;
  white-space: normal;
}
.rc-cal-day-empty-note{
  color: var(--rc-muted);
  font-size: .9rem;
}

/* =========================================
   POPOVER
   ========================================= */
.rc-cal-popover{
  position: absolute;
  z-index: 20;
  background: var(--rc-bg-deep);
  border: 1px solid var(--rc-line-strong);
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 190px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  font-size: .82rem;
  display: none;
}
.rc-cal-popover.is-open{ display: block; }
.rc-cal-popover-date{
  color: var(--rc-muted);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 8px;
}
.rc-cal-popover-item{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--rc-text);
}
.rc-cal-popover-item:last-child{ margin-bottom: 0; }
.rc-cal-popover-dot{
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* =========================================
   LEGEND
   ========================================= */
.rc-cal-legend{
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 18px;
  font-size: .8rem;
  color: var(--rc-muted);
}
.rc-cal-legend-item{ display: flex; align-items: center; gap: 7px; }
.rc-cal-legend-dot{ width: 10px; height: 10px; border-radius: 3px; }
.rc-cal-legend-dot.is-range{
  background: rgba(var(--rc-primary-rgb), .15);
  border: 1px solid var(--rc-accent);
}

/* =========================================
   MOBILE
   ========================================= */
@media (max-width: 640px){
  .rc-calendar{ padding: 16px 12px 20px; }
  .rc-cal-title{ font-size: 1.15rem; }
  .rc-cal-header{ gap: 10px; }
  .rc-cal-zoom button{ padding: 6px 12px; font-size: .75rem; }
  .rc-cal-weekday{ font-size: .62rem; padding: 9px 2px; }

  .rc-cal-grid.is-month .rc-cal-day,
  .rc-cal-grid.is-week .rc-cal-day{
    min-height: 0;
    aspect-ratio: 1;
    align-items: center;
    justify-content: center;
    padding: 2px;
    gap: 2px;
  }
  .rc-cal-grid.is-month .rc-cal-day-events,
  .rc-cal-grid.is-week .rc-cal-day-events{ display: none; }

  .rc-cal-grid.is-month .rc-cal-day.has-event::after,
  .rc-cal-grid.is-week .rc-cal-day.has-event::after{
    content: '';
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--rc-primary);
  }
  .rc-cal-day-number{ font-size: .8rem; }
  .rc-cal-grid.is-day .rc-cal-day{ padding: 18px; }
}

/* =========================================
   COURSE TITLE ABOVE A CALENDAR
   ========================================= */
.rc-calendar-wrap{ margin-bottom: 32px; }
.rc-calendar-course-title{
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-heading, #f5f4ef);
  margin: 0 0 14px;
}

/* =========================================
   COURSE TABS (all-calendars page)
   ========================================= */
/* The course selector is one control, so it looks like one.
   Four separately outlined pills floating above the card read as four
   unrelated buttons; a single tinted track with the choice sitting inside
   it says "pick one of these". It is deliberately the same shape as the
   Day/Week/Month/Year control inside the calendar, so the page has one
   way of asking a question rather than two.

   This block sits OUTSIDE .rc-calendar, so it cannot use --rc-primary-rgb,
   which is declared on that element. It reads the site-wide token instead. */
.rc-cal-tabs-nav{
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  background: rgba(255,255,255,.05);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 22px;
  max-width: 100%;
}
.rc-cal-tab{
  border: none;
  background: transparent;
  color: var(--color-text-muted, #a39e93);
  font-family: inherit;
  font-size: .84rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s ease, color .14s ease;
}
.rc-cal-tab:hover{
  background: rgba(255,255,255,.06);
  color: var(--color-text, #e8e6dc);
}
.rc-cal-tab:focus-visible{
  outline: 2px solid var(--color-primary, #008a81);
  outline-offset: 1px;
}
.rc-cal-tab.is-active{
  background: color-mix(in srgb, var(--color-primary, #008a81) 87%, #000);
  color: #fff;
}

@supports not (background: color-mix(in srgb, red 50%, #000)){
  .rc-cal-tab.is-active{ background: var(--color-primary-dark, #006c65); }
}

/* On a narrow screen four courses will not sit on one line, so the track
   scrolls sideways instead of stacking into a block four rows tall. */
@media (max-width: 640px){
  .rc-cal-tabs-nav{
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .rc-cal-tabs-nav::-webkit-scrollbar{ display: none; }
}
.rc-cal-tab-panel{ display: none; }
.rc-cal-tab-panel.is-active{ display: block; }

/* =========================================
   YEAR VIEW — twelve mini months
   ========================================= */
.rc-cal-grid.is-year{
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  border: none;
  overflow: hidden; /* year view doesn't need the hover-bubble escape */
  min-width: 0;
}
.rc-cal-mini-month{
  /* min-width: 0 is the actual fix — without it, a grid item won't
     shrink below its content's natural width, so the 7-column mini
     calendar inside kept forcing this card (and the whole year grid)
     wider than its container, clipping the leftmost columns. */
  min-width: 0;
  background: var(--rc-surface);
  border: 1px solid var(--rc-line);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.rc-cal-mini-month:hover{
  border-color: var(--rc-primary);
  background: rgba(255,255,255,.03);
}
.rc-cal-mini-title{
  font-size: .85rem;
  font-weight: 700;
  color: var(--rc-heading);
  margin-bottom: 10px;
  text-align: center;
}
.rc-cal-mini-grid{
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.rc-cal-mini-weekday{
  font-size: .58rem;
  font-weight: 700;
  color: var(--rc-muted);
  text-align: center;
  padding-bottom: 4px;
}
.rc-cal-mini-day{
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .62rem;
  color: var(--rc-text);
  border-radius: 3px;
}
.rc-cal-mini-day.is-blank{ visibility: hidden; }
.rc-cal-mini-day.in-timeline{ background: rgba(var(--rc-primary-rgb), .16); }
.rc-cal-mini-day.has-event{
  color: var(--rc-bg-deep);
  font-weight: 700;
}
.rc-cal-mini-day.is-today{
  outline: 1px solid var(--rc-primary);
  font-weight: 700;
}

@media (max-width: 1000px){
  .rc-cal-grid.is-year{ grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px){
  .rc-cal-grid.is-year{ grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .rc-cal-mini-month{ padding: 10px; }
}
@media (max-width: 420px){
  .rc-cal-grid.is-year{ grid-template-columns: 1fr; }
}
