/* The officer hub's Events section (/js/hub/events.js) and its editor (/js/hub/events-editor.js), plus
   the dashboard's Coming up card. Colors come from the tokens in app.css, so light and dark both work. */

/* ---------- the toolbar ---------- */

.ev-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin: -4px 0 16px; }
.ev-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); }
.ev-switch button {
  min-height: 36px; padding: 0 16px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font: inherit; font-weight: 650; font-size: 14px; cursor: pointer;
}
.ev-switch button:hover { color: var(--text); }
.ev-switch button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.ev-switch button:focus-visible { outline-offset: -2px; }
.ev-site-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 14px; }
.ev-body[aria-busy="true"] { opacity: 0.6; }

/* ---------- the upcoming list ---------- */

.ev-summary { margin: 0 0 12px; }
.ev-month-group + .ev-month-group { margin-top: 22px; }
.ev-month-title { margin: 0 0 10px; font-size: 12px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ev-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "date main" "date tags"; gap: 0 14px; align-items: start;
  padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.ev-row > .ev-date { grid-area: date; }
.ev-row > .ev-row-main { grid-area: main; }
.ev-row > .ev-tags { grid-area: tags; }
/* Wide screens: the tags on the right of the row, with room for Check-in beside them. */
@media (min-width: 900px) {
  .ev-row { grid-template-columns: auto minmax(0, 1fr) minmax(0, 400px); grid-template-areas: "date main tags"; align-items: center; }
  .ev-row > .ev-tags { justify-content: flex-end; margin-top: 0; }
}
/* A later date of a weekly event: the date, the title, the time and who can see it. */
/* Its date tile stays at the top by the title (centered only where the row is one line, from 900px). */
.ev-row.is-repeat { padding-top: 8px; padding-bottom: 8px; }
.ev-row.is-repeat .ev-date { min-height: 0; padding: 4px 0; }
.ev-row.is-repeat .ev-date-dow { display: none; }
.ev-row.is-repeat .ev-row-title { font-size: 15px; }
.ev-row.is-repeat .ev-row-when { color: var(--muted); }
.ev-row:hover { border-color: var(--line-strong); }
.ev-row-main { min-width: 0; }
.ev-row-title { margin: 0; font-size: 16px; }
.ev-open {
  display: inline; padding: 0; margin: 0; border: 0; background: none; color: var(--text);
  font: inherit; font-weight: 750; text-align: left; cursor: pointer; overflow-wrap: anywhere;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px;
}
.ev-open:hover { text-decoration-color: var(--accent); color: var(--accent); }
.ev-open:focus-visible { outline-offset: 3px; border-radius: 4px; }
.ev-row-when { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 4px 0 0; font-weight: 600; font-size: 14px; }
.ev-rel { padding: 0 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); font-size: 12px; font-weight: 800; line-height: 20px; }
.ev-rel.is-now { background: var(--accent); color: var(--accent-ink); }
/* On its light tint the text needs to be a little darker for 4.5:1 (as .hub-badge). */
@media (prefers-color-scheme: light) {
  .ev-rel:not(.is-now) { color: color-mix(in srgb, var(--accent) 82%, var(--text)); }
}
.ev-row-place { display: flex; align-items: flex-start; gap: 6px; margin: 3px 0 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.ev-row-place .hub-icon { flex: none; margin-top: 3px; }
.ev-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ev-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.6; white-space: nowrap;
}
.ev-tag.is-cancelled { border-color: var(--danger); color: var(--danger); }
.ev-row.is-cancelled .ev-open { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); }
/* A cancelled date: the tile fades, its words keep their contrast. */
.ev-row.is-cancelled .ev-date { background: transparent; border-color: color-mix(in srgb, var(--line) 60%, transparent); border-style: dashed; }
.ev-foot { margin: 18px 0 0; }
.ev-foot .btn.linkish { min-height: 0; padding: 0; font-size: inherit; }

/* ---------- the month ---------- */

.ev-cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin: 0 0 8px; }
.ev-cal-title { margin: 0; font-size: 21px; letter-spacing: -0.01em; }
.ev-cal-count { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.ev-cal-nav { display: flex; gap: 6px; }
.ev-cal-arrow { width: 42px; padding: 0; font-size: 22px; line-height: 1; }
.ev-cal-key { margin: 0 0 12px; font-size: 13px; }
.ev-cal-wrap { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.ev-cal-grid { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.ev-cal-grid th {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.ev-cal-grid abbr { text-decoration: none; }
.ev-cal-cell { position: relative; vertical-align: top; height: 112px; padding: 34px 6px 6px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.ev-cal-grid tbody tr:first-child .ev-cal-cell { border-top: 0; }
.ev-cal-cell:first-child { border-left: 0; }
.ev-cal-cell.is-outside { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.ev-cal-day {
  position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: flex-start;
  padding: 6px 8px; border: 0; border-radius: 0; background: transparent; color: var(--text); font: inherit; cursor: copy;
}
.ev-cal-day:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.ev-cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.ev-cal-num { display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 999px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ev-cal-cell.is-outside .ev-cal-num { color: var(--muted); font-weight: 500; }
.ev-cal-cell.is-today .ev-cal-num { background: var(--accent); color: var(--accent-ink); }
.ev-cal-entries { position: relative; z-index: 1; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; pointer-events: none; }
.ev-cal-entries li { min-width: 0; }
.ev-cal-entry {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 0 4px; width: 100%; min-height: 24px; padding: 3px 6px;
  border: 0; border-left: 3px solid var(--line-strong); border-radius: 5px;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 12px; line-height: 1.3; text-align: left; cursor: pointer;
}
/* Who can see it, in the badges' colors: Members cyan, Everyone green. */
.ev-cal-entry.vis-members { border-left-color: var(--accent); }
.ev-cal-entry.vis-everyone { border-left-color: var(--free); background: color-mix(in srgb, var(--free) 12%, var(--surface)); }
.ev-cal-entry:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.ev-cal-time { flex: none; color: var(--muted); font-weight: 650; font-variant-numeric: tabular-nums; }
/* A title shows two lines before it is cut, never just a few letters. */
.ev-cal-entry-title {
  flex: 1 1 auto; min-width: 0; font-weight: 650; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.ev-cal-vis { flex: none; margin-top: 1px; color: var(--muted); }
/* A narrower grid: the time and the icon on the first line, the title across the day under them. */
@media (max-width: 1099px) {
  .ev-cal-entry { flex-wrap: wrap; }
  .ev-cal-time { margin-right: auto; }
  .ev-cal-vis { order: 1; }
  .ev-cal-entry-title { order: 2; flex-basis: 100%; }
}
.ev-cal-entry.is-cancelled { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.ev-cal-entry.is-cancelled .ev-cal-entry-title { color: var(--muted); font-weight: 500; text-decoration: line-through; }
.ev-cal-more {
  position: relative; z-index: 1; margin-top: 3px; padding: 2px 6px; border: 0; border-radius: 5px;
  background: transparent; color: var(--accent); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.ev-cal-more:hover { background: var(--surface-2); }

/* Phones read the month as an agenda, not a grid. */
.ev-agenda { display: none; }
.ev-agenda-day { padding: 10px 12px 12px; margin-bottom: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.ev-agenda-day.is-today { border-color: var(--accent); }
.ev-agenda-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ev-agenda-date { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0; font-size: 15px; }
.ev-today-tag { padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; line-height: 18px; }
.ev-agenda-add { flex: none; }
.ev-agenda-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.ev-agenda-entry {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 8px 12px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.ev-agenda-entry:hover { border-color: var(--accent); }
.ev-agenda-text { display: grid; min-width: 0; }
.ev-agenda-title { font-weight: 650; overflow-wrap: anywhere; text-wrap: balance; }
.ev-agenda-entry.is-cancelled .ev-agenda-title { color: var(--muted); text-decoration: line-through; }
.ev-agenda-meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.ev-agenda-entry .vis-badge { flex: none; }
.ev-agenda-empty { padding: 24px 16px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); }

/* ---------- the editor ---------- */

.ev-ed .hub-field { margin-bottom: 14px; }
.ev-ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 16px; align-items: end; }
.ev-ed-allday { display: flex; align-items: center; min-height: 46px; }
.ev-ed-check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; font-weight: 650; cursor: pointer; }
.ev-ed-times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.ev-ed-when legend { margin-bottom: 6px; }
.ev-ed-when-row { display: flex; gap: 8px; min-width: 0; }
.ev-ed-part { flex: 1 1 auto; min-width: 0; }
.ev-ed-part.ev-ed-time { flex: 0 1 132px; }
.ev-ed input[type="time"] {
  width: 100%; min-height: 46px; padding: 0 10px;
  border-radius: 10px; border: 1px solid var(--field-line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
.ev-ed input[type="date"] { padding: 0 10px; }
.ev-ed input[type="time"].is-empty { color: var(--muted); }
.ev-ed input[type="time"].is-empty::-webkit-datetime-edit { opacity: 0.55; }
.ev-ed input[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.ev-ed-tz { display: flex; align-items: center; gap: 6px; margin: 6px 0 10px; font-size: 13px; }
.ev-ed-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ev-ed-count { color: var(--muted); font-size: 13px; }
.ev-ed-repeat { margin: 0 0 14px; padding: 8px 12px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.ev-ed-until { display: flex; align-items: center; gap: 10px; margin: 4px 0 2px; max-width: 320px; }
.ev-ed-until label { margin: 0; flex: none; }
.ev-ed-repeat-note { margin: 6px 0 0; }
.ev-ed-repeat-note:empty { display: none; }
/* A date of a weekly event: the choice sits at the top of the form, before the fields it applies to. */
.ev-ed-scope {
  margin: 0 0 14px; padding: 10px 12px 6px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
/* The legend sits inside the box (float), so a two-line legend on a phone does not straddle the border. */
.ev-ed-scope legend { float: left; width: 100%; display: flex; align-items: flex-start; gap: 6px; margin: 0 0 2px; padding: 0; font-weight: 650; }
.ev-ed-scope legend .hub-icon { margin-top: 3px; }
.ev-ed-scope > .ev-ed-radio { clear: both; }
.ev-ed-scope legend .hub-icon, .ev-ed-series-note .hub-icon { flex: none; color: var(--accent); }
.ev-ed-series-note { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.ev-ed-series-note .hub-icon { margin-top: 3px; }
.ev-ed-radio { display: flex; align-items: center; gap: 10px; min-height: 40px; margin: 0; font-weight: 500; cursor: pointer; }
.ev-ed-cancelled {
  display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  font-weight: 600; font-size: 14px;
}
.ev-ed-cancelled .hub-icon { flex: none; color: var(--danger); }
.ev-ed-notice { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border-left: 3px solid var(--accent); font-size: 14px; }
.ev-ed-notice p { margin: 0; }
.ev-ed-conflict { margin: 0 0 14px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.ev-ed-conflict h3 { margin: 0 0 6px; font-size: 15px; }
.ev-ed-conflict p { font-size: 14px; }
.ev-ed-conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ev-ed-record { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.ev-ed-record ul { margin: 0 0 8px; padding-left: 18px; }
/* The same label as the assignment editor's History (hub-tasks.css .tk-ed-record-title). */
.ev-ed-record-title { margin: 6px 0 6px; font-size: 12px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ev-ed-record .ev-ed-dates { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ev-ed-date {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ev-ed-date:hover { border-color: var(--accent); }
.ev-ed-date.is-here { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg)); cursor: default; }
.ev-ed-date.is-off { color: var(--muted); text-decoration: line-through; }
.ev-editor .hub-dialog-actions .ev-ed-left-last { margin-right: auto; }

/* The college calendar under the times: a quiet line when all is clear, a heads up when not. */
.ev-campus { margin: 0 0 14px; font-size: 14px; }
.ev-campus:empty { display: none; }
.ev-campus-line { display: flex; align-items: flex-start; gap: 8px; margin: 0; }
.ev-campus-line .hub-icon { flex: none; margin-top: 2px; }
.ev-campus.is-checking, .ev-campus.is-clear, .ev-campus.is-unknown { color: var(--muted); }
.ev-campus.is-clear .hub-icon { color: var(--ok); }
.ev-campus.is-clash { padding: 10px 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
.ev-campus.is-clash .ev-campus-line .hub-icon { color: var(--warn); }
.ev-campus-list { margin: 6px 0 6px; padding-left: 24px; }
.ev-campus-list li { margin: 2px 0; overflow-wrap: anywhere; }
.ev-campus-list.is-dates > li { margin: 6px 0 0; }
.ev-campus-sub { margin: 2px 0 0; padding-left: 18px; list-style: circle; }
.ev-campus-sub .ev-campus-more { list-style: none; margin-top: 2px; }
.ev-campus-more, .ev-campus-foot, .ev-campus-also { margin: 4px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.ev-campus.is-clear .ev-campus-also { margin-left: 24px; }

/* ---------- the dashboard's Coming up ---------- */

.dash-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
/* The date tile stays by the title, also on an event with an Open check-in button under it. */
.dash-event { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; }
.dash-event .ev-date { width: 50px; min-height: 54px; }
.dash-event .ev-date-day { font-size: 19px; }
/* The same title look as My assignments: plain, underlined on hover or focus. */
/* A block of its own, so its lines balance. */
.dash-event-title { display: block; width: fit-content; max-width: 100%; color: var(--text); font-weight: 650; text-decoration: none; overflow-wrap: anywhere; text-wrap: balance; }
.dash-event-title:hover, .dash-event-title:focus-visible { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.dash-event-meta { margin: 1px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.dash-event-meta .vis-badge { margin-left: 6px; vertical-align: 1px; }

/* ---------- phones ---------- */

@media (max-width: 759px) {
  /* Tap targets of at least 44 px (app.css): an event's title, its Check-in button, Open the Month view
     and the link to the site's Events page. */
  .ev-open { display: inline-block; min-height: 44px; padding: 12px 0; margin: -12px 0; }
  .hub .btn.small { min-height: 44px; }
  .ev-site-link { min-height: 44px; }
  .ev-toolbar { margin-top: 0; }
  .ev-switch { width: 100%; }
  .ev-switch button { flex: 1 1 0; min-height: 44px; }
  /* The date tile stays by the title on every row, and the tags sit 8px under the words, as at 768. */
  .ev-row { padding: 12px; gap: 0 12px; }
  .ev-cal-wrap, .ev-cal-key { display: none; }
  .ev-agenda { display: block; }
  /* .btn.ev-agenda-add: two classes, so it outranks .btn.small (app.css). */
  .ev-cal-arrow, .ev-cal-today, .btn.ev-agenda-add { min-height: 44px; }
  .ev-ed-times { grid-template-columns: minmax(0, 1fr); }
  .ev-ed-grid { grid-template-columns: minmax(0, 1fr); }
  .ev-ed-allday { min-height: 0; margin-top: -4px; }
  .ev-ed-until { max-width: none; }
  .ev-editor .hub-dialog-actions .ev-ed-left-last { margin-right: 0; }
  /* The footer: two buttons a row at every phone width (Delete and Cancel event, then Close and Save);
     a lone Cancel event takes its row. */
  .ev-editor .hub-dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ev-editor .hub-dialog-actions .btn { padding: 0 10px; }
  .ev-editor .hub-dialog-actions .ev-ed-left-last:first-child { grid-column: 1 / -1; }
}

/* The narrowest phones (320 wide): the date box gets the room it needs to show the whole date, the
   view switch fits its frame, and a day's events put who can see them under the words. */
@media (max-width: 360px) {
  .ev-ed-part.ev-ed-time { flex-basis: 104px; }
  .ev-ed input[type="date"] { padding: 0 8px; }
  .ev-switch button { padding: 0 8px; }
  .ev-agenda-entry { flex-direction: column; align-items: flex-start; gap: 6px; }
}
