/* ==========================================================================
   STEP St. John's — Sport events calendar (page-specific styles)
   Loaded only by calendar.html. Tokens come from css/style.css.

   Layout follows the Destination St. John's calendar so visitors moving
   between the two sites recognise the controls: a search bar, List / Month /
   Day view tabs, a category sidebar, and airy event rows with a stacked date
   block on the left and a thumbnail on the right.
   ========================================================================== */

/* ---------- Search bar ---------- */
.cal-search {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding: 18px;
  margin-bottom: 20px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cal-search__field {
  flex: 1 1 220px;
  min-width: 0;
}

.cal-search__field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.cal-search__input {
  position: relative;
  display: flex;
  align-items: center;
}

.cal-search__input > i {
  position: absolute;
  left: 13px;
  font-size: 0.85rem;
  color: var(--muted);
  pointer-events: none;
}

.cal-search__input input,
.cal-search__input select {
  width: 100%;
  padding: 11px 13px 11px 36px;
  font-family: var(--font-base);
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  appearance: none;
}

.cal-search__input select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23718096' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 32px;
}

.cal-search__input input:focus,
.cal-search__input select:focus {
  outline: none;
  border-color: var(--navy-800);
  box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.12);
}

.cal-search__go {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* ---------- View switcher ---------- */
.cal-viewbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.cal-viewtabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.cal-viewtab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-family: var(--font-base);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.cal-viewtab:hover {
  color: var(--navy-800);
}

.cal-viewtab.is-active {
  color: #fff;
  background: var(--navy-800);
  box-shadow: var(--shadow-sm);
}

.cal-viewtab:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

.cal-resultcount {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.cal-resultcount strong {
  color: var(--ink);
}

/* ---------- Two-column layout: sidebar + view ---------- */
.cal-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.cal-side {
  position: sticky;
  top: calc(var(--header-h) + 16px);
}

.cal-side__head {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.cal-side__chips {
  display: grid;
  gap: 6px;
}

/* The shared .chip is a pill built for horizontal rows; in the sidebar it
   becomes a full-width list item so the labels line up. */
.cal-side__chips .chip {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
}

.cal-main {
  min-width: 0;
}

.cal-view[hidden] {
  display: none !important;
}

/* ---------- Event rows (List + Day views) ---------- */
.cal-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cal-grouphead {
  margin: 0;
  padding: 22px 0 10px;
  font-family: var(--font-head);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red-700);
}

.cal-grouphead:first-child {
  padding-top: 0;
}

/* "Recently held" divider. An event that already happened must not silently
   vanish from the list — a visitor told the calendar has it would conclude the
   page is broken — so past events stay, in their own labelled, muted group. */
.cal-grouphead--past {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-top: 18px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.cal-grouphead--past em {
  font-family: var(--font-base);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  opacity: 0.8;
}

/* Muted so a skimming eye reads these as archive, not as upcoming fixtures. */
.cal-row--past .cal-row__date {
  background: var(--muted);
}

.cal-row--past .cal-row__title {
  color: var(--muted);
}

.cal-tag--past {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.cal-row--past .cal-thumb {
  opacity: 0.55;
}

.cal-row {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) 132px;
  gap: 20px;
  align-items: start;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.cal-row:last-child {
  border-bottom: 0;
}

/* Stacked date block: weekday above, big day number, month below. */
.cal-row__date {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  background: var(--navy-800);
  color: #fff;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.cal-row__dow {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.8;
}

.cal-row__day {
  font-family: var(--font-head);
  font-size: 1.55rem;
  font-weight: 800;
  margin: 3px 0;
}

.cal-row__mon {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  opacity: 0.8;
}

.cal-row__body {
  min-width: 0;
}

.cal-row__when {
  margin: 0 0 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.cal-row__when i {
  margin-right: 3px;
}

.cal-row__title {
  margin: 0 0 7px;
  font-family: var(--font-head);
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.cal-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 0 0 8px;
  font-size: 0.84rem;
  color: var(--muted);
}

.cal-row__where {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Sport tag — colour-coded by series so a row is scannable at a glance. */
.cal-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 999px;
  color: #fff;
  background: var(--navy-600);
}

.cal-tag--hockey     { background: var(--red-700); }
.cal-tag--curling    { background: #475569; }
.cal-tag--soccer     { background: #0f766e; }
.cal-tag--water      { background: var(--navy-800); }
.cal-tag--running    { background: var(--orange); }
.cal-tag--skating    { background: #6b46c1; }
.cal-tag--golf       { background: #a16207; }
.cal-tag--wrestling  { background: #9d174d; }
.cal-tag--motorsport { background: var(--navy-600); }
.cal-tag--outdoor    { background: #1d4ed8; }
.cal-tag--multi      { background: var(--ok, #2f855a); }

.cal-row__desc {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--body);
}

/* Why this date is the date — shown only for rule-based events, so a visitor
   seeing "Sun, July 25, 2027" also learns it is always the fourth Sunday. */
.cal-row__recurs {
  margin: 7px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.cal-row__recurs i {
  margin-right: 4px;
  color: var(--navy-600);
}

.cal-row__status {
  margin: 8px 0 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--red-700);
}

.cal-row__link {
  margin: 9px 0 0;
  font-size: 0.86rem;
}

.cal-row__link a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--red-700);
  text-decoration: none;
}

.cal-row__link a:hover,
.cal-row__link a:focus-visible {
  text-decoration: underline;
}

.cal-row__link i {
  font-size: 0.72em;
}

/* ---------- Thumbnail ---------- */
.cal-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.cal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* No photo yet: a branded panel with the sport icon, never a grey hole.
   Most events are in this state by design — see images/events/README.txt. */
.cal-thumb--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2rem;
  background: linear-gradient(135deg, var(--navy-800), var(--navy-600));
}

.cal-thumb--hockey     { background: linear-gradient(135deg, #8b1a1a, #ac162e); }
.cal-thumb--curling    { background: linear-gradient(135deg, #334155, #475569); }
.cal-thumb--soccer     { background: linear-gradient(135deg, #0b5d56, #0f766e); }
.cal-thumb--water      { background: linear-gradient(135deg, #1a365d, #2c5282); }
.cal-thumb--running    { background: linear-gradient(135deg, #c05621, #f97316); }
/* Figure skating reads as its own sport, not "multi-sport", so it gets a
   distinct violet rather than borrowing the generic green. */
.cal-thumb--skating    { background: linear-gradient(135deg, #44337a, #6b46c1); }
.cal-thumb--golf       { background: linear-gradient(135deg, #78350f, #a16207); }
.cal-thumb--wrestling  { background: linear-gradient(135deg, #831843, #9d174d); }
.cal-thumb--motorsport { background: linear-gradient(135deg, #223248, #4a5568); }
.cal-thumb--outdoor    { background: linear-gradient(135deg, #1e3a8a, #1d4ed8); }
.cal-thumb--multi      { background: linear-gradient(135deg, #276749, #2f855a); }

/* ---------- Month view ---------- */
.cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.cal-monthnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-monthlabel {
  margin: 0;
  min-width: 190px;
  text-align: center;
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.cal-monthlabel--day {
  min-width: 260px;
}

.cal-navbtn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy-800);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.cal-navbtn:hover:not(:disabled) {
  background: var(--navy-800);
  border-color: var(--navy-800);
  color: #fff;
}

.cal-navbtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cal-todaybtn {
  width: auto;
  padding: 0 14px;
  font-size: 0.86rem;
  font-weight: 600;
  font-family: var(--font-base);
}

.cal-wrap {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.cal-dow {
  background: var(--bg);
  padding: 10px 6px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.cal-dow abbr {
  text-decoration: none;
}

.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 78px;
  padding: 8px;
  background: var(--white);
  border: 0;
  font: inherit;
  text-align: left;
  color: var(--body);
}

.cal-cell--pad {
  background: var(--bg);
}

.cal-daynum {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.cal-cell--today {
  background: var(--red-050);
  box-shadow: inset 0 0 0 2px var(--red-700);
}

.cal-cell--today .cal-daynum {
  color: var(--red-700);
  font-weight: 800;
}

/* A day with events is a real button and must look interactive. */
button.cal-cell {
  cursor: pointer;
  transition: background 0.15s;
}

button.cal-cell:hover {
  background: var(--red-050);
}

button.cal-cell:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: -3px;
  z-index: 1;
}

.cal-daymarks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
}

.cal-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: block;
}

/* Series colours — kept few and brand-adjacent so a legend stays readable.
   Each key here must also exist as a .cal-tag-- and .cal-thumb-- variant
   above, or a new category renders with an uncoloured chip/panel. */
.cal-dot--hockey     { background: var(--red-700); }
.cal-dot--curling    { background: #475569; }
.cal-dot--soccer     { background: #0f766e; }
.cal-dot--water      { background: var(--navy-800); }
.cal-dot--running    { background: var(--orange); }
.cal-dot--skating    { background: #6b46c1; }
.cal-dot--golf       { background: #a16207; }
.cal-dot--wrestling  { background: #9d174d; }
.cal-dot--motorsport { background: var(--navy-600); }
.cal-dot--outdoor    { background: #1d4ed8; }
.cal-dot--multi      { background: var(--ok, #2f855a); }

/* ---------- Legend ---------- */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 16px;
  font-size: 0.84rem;
  color: var(--muted);
}

.cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* ---------- Date to be confirmed ---------- */
.cal-tbc-panel {
  margin-top: 40px;
  padding: 24px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cal-tbc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.cal-tbc__item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.9rem;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.cal-tbc__item > i {
  color: var(--navy-800);
  margin-top: 3px;
}

/* A TBC event never reaches the dated list, so this panel is the only place
   its photo can appear in the calendar. Small square so the stacked TBC grid
   keeps its compact two-column rhythm — do NOT enlarge it to a card-sized
   image, that would break the panel's alignment against the List rows. */
.cal-tbc__thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--bg);
}

.cal-tbc__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cal-tbc__item strong {
  color: var(--ink);
}

.cal-tbc__meta {
  color: var(--muted);
  font-size: 0.84rem;
}

/* An event awaiting a date can still have a page worth visiting — Street Jam
   announces its dates there first. Only rendered when a real page exists. */
.cal-tbc__link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--red-700);
  text-decoration: none;
}

.cal-tbc__link:hover,
.cal-tbc__link:focus-visible {
  text-decoration: underline;
}

.cal-tbc__link i {
  font-size: 0.72em;
}

.cal-tbc__item--empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-style: italic;
}

/* A two-column grid with an ODD number of items leaves a hole in the last
   row, which reads as a rendering bug rather than a design. Let a trailing
   odd item span the full width instead. This is a no-op when the count is
   even, so it stays correct as events are added and removed. */
.cal-tbc__item:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* ---------- Outbound: community calendar ---------- */
/* Deliberate hand-off, not a gap in the page: this calendar is sport-only, so
   non-sport events must be pointed at rather than silently absent. */
.cal-community {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 22px;
  margin-top: 26px;
  padding: 22px 24px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy-800);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.cal-community__icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--navy-800);
  color: #fff;
  font-size: 1.15rem;
}

.cal-community__body {
  flex: 1 1 320px;
  min-width: 0;
}

.cal-community__body h2 {
  margin: 0 0 5px;
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.cal-community__body p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--body);
}

.cal-community__go {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .cal-community {
    padding: 18px;
  }

  .cal-community__go {
    width: 100%;
    justify-content: center;
  }
}

/* ---------- Send us an event ---------- */
/* The counterpart to the community hand-off above: that one says "not here,
   try elsewhere", this one says "this belongs here, tell us". Uses the brand
   red rather than navy so the two blocks read as a pair, not a repeat. */
.cal-submit {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 18px 22px;
  margin-top: 14px;
  padding: 24px;
  background: var(--red-050);
  border: 1px solid #f5d9de;
  border-left: 4px solid var(--red-700);
  border-radius: var(--radius);
}

.cal-submit__icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--red-700);
  color: #fff;
  font-size: 1.15rem;
}

.cal-submit__body {
  flex: 1 1 340px;
  min-width: 0;
}

.cal-submit__body h2 {
  margin: 0 0 6px;
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.cal-submit__body p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--body);
}

/* "What to include" list — a visitor writing a cold email rarely knows what
   an events team needs, so the page asks for it up front. */
.cal-submit__tips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.84rem;
  color: var(--body);
}

.cal-submit__tips li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cal-submit__tips i {
  font-size: 0.72em;
  color: var(--ok);
}

.cal-submit__actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 260px;
}

.cal-submit__go {
  white-space: nowrap;
}

.cal-submit__note {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 640px) {
  .cal-submit {
    padding: 18px;
  }

  .cal-submit__actions {
    flex: 1 1 100%;
    max-width: none;
    align-items: stretch;
  }

  .cal-submit__go {
    width: 100%;
    justify-content: center;
    white-space: normal;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .cal-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  /* Sidebar stops being a column and becomes a scrolling row of chips. */
  .cal-side {
    position: static;
  }

  .cal-side__chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .cal-side__chips .chip {
    width: auto;
    flex: 0 0 auto;
  }

  .cal-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .cal-tbc__list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .cal-search {
    padding: 14px;
  }

  .cal-search__go {
    width: 100%;
    justify-content: center;
  }

  .cal-viewbar {
    gap: 10px;
  }

  .cal-viewtab {
    padding: 7px 12px;
    font-size: 0.82rem;
  }

  /* Date block left, body right, thumbnail kept but small — it still tells a
     visitor at a glance whether a photo exists for the event. */
  .cal-row {
    grid-template-columns: 54px minmax(0, 1fr) 64px;
    gap: 12px;
    padding: 18px 0;
  }

  .cal-row__date {
    padding: 8px 2px;
  }

  .cal-row__day {
    font-size: 1.3rem;
  }

  .cal-row__title {
    font-size: 1rem;
  }

  .cal-thumb--fallback {
    font-size: 1.3rem;
  }

  .cal-dow {
    font-size: 0.6rem;
    padding: 8px 2px;
  }

  .cal-cell {
    min-height: 58px;
    padding: 6px 4px;
  }

  .cal-daynum {
    font-size: 0.76rem;
  }

  .cal-dot {
    width: 7px;
    height: 7px;
  }

  /* Sticky header would otherwise cover the month label on jump-to-day. */
  .cal-monthlabel,
  .cal-monthlabel--day {
    min-width: 0;
    flex: 1;
    font-size: 0.95rem;
  }

  .cal-tbc-panel {
    padding: 18px;
  }
}
