/* ── DailyCalendar — reusable calendar widget ────────────────────────────────
 *
 * Theme variables: override in the host game's CSS to change colors.
 *
 *   :root {
 *     --cal-primary:        #4a90e2;
 *     --cal-primary-dark:   #357abd;
 *     --cal-primary-darker: #2a6099;
 *     --cal-green:          #4caf50;
 *     --cal-yellow:         #ffc107;
 *     --cal-red:            #f44336;
 *   }
 * ─────────────────────────────────────────────────────────────────────────── */

:root {
  --cal-primary:        #4a90e2;
  --cal-primary-dark:   #357abd;
  --cal-primary-darker: #2a6099;
  --cal-green:          #4caf50;
  --cal-yellow:         #ffc107;
  --cal-red:            #f44336;
}

/* ── Date display strip (contains arrows + date-picker-container) ──────── */

.date-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
  font-size: 1.1em;
}

.arrow {
  cursor: pointer;
  user-select: none;
}

.arrow.disabled {
  cursor: not-allowed;
  opacity: 0.4;
  color: #999;
}

.date-picker-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 10px;
}

.date-selector {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  transition: background-color 0.2s;
  border: 1px solid transparent;
}

.date-selector:hover {
  background-color: rgba(0, 0, 0, 0.05);
  border: 1px solid #e0e0e0;
}

#current-date {
  min-width: 150px;
  text-align: center;
  position: relative;
  z-index: 1;
  color: #333;
}

.date-selector:hover #current-date {
  color: var(--cal-primary);
}

/* ── Calendar toggle button (📅) ──────────────────────────────────────── */

.calendar-button {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--cal-primary);
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

/* ── Dropdown container ───────────────────────────────────────────────── */

.custom-calendar {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 230px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  padding: 8px;
  margin-top: 8px;
  border: 1px solid #e0e0e0;
}

.custom-calendar.show {
  display: block;
  animation: cal-fadeIn 0.2s ease-out;
}

@keyframes cal-fadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ── Header row (◀ Month Year ▶) ──────────────────────────────────────── */

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
}

#month-year {
  font-weight: bold;
  color: #333;
  font-size: 1rem;
}

.month-nav {
  background: none;
  border: none;
  color: var(--cal-primary);
  cursor: pointer;
  font-size: 0.9rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.month-nav:hover {
  background-color: rgba(74, 144, 226, 0.1);
}

.month-nav:disabled {
  color: #ccc;
  cursor: default;
  opacity: 0.3;
  pointer-events: none;
}

/* ── Today button ─────────────────────────────────────────────────────── */

.today-button {
  display: block;
  margin: 4px auto 6px;
  padding: 3px 14px;
  background: var(--cal-primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.today-button:hover   { background: var(--cal-primary-dark); }
.today-button:active  { background: var(--cal-primary-darker); }

/* ── Weekday labels (Su Mo … Sa) ──────────────────────────────────────── */

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
  width: 100%;
}

.weekdays div {
  text-align: center;
  font-size: 0.7rem;
  color: #666;
  font-weight: 600;
  width: 30px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Day grid ─────────────────────────────────────────────────────────── */

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  width: 100%;
}

.calendar-day {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 0.9em;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-radius: 50%;
}

/* Hover (unplayed, unselected days) */
.calendar-day:hover:not(.empty):not(.selected):not(.played-green):not(.played-yellow):not(.played-red) {
  background-color: rgba(74, 144, 226, 0.1);
}

/* ── Score color fills ────────────────────────────────────────────────── */

.calendar-day.played-green {
  background-color: var(--cal-green) !important;
  color: white;
  font-weight: bold;
}

.calendar-day.played-yellow {
  background-color: var(--cal-yellow) !important;
  color: #333 !important;
  font-weight: bold;
}

.calendar-day.played-red {
  background-color: var(--cal-red) !important;
  color: white;
  font-weight: bold;
}

/* Subtle hover for played dates */
.calendar-day.played-green:hover:not(.selected),
.calendar-day.played-yellow:hover:not(.selected),
.calendar-day.played-red:hover:not(.selected) {
  opacity: 0.9;
  cursor: pointer;
}

/* ── Special day states ───────────────────────────────────────────────── */

.calendar-day.today {
  border: 2px solid var(--cal-primary);
  font-weight: bold;
  box-sizing: border-box;
}

/* Today + played: use dark border so score color shows */
.calendar-day.today.played-green,
.calendar-day.today.played-yellow,
.calendar-day.today.played-red {
  border: 2px solid #333;
}

.calendar-day.selected {
  background-color: var(--cal-primary);
  color: white;
  font-weight: bold;
  border-radius: 50%;
}

/* Selected + played: thick primary border instead of overwriting score color */
.calendar-day.selected.played-green,
.calendar-day.selected.played-yellow,
.calendar-day.selected.played-red {
  border: 3px solid var(--cal-primary);
  box-sizing: border-box;
}

.calendar-day.empty {
  cursor: default;
}

/* ── "Has content" ring + pulse ───────────────────────────────────────── */

.calendar-day.has-content {
  position: relative;
  z-index: 1;
}

.calendar-day.has-content::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.2em;
  height: 2.2em;
  transform: translate(-50%, -50%);
  border: 1px solid #1976d2;
  border-radius: 50%;
  box-sizing: border-box;
  pointer-events: none;
  background: transparent;
  z-index: 2;
  animation: cal-pulse 2s infinite;
}

@keyframes cal-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(25, 118, 210, 0.4); }
  70%  { box-shadow: 0 0 0 5px rgba(25, 118, 210, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(25, 118, 210, 0);   }
}

/* No old-style dot */
.calendar-day.has-content::after {
  display: none;
}

/* ── Future / out-of-window / no-content states ───────────────────────── */

.calendar-day.future-date {
  cursor: not-allowed;
  opacity: 0.4;
  color: #999;
}

.calendar-day.future-date::before {
  border-color: #999;
  animation: none;
}

.calendar-day.future-date:hover {
  background-color: transparent;
}

.calendar-day.no-content {
  color: #ccc;
  cursor: default;
  pointer-events: none;
}

.calendar-day.no-content:hover {
  background-color: transparent;
}

.calendar-day.too-old {
  color: #ccc;
  cursor: default;
  pointer-events: none;
}

.calendar-day.too-old::before {
  display: none;
}

.calendar-day.too-old:hover {
  background-color: transparent;
}
