/* Tävlingar (webapp/js/calendar/): loaded by that page only. */

.cal-badge {
  display: inline-flex; align-items: center; min-height: 26px; padding: 2px 10px; border-radius: 13px;
  font-size: 14px; font-weight: 700; line-height: 1.2;
}
.cal-badge--ok { background: #DCFCE7; color: var(--ok); }
.cal-badge--outside { background: #DBEAFE; color: #1E3A8A; }
.cal-badge--check { background: #FFEDD5; color: #9A3412; }
.cal-badge--likely { background: #FEF3C7; color: #92400E; }
.cal-badge--members { background: var(--chip-bg); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.cal-badge--invited { box-shadow: inset 0 0 0 2px currentColor; background: transparent; }

.cal-card { align-items: center; }
.cal-date {
  flex: none; width: 64px; font-family: var(--font-cond); font-weight: 700; font-size: 18px; line-height: 1.1;
  color: var(--accent); text-align: center;
}
.cal-status { font-size: 14px; }
/* signed out: "Logga in för att spara dina val ..." (small, under the intro) */
.cal-signin { margin: -8px 0 0; font-size: 14px; }
/* SSF's attribution, always at the bottom (small, muted) */
.cal-source { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12px; line-height: 1.45; }
.cal-source p { margin: 0 0 6px; }
.cal-source p:last-child { margin-bottom: 0; }
.cal-source__title { font-weight: 600; color: var(--ink-2); }
.cal-source a { color: inherit; }

.cal-seg { display: inline-flex; align-self: flex-start; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; }
.cal-seg__btn { min-height: var(--tap); padding: 0 18px; border: 0; background: transparent; font-weight: 600; font-size: 16px; }
.cal-seg__btn--on { background: var(--ink); color: #fff; }

/* (isolation: Leaflet's own z-indexes stay inside the map, under sheets) */
.cal-map {
  position: relative; z-index: 0; isolation: isolate;
  height: 40vh; height: 40dvh; min-height: 240px; max-height: 480px;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #DCE7F0;
}
.cal-mappanel { min-height: 60px; }
.cal-maphead { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 12px; }
.cal-maphead .section-title { margin: 0; }
.cal-card--hl { box-shadow: 0 0 0 3px var(--accent); }
/* The other competitions while a map place is picked: greyed, still tappable. */
.cal-card--dim { opacity: .45; filter: grayscale(1); }
.cal-maphint { font-size: 14px; }

.cal-part { gap: 8px; }
.cal-part--off { opacity: .55; }
.cal-reason, .cal-info, .cal-entry, .cal-deadline, .cal-note { margin: 0; font-size: 15px; }
.cal-info { color: var(--ink-2); }
.cal-entry { font-weight: 600; }
.cal-deadline { font-weight: 700; color: var(--ink); }
.cal-note { white-space: pre-line; color: var(--ink-2); padding: 8px 10px; background: var(--ground); border-radius: 8px; overflow-wrap: anywhere; }
.cal-comps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.cal-comp { display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.cal-comp__head { font-weight: 600; }
.cal-classes { color: var(--ink-2); font-size: 14px; }
.cal-classes--mine { color: var(--ok); font-weight: 700; font-size: 15px; }
.cal-links { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 15px; font-weight: 600; }
.cal-links a { min-height: 32px; display: inline-flex; align-items: center; }

.cal-clubbtn { text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-clublist { max-height: none; }
.cal-clubhelp { margin: 8px 0; font-size: 14px; }
.cal-clubrow { width: 100%; border: 0; border-bottom: 1px solid var(--line-soft); background: var(--surface); text-align: left; font: inherit; cursor: pointer; }
.cal-clubrow--on { background: #FFF1E8; font-weight: 700; }
.cal-clubhead { padding: 10px 16px 4px; font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-2); background: var(--ground); }
.cal-clubnote { margin: 0; padding: 10px 16px; font-size: 14px; }
/* the club's district, small under the club button */
.cal-clubdist { font-size: 13px; }
/* the picker's district dropdown, between the search and the clubs */
.cal-clubdistsel { margin: 8px 0; }

/* several classes: one compact row per class (card, part) */
.cal-badge--none { background: var(--chip-bg); color: var(--ink-2); font-weight: 600; }
.cal-badge--no { background: transparent; color: var(--ink-3); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.cal-clsrows { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.cal-clsrow { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; }
.cal-clsrow .cal-badge { min-height: 24px; font-size: 13px; padding: 2px 9px; }
.cal-cls { flex: none; min-width: 34px; font-family: var(--font-cond); font-weight: 700; font-size: 16px; color: var(--ink); }
.cal-clssec { gap: 6px; }

/* no club (so no district): the hint under the club; several classes: all / at least one */
.cal-hint { margin: 0; padding: 8px 12px; border-radius: var(--radius-s); background: var(--ghost-bg); color: var(--ink); font-size: 15px; }
/* (two equal halves that always fit side by side; a long label wraps inside its half) */
.cal-mode { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.cal-mode[hidden] { display: none; }
.cal-mode__seg { display: flex; align-self: stretch; max-width: 360px; }
.cal-mode .cal-seg__btn { flex: 1 1 0; min-width: 0; min-height: 40px; padding: 4px 10px; font-size: 15px; line-height: 1.2; }
.cal-mode__hint { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.4; }

/* link-like buttons ("Återställ alla filter", the map list's) */
.cal-advlink {
  align-self: flex-start; min-height: 36px; padding: 0; border: 0; background: none;
  color: var(--link); font-size: 16px; font-weight: 600; cursor: pointer;
}

/* time window */
.cal-seg--wrap { flex-wrap: wrap; }
.cal-seg--wrap .cal-seg__btn { padding: 0 12px; font-size: 15px; }
.cal-win__row { display: flex; align-items: center; gap: 8px; }
.cal-win__step { font-size: 14px; }
.cal-win__track { position: relative; flex: 1; min-width: 0; padding-bottom: 8px; }
.cal-win__range { display: block; }
.cal-win__ticks { position: absolute; left: 8px; right: 8px; bottom: 0; height: 6px; pointer-events: none; }
.cal-win__tick { position: absolute; top: 0; width: 2px; height: 6px; margin-left: -1px; border-radius: 1px; background: var(--accent); opacity: .7; }
.cal-win__label { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }

/* map legend */
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--ink-2); }
.cal-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend__dot { width: 12px; height: 12px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-2); }
.cal-legend__dot--approx { opacity: .55; }

/* Old results stay (dimmed) while new ones load, so the page doesn't jump. */
.cal-busy { opacity: .5; pointer-events: none; transition: opacity .15s; }
/* "Visa alla tävlingar": the filters greyed out (kept as saved), the banner over the results */
.cal-off { opacity: .45; }
.cal-off button, button.cal-off { cursor: default; }
.cal-allbanner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 10px 12px; border-radius: var(--radius-s); background: #FFEDD5; color: var(--ink);
  border-left: 4px solid var(--accent);
}
.cal-allbanner[hidden] { display: none; }
.cal-allbanner p { margin: 0; flex: 1 1 200px; font-size: 15px; font-weight: 600; }

/* "Visa om inbjuden" + its (i) (same height as the chip: no jump) */
.cal-help { margin: 0 0 8px; font-size: 16px; line-height: 1.45; }

/* a part's entry: button + deadline / where; several parts of one weekend */
.cal-signup { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.cal-signup__meta { margin: 0; font-size: 14px; color: var(--ink-2); }
.cal-due { font-weight: 700; color: var(--ink); }
.cal-partsnote { margin: -4px 0 0; font-size: 14px; }

/* a card's disciplines and series under its title ("SL · GS · MVC") */
.cal-kinds { font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--ink-2); letter-spacing: 0.02em; }

/* tags next to a name: a training (event or part), an event abroad */
.cal-tags { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.cal-tag {
  display: inline-flex; align-items: center; min-height: 22px; padding: 1px 8px; border-radius: 11px;
  font-size: 13px; font-weight: 700; line-height: 1.2; vertical-align: middle;
}
.cal-tag--training { background: #EDE9FE; color: #5B21B6; }
.cal-tag--abroad { background: var(--chip-bg); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-2); }

/* past races (Sparade), muted */
.cal-card--past, .cal-part--past { opacity: .6; }
.cal-card--past .cal-date { color: var(--ink-2); }
.cal-tag--past { background: var(--chip-bg); color: var(--ink-2); }

/* TA "Inställt": a cancelled event (card) or part, muted, title and date struck through */
.cal-card--cancelled, .cal-part--cancelled { opacity: .65; }
.cal-card--cancelled .card__title, .cal-card--cancelled .cal-date,
.cal-part--cancelled .panel__title, .cal-part--cancelled .cal-when { text-decoration: line-through; color: var(--ink-2); }
.cal-tag--cancelled { background: #FEE2E2; color: #991B1B; text-decoration: none; }

/* "Ny": an event first seen in TA within the last 14 days (first_seen) */
.cal-tag--new { background: #DCFCE7; color: #166534; }
.cal-changes { font-size: 14px; color: var(--ink-2); }
.cal-changes summary { cursor: pointer; }
.cal-changes ul { margin: 6px 0 0; padding-left: 18px; }

/* Disciplin (under the classes): a discipline this season lacks stays in
   the row (no jump), dimmed; still tappable. */
.cal-chip--none:not(.chip--on) { opacity: .5; }

/* Disciplin, Kön, Typ: collapsible rows (closed at page load), lines between
   them; the summary muted ("Alla") or dark and bold (something chosen). */
.cal-folds { border-top: 1px solid var(--line-soft); }
.cal-fold { border-bottom: 1px solid var(--line-soft); }
.cal-fold[hidden] { display: none; }
.cal-fold__head {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: var(--tap); padding: 10px 0;
  border: 0; background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer;
}
.cal-fold__name { flex: none; font-weight: 600; }
.cal-fold__sum { flex: 1 1 auto; min-width: 0; text-align: right; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chiprow { display: flex; flex-wrap: wrap; gap: 8px; }
.cal-chiprow > .chips { display: contents; }
.cal-fold__body > .input { width: 100%; }
.cal-qwrap > .input { width: 100%; }
/* Sök's live box under the field (focus + a query): the count, then up to 5
   rows (name left, date right, muted) and "…och N till". */
.cal-qbox { margin-top: 8px; }
.cal-qbox[hidden] { display: none; }
.cal-qbox__count { margin: 0; padding: 8px 16px; font-size: 14px; color: var(--ink-2); border-bottom: 1px solid var(--line-soft); }
.cal-qrow { width: 100%; min-height: 44px; border: 0; border-bottom: 1px solid var(--line-soft); background: var(--surface); text-align: left; font: inherit; cursor: pointer; gap: 12px; padding-right: 16px; }
.cal-qrow__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-qrow__date { flex: none; font-size: 15px; color: var(--ink-2); }
.cal-qrow--more { color: var(--ink-2); }
.cal-fold__chev { flex: none; width: 14px; color: var(--ink-2); }
.cal-fold__body { padding: 0 0 12px; }

/* Under the club field: whose club it is. */
.cal-who { margin-top: -10px; font-size: 13px; }

/* Sparade: tabs at the top; a star at the right of each card (accent, not
   green: green is "Får åka"); a removed saved event grey; "Datumet ändrat" ... */
.cal-tabs { align-self: stretch; }
.cal-tabs .cal-seg__btn { flex: 1 1 0; padding: 0 10px; }
.cal-cardwrap { position: relative; border-radius: var(--radius); }
.cal-cardwrap > .cal-card { padding-right: 52px; }
.cal-star {
  position: absolute; top: 4px; right: 4px; width: var(--tap); height: var(--tap);
  display: flex; align-items: center; justify-content: center;
  border: 0; background: transparent; font-size: 26px; line-height: 1; color: var(--ink-2); cursor: pointer;
}
.cal-star--on { color: var(--accent); }
/* (in the detail sheet's header, before the close button) */
.cal-star--head { position: static; font-size: 30px; }
.cal-card--removed { opacity: .6; filter: grayscale(1); }
.cal-tag--removed { background: var(--chip-bg); color: var(--ink-2); }
.cal-tag--changed { background: #FFEDD5; color: #9A3412; }

/* Desktop. cal-side (title, tabs, filters, "Om kalendern") and cal-main
   (banner, Lista / Karta, time window, status, list / map) vanish on a phone
   (display: contents): one column, the footer last, as before. From 900 px
   the filters are a sidebar scrolling on its own; from 1200 px
   filters | map | list, each column scrolling on its own (index.js: always
   the map there, the list beside it is the map's). */
.cal-side, .cal-main { display: contents; }
.cal-side > .cal-source { order: 1; }
@media (min-width: 900px) {
  .cal-page { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 0; height: 100%; min-height: 0; padding: 0; }
  .cal-side, .cal-main {
    display: flex; flex-direction: column; gap: 16px; min-height: 0;
    overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  }
  .cal-side { padding: 20px 20px 16px; background: var(--surface); border-right: 1px solid var(--line); }
  .cal-side > .cal-source { order: 0; margin-top: auto; }
  .cal-side .page-title { font-size: 34px; }
  .cal-main { padding: 20px 24px 24px; }
  .cal-side > *, .cal-main > * { flex: none; }   /* (no squeezing: the column scrolls) */
}
@media (min-width: 1200px) {
  .cal-page { grid-template-columns: 330px minmax(0, 1fr); }
  .cal-main { overflow: hidden; padding-bottom: 16px; gap: 12px; }
  .cal-viewbox { display: none; }
  .cal-main > .cal-body {
    flex: 1 1 auto; min-height: 0; display: grid; gap: 10px 20px;
    grid-template-columns: minmax(0, 1fr) clamp(360px, 30vw, 440px); grid-template-rows: minmax(0, 1fr) auto auto;
  }
  .cal-body > * { grid-column: 1 / -1; align-self: start; }
  .cal-body > .cal-map { grid-column: 1; grid-row: 1; align-self: stretch; height: auto; min-height: 0; max-height: none; }
  .cal-body > .cal-legend, .cal-body > .cal-maphint { grid-column: 1; }
  .cal-body > .cal-maphint:empty { display: none; }
  .cal-body > .cal-mappanel {
    grid-column: 2; grid-row: 1 / -1; align-self: stretch; min-height: 0;
    overflow-y: auto; overscroll-behavior: contain; padding: 3px 6px 12px 3px;   /* (room for the highlight ring) */
  }
}

/* the title with its (i): what the calendar is */
.cal-head { display: flex; align-items: center; gap: 4px; }
.cal-infobtn { color: var(--ink-2); }
.cal-infobtn svg { width: 22px; height: 22px; }
