/* The programme diagram's look (diagram.js draws it; design-pages-and-look.md §5.3 and §4.2, item 6; the look
   verdict's rulings 3, 4 and 5). Every size and colour of the diagram is here; the tile itself and its states are
   house.css section 14. Every colour is a custom property of ../styles.css or house.css.

   1. The diagram (HouseDiagram.draw): the course's figure panel, a part's heading, a week's heading with its state
      and its tiles, a thin row for a stop or a questionnaire, Week 6's split tile, the caption. It is drawn as the
      accepted "About the programme" and Part 1 pages draw it (look-accepted/home.css and landing.css, "The diagram").
      The element it is drawn in is a container, so the diagram sizes itself by its own width, wherever a page puts
      it: at 1,192 px (the frame's full width) a week's heading stands in a 148 px column at the left, so that the five
      tiles keep the course diagram's 970 px and its 186 px tiles; from 641 to 1,191 px the heading stands above its
      tiles and the panel's sides are 30 px, so that at 976 px (a 1,024 px window) the tiles are the course's 174.8 px;
      at 640 px and below the panel is narrower and, once the panel's own width is 640 px or less, the tiles are rows.
   2. The compact strip (HouseDiagram.route): the parts side by side, and in each its weeks and stops as pieces of a
      6 px track (the day strip's track, thinner) with their names and states (look-accepted/home.css, "The programme
      strip"). Done is the tile's green, now is today's coral, and an item not open yet keeps the empty track and a
      dimmed name. A stop counts 1.4 weeks, because its name is longer. Up to 1,132 px the widest part (Part 1) takes
      the first line and the others stand under it at the same scale; at 640 px and below the strip is a list. */

/* ---- 1. The diagram ----------------------------------------------------------------------------------------------- */

.house-diagram { display: block; min-width: 0; container: house-diagram / inline-size; }
/* The course's figure panel. Its own width decides the tiles' form (house.css section 14 asks the nearest container). */
.house-diagram-figure { margin: 0; padding: 26px 30px 22px; border: 1px solid var(--line); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 55%, var(--bg)); container-type: inline-size; }

/* A part's heading, when the diagram holds more than one part. */
.house-diagram-part + .house-diagram-part { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); }
.house-diagram-part-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0 0 16px; }
.house-diagram-part-head .house-diagram-part-title { font-size: 24px; line-height: 1.2; }
.house-diagram-part.is-closed .house-diagram-part-title { color: var(--ink-3); }

/* The rows: the part's weeks and, between them, its stops and each week's questionnaire. */
.house-diagram-rows { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.house-diagram-rows > li { margin: 0; }
.house-diagram-rows > .house-diagram-week:not(:first-child) { margin-top: 8px; }
.house-diagram-rows > .house-diagram-week:not(:last-child) { margin-bottom: 8px; }

/* A week: its heading (the label in small capitals, the title, the note, the state), then its tiles. */
.house-diagram-week { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }
.house-diagram-week-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin: 0;
  font-family: var(--sans); font-size: 15px; font-weight: 650; line-height: 1.35; letter-spacing: normal;
  color: var(--ink); }
.house-diagram-week-h > b { font-size: 12px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-3); }
.house-diagram-week-h a, .house-diagram-name a { color: var(--ink); text-decoration: none; }
.house-diagram-week-h a:hover, .house-diagram-name a:hover { color: var(--accent); }
.house-diagram-week.is-closed .house-diagram-week-h { font-weight: 600; color: var(--ink-3); }
.house-diagram-note { font-size: 13px; font-weight: 400; color: var(--ink-3); }

/* A state in words: at the right of a row or a heading. Done is the tile's green; now is in ink. */
.house-diagram-state { margin-left: auto; font-size: 13px; font-weight: 400; line-height: 1.4; white-space: nowrap;
  color: var(--ink-3); }
.house-diagram-state.is-now { font-weight: 650; color: var(--ink); }
.house-diagram-state.is-done { color: var(--ok); }
/* Staff: something not released to the cohort carries the tile's 12 px lock before its words. */
:is(.house-diagram-state, .house-route-state).is-not-released::before { content: ""; display: inline-block; width: 12px;
  height: 12px; margin-right: 5px; vertical-align: -1px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3.6 5.4V3.9a2.4 2.4 0 0 1 4.8 0v1.5' fill='none' stroke='%23000' stroke-width='1.4'/%3E%3Crect x='2' y='5.2' width='8' height='6.3' rx='1.4'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3.6 5.4V3.9a2.4 2.4 0 0 1 4.8 0v1.5' fill='none' stroke='%23000' stroke-width='1.4'/%3E%3Crect x='2' y='5.2' width='8' height='6.3' rx='1.4'/%3E%3C/svg%3E") center / contain no-repeat; }

/* A thin row: a stop, a week's questionnaire, or a week whose days are not listed. Its states are the tile's: open,
   done, not open yet (dashed, its name dimmed); for staff, in preparation and off the path are dashed too. An outline
   (the exam, the capstone assessment) is open: its page is read in full. */
.house-diagram-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; min-height: 46px;
  padding: 5px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  font-size: 15px; line-height: 1.35; }
.house-diagram-row:has(> .house-pill) { padding-right: 6px; }
.house-diagram-name { font-weight: 650; color: var(--ink); }
.house-diagram-text { font-size: 13px; color: var(--ink-3); }
.house-diagram-row > .house-pill { margin-left: auto; }
.house-diagram-row > .house-diagram-state + .house-pill { margin-left: 0; }
.house-diagram-row:is(.is-closed, .is-preparing, .is-off) { background: none; border-style: dashed; }
.house-diagram-row.is-closed .house-diagram-name { font-weight: 600; color: var(--ink-3); }
.house-diagram :is(.house-diagram-week-h, .house-diagram-name, .house-diagram-part-title) a:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

/* A tile's lines break as the course diagram's do. house.css asks every paragraph of the main column for
   text-wrap: pretty, which Safari honours by moving words to avoid a short last line: "Exercise 1, the account check
   that everyone runs" then takes three lines where module1.html has two, and the row grows by 18 px. */
.house-diagram .house-tile > p, .house-diagram-half { text-wrap: wrap; }

/* A tile with a state line and no exercise line (staff's "In preparation", a Week 4 day): the state stands at the
   tile's foot, where the line would be, so that a row of tiles reads across. */
@container (min-width: 641px) {
  .house-diagram .house-tile:not(.house-diagram-split) > p.house-tile-state:first-of-type { margin-top: auto; }
}

/* Week 6's tile: the morning and the afternoon under the title, split by a hairline, each named in the tile chip's
   small capitals (look §5.3: "MORNING", "AFTERNOON · CAPSTONE"; a day taught all day, "TAUGHT ALL DAY"). */
.house-diagram-halves { display: grid; margin: auto 0 0; }
.house-tile-line + .house-diagram-halves { margin-top: .2em; }
.house-diagram-half { margin: 0; padding: .5em 0; font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.house-diagram-half:first-child { padding-top: .1em; }
.house-diagram-half:last-child { padding-bottom: 0; }
.house-diagram-half + .house-diagram-half { border-top: 1px solid var(--line); }
.house-diagram-half > b { display: block; font-size: 10.5px; font-weight: 750; letter-spacing: .11em; line-height: 1.35;
  text-transform: uppercase; color: var(--ink-3); }
.house-diagram-half > span { display: block; margin-top: .1em; }

/* The caption: the course's own words about the diagram, under the course's part. */
.house-diagram-caption { max-width: 60rem; margin: 18px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-3); }
.house-diagram-caption b { color: var(--ink-2); }

/* At the frame's full width: the week's heading in a column at the left, the tiles at the course's 970 px. */
@container house-diagram (min-width: 1192px) {
  .house-diagram-figure { padding: 26px 26px 22px; }
  .house-diagram-week { grid-template-columns: 148px minmax(0, 1fr); gap: 20px; align-items: start; }
  .house-diagram-week-h { flex-direction: column; align-items: flex-start; gap: 3px; padding-top: 3px; }
  .house-diagram-week-h > .house-diagram-state { margin: 7px 0 0; white-space: normal; }
}
/* A phone: a narrower panel; a row's text under its name. */
@container house-diagram (max-width: 640px) {
  .house-diagram-figure { padding: 18px 14px 14px; }
  .house-diagram-row { padding: 9px 12px; }
  .house-diagram-row:has(> .house-pill) { padding-right: 12px; }
  .house-diagram-text { flex-basis: 100%; order: 3; }
  .house-diagram-row > .house-pill { order: 4; margin-left: 0; }
}
@media print {
  .house-diagram-week, .house-diagram-row { break-inside: avoid; }
}

/* ---- 2. The compact strip ----------------------------------------------------------------------------------------- */

.house-route { display: block; min-width: 0; container: house-route / inline-size; }
/* The card: the course's white card (../styles.css .card), with the strip's own padding. */
.house-route-parts { --stop: 1.4; --lead-n: calc(var(--lead-weeks, 1) + var(--lead-stops, 0) * var(--stop));
  display: flex; margin: 0; padding: 20px 24px 22px; list-style: none; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  animation: rise .4s cubic-bezier(.2,.7,.2,1) both; }
/* A part is as wide as its items: a week counts 1 and a stop 1.4, and its padding is outside that width. */
.house-route-part { --n: calc(var(--weeks, 1) + var(--stops, 0) * var(--stop)); flex-grow: var(--n); flex-shrink: 1;
  flex-basis: 0; box-sizing: content-box; min-width: 0; margin: 0; padding: 0 20px; border-left: 1px solid var(--line); }
.house-route-part:first-child { padding-left: 0; border-left: 0; }
.house-route-part:last-child { padding-right: 0; }
.house-route-head { display: grid; gap: 3px; margin: 0 0 14px; font-size: 14px; font-weight: 600; line-height: 1.4;
  color: var(--ink); }
.house-route-head a { color: var(--ink); text-decoration: none; }
.house-route-head a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.house-route-part.is-closed .house-route-head { color: var(--ink-2); }
.house-route-items { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.house-route-item { flex: 1 1 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; margin: 0;
  font-size: 13px; line-height: 1.35; }
.house-route-item.is-stop { flex-grow: var(--stop); }
.house-route-item::before { content: ""; display: block; height: 6px; margin: 0 0 9px; border-radius: 999px;
  background: repeating-linear-gradient(90deg, transparent 0 6px, var(--line-strong) 6px 7px); }
.house-route-item.is-done::before { background: var(--ok); }
.house-route-item.is-now::before { background: var(--brand-b); }
.house-route-name { font-weight: 650; color: var(--ink); }
a.house-route-name { color: var(--ink); text-decoration: none; }
a.house-route-name:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
:is(a.house-route-name, .house-route-head a):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px;
  border-radius: 2px; }
.house-route-state { font-size: 12.5px; color: var(--ink-3); }
.house-route-state.is-now { font-weight: 650; color: var(--ink); }
.house-route-state.is-done { color: var(--ok); }
.house-route-item.is-closed .house-route-name { font-weight: 600; color: var(--ink-3); }

/* Up to 1,132 px: the widest part takes the first line, and the others stand under it at the same scale. */
@container house-route (max-width: 1132px) {
  .house-route-parts { flex-wrap: wrap; row-gap: 22px; }
  .house-route-part { flex: 0 0 calc(100% * var(--n) / var(--lead-n)); box-sizing: border-box; }
  .house-route-part:first-child { flex-basis: 100%; padding-right: 0; }
  .house-route-part:nth-child(2) { padding-left: 0; border-left: 0; }
}
/* A phone: a list, a part's name and then a row for each item, with its state at the right. */
@container house-route (max-width: 640px) {
  .house-route-parts { display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 20px; padding: 18px 20px 14px; }
  .house-route-part, .house-route-part:first-child, .house-route-part:nth-child(2), .house-route-part:last-child {
    padding: 0; border-left: 0; }
  .house-route-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-bottom: 4px; }
  .house-route-items { display: block; }
  .house-route-item { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 0 10px;
    padding: 9px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
  .house-route-item::before { margin: 0; }
  .house-route-state { font-size: 13.5px; text-align: right; }
}
@media print {
  .house-route-item::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
