/* calendar.css — scoped to the calendar module.
 *
 * Platform is a hue, carried on --hue per card. Status is a treatment, so the
 * two dimensions never collide and `posted` recedes: a month that is mostly
 * done looks calm, and the unfinished cards are the loudest things in it.
 */

.view__spacer { flex: 1; }

.view__body--grid { padding: 0; display: flex; flex-direction: column; }

.monthnav { display: flex; align-items: center; gap: var(--s-1); }
.btn--icon { padding: 7px; }

/* ---- grid ------------------------------------------------------------ */
.month { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.month__head {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  flex: none;
}

.month__weekday {
  padding: var(--s-2) var(--s-3);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.month__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(var(--cell-min-h), 1fr);
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.month__cell {
  /* The cell is the container the card responds to, so a card sheds detail
   * when its own column is narrow -- opening the editor, a small laptop, a
   * phone -- rather than when the viewport happens to cross a breakpoint. */
  container-type: inline-size;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: 6px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.month__cell:nth-child(7n) { border-right: 0; }

/* Weekends are recessed, not coloured: bands post on weekends, so the
 * distinction is orientation rather than de-emphasis. */
.month__cell.is-weekend { background: rgba(255, 255, 255, .028); }

/* A month grid that hides its edges makes the first and last weeks feel
 * broken, so adjacent days keep their cells and lose their weight. */
.month__cell.is-outside { background: rgba(0, 0, 0, .25); }
.month__cell.is-outside .month__daynum { color: var(--faint); }

.month__cell.is-drop {
  box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.month__cellhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-1);
  min-height: 20px;
}

.month__daynum {
  font-size: var(--t-day);
  font-weight: 600;
  color: var(--muted);
  padding: 0 3px;
  font-variant-numeric: tabular-nums;
}

.month__daynum.is-today {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 999px;
  min-width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.month__add {
  opacity: 0;
  color: var(--muted);
  border-radius: 4px;
  padding: 2px;
  transition: opacity var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.month__cell:hover .month__add,
.month__add:focus-visible { opacity: 1; }
.month__add:hover { color: var(--text); background: var(--panel-2); }

.month__cards {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
}

.month__more {
  font-size: var(--t-meta);
  color: var(--muted);
  text-align: left;
  padding: 2px 4px;
  border-radius: 4px;
}
.month__more:hover { color: var(--text); background: var(--panel-2); }

/* ---- card -------------------------------------------------------------
 * Status treatments. The border-left carries the platform hue at full
 * strength on `ready` because that is the state that should read as armed. */
.card {
  --fill: color-mix(in srgb, var(--hue) 14%, transparent);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--card-h);
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--hue) 45%, transparent);
  border-left: 2px solid var(--hue);
  background: var(--fill);
  cursor: grab;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.card:hover { border-color: var(--hue); }
.card:active { cursor: grabbing; }

.card.is-idea {
  background: none;
  border-style: dashed;
  border-left-style: solid;
}

.card.is-draft { background: color-mix(in srgb, var(--hue) 14%, transparent); }

.card.is-ready {
  background: color-mix(in srgb, var(--hue) 28%, transparent);
  border-left-width: 3px;
}

.card.is-posted {
  background: color-mix(in srgb, var(--hue) 8%, transparent);
  border-color: color-mix(in srgb, var(--hue) 25%, transparent);
}
.card.is-posted .card__title { color: var(--muted); }
.card__done { color: var(--hue); flex: none; }

.card__repeat {
  color: var(--hue);
  font-size: 0.75rem;
  line-height: 1;
  flex: none;
  opacity: .75;
}

/* ---- repeat controls -------------------------------------------------- */
.repeat {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}



.card__time {
  font-size: var(--t-meta);
  font-weight: 600;
  color: var(--hue);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

/* Hidden by default: at 118px a column has no room for a second line. */
.card__platform { display: none; }

.card--wide .card__platform {
  display: block;
  font-size: var(--t-meta);
  font-weight: 600;
  color: var(--hue);
}

.card__title {
  font-size: var(--t-card);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* Below ~132px the title has almost nothing left, so the card gives up its
 * time first and its owner disc second. The title is the thing you scan. */
@container (max-width: 132px) {
  .card__time { display: none; }
}
@container (max-width: 96px) {
  .card .disc { display: none; }
}

.card.is-dragging {
  opacity: .55;
  transform: scale(1.02);
  box-shadow: var(--shadow-drag);
}

/* ---- phones ----------------------------------------------------------- */
/* ---- compact month (phones) ------------------------------------------
 * Dots in the grid, the selected day listed below at full width. */
.month .month__grid--compact {
  grid-auto-rows: auto;
  flex: none;
  overflow: visible;
}

.month__cell--compact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7px 2px 8px;
  min-height: 0;
  border-radius: 0;
}
.month__cell--compact .month__daynum { padding: 0; }

.month__cell--compact.is-selected {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.month__dots {
  display: flex;
  gap: 2px;
  min-height: 5px;
  align-items: center;
}

.month__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--hue);
}

.daylist {
  border-top: 1px solid var(--line);
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.daylist__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.daylist__date {
  font-size: var(--t-body);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.btn--small { padding: 5px 9px; font-size: var(--t-meta); }

.daylist__rows { display: flex; flex-direction: column; gap: 5px; }

.daylist__empty {
  margin: 0;
  padding: var(--s-4) 0;
  text-align: center;
  font-size: var(--t-card);
  color: var(--muted);
}

/* Full width, so the title is actually readable and the tap target is real. */
.card--wide {
  min-height: 40px;
  padding: 7px 9px;
  cursor: pointer;
}
.card--wide .card__title { white-space: normal; font-size: var(--t-body); }
.card--wide .card__time { display: inline; }
.card--wide .disc { display: inline-flex; }

@media (max-width: 819px) {
  .month__grid { grid-auto-rows: minmax(88px, auto); }
  .month__weekday { padding: 6px; font-size: 0.625rem; letter-spacing: .08em; }
  .card__time { display: none; }
  .view__bar { padding-inline: var(--s-3); flex-wrap: wrap; }
}

/* ---- year view --------------------------------------------------------
 * Encodes cadence, not content. The design goal is that an empty month
 * reads as empty at a glance; everything else defers to that. */
.year { padding: var(--s-5); }

.year__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-5) var(--s-6);
}

/* Blocks are capped at 156px, so a column needs far less room than it did
 * when cells could stretch. Four months fit well below the old 1240 mark. */
@media (max-width: 1000px) { .year__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .year__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px)  { .year__grid { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); } }

.ymonth { min-width: 0; }

.ymonth__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  max-width: 156px;
  padding: 0 2px var(--s-2);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-2);
}
.ymonth__head:hover .ymonth__name { color: var(--accent); }

.ymonth__name {
  font-size: var(--t-card);
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: color var(--t-fast) var(--ease);
}

.ymonth__count {
  font-size: var(--t-meta);
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ymonth__count.is-empty { color: var(--faint); }

.ymonth__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  /* Capped so cells stay around 20px. Let loose in a 4-column layout they
   * reach 33px, and three 2px bars float in the middle of an empty square --
   * which loses the density the whole view exists for. The leftover width
   * becomes gutter, which costs nothing. */
  max-width: 156px;
}

.ycell {
  position: relative;
  aspect-ratio: 1;
  min-height: 15px;
  border-radius: 2px;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}
.ycell.is-outside { background: none; }
.ycell.is-clickable { cursor: pointer; }
.ycell.is-clickable:hover { outline: 1px solid var(--faint); }

.ycell.is-today { box-shadow: inset 0 0 0 1px var(--accent); }

.ycell__bars {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
}

.ybar {
  height: 2px;
  border-radius: 1px;
  background: var(--hue);
}
.ybar.is-dense { height: 4px; }

/* The status mode answers the other question a year view is for: not what
 * are we posting, but how much of it is actually ready. */
.ybar--idea {
  background: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hue) 65%, transparent);
}
.ybar--draft { background: color-mix(in srgb, var(--hue) 45%, transparent); }
.ybar--ready { background: var(--hue); }
.ybar--posted { background: color-mix(in srgb, var(--hue) 22%, transparent); }

/* ---- segmented control ------------------------------------------------ */
.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  gap: 2px;
}

.segmented__btn {
  padding: 5px 11px;
  border-radius: 4px;
  font-size: var(--t-card);
  font-weight: 600;
  color: var(--muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.segmented__btn:hover { color: var(--text); }
.segmented__btn.is-active { background: var(--panel-2); color: var(--text); }

/* ---- filter bar ------------------------------------------------------- */
.filter { display: flex; align-items: center; gap: var(--s-1); }
.filter__icon { color: var(--muted); margin-right: 2px; }

.filter__select {
  font: inherit;
  font-size: var(--t-card);
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 5px 6px;
  cursor: pointer;
}
.filter__select:hover { color: var(--text); background: var(--panel-2); }
.filter__select.is-set {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.filter__select option { background: var(--panel-2); color: var(--text); }

.filter__clear {
  font-size: var(--t-meta);
  font-weight: 600;
  color: var(--muted);
  padding: 5px 7px;
  border-radius: var(--radius);
}
.filter__clear:hover { color: var(--text); background: var(--panel-2); }

/* ---- mine -------------------------------------------------------------
 * A to-do list, so finished work is absent rather than greyed. */
.mine { padding: var(--s-5); max-width: 720px; }

.mine__count {
  margin: 0 0 var(--s-3);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.mine__rows { display: flex; flex-direction: column; gap: 4px; }

.mine__row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
  transition: border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.mine__row:hover { background: var(--panel-2); border-color: var(--faint); }
.mine__row:active { transform: scale(.995); }

.mine__edge {
  width: 3px;
  align-self: stretch;
  min-height: 26px;
  border-radius: 2px;
  background: var(--hue);
  flex: none;
}

.mine__body { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }

.mine__title {
  font-size: var(--t-body);
  font-weight: 600;
  letter-spacing: -0.008em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mine__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--t-meta);
  color: var(--muted);
}
.mine__platform { color: var(--hue); font-weight: 600; }
.mine__status { text-transform: capitalize; }
.mine__dot { color: var(--faint); }

.mine__due {
  font-size: var(--t-meta);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.mine__due.is-overdue { color: var(--danger); }
.mine__due.is-today { color: var(--accent); }
.mine__due.is-far { color: var(--faint); font-weight: 500; }

@media (max-width: 819px) {
  .mine { padding: var(--s-3); }

  /* The bar is three stacked rows on a phone, and every pixel it takes is a
   * pixel the grid and the day list have to share. */
  .view__bar {
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    row-gap: var(--s-2);
  }
  .view__title { font-size: 1.125rem; }
  .view__spacer { display: none; }

  /* Filters scroll rather than wrapping onto a fourth row. */
  .filter {
    order: 3;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .filter::-webkit-scrollbar { display: none; }
  .filter__select { flex: none; }

  .segmented { order: 2; }
  .view__bar > .btn--primary { order: 2; margin-left: auto; }
  .monthnav { order: 1; margin-left: auto; }
}
