/* The plan dashboard's fortnight (Views::PlanDashboards::FortnightCard):
   each week under its head line: this week as a DataTable of days, a later
   week as a details whose summary is the head line and whose body is the
   same table; then, folded, what the days repeat (the plan calendar's
   attention grid). In a narrow panel each row stacks: the day and its step
   on one line, then what it holds with what is wrong under it. In a panel
   48rem wide or more it is the table, three columns (when, what, step)
   whose when and step are at fixed widths so every week's table lines up
   with the others, and with the Next queue's, whose middle cell is
   .fortnight-why. The dashboard's Next queue
   (Views::PlanDashboards::NextQueueCard) draws its rows with the same
   classes. */

.fortnight {
  display: block;
}

.fortnight-head {
  display: none;
}

/* A heading only a screen reader reads (the Next queue): no line of its own. */
.fortnight-col-bare {
  padding: 0;
  border: 0;
}

.fortnight-body {
  display: block;
}

.fortnight-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: var(--line-width) solid var(--line);
}

.fortnight-today {
  background: var(--surface-sunken);
}

.fortnight-when {
  padding: 0 var(--space-2);
  border-bottom: 0;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fortnight-what,
.fortnight-why,
.fortnight-rest {
  grid-column: 1 / -1;
  padding: 0 var(--space-2);
  border-bottom: 0;
}

.fortnight-when-list {
  white-space: normal;
}

.fortnight-step {
  grid-column: 2;
  grid-row: 1;
  max-width: 16rem;
  padding: 0 var(--space-2);
  border-bottom: 0;
  text-align: right;
  white-space: nowrap;
}

.fortnight-rest {
  color: var(--ink-muted);
}

/* Where the day has been exported, under what it holds: state, kept out
   of the step column so that column holds only steps. */
.fortnight-exported {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* Why the day is flagged, a line under what it holds. */
.fortnight-reason {
  margin-top: var(--space-1);
}

/* A finish or release set in place from the Next queue
   (NeedsAttentionCard::NextStep#render_status_step). */
.fortnight-step-form {
  display: contents;
}

/* A day's step as words: the Next queue above holds the buttons. */
.fortnight-step-link {
  /* A long step wraps in its cell rather than running out of it. */
  white-space: normal;
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* A note is optional: its link, which also has the base class, steps back
   in colour alone. */
.fortnight-step-link-quiet {
  color: var(--ink-muted);
}

/* Under a finger the words alone are too short a target. */
@media (pointer: coarse) {
  .fortnight-step-link {
    display: inline-block;
    padding-block: var(--space-3);
  }
}

.fortnight-step-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* The day opens in the weekly planner; it reads as the day, not a link,
   until it is pointed at. */
.fortnight-day {
  color: var(--ink);
  text-decoration: none;
}

.fortnight-day:hover {
  color: var(--accent-ink);
  text-decoration: underline;
}

.fortnight-day:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.fortnight-problem {
  color: var(--ink);
}

.fortnight-problem-quiet,
.fortnight-done {
  color: var(--ink-muted);
}

/* What repeats, inside "Why these days", its readout under the grid. */
.fortnight-repeats {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

/* The Next queue's count of the days still owing a step below it. */
.next-queue-more {
  margin: 0;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.fortnight-week {
  border-top: var(--line-width) solid var(--line);
}

/* This week's head line: its name, its steps by kind, and its actions at
   the end. A later week's is a band Disclosure's summary, drawn alike. */
.fortnight-week-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  min-height: var(--tap);
  padding: var(--space-1) var(--space-2);
  background: var(--surface-sunken);
}

.fortnight-week-title {
  font-weight: 600;
}

.fortnight-week-subjects {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.fortnight-week-more,
.fortnight-week-kinds {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.fortnight-week-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* Tracing a row of what repeats fades the days without it. */
.fortnight-row[data-score-match="false"] {
  opacity: 0.35;
}

/* The panel's width, not the window's: in the dashboard's main column a
   wide window can still leave too little room for four columns. */
@container (min-width: 48rem) {
  .fortnight {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  .fortnight-head {
    display: table-row;
  }

  .fortnight-body {
    display: table-row-group;
  }

  .fortnight-row {
    display: table-row;
  }

  .fortnight-when,
  .fortnight-what,
  .fortnight-why,
  .fortnight-step,
  .fortnight-rest {
    padding: var(--space-2);
    border-bottom: var(--line-width) solid var(--line);
    vertical-align: baseline;
  }

  /* On the cells too: a card whose headings are only for a screen reader
     (the Next queue, Needs attention) takes its widths from its first row. */
  .fortnight-col-when,
  .fortnight-when {
    width: 8rem;
  }

  .fortnight-col-step,
  .fortnight-step {
    width: 16rem;
  }

}
