/* Forthwright: the A3 report. One sheet pinned to a steel obeya wall.
   Ink set: graphite (structure), ballpoint blue (action), red pen (corrections only). */

@font-face {
  font-family: "Archivo";
  src: url("/assets/fonts/archivo-variable.woff2") format("woff2-variations"),
       url("/assets/fonts/archivo-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --wall: #d9dbd6;
  --sheet: #fdfdfb;
  --graphite: #22252a;
  --graphite-soft: #4a4f57;
  --rule: #22252a;
  --rule-light: #b9bcb6;
  --blue: #1d45b0;
  --blue-deep: #142f7a;
  --blue-wash: #e8edfa;
  --red: #c4261d;

  --rule-w: 1.5px;
  --pad: clamp(1rem, 2.2vw, 1.75rem);
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--wall);
  color: var(--graphite);
  font-family: var(--font);
  font-size: 100%;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--graphite-soft) var(--wall);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(0.75rem, 3vw, 2.5rem);
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--blue); color: #fff; }

a {
  color: var(--blue);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}
a:hover { color: var(--blue-deep); }

:focus-visible {
  outline: 2.5px solid var(--blue);
  outline-offset: 3px;
}

.nowrap { white-space: nowrap; }

/* ---------- The sheet ---------- */

.sheet {
  max-width: 88rem;
  margin: 0 auto;
  background: var(--sheet);
  border: var(--rule-w) solid var(--rule);
  box-shadow: 0 1px 2px rgba(34, 37, 42, 0.12), 0 12px 32px -12px rgba(34, 37, 42, 0.28);
}

/* ---------- Title block ---------- */

.titleblock {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(0, 3.2fr) minmax(16rem, 1.25fr);
  grid-template-areas:
    "mark theme action"
    "fields fields fields";
  border-bottom: calc(var(--rule-w) * 2) solid var(--rule);
}

.wordmark {
  grid-area: mark;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: var(--pad);
  border-right: var(--rule-w) solid var(--rule);
  color: var(--graphite);
  text-decoration: none;
  font-weight: 800;
  font-stretch: 85%;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.wordmark:hover { color: var(--blue); }
.wordmark__mark { width: 1.6rem; height: 1.6rem; flex: none; }

.field-label,
.titleblock__fields dt,
.box__title,
.table thead th,
.table caption {
  font-stretch: 72%;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--graphite-soft);
}

.titleblock__theme {
  grid-area: theme;
  padding: var(--pad) clamp(1.25rem, 3vw, 2.75rem) calc(var(--pad) * 1.4);
  border-right: var(--rule-w) solid var(--rule);
}

.titleblock__theme h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(2.6rem, 6.4vw, 5.75rem);
  line-height: 0.95;
  font-weight: 800;
  font-stretch: 78%;
  letter-spacing: -0.025em;
  text-wrap: balance;
  color: var(--graphite);
}

.titleblock__lede {
  margin: 1.1rem 0 0;
  max-width: 52ch;
  font-size: clamp(1.05rem, 1.35vw, 1.2rem);
  color: var(--graphite);
}

.titleblock__action {
  grid-area: action;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  padding: var(--pad);
}
.titleblock__mail { font-size: 0.95rem; }
.titleblock__nav {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  font-weight: 600;
  font-stretch: 85%;
}
.titleblock__nav a { color: var(--graphite); text-decoration: none; }
.titleblock__nav a:hover { color: var(--blue); text-decoration: underline; }

.titleblock__fields {
  grid-area: fields;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border-top: var(--rule-w) solid var(--rule);
}
.titleblock__fields div {
  padding: 0.6rem var(--pad) 0.7rem;
  border-right: var(--rule-w) solid var(--rule);
}
.titleblock__fields div:last-child { border-right: 0; }
.titleblock__fields dt { font-size: 0.72rem; }
.titleblock__fields dd {
  margin: 0.1rem 0 0;
  font-weight: 600;
  font-size: 0.98rem;
}

.tick {
  width: 0.95em;
  height: 0.95em;
  margin-right: 0.35rem;
  vertical-align: -0.12em;
  fill: none;
  stroke: var(--blue);
  stroke-width: 2.25;
}

/* A3 sheet fields: issued / revision / sheet */
.titleblock__sheet {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: 0 1.5rem;
  margin: 0.75rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule-light);
}
.titleblock__sheet dt {
  font-stretch: 72%;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--graphite-soft);
}
.titleblock__sheet dd { margin: 0.1rem 0 0; font-weight: 600; font-size: 0.95rem; }

/* ---------- Buttons: ballpoint ink ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.15rem 0.85rem;
  background: var(--blue);
  color: #fff;
  border: var(--rule-w) solid var(--blue-deep);
  font-weight: 700;
  font-stretch: 90%;
  font-size: 1.02rem;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 160ms cubic-bezier(0.22, 1, 0.36, 1), transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}
.btn::after {
  content: "";
  width: 0.9em;
  height: 0.9em;
  flex: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8h11M9 3.5 13.5 8 9 12.5' fill='none' stroke='black' stroke-width='2'/%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 16 16'%3E%3Cpath d='M2 8h11M9 3.5 13.5 8 9 12.5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}
.btn:hover { background: var(--blue-deep); color: #fff; }
.btn:hover::after { transform: translateX(3px); }
.btn:active { transform: translateY(1px); }
.btn--large { font-size: clamp(1.05rem, 1.6vw, 1.3rem); padding: 1rem 1.4rem 1.05rem; }

/* ---------- A3 body ---------- */

.a3 {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.a3__half { display: flex; flex-direction: column; }
.a3__half + .a3__half { border-left: calc(var(--rule-w) * 2) solid var(--rule); }

.box {
  padding: calc(var(--pad) * 0.9) var(--pad) calc(var(--pad) * 1.3);
  border-bottom: var(--rule-w) solid var(--rule);
  scroll-margin-top: 1rem;
}
.a3__half .box:last-child { flex: 1; border-bottom: 0; }

.box__title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.1rem;
  font-size: 0.85rem;
  color: var(--graphite);
}
.box__no {
  display: inline-grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  border: var(--rule-w) solid var(--rule);
  font-stretch: 85%;
  font-size: 0.82rem;
  letter-spacing: 0;
}
.box__subtitle {
  margin: 1.75rem 0 0.5rem;
  font-size: 0.8rem;
  font-stretch: 72%;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--graphite-soft);
}

.box p { margin: 0 0 0.85rem; max-width: 64ch; }
.box p:last-child { margin-bottom: 0; }
.box__lead { font-weight: 600; }

.ticks { margin: 0; padding: 0; list-style: none; }
.ticks li {
  position: relative;
  padding: 0.5rem 0 0.5rem 1.6rem;
  border-top: 1px solid var(--rule-light);
}
.ticks li:first-child { border-top: 0; padding-top: 0; }
.ticks li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 0.95em;
  width: 0.7rem;
  height: 2px;
  background: var(--graphite);
}
.ticks li:first-child::before { top: 0.75em; }

/* Root cause: five whys */
.whys { margin: 0; padding: 0; list-style: none; counter-reset: why; }
.whys li {
  display: grid;
  grid-template-columns: minmax(9.5rem, 0.9fr) 2fr;
  gap: 0.25rem 1rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--rule-light);
}
.whys li:first-child { border-top: 0; padding-top: 0; }
.whys li > b {
  font-weight: 700;
  font-stretch: 85%;
}
.annotation {
  margin-top: 1rem !important;
  color: var(--blue);
  font-weight: 600;
  font-stretch: 92%;
}

/* The one red-pen correction on the sheet: the words stay graphite; the pen circles them. */
mark.redpen {
  position: relative;
  display: inline-block;
  margin: 0 1.05em;
  background: none;
  color: inherit;
  white-space: nowrap;
}
mark.redpen svg {
  position: absolute;
  left: -1.15em;
  top: -0.75em;
  width: calc(100% + 2.3em);
  height: calc(100% + 1.5em);
  overflow: visible;
  pointer-events: none;
  transform: rotate(-2deg);
}
.redpen__ink { fill: var(--red); }
.redpen__reveal {
  fill: none;
  stroke: #fff;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 520;
  stroke-dashoffset: 0;
}
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .redpen__reveal {
      animation: redpen linear both;
      animation-timeline: view();
      animation-range: entry 60% cover 45%;
    }
  }
}
@keyframes redpen {
  from { stroke-dashoffset: 520; }
  to { stroke-dashoffset: 0; }
}

/* Target chart */
.chart { margin: 1.25rem 0 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart__grid line { stroke: var(--graphite); stroke-width: 1.5; }
.chart__phases line { stroke: var(--rule-light); stroke-width: 1; stroke-dasharray: 3 4; }
.chart__phases text,
.chart__axis {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  font-stretch: 85%;
  fill: var(--graphite-soft);
  text-anchor: middle;
}
.chart__axis { text-anchor: end; }
.chart__target { stroke: var(--blue); stroke-width: 1.5; stroke-dasharray: 7 5; }
.chart__target-label {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  fill: var(--blue);
}
.chart__line {
  fill: none;
  stroke: var(--graphite);
  stroke-width: 2.25;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart figcaption {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--graphite-soft);
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}
.table caption {
  text-align: left;
  padding-bottom: 0.4rem;
}
.table thead th {
  text-align: left;
  padding: 0 0.9rem 0.45rem 0;
  border-bottom: var(--rule-w) solid var(--rule);
  font-size: 0.72rem;
}
.table tbody th,
.table td {
  text-align: left;
  vertical-align: top;
  padding: 0.75rem 0.9rem 0.75rem 0;
  border-bottom: 1px solid var(--rule-light);
}
.table tbody th {
  width: 36%;
  font-weight: 700;
  font-stretch: 88%;
  font-size: 1.04rem;
  line-height: 1.3;
}
.table tbody tr:last-child > * { border-bottom: 0; }

.table--log { margin-top: 1.25rem; font-size: 0.92rem; }
.table--log thead th { width: auto; }
.table--log .pending td {
  padding: 1rem 0.9rem;
  color: var(--graphite-soft);
  background: repeating-linear-gradient(-45deg, transparent 0 7px, rgba(34, 37, 42, 0.045) 7px 8px);
  border: 1px dashed var(--rule-light);
}

/* Implementation plan: Gantt rows on a 12-column week grid */
.gantt {
  --cols: 12;
  margin: 1.25rem 0 0;
  padding: 0.25rem 0 0;
  list-style: none;
  display: grid;
  gap: 0.6rem;
}
.gantt li {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}
.gantt li > * { grid-column: var(--from) / var(--to); }
.gantt strong {
  display: block;
  padding: 0.35rem 0.6rem 0.1rem;
  background: var(--blue-wash);
  border: var(--rule-w) solid var(--blue);
  border-bottom: 0;
  color: var(--blue-deep);
  font-stretch: 85%;
  font-size: 0.95rem;
}
.gantt span {
  display: block;
  padding: 0 0.6rem 0.4rem;
  background: var(--blue-wash);
  border: var(--rule-w) solid var(--blue);
  border-top: 0;
  font-size: 0.88rem;
  line-height: 1.35;
}
.gantt__report strong,
.gantt__report span {
  background: var(--sheet);
  border-color: var(--graphite);
  border-style: dashed;
  color: var(--graphite);
}

.gantt__decisions {
  --cols: 12;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  margin: 0.5rem 0 0;
  padding: 0.6rem 0 0;
  list-style: none;
  border-top: var(--rule-w) solid var(--rule);
}
.gantt__decisions li {
  grid-row: 1;
  grid-column-start: span 1;
  grid-column-end: var(--at);
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  margin-top: -1.05rem;
  font-size: 0.78rem;
  font-weight: 700;
  font-stretch: 80%;
  color: var(--graphite-soft);
}
.gantt__decisions li::before,
.gantt__diamond {
  content: "";
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  background: var(--graphite);
  transform: rotate(45deg);
}
.gantt__decisions li::before { margin-right: -0.35rem; }
.gantt__legend {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem !important;
  font-size: 0.9rem;
  color: var(--graphite-soft);
}

/* References */
.refs { margin: 0; padding: 0; list-style: none; }
.refs li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.1rem 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--rule-light);
}
.refs li:first-child { border-top: 0; }
.refs a { font-weight: 600; }
.refs time { color: var(--graphite-soft); font-size: 0.9rem; }

/* ---------- Approval (footer) ---------- */

.approval {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem 2rem;
  padding: calc(var(--pad) * 1.2) var(--pad);
  border-top: calc(var(--rule-w) * 2) solid var(--rule);
}
.approval h2 {
  margin: 0;
  max-width: 30ch;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  line-height: 1.15;
  font-weight: 750;
  font-stretch: 82%;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--graphite);
}
.approval__signoff {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  min-width: min(100%, 22rem);
}
.approval__fields {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1.25rem;
  margin: 0;
}
.approval__fields dt {
  font-stretch: 72%;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--graphite-soft);
}
.approval__fields dd {
  height: 1.9rem;
  margin: 0;
  border-bottom: var(--rule-w) solid var(--rule);
}
.approval__rev {
  grid-column: 1 / -1;
  margin: 0.75rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--rule-light);
  font-size: 0.82rem;
  color: var(--graphite-soft);
}

/* ---------- Site bar (pages other than home) ---------- */

.sitebar {
  max-width: 52rem;
  margin: 0 auto 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}
.sitebar .wordmark { padding: 0.25rem 0; border: 0; }
.sitebar nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-weight: 600; font-stretch: 90%; }
.sitebar nav a { color: var(--graphite); text-decoration: none; }
.sitebar nav a:hover { color: var(--blue); text-decoration: underline; }

/* ---------- Error sheet ---------- */

.errsheet {
  max-width: 40rem;
  margin: 0 auto;
  padding: calc(var(--pad) * 1.4) var(--pad) calc(var(--pad) * 1.6);
  background: var(--sheet);
  border: var(--rule-w) solid var(--rule);
  box-shadow: 0 1px 2px rgba(34, 37, 42, 0.12), 0 12px 32px -12px rgba(34, 37, 42, 0.28);
}
.errsheet h1 {
  margin: 0.35rem 0 0.75rem;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.05;
  font-weight: 800;
  font-stretch: 78%;
  letter-spacing: -0.02em;
}
.errsheet .status { color: var(--red); font-weight: 700; font-stretch: 85%; }
.errsheet p { margin: 0 0 1.25rem; max-width: 52ch; }

/* ---------- Responsive ---------- */

@media (max-width: 64rem) {
  .titleblock {
    grid-template-columns: minmax(0, 1fr) minmax(14rem, 0.8fr);
    grid-template-areas:
      "mark action"
      "theme theme"
      "fields fields";
  }
  .wordmark { border-bottom: var(--rule-w) solid var(--rule); }
  .titleblock__action { border-bottom: var(--rule-w) solid var(--rule); }
  .titleblock__theme { border-right: 0; }
  .titleblock__fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .titleblock__fields div:nth-child(2) { border-right: 0; }
  .titleblock__fields div:nth-child(-n + 2) { border-bottom: var(--rule-w) solid var(--rule); }
}

@media (max-width: 46rem) {
  body { padding: 0.5rem; }
  .titleblock {
    grid-template-columns: 1fr;
    grid-template-areas: "mark" "theme" "action" "fields";
  }
  .wordmark { border-right: 0; }
  .titleblock__action { border-bottom: 0; border-top: var(--rule-w) solid var(--rule); }
  .titleblock__theme { padding-bottom: var(--pad); }
  .titleblock__fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .titleblock__fields div { padding-left: var(--pad); padding-right: 0.75rem; }
  .gantt li > * { grid-column: 1 / -1; margin-left: calc((var(--from) - 1) * 0.7rem); }
  .gantt__report strong, .gantt__report span { margin-left: 0; }
  .gantt__decisions, .gantt__legend { display: none; }
  .a3 { grid-template-columns: 1fr; }
  .a3__half + .a3__half { border-left: 0; border-top: calc(var(--rule-w) * 2) solid var(--rule); }
  .a3__half .box:last-child { border-bottom: 0; }
  .whys li { grid-template-columns: 1fr; }
  .table tbody th { width: 40%; }
  .approval { grid-template-columns: 1fr; }
  .chart__phases text, .chart__axis, .chart__target-label { font-size: 20px; }
  .approval__signoff { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .redpen__reveal { animation: none; stroke-dashoffset: 0; }
  .btn, .btn::after { transition: none; }
}

@media print {
  html, body { background: #fff; padding: 0; }
  .sheet { box-shadow: none; }
}
