/* Calendar — public week view. Scoped to .cal-* selectors. */

.cal {
  margin-top: 4px;
  font-size: 0.88rem;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.cal-nav-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--fg);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.4;
}
.cal-nav-btn:hover { background: var(--bg); }
.cal-nav-btn:active { background: var(--line); }

.cal-range {
  margin-left: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cal-tz-note {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: normal;
}

.cal-scroll {
  max-height: 480px;
  overflow-y: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

/* Sticky header inside the scroll container — guarantees its columns stay
   aligned with the body's day columns regardless of scrollbar presence. */
.cal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 48px repeat(7, 1fr);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.cal-gutter {
  /* spacer above time column */
}

.cal-day-header {
  text-align: center;
  padding: 6px 0;
  border-left: 1px solid var(--line);
}
.cal-day-header.cal-today {
  background: #fffbe6;
}

.cal-day-name {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.cal-day-date {
  margin-top: 2px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.cal-grid {
  display: grid;
  grid-template-columns: 48px repeat(7, 1fr);
  position: relative;
  background: #fff;
  /* Height set inline by JS = HOURS * HOUR_PX. Parent .cal-scroll provides
     the bounded viewport + vertical scroll. */
}

.cal-times {
  position: relative;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.cal-hour-label {
  position: absolute;
  right: 6px;
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transform: translateY(-50%);
}

.cal-day {
  position: relative;
  border-left: 1px solid var(--line);
}
.cal-day:first-of-type { border-left: 0; }

/* Horizontal hour gridlines as a background gradient — no per-hour DOM nodes */
.cal-day {
  background-image: linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--cal-hour-px) - 1px),
    var(--line) var(--cal-hour-px)
  );
  background-size: 100% var(--cal-hour-px);
}

.cal-day.cal-today {
  background-color: #fffbe6;
}

.cal-event {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 3px;
  padding: 3px 5px;
  font-size: 0.72rem;
  line-height: 1.25;
  overflow: hidden;
  box-sizing: border-box;
  cursor: default;
}

/* Visitor view — only colored block, no text inside */
.cal-event-blocked {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
}

/* Admin view — full details */
.cal-event-detailed {
  background: #dbeafe;
  border: 1px solid #93c5fd;
  color: var(--fg);
}
.cal-event-detailed .cal-event-time {
  font-size: 0.66rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cal-event-detailed .cal-event-title {
  font-weight: 600;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event-detailed .cal-event-desc {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Current-time indicator: red horizontal line across today's column */
.cal-now {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #dc2626;
  z-index: 2;
  pointer-events: none;
}
.cal-now::before {
  content: "";
  position: absolute;
  left: -3px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
}

.cal-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 720px) {
  .cal-header, .cal-grid {
    grid-template-columns: 36px repeat(7, 1fr);
  }
  .cal-hour-label { font-size: 0.62rem; right: 4px; }
  .cal-event { font-size: 0.66rem; padding: 2px 3px; }
  .cal-day-date { font-size: 0.8rem; }
}
