/* SPDX-License-Identifier: AGPL-3.0-only */
/* Copyright (c) 2026 sol pbc */

.daygrid,
.daygrid-legend {
  --daygrid-cell: 13px;
  --daygrid-gap: 3px;
  --daygrid-radius: 3px;
}

.daygrid {
  position: relative;
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  color: var(--ink);
}

.daygrid-scroller {
  position: relative;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding: var(--space-5) 0 var(--space-2);
  scrollbar-gutter: stable;
}

.daygrid-body {
  display: grid;
  gap: var(--space-4);
  width: max-content;
  min-width: 100%;
}

.daygrid-year-block {
  display: grid;
  grid-template-columns: max-content auto;
  align-items: start;
  width: max-content;
  min-width: 100%;
}

.daygrid-gutter {
  position: sticky;
  left: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: 18px auto;
  gap: var(--space-1);
  padding-right: var(--space-2);
  background: var(--paper);
  color: var(--ink-faint-paper);
  font-size: var(--text-min);
  line-height: 1;
}

.daygrid-gutter--week {
  grid-template-rows: 18px;
}

.daygrid-year-label {
  align-self: end;
  font-weight: var(--weight-medium);
}

.daygrid-weekdays {
  display: grid;
  grid-template-rows: repeat(7, var(--daygrid-cell));
  gap: var(--daygrid-gap);
}

.daygrid-weekday-label {
  display: grid;
  align-items: center;
  min-width: 28px;
}

.daygrid-year-grid {
  display: grid;
  gap: var(--space-1);
}

.daygrid-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--daygrid-cell);
  gap: var(--daygrid-gap);
  min-height: 18px;
  color: var(--ink-faint-paper);
  font-size: var(--text-min);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
}

/* grid-row pins every label to the one label row. Month column ranges are disjoint
   by construction; this keeps a future placement bug from silently wrapping the row
   onto a second line instead of rendering visibly wrong. */
.daygrid-months span {
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.daygrid-months a {
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  text-overflow: ellipsis;
}

.daygrid-months a:hover,
.daygrid-months a:focus-visible {
  color: var(--focus);
  outline: 0;
  text-decoration: underline;
}

.daygrid-track {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, var(--daygrid-cell));
  grid-auto-columns: var(--daygrid-cell);
  gap: var(--daygrid-gap);
}

.daygrid-track--week {
  grid-template-rows: var(--daygrid-cell);
}

.daygrid-cell {
  display: grid;
  place-items: center;
  width: var(--daygrid-cell);
  height: var(--daygrid-cell);
  border: 1px solid var(--hairline);
  border-radius: var(--daygrid-radius);
  background: var(--cream-bright);
  color: var(--ink-faint-paper);
  appearance: none;
  font: inherit;
  font-size: 0;
  line-height: 1;
  padding: 0;
  text-decoration: none;
}

.daygrid-cell[href],
button.daygrid-cell {
  cursor: pointer;
}

.daygrid-cell--data {
  border-color: color-mix(in srgb, var(--orange) calc(var(--daygrid-heat, 0) * 80%), var(--hairline));
  background: color-mix(
    in srgb,
    var(--orange) calc(var(--daygrid-heat, 0) * 100%),
    var(--orange-wash)
  );
}

.daygrid-cell--presence {
  border-color: color-mix(in srgb, var(--orange) 58%, var(--hairline));
  background: color-mix(in srgb, var(--orange) 72%, var(--orange-wash));
}

.daygrid-cell--pending {
  border-color: var(--hairline-2);
  background: var(--cream-bright);
}

.daygrid-cell--pending::after {
  content: "";
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: var(--ink-faint-paper);
}

.daygrid-cell--empty {
  background: var(--paper);
}

.daygrid-cell--pad {
  border-color: transparent;
  background: transparent;
}

.daygrid-cell--today {
  outline: 1px solid var(--ink-faint-paper);
  outline-offset: 1px;
}

.daygrid-cell--range-endpoint {
  border-color: var(--orange);
  background: var(--orange);
  color: var(--orange-ink);
  opacity: 1;
}

.daygrid-cell--range-inner {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--orange) 45%, transparent);
  opacity: 1;
}

.daygrid-cell--range-outside {
  opacity: 0.28;
}

.daygrid-cell[href]:hover,
.daygrid-cell:focus-visible {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.daygrid-cell[aria-disabled="true"] {
  cursor: default;
}

.daygrid-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  color: var(--ink-faint-paper);
  font-size: var(--text-min);
}

.daygrid-legend-scale,
.daygrid-legend-pending {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.daygrid-legend-swatch {
  display: inline-block;
  width: var(--daygrid-cell);
  height: var(--daygrid-cell);
  border: 1px solid var(--hairline);
  border-radius: var(--daygrid-radius);
  background: color-mix(
    in srgb,
    var(--orange) calc(var(--daygrid-heat, 0) * 100%),
    var(--orange-wash)
  );
}

.daygrid-legend-swatch--empty {
  background: var(--paper);
}

.daygrid-legend-swatch--presence {
  border-color: color-mix(in srgb, var(--orange) 58%, var(--hairline));
  background: color-mix(in srgb, var(--orange) 72%, var(--orange-wash));
}

.daygrid-legend-pending-mark {
  display: inline-grid;
  place-items: center;
  width: var(--daygrid-cell);
  height: var(--daygrid-cell);
  border: 1px solid var(--hairline-2);
  border-radius: var(--daygrid-radius);
  background: var(--cream-bright);
}

.daygrid-legend-pending-mark::after {
  content: "";
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: var(--ink-faint-paper);
}

.daygrid-peek {
  position: absolute;
  z-index: 3;
  max-width: min(220px, calc(100% - var(--space-4)));
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-sm);
  background: var(--paper);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--ink) 12%, transparent);
  color: var(--ink-soft-paper);
  font-size: var(--text-min);
  line-height: 1.25;
  pointer-events: none;
  white-space: nowrap;
}

.daygrid-peek[hidden] {
  display: none;
}

.daygrid-peek-open {
  pointer-events: auto;
  color: var(--focus);
  font-weight: var(--weight-medium);
  text-decoration: none;
}

.daygrid-peek-open:hover,
.daygrid-peek-open:focus-visible {
  outline: 0;
  text-decoration: underline;
}

.daygrid-peek-hint {
  display: block;
  margin-top: 2px;
  color: var(--ink-faint-paper);
}

.daygrid-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 768px) {
  .daygrid,
  .daygrid-legend {
    --daygrid-cell: 12px;
    --daygrid-gap: 3px;
  }

  .daygrid-legend {
    align-items: flex-start;
    flex-direction: column;
  }
}
