.calendar-page {
  min-width: 20rem;
}

/* The shell grows to the viewport so the footer sits at the bottom (see the
   sticky-footer rules in dashboard.css). A grid hands that spare height to its
   auto rows, which on a tall window stretched the filter row and the shelf
   below it — the trigger came out as a 174px ellipse until the covers arrived
   and made the page tall enough again. The rows keep their own heights and the
   spare space stays where it belongs: at the bottom. */
.calendar-shell {
  position: relative;
  width: min(var(--page-content-max), calc(100% - var(--page-gutter) * 2));
  margin: 0 auto;
  padding: var(--space-5) 0 var(--space-8);
  display: grid;
  align-content: start;
  gap: var(--space-6);
}

/* Section rhythm mirrors /trophies: --space-8 between blocks, --space-panel
   under the filter trigger. */
.calendar-shell main {
  display: grid;
  align-content: start;
  gap: var(--space-8);
}

.calendar-game:focus-visible,
.calendar-action-close:focus-visible,
.calendar-action-link:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-xs);
}

/* Same shape as /trophies: one filter trigger, then the page's own warnings.
   The groups themselves live in the shared popover, so the calendar no longer
   spends its first screen on controls. */
.calendar-lead {
  display: grid;
  gap: var(--space-4);
  padding: 0 0 var(--space-6);
}

.calendar-platform-filter {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.calendar-platform-filter .platform-filter-btn {
  min-width: 0;
}

/* These three were the only checkboxes in the product. They are switches over a
   list, exactly like every other filter on the site, so they now speak the same
   segmented language: a pill in a track, state shown by fill. The checkbox stays
   in the markup — it is what a screen reader and the form state need — and the
   span beside it draws the pill. The fill hangs off `input:checked + span`
   rather than `:has(input:checked)` on the label: Chrome did not repaint the
   label when the box was unchecked, so a switched-off filter kept its fill. */
.calendar-filter-option {
  display: inline-flex;
  align-items: center;
}

.calendar-filter-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.calendar-filter-option input:checked + .seg-btn {
  background: var(--text);
  color: var(--background);
}

.calendar-filter-option input:focus-visible + .seg-btn {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

.calendar-warning {
  flex: 1 0 100%;
  margin-top: 0;
}

.calendar-results {
  min-height: 24rem;
}

/* The calendar answers from cache in well under a tenth of a second, so this
   shelf used to paint and vanish inside one blink: opening the page read as a
   flicker rather than as loading. Holding the tiles transparent for the first
   fifth of a second lets a fast answer arrive before they are ever seen; a slow
   one still gets the pulse. Opacity rather than display, so the tiles keep
   their box and the shelf below them does not jump when they do appear. */
.calendar-loading {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-6);
  padding-top: var(--space-2);
  animation: calendar-loading-in var(--dur-2) var(--ease-out) 200ms both;
}

@keyframes calendar-loading-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.calendar-loading span {
  aspect-ratio: 3 / 4.35;
  border-radius: var(--radius-surface);
  background: var(--surface);
  animation: calendar-loading 1.6s ease-in-out infinite alternate;
}

@keyframes calendar-loading {
  to { opacity: var(--opacity-soft); }
}

.calendar-error {
  display: grid;
  justify-items: start;
  gap: var(--space-5);
  color: var(--danger);
}

.calendar-error[hidden],
.calendar-content[hidden],
.calendar-loading[hidden] {
  display: none;
}

.calendar-retry {
  min-height: 2.35rem;
  padding: var(--space-4) var(--space-5);
  border: 0;
  border-radius: var(--radius-control);
  background: var(--brand);
  color: var(--background);
  font: var(--text-item);
  cursor: pointer;
}

.calendar-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: var(--space-8) var(--space-7);
  align-items: start;
}

.calendar-content > * {
  grid-column: 1 / -1;
  min-width: 0;
}

.calendar-section {
  padding-top: var(--space-7);
}

.calendar-section-compact {
  grid-column: auto;
}

.calendar-month-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.calendar-month-head h2 {
  font: var(--text-title);
  text-wrap: balance;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: var(--space-6) var(--space-5);
}

.calendar-game {
  appearance: none;
  display: grid;
  align-content: start;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.calendar-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-surface);
  background: var(--surface);
  transition:
    border-color var(--dur-1) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}

.calendar-game:hover .calendar-cover {
  border-color: var(--muted);
  transform: translateY(-2px);
}

.calendar-game:active .calendar-cover {
  transform: translateY(0);
}

.calendar-cover img,
.calendar-cover-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.calendar-cover img {
  z-index: 1;
  display: block;
  object-fit: cover;
}

.calendar-cover img.is-broken {
  display: none;
}

.calendar-cover-fallback {
  display: grid;
  place-items: end start;
  padding: var(--space-5);
  background: var(--raised);
}

.calendar-cover-fallback span {
  color: var(--muted);
  font: var(--text-meta);
  overflow-wrap: anywhere;
}

.calendar-cover-tags {
  position: absolute;
  z-index: 3;
  top: 0.5rem;
  right: 0.5rem;
  left: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  pointer-events: none;
}

.calendar-exclusive {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 100%;
  min-height: 1.45rem;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  font: var(--text-micro);
  font-weight: var(--weight-bold);
  line-height: 1;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.calendar-cover-tags .calendar-exclusive {
  border: var(--border-width) solid var(--line);
  background: var(--shade-7);
  color: var(--text);
  backdrop-filter: blur(10px) saturate(1.2);
  box-shadow:
    0 6px 16px var(--shade-4),
    0 0 10px 3px var(--shade-3);
}

.calendar-exclusive-copy {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-cover-meta {
  position: absolute;
  z-index: 2;
  bottom: 0.5rem;
  left: 0.5rem;
  right: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.calendar-date-chip,
.calendar-game-type {
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-4);
  font: var(--text-meta);
  font-weight: var(--weight-bold);
  white-space: nowrap;
  text-overflow: ellipsis;
  backdrop-filter: blur(8px);
  box-shadow:
    0 4px 12px var(--shade-3),
    0 0 10px 3px var(--shade-3);
}

.calendar-date-chip {
  color: var(--text);
  background: var(--shade-7);
  border: var(--border-width) solid var(--line);
  font-variant-numeric: tabular-nums;
}

.calendar-game-copy {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-1) 0;
}

.calendar-game-title {
  font: var(--text-item);
  color: var(--text);
  overflow-wrap: anywhere;
}

.calendar-game:hover .calendar-game-title {
  color: var(--text);
}

.calendar-platforms {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.calendar-platforms {
  min-height: 1.2rem;
}

.calendar-platforms-hidden .calendar-platforms {
  display: none;
}

/* Platform chips are intentionally single-tone: the label names the platform,
   so per-platform colors only added noise. */
.calendar-platform {
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  background: var(--raised);
  color: var(--text);
  font: var(--text-micro);
  font-weight: var(--weight-bold);
}

.calendar-game-type {
  padding: var(--space-2) var(--space-3);
  border: var(--border-width) solid color-mix(in srgb, var(--warning) calc(var(--opacity-soft) * 100%), transparent);
  background:
    linear-gradient(color-mix(in srgb, var(--warning) calc(var(--opacity-tint) * 100%), transparent), color-mix(in srgb, var(--warning) calc(var(--opacity-tint) * 100%), transparent)),
    var(--shade-7);
  color: var(--warning);
  font: var(--text-micro);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.calendar-modal-open {
  overflow: hidden;
}

.calendar-action-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  overflow-y: auto;
  background: var(--shade-6);
  backdrop-filter: blur(12px);
}

.calendar-action-overlay[hidden] {
  display: none;
}

.calendar-action-dialog {
  position: relative;
  width: min(45rem, 100%);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: var(--space-7);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-surface);
  background: var(--raised);
  box-shadow: 0 24px 70px var(--shade-4);
  animation: calendar-action-enter var(--dur-2) var(--ease-out) both;
}

@keyframes calendar-action-enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}

.calendar-action-close {
  position: absolute;
  z-index: 2;
  top: 0.85rem;
  right: 0.85rem;
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--shade-6);
  color: var(--muted);
  font: var(--text-icon);
  cursor: pointer;
  transition:
    color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    background var(--dur-1) var(--ease-out);
}

.calendar-action-close svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.calendar-action-close:hover {
  border-color: var(--muted);
  background: var(--raised);
  color: var(--text);
}

.calendar-action-header {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-1) var(--space-9) var(--space-6) 0;
  border-bottom: var(--border-width) solid var(--line);
}

.calendar-action-cover {
  position: relative;
  display: grid;
  place-items: center;
  width: 5rem;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-surface);
  background: var(--surface);
  color: var(--muted);
  font: var(--text-title);
}

.calendar-action-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.calendar-action-heading {
  display: grid;
  justify-items: start;
  gap: var(--space-2);
  min-width: 0;
}

.calendar-action-group h3 {
  color: var(--muted);
  font: var(--text-micro);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.calendar-action-heading h2 {
  max-width: 32rem;
  color: var(--text);
  font: var(--text-title);
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.calendar-action-release {
  color: var(--muted);
  font: var(--text-meta);
}

.calendar-action-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.calendar-action-sections {
  display: grid;
  gap: var(--space-6);
  padding-top: var(--space-6);
}

.calendar-action-group {
  display: grid;
  gap: var(--space-3);
}

.calendar-action-group h3 {
  margin: 0;
}

.calendar-action-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.calendar-action-link {
  appearance: none;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-5);
  min-height: 3.9rem;
  width: 100%;
  padding: var(--space-5);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-surface);
  background: var(--raised);
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    border-color var(--dur-1) var(--ease-out),
    background var(--dur-1) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}

.calendar-action-link:hover:not(:disabled) {
  border-color: var(--muted);
  background: var(--raised);
  transform: translateY(-1px);
}

.calendar-action-link:active:not(:disabled) {
  transform: translateY(0);
}

.calendar-action-link.is-primary {
  grid-column: 1 / -1;
  border-color: var(--muted);
  background: var(--raised);
}

.calendar-action-link:disabled {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
}

.calendar-action-icon {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-control);
  background: var(--raised);
}

.calendar-action-icon img {
  display: block;
  width: 1.7rem;
  height: 1.7rem;
  object-fit: contain;
}

.calendar-action-icon-calendar {
  background: var(--raised);
  color: var(--text);
}

.calendar-action-icon-calendar svg {
  width: 1.45rem;
  height: 1.45rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.calendar-action-icon.service-youtube {
  background: var(--white);
}

.calendar-action-icon.service-youtube img {
  width: 1.75rem;
  height: auto;
}

.calendar-action-icon.service-backloggd,
.calendar-action-icon.service-igdb {
  background: transparent;
}

.calendar-action-icon.service-backloggd img,
.calendar-action-icon.service-igdb img {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: var(--radius-control);
}

.calendar-action-copy {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.calendar-action-copy strong {
  color: inherit;
  font: var(--text-item);
}

.calendar-action-copy span {
  overflow: hidden;
  color: var(--muted);
  font: var(--text-micro);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-action-arrow {
  color: var(--muted);
  font: var(--text-meta);
}

.calendar-empty {
  min-height: 14rem;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-3);
  text-align: center;
  color: var(--muted);
}

.calendar-empty strong {
  color: var(--text);
  font: var(--text-title);
}

@media (max-width: 900px) {
  .calendar-lead {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .calendar-loading {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .calendar-lead {
    grid-template-columns: 1fr;
  }

  .calendar-loading,
  .calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-grid {
    gap: var(--space-6) var(--space-5);
  }

  .calendar-action-overlay {
    place-items: end center;
    padding: var(--space-4);
  }

  .calendar-action-dialog {
    width: 100%;
    max-height: calc(100dvh - 1rem);
    padding: var(--space-6);
    border-radius: var(--radius-surface);
  }

  .calendar-action-header {
    grid-template-columns: 4.15rem minmax(0, 1fr);
    gap: var(--space-5);
    padding-right: var(--space-9);
  }

  .calendar-action-cover {
    width: 4.15rem;
  }

  .calendar-action-list {
    grid-template-columns: 1fr;
  }

}

@media (prefers-reduced-motion: reduce) {
  .calendar-loading span,
  .calendar-action-dialog {
    animation: none;
  }

  .calendar-cover {
    transition: border-color var(--dur-1) var(--ease-out);
  }

  .calendar-game:hover .calendar-cover,
  .calendar-game:active .calendar-cover {
    transform: none;
  }
}
