/* public/content-calendar.css: the content calendar on the Brands tab
   (public/content-calendar.js, docs/CONTENT_CALENDAR.md).

   In the report look (theme.css): ink on paper, hairline rules, a 2px rule
   over each block, square shapes, small tracked capitals. The one accent
   (oxblood) marks what went wrong: a failed run is filled with it, a flagged
   one is outlined in it. Everything else is ink, dashed while it is still to
   come. Every rule is scoped to #cal-view, so no other screen changes. */

#cal-view {
  --cal-lane-w: minmax(132px, 168px);
  --cal-col-min: 120px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
#cal-view[hidden] { display: none; }

/* ── Toolbar ── */
#cal-view .cal-nav { gap: 10px 14px; }
#cal-view .cal-range { font-size: 15px; font-weight: 500; white-space: nowrap; }
#cal-view .cal-tz,
#cal-view .cal-corner,
#cal-view .cal-now-label,
#cal-view .cal-day-wd,
#cal-view .cal-lane-kicker,
#cal-view .cal-row-lane {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Right now ── */
#cal-view .cal-now {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  border-top: 2px solid var(--rep-ink);
}
#cal-view .cal-now:empty { display: none; }
#cal-view .cal-now-tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 12px 16px 12px 0;
  border: 0;
  border-bottom: 1px solid var(--rep-line);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
}
#cal-view .cal-now-value { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 500; }
#cal-view .cal-now-note { font-size: 13px; line-height: 1.4; color: var(--text-muted); overflow-wrap: anywhere; }
#cal-view .cal-now-tile.is-live .cal-now-value::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--rep-ink);
  animation: cal-pulse 1.4s ease-in-out infinite;
}
#cal-view button.cal-now-problems { cursor: pointer; }
#cal-view button.cal-now-problems:hover .cal-now-note,
#cal-view button.cal-now-problems:focus-visible .cal-now-note { color: var(--text); text-decoration: underline; }
#cal-view .cal-now-problems.has-failed .cal-now-value { color: var(--rep-accent); }
#cal-view .cal-now-tile.is-stale .cal-now-value { color: var(--rep-accent); }
#cal-view .cal-now-tile.has-overlaps .cal-now-note { color: var(--rep-accent); }

/* ── Notices and legend ── */
#cal-view .cal-notices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#cal-view .cal-notice { padding: 6px 12px; border-left: 2px solid var(--rep-rule); font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
#cal-view .cal-notice.is-warn { border-left-color: var(--rep-accent); }
#cal-view .cal-notice.is-error { border-left-color: var(--rep-accent); color: var(--rep-accent); }
#cal-view .cal-legend { display: flex; flex-wrap: wrap; gap: 6px 10px; }

/* ── A status: badge, chip, platform mark ── */
#cal-view .cal-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border: 1px solid var(--rep-line);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}
#cal-view .cal-glyph { display: inline-block; min-width: 1ch; text-align: center; font-weight: 600; }
#cal-view .is-failed.cal-badge { background: var(--rep-accent); border-color: var(--rep-accent); color: var(--rep-paper); }
#cal-view .is-flagged.cal-badge { background: var(--rep-accent-soft); border-color: var(--rep-accent); color: var(--rep-accent); }
#cal-view .is-running.cal-badge { background: var(--rep-ink); border-color: var(--rep-ink); color: var(--rep-paper); }
#cal-view .is-queued.cal-badge { border: 1px dashed var(--rep-ink); color: var(--text); }
#cal-view .is-upcoming.cal-badge { border: 1px dashed var(--rep-rule); }
#cal-view .is-paused.cal-badge { border: 1px dashed var(--rep-rule); color: var(--text-muted); }
#cal-view :is(.is-cancelled, .is-skipped).cal-badge { border-color: transparent; color: var(--text-muted); }

#cal-view .cal-chip {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  padding: 3px 6px;
  border: 1px solid var(--rep-line);
  border-left-width: 3px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-secondary);
}
#cal-view .cal-chip-time { flex: none; white-space: nowrap; color: var(--text-muted); }
#cal-view .cal-chip-title {
  flex: 1 1 auto;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: break-word;
}
/* A booked video: its time and one mark per platform; its title is in the day below. */
#cal-view .cal-chip-plats { flex: 1 1 auto; display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; }
#cal-view .cal-chip.is-failed { background: var(--rep-accent); border-color: var(--rep-accent); color: var(--rep-paper); font-weight: 500; }
#cal-view .cal-chip.is-failed .cal-chip-time { color: var(--rep-paper); }
#cal-view .cal-chip.is-flagged { background: var(--rep-accent-soft); border-color: var(--rep-accent); color: var(--text); }
#cal-view .cal-chip.is-running { border-color: var(--rep-ink); color: var(--text); }
#cal-view .cal-chip.is-queued { border-style: dashed; border-color: var(--rep-ink); border-left-style: solid; color: var(--text); }
#cal-view .cal-chip.is-upcoming { border-style: dashed; border-color: var(--rep-rule); }
#cal-view .cal-chip.is-paused { border-style: dashed; color: var(--text-muted); }
#cal-view .cal-chip.is-done { border-left-color: var(--rep-rule); }
#cal-view .cal-chip:is(.is-cancelled, .is-skipped) { border-color: transparent; color: var(--text-muted); }
#cal-view .cal-chip.is-cancelled .cal-chip-title { text-decoration: line-through; }
#cal-view :is(.cal-chip, .cal-badge, .cal-row-plat).is-running .cal-glyph { animation: cal-pulse 1.4s ease-in-out infinite; }
/* Two runs on the box at once: marked in the accent, wherever they show. */
#cal-view .cal-badge.is-overlap { border: 1px dashed var(--rep-accent); color: var(--rep-accent); background: transparent; }
#cal-view .cal-chip-overlap { flex: none; color: var(--rep-accent); font-weight: 600; }
#cal-view .cal-chip.is-failed .cal-chip-overlap { color: var(--rep-paper); }

#cal-view .cal-plat {
  padding: 0 3px;
  border: 1px solid var(--rep-line);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--text-secondary);
}
#cal-view .cal-plat.is-failed { background: var(--rep-accent); border-color: var(--rep-accent); color: var(--rep-paper); }
#cal-view .cal-chip.is-failed .cal-plat:not(.is-failed) { border-color: var(--rep-paper); color: var(--rep-paper); }
#cal-view .cal-plat.is-flagged { border-color: var(--rep-accent); color: var(--rep-accent); }
#cal-view .cal-plat.is-done { border-color: var(--rep-ink); color: var(--text); }
#cal-view .cal-plat:is(.is-upcoming, .is-queued) { border-style: dashed; }
#cal-view .cal-plat:is(.is-cancelled, .is-skipped) { color: var(--text-muted); text-decoration: line-through; }

/* ── The grid: one column per day, one row per lane ── */
/* contain: inline-size keeps the grid's own width out of the page's, and
   position: relative clips the screen-reader labels (.pb-sr, absolutely
   placed) with it: on a phone the grid scrolls sideways, the page never does. */
#cal-view .cal-scroll { position: relative; overflow-x: auto; min-width: 0; contain: inline-size; border-top: 2px solid var(--rep-ink); -webkit-overflow-scrolling: touch; }
#cal-view .cal-scroll:empty { border-top: 0; }
#cal-view .cal-grid { display: grid; min-width: min-content; }
#cal-view .cal-corner,
#cal-view .cal-lane {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg);
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--rep-line);
}
#cal-view .cal-corner { display: flex; align-items: flex-end; border-bottom-color: var(--rep-ink); }
#cal-view .cal-lane { display: flex; flex-direction: column; gap: 2px; font-size: 13px; font-weight: 500; color: var(--text); }
#cal-view .cal-lane-title { overflow-wrap: anywhere; }
#cal-view .cal-lane-kicker { display: block; }
#cal-view .cal-lane-note { font-size: 11px; color: var(--text-muted); }
#cal-view .cal-lane-note.is-error { color: var(--rep-accent); }

#cal-view .cal-day {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 10px 8px 8px;
  border: 0;
  border-bottom: 1px solid var(--rep-ink);
  border-left: 1px solid var(--rep-line);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
#cal-view .cal-day-date { font-size: 15px; font-weight: 500; white-space: nowrap; }
#cal-view .cal-day.is-past .cal-day-date { color: var(--text-secondary); }
#cal-view .cal-day.is-today { box-shadow: inset 0 3px 0 var(--rep-accent); }
#cal-view .cal-day.is-today .cal-day-wd { color: var(--rep-accent); }
#cal-view .cal-day-failed { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--rep-accent); }
#cal-view .cal-day-failed .cal-badge { padding: 0 3px; }

#cal-view .cal-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  min-height: 64px;
  padding: 6px;
  border: 0;
  border-bottom: 1px solid var(--rep-line);
  border-left: 1px solid var(--rep-line);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
#cal-view button.cal-cell { cursor: pointer; }
#cal-view .cal-cell.is-today,
#cal-view .cal-day.is-today { background: var(--glass); }
#cal-view button:is(.cal-cell, .cal-day):hover { background: var(--glass-hover); }
#cal-view button:is(.cal-cell, .cal-day)[aria-pressed="true"] { outline: 2px solid var(--rep-ink); outline-offset: -2px; }
#cal-view button:is(.cal-cell, .cal-day):focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
#cal-view .cal-more { font-size: 11px; color: var(--text-muted); }

/* The takes: how many, one bar of their outcomes, the counts in words. */
#cal-view .cal-takes-total { font-size: 13px; font-weight: 500; }
#cal-view .cal-bar { display: flex; gap: 1px; height: 8px; }
#cal-view .cal-seg { min-width: 3px; background: var(--rep-line); }
#cal-view .cal-seg.is-failed { background: var(--rep-accent); }
#cal-view .cal-seg.is-flagged { background: repeating-linear-gradient(135deg, var(--rep-accent) 0 2px, var(--rep-accent-soft) 2px 4px); }
#cal-view .cal-seg.is-running { background: var(--rep-ink); animation: cal-pulse 1.4s ease-in-out infinite; }
#cal-view .cal-seg.is-queued { background: var(--rep-rule); }
#cal-view .cal-seg.is-done { background: var(--text-secondary); }
#cal-view .cal-takes-words { font-size: 11px; line-height: 1.4; color: var(--text-muted); }
#cal-view .cal-word-failed { color: var(--rep-accent); font-weight: 600; }

/* ── The day (or the problems) under the grid ── */
#cal-view .cal-detail { border-top: 2px solid var(--rep-ink); padding-top: 12px; }
#cal-view .cal-detail[hidden] { display: none; }
#cal-view .cal-detail-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; }
#cal-view .cal-detail-title { margin: 0; font-size: 18px; font-weight: 500; }
#cal-view .cal-detail-title:focus { outline: none; }
#cal-view .cal-detail-sub { flex: 1 1 auto; font-size: 12px; color: var(--text-muted); }
#cal-view .cal-rows { list-style: none; margin: 8px 0 0; padding: 0; }
#cal-view .cal-row {
  display: grid;
  grid-template-columns: 168px 112px minmax(0, 1fr) 150px;
  align-items: baseline;
  gap: 4px 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rep-line);
}
/* The accent bar sits in the gutter, so a failed row's columns line up with the others. */
#cal-view .cal-row.is-failed { border-left: 3px solid var(--rep-accent); padding-left: 10px; margin-left: -13px; }
#cal-view .cal-row-time { font-size: 13px; color: var(--text-secondary); }
#cal-view .cal-row-badges { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
#cal-view .cal-row-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#cal-view .cal-row-title { font-weight: 500; overflow-wrap: anywhere; }
#cal-view .cal-row-detail { font-size: 13px; line-height: 1.45; color: var(--text-muted); overflow-wrap: anywhere; }
#cal-view .cal-row.is-failed .cal-row-detail { color: var(--rep-accent); }
#cal-view .cal-row-plats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
#cal-view .cal-row-plat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 6px;
  border: 1px solid var(--rep-line);
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
}
#cal-view a.cal-row-plat:hover,
#cal-view a.cal-row-plat:focus-visible { border-color: var(--rep-ink); }
#cal-view .cal-row-plat .cal-badge { padding: 0 3px; }
#cal-view .cal-row-lane { text-align: right; overflow-wrap: anywhere; }
#cal-view .cal-empty { margin: 12px 0 0; color: var(--text-muted); }

/* ── The day's timeline: 24 hours, a bar per run ── */
#cal-view .cal-tl { --tl-label: 136px; position: relative; display: flex; flex-direction: column; gap: 6px; margin: 14px 0 6px; }
#cal-view .cal-tl-row { display: grid; grid-template-columns: var(--tl-label) minmax(0, 1fr); align-items: center; min-height: 18px; }
#cal-view .cal-tl-label { padding-right: 10px; font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cal-view .cal-tl-kicker { display: block; font-size: 10px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
#cal-view .cal-tl-scale { position: relative; height: 14px; }
#cal-view .cal-tl-mark { position: absolute; top: 0; transform: translateX(-50%); font-size: 10px; color: var(--text-muted); white-space: nowrap; }
#cal-view .cal-tl-mark:first-child { transform: none; }
#cal-view .cal-tl-mark:last-child { transform: translateX(-100%); }
#cal-view .cal-tl-track {
  position: relative;
  height: 16px;
  border-left: 1px solid var(--rep-line);
  border-right: 1px solid var(--rep-line);
  background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--rep-line) calc(25% - 1px) 25%);
}
#cal-view .cal-tl-bar { position: absolute; top: 2px; bottom: 2px; min-width: 2px; border: 1px solid var(--rep-rule); background: transparent; }
#cal-view .cal-tl-bar.is-box { border-color: var(--text-secondary); background: var(--text-secondary); }
#cal-view .cal-tl-bar.is-box.is-approx { background: transparent; border: 1px dashed var(--rep-ink); }
#cal-view .cal-tl-bar.is-failed { border-color: var(--rep-accent); background: var(--rep-accent); }
#cal-view .cal-tl-bar.is-cancelled { opacity: 0.45; }
#cal-view .cal-tl-bar.is-run { border-color: var(--rep-ink); }
#cal-view .cal-tl-bar.is-overlap { box-shadow: 0 0 0 1px var(--rep-accent); }
/* A render that follows the one before at once still shows where it starts. */
#cal-view .cal-tl-bar.is-again { border-left: 2px solid var(--rep-paper); }
#cal-view .cal-tl-row.is-overlaps .cal-tl-bar { border-color: var(--rep-accent); background: var(--rep-accent); }
#cal-view .cal-tl-row.is-free .cal-tl-bar { border: 1px dashed var(--rep-rule); background: var(--glass-strong); }
#cal-view .cal-tl-row.is-overlaps .cal-tl-label { color: var(--rep-accent); }
#cal-view .cal-tl-now { position: absolute; top: 20px; bottom: 0; width: 2px; background: var(--rep-accent); left: calc(var(--tl-label) + (100% - var(--tl-label)) * var(--now)); pointer-events: none; }
#cal-view .cal-tl-words { list-style: none; margin: 4px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-secondary); }
#cal-view .cal-tl-words b { font-weight: 500; color: var(--text); }

/* ── Where this comes from ── */
#cal-view .cal-sources { font-size: 12px; color: var(--text-muted); }
#cal-view .cal-sources summary { cursor: pointer; width: max-content; }
#cal-view .cal-sources ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#cal-view .cal-source-name { color: var(--text-secondary); font-weight: 500; }
#cal-view .cal-source.is-error .cal-source-state { color: var(--rep-accent); }

/* On a wide window the header row holds the brand tabs' place (style.css,
   min-width 1700px): like Recent posts, the calendar starts under it. */
@media (min-width: 1700px) {
  #tab-performance #cal-view { margin-top: 12px; }
}

@keyframes cal-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  #cal-view * { animation: none !important; }
}

/* ── Phones: the grid scrolls sideways under the sticky lane names; the
   day below it is a plain list. ── */
@media (max-width: 640px) {
  #cal-view { --cal-lane-w: 104px; --cal-col-min: 132px; }
  #cal-view .cal-range { order: 3; }
  #cal-view .cal-tz { display: none; }
  #cal-view .cal-now-tile { padding-right: 0; }
  /* On a phone the page has no gutter for the failed row's bar: it stays inside. */
  #cal-view .cal-row.is-failed { margin-left: 0; }
  /* On a phone the time has its own line, the outcome under it. */
  #cal-view .cal-row { grid-template-columns: minmax(0, 1fr); }
  #cal-view .cal-row-time { grid-column: 1 / -1; }
  #cal-view .cal-row .cal-row-badges { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  #cal-view .cal-tl { --tl-label: 84px; }
  #cal-view .cal-row-main { grid-column: 1 / -1; }
  #cal-view .cal-row-lane { grid-column: 1 / -1; text-align: left; }
}
