/* The week audit. Loaded after articles.css, for this article only.

   The colour rule does the arguing here. Orange is a leak and nothing else, indigo is time that came
   back, and everything the reader keeps stays grey. A line on their list only turns orange once they
   call it a leak. Grey until then: the page has no business deciding that for them.

   Indigo comes in two strengths. In the drawn week it is a mid tint with dark labels: eleven solid
   blocks shouted over everything around them, and the front door's own week is calm. Bars carry no
   text, so they use the deep one. */

/* ---------- The set piece: one week ----------
   Blocks hold their place, so the week never stretches. A leak fills from the top with indigo and
   what stays behind is an orange sliver, because a leak rarely goes to zero. Armed by articles.js:
   without JS, or with reduced motion, this is simply the finished picture. */
.wk-fig { --wk-back: #C9D2FC; margin: 0; padding: clamp(16px, 2.6vw, 24px); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-float); display: grid; gap: 16px; min-width: 0; }
.wk-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.wk-head .eyebrow { color: var(--ink-hint); }
.wk-toggle { padding: 0.5em 0.95em; border: 0; border-radius: 999px; background: var(--grid); color: var(--ink); font: 700 0.8125rem/1.2 var(--sans); cursor: pointer; transition: background-color 0.2s; }
.wk-toggle:hover { background: var(--rule); }
.wk-toggle[hidden] { display: none; }

.wk-grid { display: grid; grid-template-columns: 38px repeat(5, minmax(0, 1fr)); column-gap: 6px; }
.wk-axis { position: relative; margin-top: 28px; height: 352px; }
.wk-axis span { position: absolute; right: 6px; transform: translateY(-50%); font: 500 0.6875rem/1 var(--mono); color: var(--ink-hint); }
.wk-axis span:nth-child(1) { top: 0; transform: none; }
.wk-axis span:nth-child(2) { top: 25%; }
.wk-axis span:nth-child(3) { top: 50%; }
.wk-axis span:nth-child(4) { top: 75%; }
.wk-axis span:nth-child(5) { top: 100%; transform: translateY(-100%); }
.wk-day { min-width: 0; }
.wk-d { height: 22px; margin-bottom: 6px; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.12em; line-height: 22px; text-transform: uppercase; color: var(--ink-hint); }
.wk-track { position: relative; height: 352px; background: repeating-linear-gradient(to bottom, var(--grid) 0 1px, transparent 1px 88px); }

.wk-b { position: absolute; left: 0; right: 0; top: calc(var(--t) * 100% / 32); height: calc(var(--h) * 100% / 32 - 3px); overflow: hidden; border-radius: 5px; background: #EFF0F6; color: var(--ink-hint); font-size: 0.6875rem; font-weight: 600; line-height: 1.2; }
.wk-t { position: relative; display: block; padding: 4px 6px; overflow: hidden; overflow-wrap: anywhere; color: var(--ink); transition: color 0.5s; }
.wk-b:not(.wk-leak) .wk-t { color: inherit; }
/* The solid orange waits for the indigo to land, or the labels sit white on orange for a moment. */
.wk-leak { background: var(--lift); transition: background-color 0.3s 0.75s, box-shadow 0.3s 0.75s; }
.wk-back { position: absolute; inset: 0 0 calc(var(--l) / var(--h) * 100%) 0; background: var(--wk-back); transform-origin: 50% 0; transition: transform 0.85s var(--ease); transition-delay: calc(var(--d, 0) * 45ms); }

/* Before the cut a leak carries its label, so it needs the tint. After, the sliver left is thin and
   has to read as orange at a glance, so it goes solid. */
.is-armed:not(.is-cut) .wk-leak { background: var(--lift-tint); box-shadow: inset 0 0 0 1px var(--lift); transition: none; }
.is-armed:not(.is-cut) .wk-back { transform: scaleY(0); transition: none; }
.is-armed:not(.is-cut) .wk-t { color: var(--lift-ink); transition: none; }

/* Two numbers, one of them hidden. The finished one is the default, so no JS still reads true. */
.wk-b4 { display: none; }
.is-armed:not(.is-cut) .wk-b4 { display: inline; }
.is-armed:not(.is-cut) .wk-af { display: none; }

.wk-read { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wk-read > div { display: grid; gap: 3px; padding: 12px 14px; border-radius: 12px; background: var(--paper); min-width: 0; }
.wk-read .eyebrow { color: var(--ink-hint); }
.wk-read b { font: 600 1.375rem/1.15 var(--mono); }
.wk-read small { font-size: 0.8125rem; line-height: 1.3; color: var(--ink-hint); }
.wk-leaking b { color: var(--lift-ink); }
.wk-backnum b { color: var(--primary-deep); }

.a-body .wk-key { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; list-style: none; font-size: 0.875rem; line-height: 1.3; color: var(--ink-2); }
.wk-key li { display: flex; align-items: center; gap: 7px; }
.wk-key i { width: 14px; height: 14px; border-radius: 4px; background: #E3E5EF; }
.wk-key .k-leak { background: var(--lift); }
.wk-key .k-back { background: var(--wk-back, var(--primary-deep)); }
.wk-key .k-none { background: #D9DCEB; }
.wk-cap { font-size: 0.9375rem; line-height: 1.5; color: var(--ink-hint); }

/* ---------- Fifteen minutes, three times over ---------- */
.wk-pile { margin: 0; padding: clamp(18px, 3vw, 26px); border-radius: 22px; background: var(--wash); display: grid; gap: 16px; }
.wk-pile-row { display: grid; grid-template-columns: 7rem minmax(0, 1fr) 6.5rem; gap: 14px; align-items: center; }
.wk-pile-row > span:first-child { font-size: 0.9375rem; font-weight: 700; line-height: 1.25; color: var(--ink); }
.wk-pile-row b { font: 600 1rem/1.2 var(--mono); color: var(--lift-ink); text-align: right; }
.wk-pile svg { display: block; width: 100%; height: auto; }
.wk-pile .wk-small { width: calc(100% / 46); min-width: 8px; }
.wk-pile .wk-five { width: calc(100% / 46 * 5); min-width: 42px; }
.wk-tile { fill: var(--lift); }
.wk-tall { display: none !important; }

/* ---------- The sort, as a path ---------- */
.wk-flow { margin: 0; display: grid; gap: 0; }
.wk-q { display: grid; grid-template-columns: minmax(0, 1fr) 4.5rem 7.5rem; align-items: center; }
.wk-q > span:first-child { padding: 13px 16px; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule); font-size: 1rem; font-weight: 600; line-height: 1.3; color: var(--ink); }
.wk-to { position: relative; height: 2px; background: var(--lift); font-size: 0.75rem; font-style: normal; font-weight: 700; color: var(--lift-ink); }
.wk-to::after { content: ""; position: absolute; right: 0; top: -4px; border-left: 7px solid var(--lift); border-block: 5px solid transparent; }
.wk-to span { position: absolute; left: 0; right: 7px; bottom: 5px; line-height: 1.2; text-align: center; }
.wk-out { padding: 10px 12px; border-radius: 12px; font-size: 0.9375rem; font-weight: 700; line-height: 1.2; text-align: center; background: var(--lift-tint); color: var(--lift-ink); box-shadow: inset 0 0 0 1px var(--lift); }
.wk-on { position: relative; height: 30px; margin-left: 28px; border-left: 2px solid #AEB5D6; font-size: 0.75rem; font-weight: 700; line-height: 30px; color: var(--ink-hint); }
.wk-on span { padding-left: 10px; }
.wk-end { justify-self: start; padding: 10px 18px; border-radius: 12px; background: #EFF0F6; font-size: 0.9375rem; font-weight: 700; color: var(--ink-2); }

/* ---------- The tool ----------
   The one dark surface in the reading column, the way the first article's code blocks anchor its page.
   This is where the reader stops reading and does the thing, so it should look like a different place. */
.wk-tool { padding: clamp(16px, 2.6vw, 26px); border-radius: 22px; background: var(--night); color-scheme: dark; display: grid; gap: 14px; min-width: 0; }
.a-body .wk-tool .fine { line-height: 1.5; color: var(--on-night-2); }
.wk-sets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 0.9375rem; color: var(--on-night); }

.wk-tool input, .wk-tool select {
  min-width: 0; width: 100%; padding: 0.6em 0.7em; border: 1px solid var(--night-line); border-radius: 10px;
  background: var(--night-2); color: var(--on-night); font: 500 1rem/1.3 var(--sans);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.wk-tool input::placeholder { color: var(--on-night-2); }
.wk-tool input[type="number"] { font-family: var(--mono); }
.wk-tool input:focus, .wk-tool select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 108, 248, 0.25); }
.wk-tool .wk-sets input { width: 3.6em; }

.wk-labels, .wk-row { display: grid; grid-template-columns: minmax(0, 1fr) 4.9rem 4.1rem 6.4rem 2.2rem; gap: 8px; align-items: center; }
.wk-labels { font-size: 0.75rem; font-weight: 700; color: var(--on-night-2); }
.wk-rows { display: grid; gap: 8px; }
.wk-row label { color: var(--on-night-2); }   /* hidden on wide screens, but a screen reader's text is still text on night */
.wk-x { width: 2.2rem; height: 2.2rem; border: 0; border-radius: 10px; background: none; color: var(--on-night-2); font: 600 1.25rem/1 var(--sans); cursor: pointer; }
.wk-x:hover { background: var(--night-line); color: var(--on-night); }
.wk-actions { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.wk-tool .wk-add { background: var(--primary); color: #fff; }
.wk-tool .wk-add:hover { background: var(--primary-deep); }
.wk-add { padding: 0.6em 1.05em; border: 0; border-radius: 999px; background: var(--primary-tint); color: var(--primary-deep); font: 700 0.9375rem/1.2 var(--sans); cursor: pointer; }
.wk-add:hover { background: #DFE4FD; }
.wk-text { padding: 0.2em 0; border: 0; background: none; color: var(--on-night); font: 600 0.9375rem/1.2 var(--sans); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.wk-text:hover { color: #fff; }
.wk-tool button:focus-visible, .wk-toggle:focus-visible, .wk-result button:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

/* These two set display, which would otherwise beat the hidden attribute. */
.wk-empty[hidden], .wk-result[hidden] { display: none; }
.wk-empty { padding: 16px 18px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule); font-size: 1rem; line-height: 1.5; color: var(--ink-hint); }

/* ---------- The ranking ---------- */
#wk-ranked { display: grid; gap: 16px; min-width: 0; }
.wk-sum { font-size: 1.0625rem; line-height: 1.5; color: var(--ink-2); }
.wk-sum b { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.wk-rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
.a-body .wk-rank { padding: 0; }
.wk-r { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr); gap: 2px 8px; }
.wk-rn { font: 600 0.875rem/1.5 var(--mono); color: var(--ink-hint); }
.wk-rt { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 14px; font-size: 1rem; line-height: 1.4; }
.wk-rt strong { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.wk-rt span { font: 500 0.8125rem/1.7 var(--mono); color: var(--ink-hint); white-space: nowrap; }
.wk-bar { grid-column: 2; display: flex; height: 10px; min-width: 3px; margin-top: 1px; overflow: hidden; border-radius: 3px; background: #D9DCEB; }
.wk-bar i { display: block; height: 100%; }
.wk-bar .is-back { background: var(--primary-deep); }
.wk-bar .is-leak { background: var(--lift); }
/* The sample before there is a list. Recomputed colours, not opacity: a house rule, and it stays legible. */
.is-ghost .wk-rt strong, .is-ghost .wk-rn { color: var(--ink-hint); font-weight: 500; }
.is-ghost .wk-bar { background: #E3E5EF; }

/* ---------- The sort list ---------- */
.wk-sort { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.a-body .wk-sort { padding: 0; }
.wk-s { display: grid; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule); }
.wk-sname { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: 1rem; line-height: 1.35; }
.wk-sname strong { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.wk-sname span { font: 500 0.8125rem/1.7 var(--mono); color: var(--ink-hint); white-space: nowrap; }
.wk-marks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.wk-marks button { min-height: 2.5rem; padding: 0.3em 0.2em; border: 0; border-radius: 10px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--rule); color: var(--ink-2); font: 700 0.875rem/1.15 var(--sans); cursor: pointer; transition: background-color 0.2s, box-shadow 0.2s, color 0.2s; }
.wk-marks button:hover { box-shadow: inset 0 0 0 2px #B5BAD2; }
.wk-marks button:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.wk-marks [aria-pressed="true"] { background: var(--lift-tint); box-shadow: inset 0 0 0 1px var(--lift); color: var(--lift-ink); }
.wk-marks .is-keep[aria-pressed="true"] { background: #E3E5EF; box-shadow: none; color: var(--ink); }
.wk-left { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.9375rem; line-height: 1.35; color: var(--ink-2); }
.wk-left input { width: 4.9rem; padding: 0.4em 0.6em; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); color: var(--ink); font: 500 1rem/1.3 var(--mono); }
.wk-left input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 108, 248, 0.25); }

/* ---------- The result ---------- */
.wk-result { padding: clamp(16px, 2.6vw, 24px); border-radius: 22px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule); display: grid; gap: 14px; min-width: 0; }
.wk-stack { display: flex; height: 22px; overflow: hidden; border-radius: 6px; background: #D9DCEB; }
.wk-stack i { display: block; height: 100%; }
.wk-stack .is-back { background: var(--primary-deep); }
.wk-stack .is-leak { background: var(--lift); }
.wk-first { font-size: 1.0625rem; line-height: 1.5; color: var(--ink); overflow-wrap: anywhere; }
/* This is the reader's own list, so all of it stays readable. Nothing scrolls away, on any width. */
.wk-result .a-code.is-tall pre { max-height: none; white-space: pre-wrap; overflow-wrap: anywhere; }
.wk-send { justify-self: start; }
.wk-sent { font-size: 0.9375rem; line-height: 1.5; color: var(--ink-hint); }

/* ---------- Phones: the week turns on its side ----------
   Five columns at 390 leave no room for a label, so the days become rows and the day reads left to
   right, 9:00 to 17:00. It is a different drawing of the same week, not a smaller one. */
@media (max-width: 640px) {
  .wk-fig { --wk-back: var(--primary); }   /* no labels here, so the shape has to carry it alone */
  .wk-grid { display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 8px; }
  .wk-axis { order: 0; height: 14px; margin: 0 0 0 38px; }
  .wk-axis span, .wk-axis span:nth-child(n) { top: 0; right: auto; transform: translateX(-50%); }
  .wk-axis span:nth-child(1) { left: 0; transform: none; }
  .wk-axis span:nth-child(2) { display: none; }
  .wk-axis span:nth-child(3) { left: 50%; }
  .wk-axis span:nth-child(4) { display: none; }
  .wk-axis span:nth-child(5) { left: auto; right: 0; transform: none; }
  .wk-day { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 6px; align-items: center; }
  .wk-d { height: auto; margin: 0; font-size: 0.625rem; letter-spacing: 0.08em; }
  .wk-track { height: 44px; background: repeating-linear-gradient(to right, var(--grid) 0 1px, transparent 1px 25%); }
  .wk-b { top: 0; bottom: 0; right: auto; height: auto; left: calc(var(--t) * 100% / 32); width: calc(var(--h) * 100% / 32 - 2px); border-radius: 4px; }
  .wk-t { display: none; }
  .wk-back { inset: 0 calc(var(--l) / var(--h) * 100%) 0 0; transform-origin: 0 50%; }
  .is-armed:not(.is-cut) .wk-back { transform: scaleX(0); }
  .wk-read b { font-size: 1.1875rem; }

  .wk-pile-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .wk-pile-row svg { grid-column: 1 / -1; grid-row: 2; }
  .wk-pile .wk-small { width: 8px; }
  .wk-pile .wk-five { width: 42px; }
  .wk-wide { display: none !important; }
  .wk-tall { display: block !important; }

  .wk-q { grid-template-columns: minmax(0, 1fr) 7rem; row-gap: 0; }
  .wk-q > span:first-child { grid-column: 1 / -1; }
  .wk-to { grid-column: 1; grid-row: 2; align-self: center; height: auto; margin-top: 6px; padding-right: 10px; background: none; text-align: right; }
  .wk-to::after { display: none; }
  .wk-to span { position: static; display: inline; }
  .wk-to span::after { content: " →"; }
  .wk-out { grid-column: 2; grid-row: 2; margin-top: 6px; }
  /* The Yes line has to leave from its question, so it runs up past the outcome beside it. */
  .wk-on { display: flex; align-items: flex-end; height: 74px; margin-top: -44px; line-height: 1.8; pointer-events: none; }

  .wk-labels { display: none; }
  /* Minutes and times hold a short number, and "a quarter" needs the room, so the columns are uneven.
     The remove button sits in the corner, beside the label line, where it costs no column. */
  .wk-row { position: relative; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.5fr); padding: 10px; border-radius: 14px; background: var(--night-2); }
  .wk-row .wk-name { grid-column: 1 / -1; }
  .wk-row input, .wk-row select { background: var(--night); }
  .wk-row select { padding-inline: 0.45em 0.2em; }
  .wk-row label { display: grid; gap: 3px; font-size: 0.75rem; font-weight: 700; color: var(--on-night-2); }
  .wk-x { position: absolute; top: 2px; right: 2px; }
  .wk-marks button { font-size: 0.8125rem; }
}
@media (max-width: 380px) {
  .wk-marks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 641px) {
  /* On wide screens the column headings name the fields, so the labels stay for screen readers only. */
  .wk-row label > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

@media (prefers-reduced-motion: reduce) {
  .wk-leak, .wk-back, .wk-t, .wk-toggle, .wk-marks button { transition: none; }
}
