/* /sop-with-ai: one SOP written four ways. event.css supplies the fonts, tokens, skip link, index,
   buttons and footer, and ai-time.css the sections, tables, catch, call to action and sources; this adds
   the time panel, the levels (each level's step count and board), the sticky tracker, the side-by-side
   table and the picker. Who does a step is one ordinal ramp, light to dark as the work moves from a
   person to AI (checked with the palette validator: monotone, one hue, light end 2.1:1 on white), and
   every mark carries its word. The owner is orange, the one step that never moves. Motion plays once
   and only with html.has-motion, which the script sets when motion is allowed, so without it every
   board is simply there, and print always shows the finished page. */
:root {
  --w-you: #9fb6c8;
  --w-chat: #4f9fcc;
  --w-ai: #00608a;
  --w-agent: #061525;
  --owner: #e05a26;
  --owner-bg: #fdeee7;
}

.sop .intro__sub + .intro__sub { margin-top: 10px; }

/* ------------------------------------------------------------- who does it */
/* .pill, not .who: the page header is header.who. */
.pill { display: inline-flex; align-items: center; justify-content: center; min-width: 4.75rem; padding: 3px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 700; line-height: 1.35; white-space: nowrap; }
.pill--you { background: var(--w-you); color: var(--ink); }
.pill--chat { background: var(--w-chat); color: var(--ink); }
.pill--ai { background: var(--w-ai); color: var(--white); }
.pill--agent { background: var(--w-agent); color: var(--white); }
.pill--owner { background: var(--owner-bg); color: var(--ink); box-shadow: inset 0 0 0 2px var(--owner); }

.legend--who { display: grid; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; font-size: .9375rem; color: var(--ink); }
.legend--who li { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); align-items: center; gap: 12px; }

/* The seven steps as one row of marks, with a 2px gap between them. */
.strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; }
.strip__cell { display: block; background: var(--w-you); }
.strip__cell--chat { background: var(--w-chat); }
.strip__cell--ai { background: var(--w-ai); }
.strip__cell--agent { background: var(--w-agent); }
.strip__cell--owner { background: var(--owner); }

/* ------------------------------------------------------------- the time */
.time { display: grid; gap: 12px; margin-top: 20px; padding: 18px; border: 1px solid var(--rule); border-radius: 16px; background: var(--card); }
.time__row { display: grid; grid-template-columns: 4.75rem minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.time__k { font-weight: 650; font-size: .9375rem; }
.time__track { height: 16px; border-radius: 0 4px 4px 0; background: var(--track); overflow: hidden; }
.time__fill { display: block; height: 100%; width: var(--w); border-radius: 0 4px 4px 0; }
.time__fill--alone { background: var(--alone); }
.time__fill--ai { background: var(--ai); }
.time__v { min-width: 6.25rem; font: 700 1.25rem/1.1 var(--display); font-variant-numeric: tabular-nums; text-align: right; }
.time__note { font-size: .875rem; color: var(--slate); }

/* ------------------------------------------------------------- the levels */
.levels { position: relative; }
.level h2 { display: grid; gap: 4px; }
.level__n { font: 700 .8125rem/1.2 var(--text); letter-spacing: .06em; text-transform: uppercase; color: var(--deep); }

.clock { margin-top: 18px; }
.clock__value { font: 700 clamp(2.4rem, 1.7rem + 3vw, 3.6rem)/1 var(--display); letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.clock__label { margin-top: 8px; max-width: 30rem; font-size: .9375rem; color: var(--slate); }

.board { margin-top: 22px; }
.board__head { display: grid; gap: 8px; margin: 0; }
.board__summary { font-weight: 700; font-size: .9375rem; }
.steps { margin: 12px 0 0; padding: 0; list-style: none; border: 1px solid var(--rule); border-radius: 14px; background: var(--card); overflow: hidden; }
.step { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name who" "what what"; align-items: center; gap: 4px 12px; padding: 11px 14px; border-top: 1px solid var(--rule); }
.step:first-child { border-top: 0; }
.step__name { grid-area: name; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-weight: 700; }
.step .pill { grid-area: who; justify-self: end; }
.step__what { grid-area: what; font-size: .9375rem; line-height: 1.45; color: var(--slate); }
.step.is-moved { box-shadow: inset 4px 0 0 var(--deep); }
.step__moved { padding: 1px 7px; border-radius: 4px; background: var(--sky); font-size: .75rem; font-weight: 700; letter-spacing: .02em; color: var(--ink); }
@media (min-width: 640px) {
  .step { grid-template-columns: 10.5rem 5.75rem minmax(0, 1fr); grid-template-areas: "name who what"; align-items: baseline; }
  .step__name { flex-wrap: nowrap; }
  .step .pill { justify-self: start; }
}

/* The tracker: the same seven marks, pinned under the index while you read the levels. */
.tracker { position: sticky; top: var(--index); z-index: 40; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "level summary" "strip strip"; align-items: baseline; gap: 6px 12px; margin-top: clamp(32px, 5vw, 48px); padding: 10px 0 12px; background: var(--paper); border-bottom: 1px solid var(--rule); }
.tracker[hidden] { display: none; }
.tracker__level { grid-area: level; font-weight: 750; font-size: .875rem; }
.tracker__summary { grid-area: summary; justify-self: end; font-size: .875rem; color: var(--slate); text-align: right; }
.strip--tracker { grid-area: strip; height: 10px; }
.levels:not(.is-staged) > .tracker:not([hidden]) + .level { padding-top: 28px; }
/* A jump to a level lands below the tracker too, not just below the index. */
.levels.is-tracking:not(.is-staged) > .level { scroll-margin-top: 64px; }
.levels.is-tracking .board__head .strip { display: none; }

/* ------------------------------------------------------------- where the work moved */
.moved th, .moved td { text-align: center; }
.moved thead th { white-space: normal; }
.moved td { padding: 8px 6px; }
.moved .pill { min-width: 0; width: 100%; padding-inline: 6px; }
@media (max-width: 599px) {
  .moved th[scope="row"], .moved thead th:first-child { min-width: 5.5rem; }
  .moved .pill { font-size: .75rem; padding-inline: 4px; }
}

/* ------------------------------------------------------------- your level */
.picker { display: grid; gap: 18px; margin-top: 20px; padding: 18px; border: 1px solid var(--rule); border-radius: 16px; background: var(--card); }
.picker fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.picker legend { padding: 0; font-weight: 700; }
.picker__options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.picker__option { position: relative; display: inline-flex; }
.picker__option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.picker__option span { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 15px; border: 1px solid #93a5b5; border-radius: 999px; background: var(--card); font-weight: 650; font-size: .9375rem; }
.picker__option input:checked + span { border-color: var(--navy); background: var(--navy); color: var(--white); }
.picker__option input:focus-visible + span { outline: 3px solid var(--deep); outline-offset: 2px; }
@media (hover: hover) { .picker__option:hover span { border-color: var(--deep); } }
.verdict { padding: 14px 16px; border-left: 4px solid var(--deep); border-radius: 0 12px 12px 0; background: var(--sky); }
.verdict p + p { margin-top: 6px; }
.rules { display: grid; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }
.rules li { padding: 14px 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); }
.rules strong { display: block; margin-bottom: 2px; }
.rules li.is-match { border-color: var(--deep); box-shadow: inset 4px 0 0 var(--deep); }
.part > .rules__after { margin-top: 14px; }
.rules__after strong { display: block; }

/* ------------------------------------------------------------- the wide layout (script only) */
/* On a wide, tall screen the levels break out of the column: text on the left, and one step board
   held in view on the right while GSAP hands each step over, level by level. The per-level boards
   stay in the page for screen readers; the held board is for the eye (aria-hidden). The script only
   holds the board when all seven steps fit on the screen. */
.levels.is-staged {
  display: grid; grid-template-columns: minmax(0, 1fr) 27rem; column-gap: 48px;
  width: min(1080px, 100vw - 2 * var(--gutter)); margin-inline: calc((100% - min(1080px, 100vw - 2 * var(--gutter))) / 2);
}
.levels.is-staged > .level { grid-column: 1; }
/* A short hold after level 4, so the board stays in view while its last level is read. */
.levels.is-staged::after { content: ""; grid-column: 1; grid-row: 5; height: 32vh; }
/* The wide layout is wider than the index, so the index's backing runs the full width. */
.sop .index { margin-inline: calc(50% - 50vw); padding-inline: calc(50vw - 50%); }
.levels.is-staged .tracker { display: none; }
.levels.is-staged .board { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stage { grid-column: 2; grid-row: 1 / span 5; align-self: start; position: sticky; top: calc(var(--index) + 20px); margin-top: clamp(48px, 7vw, 76px); padding: 14px; border: 1px solid var(--rule); border-radius: 18px; background: var(--card); box-shadow: 0 1px 2px rgba(6, 21, 37, .05), 0 30px 60px -40px rgba(6, 21, 37, .55); transform-origin: top center; }
.layers { display: grid; }
.layers > .layer { grid-area: 1 / 1; }
.stage__head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 12px; }
.stage__level .layer { background: var(--card); font-weight: 750; }
.stage__summary { justify-items: end; }
.stage__summary .layer { width: 100%; background: var(--card); font-size: .875rem; color: var(--slate); text-align: right; }
.strip--stage { margin-top: 8px; height: 10px; }
.stage__cell { height: 100%; }
.steps--stage { margin-top: 10px; }
.steps--stage .step { grid-template-columns: minmax(0, 1fr) 5.75rem; grid-template-areas: "name who" "what what"; align-items: center; gap: 2px 10px; padding: 8px 12px; }
.stage__who { grid-area: who; }
.stage__who .pill { width: 100%; min-width: 0; }
.stage__what { grid-area: what; font-size: .875rem; line-height: 1.4; color: var(--slate); }
.stage__what .layer { background: var(--card); }
.stage__what .step__moved { margin-right: 4px; }

/* ------------------------------------------------------------- motion */
/* Headings and paragraphs: paused keyframes that the observer starts once, when each is seen. */
@keyframes animationIn {
  from { opacity: 0; transform: translateY(30px); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
html.has-motion .animate-on-scroll { animation: animationIn .8s var(--ease) var(--delay, .05s) both; animation-play-state: paused; }
html.has-motion .animate-on-scroll.animate { animation-play-state: running; }
html.has-motion .animate-on-scroll.is-static { animation: none; }
html.has-motion [data-reveal] .step { opacity: 0; transform: translateY(14px); transition: opacity 600ms var(--ease) calc(var(--i) * 70ms), transform 600ms var(--ease) calc(var(--i) * 70ms); }
html.has-motion [data-reveal].is-in .step { opacity: 1; transform: none; }
html.has-motion [data-reveal].is-in .step.is-moved { animation: moved 1600ms var(--ease) calc(var(--i) * 70ms + 450ms) both; }
@keyframes moved { from { background: var(--sky); } to { background: var(--card); } }
html.has-motion [data-reveal] .strip__cell { transform: scaleX(0); transform-origin: left; transition: transform 500ms var(--ease) calc(var(--i) * 60ms); }
html.has-motion [data-reveal].is-in .strip__cell { transform: none; }
/* The with-AI bar starts at the by-hand length and shrinks once: by CSS without GSAP, by GSAP with it. */
html.has-motion:not(.has-gsap) [data-reveal] .time__fill--ai { width: var(--from); transition: width 1400ms var(--ease) 250ms; }
html.has-motion:not(.has-gsap) [data-reveal].is-in .time__fill--ai { width: var(--w); }
html.has-gsap .time__fill--ai { width: 100%; transform-origin: left center; }
html.has-motion [data-reveal] .moved td .pill { opacity: 0; transform: scale(.9); transition: opacity 500ms var(--ease) calc(var(--col) * 220ms + var(--row) * 30ms), transform 500ms var(--ease) calc(var(--col) * 220ms + var(--row) * 30ms); }
html.has-motion [data-reveal].is-in .moved td .pill { opacity: 1; transform: none; }
.tracker .strip__cell { transition: background-color 450ms var(--ease) calc(var(--i) * 50ms); }

@media (prefers-reduced-motion: reduce) {
  .tracker .strip__cell { transition: none; }
}
/* Print shows the finished page, whatever has or hasn't played on screen. */
@media print {
  .tracker, .picker, .stage { display: none !important; }
  .levels.is-staged { display: block; width: auto; margin-inline: 0; }
  .levels.is-staged .board { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
  html.has-motion .animate-on-scroll { animation: none !important; }
  html.has-motion [data-reveal] .step, html.has-motion [data-reveal] .moved td .pill { opacity: 1 !important; transform: none !important; animation: none !important; transition: none !important; }
  html.has-motion [data-reveal] .strip__cell, .time__fill { transition: none !important; }
  html.has-motion [data-reveal] .strip__cell { transform: none !important; }
  .time__fill { width: var(--w) !important; transform: none !important; }
  .time__fill--ai { background: var(--ai) !important; }
}
