/* The week calendar on the person page (WeekCalendarComponent in app/components, Schedule::WeekBuilder in app/models/schedule): seven real dates, one column each at the section's own width of 44rem or
   more, an agenda below that. Linked after the device rules (40-native.css), like 51-schedule-panel.css, so nothing here needs to come before them. Tokens only and logical properties only, both enforced
   (test/styles/tokens_test.rb, test/styles/components_test.rb): it reads on the light shell and the console, in light and in dark, and mirrors in a right-to-left language. It decides no mode and no
   surface, pins nothing to an edge and sets no height in vh.

   One set of elements in both layouts: a list of days, each a heading and a list of blocks. The section is a size container, so the columns follow the room the page gives it (the console's rail takes
   258px of a 1280px screen) and not the screen. A block is a 1px edge and a 4px bar in its kind's tone over a tint of it (a spine tone: the edge and the bar are graphics held to 3:1, the tint is only a
   wash), and always a word and a shape as well, so the tone is never the only signal. A block's words wrap and break a word that has no room; none ends in an ellipsis. A custom property declared on
   the section (the tone, the line) is a component's own and costs no theme token. */

.week-calendar {
  --week-line: var(--rule);
  --week-tone-line: var(--spine-neutral-line);
  --week-tone-bg: var(--spine-neutral-bg);
  container: week-calendar / inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-inline-size: 0;
  /* No margin above it: the page's grid (54-person-page.css) puts a gap between the parts of a column, and a margin of its own set the week one gap lower than the side column's first panel. */
  border: 1px solid var(--week-line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  overflow: clip;
}

/* The tones of the kinds: a spine tone each (config/compartment_tones.yml names the compartments'). */
.week-calendar [data-tone="blue"] {
  --week-tone-line: var(--spine-blue-line);
  --week-tone-bg: var(--spine-blue-bg);
}
.week-calendar [data-tone="green"] {
  --week-tone-line: var(--spine-green-line);
  --week-tone-bg: var(--spine-green-bg);
}
.week-calendar [data-tone="amber"] {
  --week-tone-line: var(--spine-amber-line);
  --week-tone-bg: var(--spine-amber-bg);
}
.week-calendar [data-tone="slate"] {
  --week-tone-line: var(--spine-slate-line);
  --week-tone-bg: var(--spine-slate-bg);
}
.week-calendar [data-tone="plum"] {
  --week-tone-line: var(--spine-plum-line);
  --week-tone-bg: var(--spine-plum-bg);
}

/* ── The bar: the title and the dates, what the calendar has now, and the two links ───────────────────────────────── */
.week-calendar-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--density-gap) var(--density-block);
  min-inline-size: 0;
  padding: 0.5rem 0.75rem;
  border-block-end: 1px solid var(--week-line);
  background: var(--surface-sunken);
}
.week-calendar-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.6rem;
  min-inline-size: 0;
}
.week-calendar-heading {
  margin: 0;
  color: var(--fg1);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.week-calendar-span {
  margin: 0;
  color: var(--fg2);
  font-size: var(--text-xs);
  font-variant-numeric: lining-nums tabular-nums;
}
.week-calendar-now {
  flex: 1 1 16rem;
  min-inline-size: 0;
  margin: 0;
  color: var(--fg1);
  font-size: var(--text-xs);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.week-calendar-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-inline-start: auto;
  min-inline-size: 0;
}
.week-calendar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 1.75rem;
  max-inline-size: 100%;
  padding-block: 0.1rem;
  padding-inline: 0.75rem;
  border: 1px solid var(--control-line);
  border-radius: 999px;
  color: var(--accent-text);
  font-size: var(--text-xs);
  font-weight: 650;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.week-calendar-link:hover {
  background: var(--accent-soft);
}
.week-calendar-link[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
}
@media (pointer: coarse) {
  .week-calendar-link {
    min-block-size: var(--target-min);
    padding-inline: 1rem;
  }
}

/* ── The days: an agenda, one under another ──────────────────────────────────────────────────────────────────────────────── */
.week-days {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
}
.week-day {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.4rem;
  align-content: start;
  min-inline-size: 0;
  padding: 0.5rem 0.75rem 0.6rem;
  border-block-start: 1px solid var(--week-line);
}
.week-day:first-child {
  border-block-start: 0;
}
.week-day[data-today="true"] {
  background: var(--surface-tint);
}
.week-day-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1rem 0.4rem;
  min-inline-size: 0;
  margin: 0;
  color: var(--fg1);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.25;
}
.week-day[data-today="true"] .week-day-head {
  color: var(--accent-text);
}
.week-day-date {
  color: var(--fg2);
  font-size: var(--text-xs);
  font-weight: 500;
}
.week-day[data-today="true"] .week-day-date {
  color: var(--accent-text);
}
.week-day-today {
  padding-block: 0.05rem;
  padding-inline: 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.3;
  text-transform: uppercase;
}
.week-empty {
  margin: 0;
  color: var(--fg2);
  font-size: var(--text-xs);
}
/* The dash is for the columns, where a day with nothing listed is a quiet mark and the words are for a screen reader; the agenda says the words. */
.week-empty-dash {
  display: none;
}

/* ── A block ─────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
.week-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  gap: 0.3rem;
  align-content: start;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.week-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.1rem;
  align-content: start;
  min-inline-size: 0;
  padding-block: 0.3rem 0.4rem;
  padding-inline: 0.5rem 0.4rem;
  border: 1px solid var(--week-tone-line);
  border-inline-start-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--week-tone-bg);
  color: var(--fg1);
  font-size: var(--text-xs);
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.week-block-kind {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-inline-size: 0;
  color: var(--fg2);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.week-icon {
  flex: none;
  inline-size: 0.9rem;
  block-size: 0.9rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}
.week-block-kind .week-icon,
.week-legend-item .week-icon {
  color: var(--week-tone-line);
}
.week-block-time {
  color: var(--fg1);
  font-size: 0.75rem;
  font-variant-numeric: lining-nums tabular-nums;
  font-weight: 600;
}
.week-block-title {
  color: var(--fg1);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.25;
}
.week-block-detail,
.week-block-place,
.week-block-code {
  color: var(--fg2);
}
.week-block-state {
  justify-self: start;
  max-inline-size: 100%;
  margin-block-start: 0.1rem;
  padding-block: 0.02rem;
  padding-inline: 0.35rem;
  border: 1px solid var(--week-tone-line);
  border-radius: var(--radius-sm);
  color: var(--fg1);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* A canceled event is quiet and still readable: the wash is gone, the time and the title are struck through in the secondary text color (7:1 on the page), and the word is plain text. The edge and the
   bar stay, so the block is still where it was and still of its kind. */
.week-block[data-state="canceled"] {
  background: var(--surface-raised);
}
.week-block[data-state="canceled"] :is(.week-block-time, .week-block-title) {
  color: var(--fg2);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
.week-block[data-state="canceled"] .week-block-state {
  padding: 0;
  border: 0;
  color: var(--fg2);
  font-size: var(--text-xs);
  letter-spacing: 0;
  text-transform: none;
}
/* The ones called off beside a live block: one small line under it, the count and the teams. */
.week-block-twins {
  margin-block-start: 0.15rem;
  padding-block-start: 0.2rem;
  border-block-start: 1px solid var(--week-tone-line);
  color: var(--fg2);
  font-size: var(--text-xs);
  line-height: 1.3;
}

/* ── The foot: the kinds that are drawn, what the words mean, and who said it ────────────────────────────────────────────────── */
.week-calendar-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.35rem;
  min-inline-size: 0;
  padding: 0.55rem 0.75rem 0.65rem;
  border-block-start: 1px solid var(--week-line);
}
.week-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--fg1);
  font-size: var(--text-xs);
}
.week-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding-inline-start: 0.4rem;
  border-inline-start: 4px solid var(--week-tone-line);
  font-weight: 600;
}
.week-note,
.week-sources {
  min-inline-size: 0;
  margin: 0;
  color: var(--fg2);
  font-size: var(--text-xs);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.week-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 1.25rem;
  padding: 0;
  list-style: none;
}
.week-source-stale {
  color: var(--tone-warn-fg);
  font-weight: 700;
}

/* ── Seven columns, when the section has the room ─────────────────────────────────────────────────────────────────────────── */
@container week-calendar (min-width: 44rem) {
  .week-days {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    align-items: stretch;
  }
  .week-day {
    gap: 0.3rem;
    min-block-size: 7rem;
    padding: 0.4rem 0.2rem 0.5rem;
    border-block-start: 0;
    border-inline-start: 1px solid var(--week-line);
  }
  .week-day:first-child {
    border-inline-start: 0;
  }
  /* Today's column: the tint, a bar across its top and the word in its head, so it is never only a color. */
  .week-day[data-today="true"] {
    box-shadow: inset 0 3px 0 var(--accent);
  }
  .week-day-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
  }
  .week-day-today {
    margin-block-start: 0.1rem;
    font-size: 0.6875rem;
  }
  .week-empty-text {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .week-empty-dash {
    display: block;
    color: var(--fg2);
  }
  /* A week with nothing in it is a short row of dashes, not seven tall empty columns. */
  .week-calendar:not(:has(.week-block)) .week-day {
    min-block-size: 0;
  }
  .week-blocks {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }
  .week-block {
    gap: 0.05rem;
    padding-block: 0.25rem 0.3rem;
    padding-inline: 0.3rem 0.2rem;
    border-inline-start-width: 3px;
  }
  .week-block-kind {
    gap: 0.2rem;
  }
  .week-icon {
    inline-size: 0.8rem;
    block-size: 0.8rem;
  }
}
