/**
 * Division schedule (player) — chalksta-app companion
 * body.chalksta-app.chalksta-page-divschedule
 *
 * Overrides calendarpen.css only under this page (calendar-grid is shared globally).
 * Uses --idx-* + ESPN red for a modern month grid without editing calendarpen.js.
 */

.chalksta-page-divschedule .chalksta-ts-main {
  padding-top: 1rem;
  padding-bottom: 2rem;
}

.chalksta-page-divschedule .chalksta-ts-toolbar--crossnav {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0 0 0.75rem 0;
  margin-bottom: 0.5rem;
}

/* Division title — light row, not a second “toolbar” card */
.chalksta-page-divschedule .chalksta-ds-divname {
  color: var(--idx-fg);
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.chalksta-page-divschedule #scheduletogglelabel {
  color: var(--idx-fg);
  font-size: 0.875rem;
}

/* Legacy list table (divisions with did ≤ 100) */
.chalksta-page-divschedule .chalksta-ds-legacy-wrap {
  border-radius: 8px;
  border: 1px solid var(--idx-border);
  overflow: hidden;
  background: var(--idx-surface-alt);
  margin-bottom: 1rem;
}

/* After popdivschedule removes #schedstable, collapse empty chrome */
.chalksta-page-divschedule .chalksta-ds-legacy-wrap .table-responsive:empty {
  display: none;
}

.chalksta-page-divschedule .chalksta-ds-legacy-wrap:has(.table-responsive:empty) {
  display: none;
  margin: 0;
  padding: 0;
  border: none;
}

.chalksta-page-divschedule #schedstable {
  color: var(--idx-fg);
  margin-bottom: 0;
  font-size: 0.8125rem;
}

.chalksta-page-divschedule #schedstable thead th {
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.45rem;
  background: linear-gradient(105deg, var(--espn-red) 0%, var(--espn-red-dark) 100%);
  color: #fff !important;
  border-color: rgba(0, 0, 0, 0.08);
}

.chalksta-page-divschedule #schedstable tbody td {
  border-color: var(--idx-border);
  vertical-align: middle;
}

.chalksta-page-divschedule #schedstable.table-striped tbody tr:nth-of-type(odd) {
  background-color: var(--idx-surface) !important;
}

.chalksta-page-divschedule #schedstable.table-striped tbody tr:nth-of-type(even) {
  background-color: var(--idx-surface-alt) !important;
}

.chalksta-page-divschedule #schedstable a {
  color: var(--espn-red);
  font-weight: 600;
}

.chalksta-page-divschedule #schedstable a:hover {
  color: var(--espn-red-dark);
}

/* Calendar stage (host + multi-division loading strip) */
.chalksta-page-divschedule .chalksta-ds-calendar-stage {
  max-width: min(52rem, 100%);
  margin: 0 auto;
}

.chalksta-page-divschedule .chalksta-ds-calendar-stage .chalksta-ds-calendar-host {
  width: 100%;
}

/* Panel strip — same language as .chalksta-loading-inline (see STYLES.md) */
.chalksta-page-divschedule .chalksta-ds-calendar-loading {
  padding: 0.65rem 1rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--idx-border);
  background: var(--idx-surface-alt);
}

/* --- Player calendar grid (#divschedule_id.calendar-grid) — modern month view --- */
.chalksta-page-divschedule #divschedule_id.calendar-grid,
.chalksta-page-divschedule .calendar-grid#divschedule_id {
  margin: 0 auto;
  width: 100%;
  height: auto;
  max-width: min(52rem, 100%);
  padding: 1rem 0.75rem 1.25rem;
  border: 1px solid var(--idx-border);
  border-radius: 12px;
  background: var(--idx-surface);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: auto auto;
  grid-auto-rows: minmax(4.25rem, auto);
  gap: 6px;
  border-top: none;
}

body.dark-theme.chalksta-app .chalksta-page-divschedule #divschedule_id.calendar-grid {
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.35);
}

/* Month title */
.chalksta-page-divschedule #divschedule_id .calendar-title {
  grid-column: 2 / -2;
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  font-size: clamp(1.15rem, 3.5vw, 1.35rem);
  letter-spacing: 0.04em;
  text-align: center;
  align-self: center;
  color: var(--idx-fg) !important;
  padding: 0.35rem 0;
}

/* Prev / next */
.chalksta-page-divschedule #divschedule_id .calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
}

.chalksta-page-divschedule #divschedule_id .calendar-nav a {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.15rem !important;
  line-height: 1;
  color: var(--idx-fg) !important;
  background: var(--idx-surface-alt);
  border: 1px solid var(--idx-border);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chalksta-page-divschedule #divschedule_id .calendar-nav a:hover {
  background: var(--espn-red);
  border-color: var(--espn-red-dark);
  color: #fff !important;
}

.chalksta-page-divschedule #divschedule_id .calendar-nav__right {
  text-align: center;
  color: inherit !important;
}

/* Weekday strip */
.chalksta-page-divschedule #divschedule_id .calendar-dayname {
  padding: 0.45rem 0.2rem;
  text-align: center;
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--idx-muted) !important;
  background: var(--idx-surface-alt);
  border-radius: 6px;
  border: 1px solid var(--idx-border);
}

/* Day cells */
.chalksta-page-divschedule #divschedule_id .calendar-day {
  min-height: 4.25rem;
  padding: 0.35rem 0.3rem;
  border-radius: 8px;
  border: 1px solid var(--idx-border);
  background: var(--idx-surface-alt);
  color: var(--idx-fg) !important;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

/* Day links: use fg + accent underline — full red on red-tinted / striped cells was illegible */
.chalksta-page-divschedule #divschedule_id .calendar-day a {
  color: var(--idx-fg);
  text-decoration: underline;
  text-decoration-color: var(--espn-red);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.chalksta-page-divschedule #divschedule_id .calendar-day a:hover {
  color: var(--idx-fg);
  text-decoration-color: var(--espn-red-dark);
  text-decoration-thickness: 2px;
}

body.dark-theme.chalksta-app .chalksta-page-divschedule #divschedule_id .calendar-day.schedule-day a,
body.dark-theme.chalksta-app .chalksta-page-divschedule #divschedule_id .calendar-day.chalksta-ds-day-multi a {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

/* Today */
.chalksta-page-divschedule #divschedule_id .calendar-day.current-day {
  border: 2px solid var(--espn-red);
  box-shadow: 0 0 0 1px rgba(227, 24, 55, 0.25);
  background: var(--idx-surface);
}

/* Single-division calendar: full cell ESPN-red tint (multi-division rows use inline gradients + .chalksta-ds-day-multi) */
.chalksta-page-divschedule #divschedule_id .calendar-day.schedule-day:not(.chalksta-ds-day-multi) {
  background: rgba(227, 24, 55, 0.26);
  border-color: rgba(227, 24, 55, 0.42);
}

/* Today + league night: keep “today” ring, still show schedule fill */
.chalksta-page-divschedule #divschedule_id .calendar-day.current-day.schedule-day:not(.chalksta-ds-day-multi) {
  background: rgba(227, 24, 55, 0.22);
}

body.dark-theme.chalksta-app .chalksta-page-divschedule #divschedule_id .calendar-day.schedule-day:not(.chalksta-ds-day-multi) {
  background: rgba(255, 107, 125, 0.42);
  border-color: rgba(255, 138, 154, 0.55);
}

body.dark-theme.chalksta-app .chalksta-page-divschedule #divschedule_id .calendar-day.current-day.schedule-day:not(.chalksta-ds-day-multi) {
  background: rgba(255, 107, 125, 0.36);
}

/* Has matches (existing schedule); whole cell opens modal on /divschedule */
.chalksta-page-divschedule #divschedule_id .calendar-day.schedule-day {
  border-left: 3px solid var(--espn-red);
  cursor: pointer;
}

/* Explicitly not a league night */
.chalksta-page-divschedule #divschedule_id .calendar-day.nonschedule-day {
  opacity: 0.45;
  background: var(--idx-bg);
  border-style: dashed;
}

/* W / L line under day */
.chalksta-page-divschedule #divschedule_id .calendar-day .showscore {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--idx-muted);
  line-height: 1.25;
}

@media (max-width: 575px) {
  .chalksta-page-divschedule #divschedule_id.calendar-grid {
    padding: 0.65rem 0.4rem 0.85rem;
    gap: 4px;
  }

  .chalksta-page-divschedule #divschedule_id .calendar-day {
    min-height: 3.5rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.15rem;
  }

  .chalksta-page-divschedule #divschedule_id .calendar-nav a {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1rem !important;
  }
}

/* Schedule detail modal */
.chalksta-page-divschedule #schedule_modal .modal-content {
  background: var(--idx-surface);
  border: 1px solid var(--idx-border);
  border-radius: 10px;
}

.chalksta-page-divschedule #schedule_modal .modal-header {
  border-bottom: 1px solid var(--idx-border);
}

.chalksta-page-divschedule #schedule_modal .modal-title {
  font-family: "Oswald", sans-serif;
  color: var(--idx-fg);
}

.chalksta-page-divschedule #schedule_modal #modal_sched_table {
  color: var(--idx-fg);
  font-size: 0.8125rem;
}

.chalksta-page-divschedule #schedule_modal #modal_sched_table thead th {
  background: var(--idx-surface-alt);
  color: var(--idx-fg);
  border-color: var(--idx-border);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chalksta-page-divschedule #schedule_modal #modal_sched_table td {
  border-color: var(--idx-border);
}

.chalksta-page-divschedule #sched_modal_body_message {
  color: var(--idx-muted);
  font-size: 0.875rem;
  margin-top: 0.75rem;
}

/* Multi-division calendar tools */
.chalksta-page-divschedule .chalksta-ds-calendar-tools {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--idx-border);
  background: var(--idx-surface-alt);
}

.chalksta-page-divschedule .chalksta-ds-multi-toggle-label {
  color: var(--idx-fg);
  font-size: 0.875rem;
}

/* Multi-calendar switch — match ESPN accent (chalksta-app toolbars) */
.chalksta-page-divschedule .chalksta-ds-calendar-tools .custom-control-input:focus ~ .custom-control-label::before {
  box-shadow: 0 0 0 0.2rem rgba(227, 24, 55, 0.25);
}

.chalksta-page-divschedule .chalksta-ds-calendar-tools .custom-control-input:checked ~ .custom-control-label::before {
  background-color: var(--espn-red);
  border-color: var(--espn-red-dark);
}

.chalksta-page-divschedule .chalksta-ds-calendar-tools .custom-control-input:checked:focus ~ .custom-control-label::before {
  box-shadow: 0 0 0 0.2rem rgba(227, 24, 55, 0.35);
}

/* iCal actions — primary outline tokens (not generic secondary) */
.chalksta-page-divschedule .chalksta-ds-ical-row {
  gap: 0.5rem;
}

/*
 * #chalksta-ds-ical-all-wrap uses Bootstrap .d-inline-flex; adding .d-none on the same node
 * can lose to .d-inline-flex depending on stylesheet order. Use this instead.
 */
.chalksta-page-divschedule #chalksta-ds-ical-all-wrap.chalksta-ds-ical-all-inactive {
  display: none !important;
}

.chalksta-page-divschedule .chalksta-ds-ical-saved {
  font-size: 1.05rem;
  line-height: 1;
  color: var(--espn-red);
}

.chalksta-page-divschedule .chalksta-ds-ical-saved .fa-download {
  vertical-align: -0.05em;
}

body.dark-theme.chalksta-app .chalksta-page-divschedule .chalksta-ds-ical-saved {
  color: #5ddf9a;
}

.chalksta-page-divschedule .chalksta-ds-ical-btn {
  border-color: var(--espn-red);
  color: var(--espn-red);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chalksta-page-divschedule .chalksta-ds-ical-btn:hover,
.chalksta-page-divschedule .chalksta-ds-ical-btn:focus {
  background: rgba(227, 24, 55, 0.1);
  border-color: var(--espn-red-dark);
  color: var(--espn-red-dark);
}

body.dark-theme.chalksta-app .chalksta-page-divschedule .chalksta-ds-ical-btn {
  color: #ff8a9a;
  border-color: rgba(255, 138, 154, 0.85);
}

body.dark-theme.chalksta-app .chalksta-page-divschedule .chalksta-ds-ical-btn:hover,
body.dark-theme.chalksta-app .chalksta-page-divschedule .chalksta-ds-ical-btn:focus {
  background: rgba(227, 24, 55, 0.22);
  border-color: #ffb3be;
  color: #fff;
}

.chalksta-page-divschedule .chalksta-ds-multi-legend {
  margin-top: 0.35rem;
}

.chalksta-page-divschedule .chalksta-ds-legend-list {
  padding-left: 0;
}

.chalksta-page-divschedule .chalksta-ds-legend-item {
  margin-right: 1rem;
  margin-bottom: 0.25rem;
}

.chalksta-page-divschedule .chalksta-ds-legend-swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  vertical-align: middle;
  border: 1px solid var(--idx-border);
}

.chalksta-page-divschedule #divschedule_id .calendar-day.chalksta-ds-day-multi {
  background-clip: padding-box;
}

/* Dark theme: stronger cell edge so stripes read on charcoal */
body.dark-theme.chalksta-app .chalksta-page-divschedule #divschedule_id .calendar-day.chalksta-ds-day-multi {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    0 1px 2px rgba(0, 0, 0, 0.35);
}

body.dark-theme.chalksta-app .chalksta-page-divschedule #divschedule_id .calendar-day.chalksta-ds-day-multi.schedule-day:hover {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.22),
    0 2px 6px rgba(0, 0, 0, 0.45);
}

.chalksta-page-divschedule #modal_sched_table td.chalksta-ds-multi-modal-sep {
  background: var(--idx-surface-alt);
  font-family: "Oswald", sans-serif;
  padding-top: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--idx-border);
}
