/*
 * Home page poster: four scenes that play in turn (flow.js adds .is-active).
 * Each scene's animations run once while it is active; --d is its length and
 * keyframe percentages are of that length. Base styles are the end state, so
 * with reduced motion (no animation) each tab shows a finished still.
 */
@property --n {
  syntax: '<integer>';
  inherits: false;
  initial-value: 0;
}

.flow {
  --green: #16a34a;
  --orange: #f97316;
  --amber-bg: #fef3c7;
  --soft: #f5f5f4;
  margin: 2.5rem 0 1rem;
}
.flow-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0 0 0.75rem;
}
.flow-tabs button {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
.flow-tabs button[aria-selected='true'] {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}
.flow-tabs button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.stage {
  display: grid;
}
.scene {
  grid-area: 1 / 1;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.4s;
}
.scene.is-active {
  visibility: visible;
  opacity: 1;
}
.card {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 8px 24px -16px rgb(28 25 23 / 0.35);
  font-size: 0.875rem;
}
.who-view {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.875rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.who-view b {
  color: var(--ink);
}
.face {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex: none;
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
}
.face.sm {
  width: 1.375rem;
  height: 1.375rem;
  font-size: 0.625rem;
}
.f-emma {
  background: #be123c;
}
.f-maria {
  background: #7c3aed;
}
.f-kwame {
  background: #0891b2;
}
.f-nimali {
  background: #ca8a04;
}
.f-lukas {
  background: #4d7c0f;
}
.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.title {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
}
.goal {
  margin: 0.125rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.8125rem;
}
.sub {
  margin: 0 0 0.5rem;
  font:
    0.6875rem ui-monospace,
    'Cascadia Mono',
    Consolas,
    monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.pill {
  display: inline-grid;
  font:
    0.6875rem/1.6 ui-monospace,
    'Cascadia Mono',
    Consolas,
    monospace;
  white-space: nowrap;
}
.pill > span {
  grid-area: 1 / 1;
  padding: 0 0.45rem;
  border-radius: 0.25rem;
  text-align: center;
  opacity: 0;
}
.pill > span:last-child {
  opacity: 1;
}
.p-grey {
  background: var(--soft);
  color: var(--muted);
}
.p-blue {
  background: #e0e7ff;
  color: #3730a3;
}
.p-orange {
  background: #ffedd5;
  color: #9a3412;
}
.p-green {
  background: #dcfce7;
  color: #166534;
}
.p-amber {
  background: var(--amber-bg);
  color: #92400e;
}
.bar {
  height: 0.375rem;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}
.pct {
  text-align: right;
  font:
    0.8125rem ui-monospace,
    'Cascadia Mono',
    Consolas,
    monospace;
  counter-reset: n var(--n);
}
.pct::after {
  content: counter(n) '%';
}
.count {
  counter-reset: n var(--n);
}
.count::after {
  content: counter(n);
}
.total {
  display: grid;
  grid-template-columns: 1fr 3rem;
  align-items: center;
  gap: 0.75rem;
}
.rows {
  margin: 0.875rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.625rem;
}
.share {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) auto;
  grid-template-areas:
    'face name pill'
    'face bar pct'
    'extra extra extra';
  column-gap: 0.625rem;
  row-gap: 0.25rem;
  align-items: center;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  background: #fafaf9;
}
.share > .face {
  grid-area: face;
}
.share > .name {
  grid-area: name;
  font-weight: 600;
}
.share small {
  font-weight: 400;
  color: var(--muted);
}
.share > .pill {
  grid-area: pill;
}
.share > .bar {
  grid-area: bar;
}
.share > .pct {
  grid-area: pct;
  min-width: 2.75rem;
}
.share > .extra {
  grid-area: extra;
}
.btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}
.btn {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 0.375rem;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.75rem;
}
.btn.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}
.box {
  overflow: hidden;
  margin-top: 0.5rem;
  padding: 0.5rem 0.625rem;
  border-radius: 0.375rem;
  background: var(--amber-bg);
  font-size: 0.8125rem;
}
.box p,
.note p {
  margin: 0;
}
.note {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
}
.quote {
  color: var(--muted);
  font-style: italic;
  font-size: 0.75rem;
}
.stack {
  display: grid;
}
.stack > * {
  grid-area: 1 / 1;
}

/* scene 2: assignee */
.offer {
  padding: 0.75rem;
  border: 1px dashed #c7d2fe;
  border-radius: 0.5rem;
  background: #eef2ff;
  opacity: 0;
  visibility: hidden;
}
.offer p {
  margin: 0;
}
.ntrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 7rem 2.75rem;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0;
  font-size: 0.8125rem;
}
.ntrow .tag {
  margin-left: 0.375rem;
  padding: 0 0.375rem;
  border-radius: 0.25rem;
  background: var(--amber-bg);
  color: #92400e;
  font:
    0.625rem ui-monospace,
    'Cascadia Mono',
    Consolas,
    monospace;
  white-space: nowrap;
}
.prio {
  font:
    700 0.6875rem ui-monospace,
    'Cascadia Mono',
    Consolas,
    monospace;
  color: var(--brand);
}
.prio.low {
  font-weight: 400;
  color: var(--muted);
}
.quick {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #fafaf9;
  opacity: 0;
  visibility: hidden;
}
.quick p {
  margin: 0;
}
.slider {
  position: relative;
  height: 0.375rem;
  margin: 0.75rem 0.5rem;
  border-radius: 999px;
  background: #e7e5e4;
}
.slider > i {
  position: absolute;
  top: 50%;
  left: 60%;
  width: 1rem;
  height: 1rem;
  margin: -0.5rem 0 0 -0.5rem;
  border-radius: 50%;
  background: var(--brand);
}
.typed {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  background: #fff;
  font-size: 0.75rem;
}
.typed > span {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  max-width: 100%;
}

/* scene 4: report */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.tile {
  padding: 0.5rem 0.625rem;
  border-radius: 0.5rem;
  background: #fafaf9;
}
.tile .count {
  display: block;
  font-size: 1.375rem;
  font-weight: 700;
}
.tile small {
  font-size: 0.6875rem;
  color: var(--muted);
}
.t-green .count {
  color: var(--green);
}
.t-orange .count {
  color: var(--orange);
}
.t-red .count {
  color: #dc2626;
}
.people {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
}
.person {
  display: grid;
  grid-template-columns: 1.375rem 6.5rem minmax(0, 1fr) 2.75rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}
.person small {
  color: var(--muted);
}
.soon {
  font-size: 0.6875rem;
  padding: 0 0.45rem;
  border-radius: 0.25rem;
  background: var(--soft);
  color: var(--muted);
}
.caption {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
}
@media (max-width: 30rem) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ntrow {
    grid-template-columns: minmax(0, 1fr) auto 3.5rem 2.5rem;
  }
  .person {
    grid-template-columns: 1.375rem 4.5rem minmax(0, 1fr) 2.5rem;
  }
}

/* ---------------- animation (only with motion allowed) ---------------- */
@media (prefers-reduced-motion: no-preference) {
  .is-active * {
    animation-duration: var(--d);
    animation-fill-mode: both;
    animation-timing-function: linear;
  }
  @keyframes in {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  /* ---- scene 1: Emma assigns (11 s) ---- */
  #s-assign {
    --d: 11s;
  }
  #s-assign.is-active .share:nth-child(1) {
    animation-name: s1-in-a;
  }
  #s-assign.is-active .share:nth-child(2) {
    animation-name: s1-in-b;
  }
  @keyframes s1-in-a {
    0%,
    15% {
      opacity: 0;
      transform: translateX(-12px);
    }
    22%,
    100% {
      opacity: 1;
      transform: none;
    }
  }
  @keyframes s1-in-b {
    0%,
    28% {
      opacity: 0;
      transform: translateX(-12px);
    }
    35%,
    100% {
      opacity: 1;
      transform: none;
    }
  }
  #s-assign.is-active .head .pill > :first-child,
  #s-assign.is-active .share:nth-child(1) .pill > :first-child {
    animation-name: s1-before-60;
  }
  #s-assign.is-active .head .pill > :last-child,
  #s-assign.is-active .share:nth-child(1) .pill > :last-child {
    animation-name: s1-after-60;
  }
  #s-assign.is-active .share:nth-child(2) .pill > :first-child {
    animation-name: s1-before-70;
  }
  #s-assign.is-active .share:nth-child(2) .pill > :last-child {
    animation-name: s1-after-70;
  }
  @keyframes s1-before-60 {
    0%,
    59% {
      opacity: 1;
    }
    60%,
    100% {
      opacity: 0;
    }
  }
  @keyframes s1-after-60 {
    0%,
    59% {
      opacity: 0;
    }
    60%,
    100% {
      opacity: 1;
    }
  }
  @keyframes s1-before-70 {
    0%,
    69% {
      opacity: 1;
    }
    70%,
    100% {
      opacity: 0;
    }
  }
  @keyframes s1-after-70 {
    0%,
    69% {
      opacity: 0;
    }
    70%,
    100% {
      opacity: 1;
    }
  }

  /* ---- scene 2: Maria accepts and updates (13 s) ---- */
  #s-assignee {
    --d: 13s;
  }
  #s-assignee.is-active .offer {
    animation-name: s2-offer;
  }
  @keyframes s2-offer {
    0% {
      opacity: 0;
      visibility: visible;
    }
    5%,
    22% {
      opacity: 1;
      visibility: visible;
    }
    26%,
    100% {
      opacity: 0;
      visibility: hidden;
    }
  }
  #s-assignee.is-active .offer .btn.primary {
    animation-name: s2-press-accept;
  }
  @keyframes s2-press-accept {
    0%,
    16% {
      box-shadow: none;
      transform: none;
    }
    19% {
      box-shadow: 0 0 0 4px rgb(30 27 75 / 0.25);
      transform: scale(0.95);
    }
    22%,
    100% {
      box-shadow: none;
      transform: none;
    }
  }
  #s-assignee.is-active .list {
    animation-name: s2-row;
  }
  @keyframes s2-row {
    0%,
    24% {
      opacity: 0;
    }
    30%,
    100% {
      opacity: 1;
    }
  }
  #s-assignee.is-active .quick {
    animation-name: s2-quick;
  }
  @keyframes s2-quick {
    0%,
    34% {
      opacity: 0;
      visibility: hidden;
      transform: translateY(6px);
    }
    38%,
    82% {
      opacity: 1;
      visibility: visible;
      transform: none;
    }
    86%,
    100% {
      opacity: 0;
      visibility: hidden;
    }
  }
  #s-assignee.is-active .slider > i {
    animation-name: s2-thumb;
  }
  @keyframes s2-thumb {
    0%,
    40% {
      left: 0%;
    }
    52%,
    100% {
      left: 60%;
    }
  }
  #s-assignee.is-active .quick .count {
    animation-name: s2-val;
  }
  @keyframes s2-val {
    0%,
    40% {
      --n: 0;
    }
    52%,
    100% {
      --n: 60;
    }
  }
  #s-assignee.is-active .typed > span {
    animation-name: s2-type;
    animation-timing-function: steps(32, end);
  }
  @keyframes s2-type {
    0%,
    54% {
      max-width: 0;
    }
    72%,
    100% {
      max-width: 100%;
    }
  }
  #s-assignee.is-active .quick .btn.primary {
    animation-name: s2-press-save;
  }
  @keyframes s2-press-save {
    0%,
    75% {
      box-shadow: none;
      transform: none;
    }
    78% {
      box-shadow: 0 0 0 4px rgb(30 27 75 / 0.25);
      transform: scale(0.95);
    }
    81%,
    100% {
      box-shadow: none;
      transform: none;
    }
  }
  #s-assignee.is-active .ntrow.new .tag {
    animation-name: s2-tag;
  }
  @keyframes s2-tag {
    0%,
    84% {
      opacity: 0;
    }
    90%,
    100% {
      opacity: 1;
    }
  }

  /* ---- scene 3: Emma approves and asks for a revision (13 s) ---- */
  #s-review {
    --d: 13s;
  }
  #s-review.is-active .share:nth-child(1) .box {
    animation-name: s3-box;
  }
  @keyframes s3-box {
    0%,
    24% {
      opacity: 1;
      visibility: visible;
      max-height: 8rem;
      padding: 0.5rem 0.625rem;
    }
    28% {
      opacity: 0;
      max-height: 8rem;
      padding: 0.5rem 0.625rem;
    }
    32%,
    100% {
      opacity: 0;
      visibility: hidden;
      max-height: 0;
      padding: 0;
    }
  }
  #s-review.is-active .share:nth-child(1) .box .btn.primary {
    animation-name: s3-press-approve;
  }
  @keyframes s3-press-approve {
    0%,
    17% {
      box-shadow: none;
      transform: none;
    }
    20% {
      box-shadow: 0 0 0 4px rgb(30 27 75 / 0.25);
      transform: scale(0.95);
    }
    23%,
    100% {
      box-shadow: none;
      transform: none;
    }
  }
  #s-review.is-active .share:nth-child(1) .note {
    animation-name: s3-approved;
  }
  @keyframes s3-approved {
    0%,
    28% {
      opacity: 0;
    }
    32%,
    100% {
      opacity: 1;
    }
  }
  #s-review.is-active .share:nth-child(1) .bar > i {
    animation-name: s3-bar-a;
  }
  @keyframes s3-bar-a {
    0%,
    30% {
      width: 0;
    }
    40%,
    100% {
      width: 60%;
    }
  }
  #s-review.is-active .share:nth-child(1) .pct {
    animation-name: s3-n-a;
  }
  @keyframes s3-n-a {
    0%,
    30% {
      --n: 0;
    }
    40%,
    100% {
      --n: 60;
    }
  }
  #s-review.is-active .share:nth-child(2) .btns .btn {
    animation-name: s3-press-revise;
  }
  @keyframes s3-press-revise {
    0%,
    51% {
      box-shadow: none;
      transform: none;
    }
    54% {
      box-shadow: 0 0 0 4px rgb(30 27 75 / 0.25);
      transform: scale(0.95);
    }
    57%,
    100% {
      box-shadow: none;
      transform: none;
    }
  }
  #s-review.is-active .share:nth-child(2) .stack > :first-child {
    animation-name: s3-hide-btn;
  }
  @keyframes s3-hide-btn {
    0%,
    58% {
      opacity: 1;
      visibility: visible;
    }
    62%,
    100% {
      opacity: 0;
      visibility: hidden;
    }
  }
  #s-review.is-active .share:nth-child(2) .stack > :last-child {
    animation-name: s3-revision;
  }
  @keyframes s3-revision {
    0%,
    60% {
      opacity: 0;
    }
    66%,
    100% {
      opacity: 1;
    }
  }
  #s-review.is-active .share:nth-child(2) .pill > :first-child {
    animation-name: s3-done;
  }
  #s-review.is-active .share:nth-child(2) .pill > :last-child {
    animation-name: s3-rev;
  }
  @keyframes s3-done {
    0%,
    60% {
      opacity: 1;
    }
    61%,
    100% {
      opacity: 0;
    }
  }
  @keyframes s3-rev {
    0%,
    60% {
      opacity: 0;
    }
    61%,
    100% {
      opacity: 1;
    }
  }
  #s-review.is-active .share:nth-child(2) .bar > i {
    animation-name: s3-bar-b;
  }
  @keyframes s3-bar-b {
    0%,
    61% {
      width: 100%;
    }
    70%,
    100% {
      width: 80%;
    }
  }
  #s-review.is-active .share:nth-child(2) .pct {
    animation-name: s3-n-b;
  }
  @keyframes s3-n-b {
    0%,
    61% {
      --n: 100;
    }
    70%,
    100% {
      --n: 80;
    }
  }
  #s-review.is-active .total .bar > i {
    animation-name: s3-bar-t;
  }
  #s-review.is-active .total .pct {
    animation-name: s3-n-t;
  }
  @keyframes s3-bar-t {
    0%,
    30% {
      width: 40%;
    }
    40%,
    61% {
      width: 76%;
    }
    70%,
    100% {
      width: 68%;
    }
  }
  @keyframes s3-n-t {
    0%,
    30% {
      --n: 40;
    }
    40%,
    61% {
      --n: 76;
    }
    70%,
    100% {
      --n: 68;
    }
  }

  /* ---- scene 4: team report (9 s) ---- */
  #s-report {
    --d: 9s;
  }
  #s-report.is-active .tile {
    animation-name: in;
    animation-duration: 0.6s;
  }
  #s-report.is-active .tile:nth-child(2) {
    animation-delay: 0.15s;
  }
  #s-report.is-active .tile:nth-child(3) {
    animation-delay: 0.3s;
  }
  #s-report.is-active .tile:nth-child(4) {
    animation-delay: 0.45s;
  }
  #s-report.is-active .count {
    animation-name: s4-count;
    animation-duration: 2s;
    animation-timing-function: ease-out;
  }
  @keyframes s4-count {
    from {
      --n: 0;
    }
  }
  #s-report.is-active .person .bar > i {
    animation-name: s4-bar;
    animation-duration: 2.4s;
    animation-delay: 0.6s;
    animation-timing-function: ease-out;
  }
  @keyframes s4-bar {
    from {
      width: 0;
    }
  }
  #s-report.is-active .person .pct {
    animation-name: s4-count;
    animation-duration: 2.4s;
    animation-delay: 0.6s;
    animation-timing-function: ease-out;
  }
}

/* Task hierarchy chart: wider than the text column, scrolls sideways on phones. */
.hier {
  position: relative;
  left: 50%;
  width: min(70rem, calc(100vw - 2rem));
  transform: translateX(-50%);
  margin: 3rem 0 1rem;
}
.hier h2,
.hier > p {
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
}
.hier h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}
.hier-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fafaf9;
}
.hier-scroll img {
  display: block;
  width: 100%;
  min-width: 760px;
  height: auto;
}
