/* ===========================================================
   Jungpanther Eiszeiten — Responsive Timeline Calendar (v13)
   =========================================================== */

#jungpanther-calendar-wrapper {
  max-width: 1000px;
  margin: 1.5em auto;
  font-family: 'Inter', sans-serif;
}

/* ===========================================================
   Header / Navigation Bar
   =========================================================== */

.calendar-controls {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(155deg, var(--jp-panel-2, #142346), var(--jp-panel, #101c3a));
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  color: #fff;
  border-radius: var(--jp-radius, 18px);
  padding: 10px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05);
}

/* Single slim toolbar row: [‹ Heute ›] … day label … [date/hall/team/KW] —
   no field captions, no stacked rows; each cluster keeps its own width
   (flex:0 0 auto) and only the center label shrinks/truncates if the row
   ever runs out of room. */
.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  width: 100%;
  flex-wrap: wrap;
}

.cal-todaynav,
.cal-rightgroup {
  flex: 0 0 auto;
}

.cal-datelabel-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

/* The day readout doubles as the button that opens the custom date
   popover — a plain <button> reset to look like the same text label it
   replaced, plus a small caret hinting that it's tappable. */
.cal-daylabel {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 4px 8px;
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background .2s ease;
}

.cal-daylabel:hover,
.cal-daylabel[aria-expanded="true"] {
  background: rgba(255,255,255,.06);
}

.cal-caret {
  font-size: .8rem;
  opacity: .55;
  transform: translateY(-1px);
}

/* ---- custom date popover: replaces the native <input type=date> picker,
   whose calendar popup can't be styled and always renders in the
   browser/OS light theme ---- */
.cal-date-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  max-width: calc(100vw - 24px);
  background: var(--jp-panel-2, #142346);
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  padding: 10px;
  z-index: 9999;
}

.cal-daypop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cal-daypop-title {
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  font-size: .85rem;
  letter-spacing: .03em;
  color: #fff;
}

.cal-daypop-nav {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1rem;
  background: transparent;
  border-color: transparent;
}

.cal-daypop-nav:hover {
  background: var(--jp-accent, #2f83f7);
  border-color: var(--jp-accent, #2f83f7);
}

.cal-daypop-weekdays,
.cal-daypop-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-daypop-weekdays {
  margin-bottom: 4px;
}

.cal-daypop-weekdays span {
  text-align: center;
  font-size: .65rem;
  font-weight: 600;
  color: var(--jp-muted, #93a3c4);
}

.cal-daypop-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #fff;
  font-size: .78rem;
  font-weight: 500;
  padding: 0;
  cursor: pointer;
}

.cal-daypop-cell:hover {
  background: rgba(255,255,255,.08);
}

.cal-daypop-cell.is-today {
  border-color: var(--jp-cyan, #8ec9ff);
}

.cal-daypop-cell.is-selected {
  background: var(--jp-accent, #2f83f7);
  color: #fff;
  font-weight: 700;
}

.cal-daypop-cell.empty {
  visibility: hidden;
  cursor: default;
}

/* visually hidden but still exposed to assistive tech — used for the
   Datum/Halle/Team <label>s the compact toolbar has no visual room for */
.cal-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Today-nav grouped into one pill-shaped stepper — [‹] Heute [›] reads as
   a single control rather than three loose buttons. */
.cal-todaynav {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  border-radius: 999px;
  padding: 3px;
}

.cal-today-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: .04em;
  background: transparent;
  border-color: transparent;
}

.cal-today-btn:hover {
  background: rgba(255,255,255,.08);
}

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

/* Buttons + selectors */

.calendar-controls button {
  background: var(--jp-panel-2, #142346);
  color: #fff;
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
  font-weight: 600;
  transition: background .2s ease, border-color .2s ease, transform .15s ease;
}

.cal-nav-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.15rem;
  font-family: 'Inter', sans-serif;
  background: transparent;
  border-color: transparent;
}

.cal-nav-btn:hover {
  background: var(--jp-accent, #2f83f7);
  border-color: var(--jp-accent, #2f83f7);
  transform: translateY(-1px);
}

.calendar-controls select,
.calendar-controls input {
  background: var(--jp-panel-2, #142346);
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  border-radius: 8px;
  padding: 0 12px;
  font-size: 0.85rem;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  height: 32px;
  box-sizing: border-box;
  color-scheme: dark;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.calendar-controls select {
  min-width: 108px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238ec9ff' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 11px;
  padding-right: 28px;
}

.calendar-controls select:hover,
.calendar-controls input:hover {
  border-color: rgba(142,201,255,.4);
}

.calendar-controls select:focus-visible,
.calendar-controls input:focus-visible,
.calendar-controls button:focus-visible {
  outline: none;
  border-color: var(--jp-accent, #2f83f7);
  box-shadow: 0 0 0 3px rgba(47,131,247,.35);
}

#calendar-timeline {
  margin-top: 16px;
  transition: opacity 0.3s ease;
}

/* ===========================================================
   Dual-Calendar Layout
   =========================================================== */

.calendar-dual {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: nowrap;
}

.calendar-single {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--jp-panel, #101c3a);
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  overflow: hidden;
  min-width: 0;
}

.calendar-single h3 {
  text-align: center;
  background: var(--jp-panel-2, #142346);
  color: #fff;
  margin: 0;
  padding: 10px 0;
  font-size: 1rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ===========================================================
   Timeline + Events
   =========================================================== */

.timeline-wrapper {
  position: relative;
  overflow-y: hidden;
  background: var(--jp-panel, #101c3a);
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  border-radius: 8px;
  padding-left: 44px; /* timeline gutter */
}

.timeline,
.events {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

.timeline {
  width: 44px;
  border-right: 1px solid var(--jp-line, rgba(255,255,255,.12));
  background: var(--jp-panel-2, #142346);
  font-size: 0;
}

.timeline .hour {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  border-bottom: 1px solid var(--jp-line, rgba(255,255,255,.12));
}

.timeline .hour span {
  font-size: 0.7rem;
  line-height: 1;
  color: var(--jp-muted, #93a3c4);
  padding: 2px 4px 0 0;
}

.events {
  margin-left: 44px;
}

/* Event blocks are themed in JS (calendar.js) from a curated palette rather
   than the raw colors the booking system sends, so they stay legible and
   consistent with the site's dark theme; only top/height/background/
   border-left-color/color are set inline per event. */
.events .event {
  position: absolute;
  left: 6px;
  right: 6px;
  border-radius: 5px;
  padding: 4px 6px 4px 9px;
  font-size: 0.75rem;
  line-height: 1.15;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left-width: 3px;
  border-left-style: solid;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.events .event .ev-title {
  font-weight: 600;
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.events .event .ev-time {
  font-size: 0.7rem;
  opacity: 0.9;
  margin-top: 2px;
  line-height: 1.1;
}

/* Tiny 15-min blocks have no inner HTML, so strip borders to keep them minimal */
.events .event:empty {
  border: none;
  box-shadow: none;
  padding: 0;
}

.timeline-wrapper.empty {
  height: auto;
  text-align: center;
  background: var(--jp-panel, #101c3a);
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  border-radius: 8px;
  padding: 20px;
  color: var(--jp-muted, #93a3c4);
  font-size: 0.9rem;
  font-style: italic;
}

/* ===========================================================
   Team Table View
   =========================================================== */

.hockey-schedule table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1em 0;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  background: var(--jp-panel, #101c3a);
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.hockey-schedule th {
  background: var(--jp-panel-2, #142346);
  color: #fff;
  text-transform: uppercase;
  font-weight: 600;
  padding: 10px 6px;
  text-align: center;
  vertical-align: middle;
  letter-spacing: 0.3px;
  font-size: 0.8rem;
}

.hockey-schedule td {
  padding: 8px 6px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--jp-line, rgba(255,255,255,.12));
  color: var(--jp-text, #eaf0fd);
  font-size: 0.8rem;
}

.hockey-schedule tr:nth-child(even) {
  background-color: var(--jp-panel-2, #142346);
}

.hockey-schedule tr:last-child td {
  border-bottom: none;
}

.calendar-date-meta {
  font-size: 0.8em;
  color: var(--jp-muted, #93a3c4);
  font-weight: 400;
  margin-left: 6px;
}

/* ===========================================================
   WEEK PNG (KW Bild) tool: icon toggle + popover
   =========================================================== */

.jp-tools {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

#jp-weekpng-toggle {
  background: var(--jp-panel-2, #142346) !important;
  color: #fff !important;
  border: 1px solid var(--jp-line, rgba(255,255,255,.12)) !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 8px !important;
  font-size: 0.9rem !important;
  line-height: 1 !important;
  opacity: .8;
}

#jp-weekpng-toggle:hover {
  opacity: 1;
  background: var(--jp-panel-2, #142346) !important;
  border-color: var(--jp-accent, #2f83f7) !important;
}

.jp-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--jp-panel-2, #142346);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  padding: 10px;
  min-width: 260px;
  max-width: 320px;
  z-index: 9999;
}

.jp-popover-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.jp-popover-row:first-child {
  margin-top: 0;
}

.jp-weekpng-pass {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.jp-weekpng-pass span {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

#jp-weekpng-pass {
  flex: 1 1 auto;
  min-width: 140px;
  height: auto;
}

.jp-popover-actions {
  justify-content: flex-end;
}

.jp-popover-actions #jp-weekpng-btn {
  width: auto;
  height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--jp-accent, #2f83f7);
  color: #fff;
  font-weight: 700;
}

.jp-popover-actions #jp-weekpng-btn:hover {
  background: var(--jp-cyan, #8ec9ff);
}

#jp-weekpng-download {
  background: rgba(142,201,255,.14);
  color: var(--jp-cyan, #8ec9ff);
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 800;
  font-size: 0.85rem;
}

#jp-weekpng-status {
  font-size: 0.8rem;
  color: var(--jp-muted, #93a3c4);
  font-style: italic;
}

/* Preview container */
#jp-weekpng-result {
  background: var(--jp-panel, #101c3a);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  overflow: hidden;
  border: 1px solid var(--jp-line, rgba(255,255,255,.12));
}

#jp-weekpng-img {
  display: block;
  width: 100%;
  height: auto;
}

/* ===========================================================
   Responsive
   =========================================================== */

@media (max-width: 768px) {
  #jungpanther-calendar-wrapper {
    margin: 0.5em auto;
  }

  .calendar-controls {
    padding: 6px 8px;
    gap: 4px;
  }

  /* Everything the desktop layout fits on one row doesn't physically fit
     on a phone (todaynav + label + 2 selects + the KW icon) without
     becoming unreadable, so mobile keeps two slim rows instead of one:
     [‹ Heute ›] ………… [day label] on top, [Halle][Team][KW] below — still
     far tighter than the old 3-row, captioned layout, and one whole
     control (the date field) is gone now that the day label itself opens
     the date popover. */
  .cal-toolbar {
    gap: 4px 6px;
  }

  .cal-todaynav {
    order: 1;
  }

  .cal-datelabel-wrap {
    order: 2;
    flex: 1 1 auto;
  }

  .cal-daylabel {
    justify-content: flex-end;
    padding: 4px 4px;
    font-size: 0.8rem;
  }

  .cal-date-popover {
    left: auto;
    right: 0;
    transform: none;
  }

  .cal-rightgroup {
    order: 3;
    flex: 1 1 100%;
    /* the rightgroup div is itself a flex item of .cal-toolbar — without
       min-width:0 here it refuses to shrink below its children's combined
       content size (flexbox's automatic minimum size), which pushed it
       (and the KW icon riding along with it) past the card's edge. */
    min-width: 0;
    gap: 5px;
  }

  .cal-today-btn {
    height: 26px;
    padding: 0 9px;
    font-size: 0.7rem;
  }

  .cal-nav-btn {
    width: 26px;
    height: 26px;
    font-size: 1rem;
  }

  .calendar-controls select,
  .calendar-controls input {
    min-width: 0;
    height: 28px;
    font-size: 0.72rem;
    padding: 0 8px;
  }

  .calendar-controls select {
    flex: 1 1 100px;
    min-width: 0;
    padding: 0 18px 0 8px;
    background-position: right 6px center;
    background-size: 8px;
    font-size: 0.7rem;
  }

  #calendar-timeline {
    margin-top: 10px;
  }

  .calendar-dual {
    flex-direction: column;
    gap: 16px;
  }

  .calendar-single {
    width: 100%;
  }

  .calendar-single h3 {
    padding: 8px 0;
    font-size: 0.9rem;
  }

  .timeline .hour {
    height: 42px;
  }

  .timeline .hour span {
    font-size: 0.65rem;
  }

  .events .event {
    font-size: 0.7rem;
    padding: 3px 5px 3px 8px;
  }

  .events .event .ev-title {
    font-size: 0.7rem;
  }

  .events .event .ev-time {
    font-size: 0.65rem;
  }

  .hockey-schedule table {
    font-size: 0.8rem;
  }

  .hockey-schedule th {
    font-size: 0.7rem;
    padding: 8px 4px;
  }

  .hockey-schedule td {
    font-size: 0.7rem;
    padding: 6px 4px;
  }

  .jp-popover {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 12px;
    width: auto;
    max-width: none;
    border-radius: 14px;
  }
}

@media (max-width: 480px) {
  .jp-popover {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }
}
