/* =============================================================================
 * story.css — the interior pages, in the operating system's dress.
 *
 * "A Tuesday" and "The work" carry direction C's argument: the day-arc narrative,
 * the margin tally, and the gaps printed at the same size as the wins. Nothing in
 * this file introduces a colour, a face, a radius or a shadow. Every value below
 * resolves through os.css's tokens, so both grounds are inherited rather than
 * restated — the paper stretch of the day re-tokenises the tally, the specimens,
 * the pin and the honest blocks with no rule of their own.
 *
 * Three things here do not exist in site.css because the home page has no use for
 * them: the margin tally, the pin at 11:58, and the honest block.
 * ========================================================================== */

/* =============================================================================
 * 1. THE MARGIN TALLY — direction C's signature, in this system's material.
 *
 * A glass panel that keeps the count of what is still open. It is not a scroll
 * indicator: every line in it is a thing the day put there, and the day takes them
 * back after the turn. It carries the ground it is over, exactly as the top bar
 * and the rail do, which is how it stays part of the chrome rather than an
 * ornament parked beside it.
 * ========================================================================== */

.tally {
  position: fixed;
  z-index: 35;
  right: clamp(12px, 1.6vw, 22px);
  top: 86px;
  width: 244px;
  max-height: calc(100vh - 120px);
  display: none;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  color: var(--ink);
  border-radius: var(--radius-card);
  -webkit-backdrop-filter: var(--frost-filter);
  backdrop-filter: var(--frost-filter);
  background-color: var(--frost);
  background-image: var(--frost-gradient);
  border: 1px solid var(--frost-line);
  border-top-color: var(--frost-line-top);
  border-bottom-color: var(--frost-line-bottom);
  box-shadow: var(--frost-shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.tally.is-live {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.tally-clock {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--micro);
}

.tally-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0;
}

.tally-head span:first-child {
  font-family: var(--mono);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--micro);
}

.tally-count {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--bright);
}

.tally[data-state='clear'] .tally-count {
  color: var(--ok);
}

.tally-list {
  list-style: none;
  margin: 0;
  padding: var(--space-0) var(--space-3);
  overflow-y: auto;
  background: var(--floor);
  border: 1px solid var(--floor-line);
  border-top-color: var(--floor-line-top);
  border-radius: var(--radius-floor);
  box-shadow: inset 0 1.5px 3px rgb(0 0 0 / 0.32);
}

[data-ground='paper'] .tally-list {
  box-shadow: inset 0 1px 2px rgb(58 48 26 / 0.05);
}

.tally-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: var(--space-2);
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--floor-line);
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.tally-item:first-child {
  border-top: 0;
}

.tally-item i {
  font-family: var(--mono);
  font-style: normal;
  font-size: var(--t-micro);
  color: var(--micro);
}

/*
 * A row arrives with an animation rather than with a class that has to be taken off
 * it again. The class-off version left rows stuck at opacity 0 when the removal frame
 * and the render raced — an entrance that can fail closed hides the argument.
 */
.tally-item.is-new {
  animation: tally-in 0.34s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes tally-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Cleared is shown, not removed on the spot: the point of the afternoon is that a
   line you watched arrive is the same line going out. */
.tally-item.is-done {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--ok);
  text-decoration-thickness: 2px;
}

.tally-empty {
  padding: 10px 0;
  font-size: 12.5px;
  color: var(--muted);
}

.tally-toggle {
  display: none;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.tally-toggle .tally-count {
  margin-left: auto;
  font-size: 20px;
}

.tally-chev {
  font-family: var(--mono);
  color: var(--micro);
  transition: transform 0.2s ease;
}

.tally[data-open='yes'] .tally-chev {
  transform: rotate(180deg);
}

/* the same panel doing its other job on "The work": an index of the page */
.tally-item--link a {
  color: var(--ink);
  text-decoration: none;
}

.tally-item--link a:hover {
  color: var(--accent);
}

.tally-item--link.is-here {
  color: var(--ink);
}

.tally-item--link.is-here i {
  color: var(--bright);
}

.tally-item--link.is-here a {
  color: var(--bright);
}

/* Under 1200px there is no margin to live in, so the panel docks to the bottom of
   the viewport as a bar that opens. It never becomes a thing you cannot reach. */
@media (min-width: 1200px) {
  .tally {
    display: flex;
  }
  /*
   * The shell is already inset on the left by the rail's width. Where the tally is a
   * margin panel it gets the same treatment on the right, so it sits BESIDE the page
   * rather than over it — measured: without this the pin list and the relief columns
   * ran under it at 1440.
   */
  .shell {
    padding-right: 272px;
  }
  /* and the paper band bleeds back out under the panel, for the reason site.css
     gives for bleeding it under the rail: the ground cannot change everywhere
     except beneath the thing reporting the change */
  .inverted {
    margin-right: -272px;
    padding-right: 272px;
  }
}

@media (max-width: 1199px) {
  .tally {
    display: flex;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-height: none;
    padding: var(--space-2) clamp(14px, 4vw, 28px) calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
    border-radius: var(--radius-card) var(--radius-card) 0 0;
    gap: var(--space-2);
  }
  .tally-clock,
  .tally-head {
    display: none;
  }
  .tally-toggle {
    display: flex;
  }
  .tally-list {
    display: none;
    max-height: 46vh;
  }
  .tally[data-open='yes'] .tally-list {
    display: block;
  }
  /* the docked panel sits over the page, so the last thing on it gets room */
  .foot {
    padding-bottom: 92px;
  }
}

/* =============================================================================
 * 2. THE STORY PAGE'S TYPE FURNITURE
 * ========================================================================== */

/* the clock mark that opens every scene. Mono, because the day is instrumentation. */
.stamp {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--micro);
}

.scene {
  padding: clamp(56px, 7vw, 104px) 0;
  position: relative;
}

.scene + .scene {
  border-top: 1px solid var(--line);
}

.scene-grid {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 46px);
  align-items: start;
}

.scene-time {
  font-family: var(--display);
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  position: sticky;
  top: 96px;
}

.scene-time span {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--micro);
}

.scene-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 68ch;
}

.scene-body > .body + .body {
  margin-top: 0;
}

/* the one line of a scene that carries it, set as display type on the open ground */
.pull {
  font-family: var(--display);
  font-size: clamp(21px, 2.2vw, 30px);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.025em;
  color: var(--ink);
  max-width: 24ch;
  padding-left: var(--space-5);
  border-left: 3px solid var(--bright);
}

/* a specimen card: the product's own card material, holding somebody else's mess */
.spec {
  max-width: 430px;
}

.spec .row-tag {
  font-family: var(--mono);
}

/* =============================================================================
 * 3. THE DESK AT 6:40 — depth, and nothing that has to load
 * ========================================================================== */

.desk-hero {
  padding: clamp(48px, 6vw, 88px) 0 clamp(60px, 7vw, 104px);
  position: relative;
  overflow: hidden;
}

.desk-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr);
  gap: clamp(28px, 3.4vw, 52px);
  align-items: center;
}

.desk-copy {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 640px;
}

.desk-hero h1 .accent-line span {
  color: var(--bright);
}

.desk {
  position: relative;
  min-height: 480px;
}

.desk-item {
  transform: translate3d(var(--px, 0px), var(--py, 0px), 0);
  will-change: transform;
}

@media (min-width: 1081px) {
  .desk-item {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: min(340px, 78%);
  }
}

.desk-note {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius);
  background: var(--well);
  color: var(--ink);
  box-shadow: var(--elev-2);
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
  transform: translate3d(var(--px, 0px), var(--py, 0px), 0) rotate(-3deg);
}

.desk-note span {
  display: block;
  margin-top: 4px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 400;
  color: var(--micro);
}

.desk-cue {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--mono);
  font-size: var(--t-small);
  color: var(--micro);
}

.desk-cue b {
  font-family: var(--display);
  font-size: 21px;
  color: var(--ink);
}

.desk-cue .arrow {
  animation: cue-drop 2.4s ease-in-out infinite;
}

@keyframes cue-drop {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(5px);
  }
}

/* =============================================================================
 * 4. 11:58 — THE PIN.
 *
 * The one place on the site where the page holds still and the content moves. It
 * is the argument: ten ordinary items are not ten problems until they are all
 * open at once, and a list you scroll past does not feel like that. Under 1080px
 * and with motion off it is an ordinary section with every item already there.
 * ========================================================================== */

.pin-track {
  position: relative;
}

.pin-stage {
  padding: clamp(56px, 7vw, 96px) 0;
}

.pin-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: clamp(24px, 3vw, 38px);
  max-width: 780px;
}

.pin-list {
  list-style: none;
  margin: 0 0 var(--space-6);
  padding: var(--space-0) var(--space-4);
  background: var(--floor);
  border: 1px solid var(--floor-line);
  border-top-color: var(--floor-line-top);
  border-radius: var(--radius-floor);
  box-shadow: inset 0 1.5px 3px rgb(0 0 0 / 0.32);
}

.pin-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: baseline;
  padding: 11px 0;
  border-top: 1px solid var(--floor-line);
}

.pin-item:first-child {
  border-top: 0;
}

.pin-item i {
  font-family: var(--mono);
  font-style: normal;
  font-size: var(--t-micro);
  color: var(--micro);
}

.pin-what {
  font-size: var(--t-body);
  font-weight: 700;
  color: var(--ink);
}

/*
 * `--micro`, not `--warn`. Measured off the rendered pixels, 12px --warn on this
 * floor where the aurora is behind it came out at 2.60:1. The lateness is in the
 * words ("since March"), so the fix is the ink rather than the material under it.
 */
.pin-since {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--micro);
  white-space: nowrap;
}

@media (min-width: 1081px) {
  .pin-track {
    height: 240vh;
  }
  .pin-stage {
    position: sticky;
    top: 62px;
    min-height: calc(100vh - 62px);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .pin-item {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
      transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .pin-item.is-up {
    opacity: 1;
    transform: none;
  }
  .pin-note {
    opacity: 0;
    transition: opacity 0.5s ease;
  }
  .is-full .pin-note {
    opacity: 1;
  }
}

/* =============================================================================
 * 5. THE TURN, AND THE RELIEF BEATS
 *
 * The ground inverts at 1:20 p.m. That is not a section topic changing — it is the
 * argument turning, carried by the mechanism the home page already uses for it.
 * ========================================================================== */

.turn-rule {
  height: 1px;
  background: linear-gradient(90deg, var(--bright), var(--accent), transparent);
  margin-bottom: var(--space-6);
}

.relief-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--micro);
}

.relief-back::before {
  content: '↑';
  color: var(--bright);
}

.holds {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.holds li {
  position: relative;
  padding-left: 26px;
  font-size: var(--t-body);
  color: var(--ink);
}

.holds li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 12px;
  height: 2px;
  border-radius: var(--radius-pill);
  background: var(--accent);
}

.holds-label,
.honest-label {
  display: block;
  margin-bottom: var(--space-3);
  font-family: var(--mono);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--micro);
}

/*
 * THE HONEST BLOCK.
 *
 * Direction C's move, kept whole: the gap is printed in the same type size as the
 * thing that works, on the same material, in the reading column rather than in a
 * footnote. The only difference from a card holding a win is the rule across the
 * top, which is the same cut the ground inversion uses.
 */
.honest {
  position: relative;
  margin-top: var(--space-5);
  padding: var(--space-5);
  border-radius: var(--radius-card);
  overflow: hidden;
  -webkit-backdrop-filter: var(--frost-filter);
  backdrop-filter: var(--frost-filter);
  background-color: var(--frost);
  background-image: var(--frost-gradient);
  border: 1px solid var(--frost-line);
  border-top-color: var(--frost-line-top);
  border-bottom-color: var(--frost-line-bottom);
  box-shadow: var(--frost-shadow);
}

.honest::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--bright), var(--accent));
}

/*
 * The label keeps `--micro` on both grounds. `--bright` measured 3.44:1 on the paper
 * glass and 4.10:1 on the ink glass at 11.5px — under the bar either way. The bright
 * is spent on the rule above instead, where it is a 3px band rather than 11.5px caps.
 */
.honest .honest-label {
  color: var(--micro);
}

.honest p {
  font-size: var(--t-body);
  color: var(--ink);
  max-width: 56ch;
}

/* the way from a relief beat onto the set-piece that proves it */
.beat-link {
  margin-top: var(--space-5);
}

/* =============================================================================
 * 6. "THE WORK" — eight jobs, each with its own gap next to its own wins
 * ========================================================================== */

.job {
  padding: clamp(48px, 6vw, 84px) 0;
}

.job + .job {
  border-top: 1px solid var(--line);
}

.job-grid {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 46px);
  align-items: start;
}

.job-idx {
  font-family: var(--display);
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--edge);
  font-variant-numeric: tabular-nums;
  position: sticky;
  top: 96px;
}

.job-when {
  display: block;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--micro);
}

.job-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(22px, 2.6vw, 40px);
  margin-top: var(--space-6);
  align-items: start;
}

.job-cols .honest {
  margin-top: 0;
}

/* =============================================================================
 * 7. RESPONSIVE
 * ========================================================================== */

@media (max-width: 1080px) {
  .desk-grid,
  .job-cols {
    grid-template-columns: minmax(0, 1fr);
  }
  .desk {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }
  .desk-item {
    transform: none;
    width: 100%;
    max-width: 460px;
  }
  .desk-note {
    transform: rotate(-2deg);
    align-self: flex-start;
  }
}

@media (max-width: 820px) {
  .scene-grid,
  .job-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }
  .scene-time,
  .job-idx {
    position: static;
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
  }
  .scene-time span,
  .job-when {
    margin-top: 0;
  }
  .pull {
    max-width: none;
  }
}

/* =============================================================================
 * 8. GLASS OFF — site.css does this for the card and the top bar; the two pieces
 *    this file adds that are made of the same material need the same fallback.
 *    UNVERIFIED: no browser here can emulate this preference.
 * ========================================================================== */

@media (prefers-reduced-transparency: reduce) {
  .tally,
  .honest {
    background-color: var(--surface);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .tally-list,
  .pin-list {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* =============================================================================
 * 9. MOTION OFF — everything above resolves to its finished state.
 *    The pin becomes an ordinary section with all ten items showing.
 * ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .tally {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .tally-item,
  .tally-item.is-new {
    opacity: 1;
    transform: none;
    transition: none;
    animation: none;
  }
  .desk-cue .arrow {
    animation: none;
  }
  .desk-item,
  .desk-note {
    transform: none !important;
  }
  .pin-track {
    height: auto;
  }
  .pin-stage {
    position: static;
    min-height: 0;
  }
  .pin-item {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .pin-note {
    opacity: 1;
  }
}
