/* Architect: visual design
   Palette: cool drafting paper, slate ink, two semantic accents.
   Amber marks judgement. Teal marks adaptive behaviour (loops). */

:root {
  --paper: #f2f3ef;
  --surface: #ffffff;
  --ink: #16232c;
  --slate: #44515a;
  --rule: #cbd1cc;
  --rule-soft: #e1e5e1;
  --amber: #c98a1e;
  --amber-ink: #7d5410;
  --amber-wash: #faf1de;
  --teal: #1e6b5c;
  --teal-wash: #e3efeb;
  --slate-wash: #e8ebe8;
  --danger: #9b2c2c;

  --font: 'Schibsted Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: 2.25rem;
  --step-4: 3.25rem;

  --radius-s: 4px;
  --radius-m: 10px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.55;
  min-height: 100vh;
}

h1, h2, h3, p { margin: 0; }

button, input, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1.25rem, 4vw, 3rem);
  border-bottom: 1px solid var(--rule);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.byline {
  color: var(--slate);
  font-size: var(--step--1);
  white-space: nowrap;
}

.bp-byline {
  display: none;
  color: var(--slate);
  font-size: var(--step--1);
  margin-top: 1.5rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-name {
  font-weight: 700;
  font-size: var(--step-1);
  letter-spacing: -0.01em;
}

.brand-sub {
  color: var(--slate);
  font-size: var(--step--1);
}

.text-button {
  background: none;
  border: 0;
  padding: 0.4rem 0;
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--rule);
  cursor: pointer;
}

.text-button:hover { text-decoration-color: var(--ink); }

.primary-button {
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: var(--radius-s);
  padding: 0.65rem 1.4rem;
  font-weight: 600;
  cursor: pointer;
}

.primary-button:hover { background: #24343f; }
.primary-button:disabled { opacity: 0.45; cursor: default; }
.composer-row .primary-button { margin-left: auto; }

.secondary-button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius-s);
  padding: 0.6rem 1.3rem;
  font-weight: 600;
  cursor: pointer;
}

.secondary-button:hover { background: var(--surface); }

/* ---------- Landing ---------- */

.landing {
  max-width: 60rem;
  margin: 0 auto;
  padding: clamp(3rem, 9vh, 6.5rem) clamp(1.25rem, 4vw, 3rem) 4rem;
}

.landing-title {
  font-size: clamp(2.25rem, 6vw, var(--step-4));
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.03em;
  max-width: 14ch;
}

.landing-copy {
  margin-top: 1.5rem;
  font-size: var(--step-1);
  color: var(--slate);
  max-width: 34rem;
}

.landing-question {
  margin-top: clamp(2.5rem, 7vh, 4rem);
  font-size: var(--step-1);
  font-weight: 600;
}

.routes {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.route {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--ink);
  border-radius: var(--radius-s);
  padding: 1.5rem 1.5rem 1.6rem;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
}

.route:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.route:disabled { opacity: 0.5; cursor: default; transform: none; }

.route-title {
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.route-text { color: var(--slate); }

.code-panel {
  margin-top: 2rem;
  max-width: 20rem;
}

.code-panel label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.code-panel input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  background: var(--surface);
}

.field-error {
  margin-top: 0.5rem;
  color: var(--danger);
  font-size: var(--step--1);
}

/* ---------- Workspace ---------- */

.workspace {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
}

.conversation {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 4.5rem);
  max-width: 42rem;
  width: 100%;
}

.log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 2.5rem 0 1.5rem;
}

.msg { max-width: 38rem; }

.msg-architect p {
  font-size: var(--step-1);
  line-height: 1.5;
}

.msg-author {
  display: block;
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--slate);
  margin-bottom: 0.2rem;
}

.msg-user {
  align-self: flex-end;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  padding: 0.75rem 1rem;
  white-space: pre-wrap;
  max-width: 32rem;
}

/* Insight cards: colour encodes what kind of design conclusion it is */
.insight {
  --accent: var(--ink);
  --wash: var(--slate-wash);
  border-left: 4px solid var(--accent);
  background: var(--wash);
  padding: 0.8rem 1rem 0.9rem;
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  max-width: 36rem;
  animation: reveal 280ms ease-out;
}

.insight-judgement_point { --accent: var(--amber); --wash: var(--amber-wash); }
.insight-agent_loop { --accent: var(--teal); --wash: var(--teal-wash); }
.insight-reframe { --accent: var(--ink); --wash: var(--surface); border: 1px solid var(--ink); border-left-width: 4px; }

.insight-label {
  display: block;
  font-weight: 600;
  font-size: var(--step--1);
  margin-bottom: 0.15rem;
}

.insight-judgement_point .insight-label { color: var(--amber-ink); }
.insight-agent_loop .insight-label { color: var(--teal); }

@keyframes reveal {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.thinking {
  color: var(--slate);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.thinking-dots { display: inline-flex; gap: 4px; }

.thinking-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--slate);
  animation: pulse 1.2s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

.error-box {
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-s);
  padding: 0.75rem 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  max-width: 36rem;
}

.error-box .text-button { color: var(--danger); text-decoration-color: currentColor; }

/* Composer */
.composer {
  position: sticky;
  bottom: 0;
  background: var(--paper);
  padding: 1rem 0 1.5rem;
  border-top: 1px solid var(--rule);
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 5.5rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--surface);
  line-height: 1.5;
}

.composer textarea:focus-visible { outline-offset: 0; }

.composer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 0.6rem;
}

.composer-hint { color: var(--slate); font-size: var(--step--1); }

/* ---------- Rail and spine (the design taking shape) ---------- */

.rail {
  position: sticky;
  top: 1.5rem;
  padding-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.rail-route {
  font-weight: 600;
  line-height: 1.35;
}

.rail-heading {
  font-weight: 600;
  font-size: var(--step--1);
  margin-bottom: 0.75rem;
}

.rail-note {
  margin-top: 0.75rem;
  color: var(--slate);
  font-size: var(--step--1);
}

.spine {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.spine::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--rule);
}

.spine li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.3rem 0;
  color: var(--slate);
}

.node {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--rule);
  background: var(--paper);
  flex: none;
  position: relative;
  z-index: 1;
  transition: background 300ms ease, border-color 300ms ease;
}

.spine li.filled { color: var(--ink); font-weight: 500; }
.spine li.filled .node { background: var(--ink); border-color: var(--ink); }
.spine li.filled[data-part='brain'] .node { background: var(--amber); border-color: var(--amber); }
.spine li.filled[data-part='loop'] .node { background: var(--teal); border-color: var(--teal); }
.spine li.none .node { background: var(--paper); border-color: var(--ink); }
.spine li.none .spine-label::after { content: ': none needed'; color: var(--slate); font-weight: 400; }

.reading-value {
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

/* ---------- Blueprint ---------- */

.blueprint {
  max-width: 54rem;
  margin: 0 auto;
  padding: 2.5rem clamp(1.25rem, 4vw, 3rem) 5rem;
}

.bp-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.bp-sheet {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  padding: clamp(1.5rem, 4vw, 3rem);
}

.bp-kicker {
  color: var(--slate);
  font-weight: 500;
}

.bp-stamp {
  color: var(--slate);
  font-size: var(--step--1);
  margin-top: 0.2rem;
}

.bp-pattern {
  margin-top: 0.25rem;
  font-size: clamp(2rem, 5vw, var(--step-4));
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.bp-why {
  margin-top: 1rem;
  font-size: var(--step-1);
  max-width: 40rem;
}

.bp-reframe {
  margin-top: 1.5rem;
  border-left: 4px solid var(--ink);
  padding: 0.25rem 0 0.25rem 1rem;
  max-width: 40rem;
}

.bp-reframe strong { display: block; font-size: var(--step--1); }

.bp-grid {
  margin-top: 2.25rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 2.5rem;
}

.bp-section { border-top: 1px solid var(--rule); padding-top: 0.75rem; }
.bp-section.wide { grid-column: 1 / -1; }

.bp-section h3 {
  font-size: var(--step-0);
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.bp-section h4 {
  font-size: var(--step--1);
  font-weight: 600;
  margin: 0.6rem 0 0.2rem;
}

.bp-section ul {
  margin: 0;
  padding-left: 1.1rem;
}

.bp-section li + li { margin-top: 0.2rem; }

.bp-empty { color: var(--slate); }

.bp-table-wrap { overflow-x: auto; }

.bp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.bp-table th,
.bp-table td {
  text-align: left;
  padding: 0.45rem 0.75rem 0.45rem 0;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}

.bp-table th { font-weight: 600; }

.access-tag {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: var(--radius-s);
  background: var(--slate-wash);
  font-weight: 500;
  white-space: nowrap;
}

.access-write { background: var(--amber-wash); color: var(--amber-ink); }

.bp-prototype {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-s);
  padding: 1.25rem 1.5rem;
  border-top: 0;
}

.bp-prototype h3 { color: var(--paper); }

.bp-product-heading {
  grid-column: 1 / -1;
  margin-top: 0.75rem;
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: -0.015em;
}

/* Before it goes live: printable, with a line to write each answer on */
.bp-golive {
  margin-top: 2.5rem;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--amber);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  padding: 1.25rem 1.5rem 1.5rem;
}

.bp-golive h3 { font-size: var(--step-1); }

.bp-golive-intro {
  color: var(--slate);
  font-size: var(--step--1);
  margin-bottom: 0.75rem;
}

.golive-list {
  margin: 0;
  padding-left: 1.2rem;
}

.golive-list li { margin-bottom: 0.9rem; }

.golive-question { display: block; font-weight: 500; }

.golive-answer {
  display: block;
  border-bottom: 1px solid var(--rule);
  height: 1.6rem;
}

.golive-scope {
  margin-top: 0.5rem;
  border-top: 1px solid var(--rule-soft);
  padding-top: 0.75rem;
}

.bp-reflection {
  margin-top: 2.5rem;
  border-top: 2px solid var(--ink);
  padding-top: 1rem;
}

.bp-reflection h3 { font-size: var(--step-1); margin-bottom: 0.5rem; }
.bp-reflection ul { margin: 0; padding-left: 1.1rem; }

.drafting {
  padding: 4rem 0;
  text-align: left;
}

.drafting p:first-child {
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.drafting p + p { margin-top: 0.5rem; color: var(--slate); }

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

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .rail {
    order: -1;
    position: static;
    padding-top: 1.25rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1rem;
  }

  .rail-note, .rail-heading { display: none; }

  .spine {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
  }

  .spine::before { display: none; }

  .spine li {
    padding: 0.15rem 0.5rem 0.15rem 0.2rem;
    gap: 0.35rem;
    font-size: var(--step--1);
  }

  .node { width: 12px; height: 12px; }
  .spine li.none .spine-label::after { content: ''; }

  .reading { display: flex; gap: 0.5rem; align-items: baseline; }
  .reading-value { font-size: var(--step-1); }
  .reading::before { content: 'Current reading:'; color: var(--slate); font-size: var(--step--1); }

  .conversation { min-height: auto; }
  .log { padding-top: 1.5rem; }
}

@media (max-width: 640px) {
  .routes { grid-template-columns: 1fr; }
  .bp-grid { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  .composer-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Print: the Blueprint on one page ---------- */

@media print {
  @page { margin: 12mm; }

  body { background: #fff; font-size: 10pt; line-height: 1.4; }
  .topbar, .bp-actions, #landing, #workspace { display: none !important; }
  .blueprint { padding: 0; max-width: none; }
  .bp-sheet { border: 0; padding: 0; }
  .bp-pattern { font-size: 22pt; }
  .bp-stamp { font-size: 8.5pt; }
  .bp-why { font-size: 10.5pt; }
  .bp-grid { gap: 0.6rem 1.5rem; margin-top: 1rem; }
  .bp-section { break-inside: avoid; }
  .bp-prototype { background: #fff; color: #000; border: 2px solid #000; }
  .bp-prototype h3 { color: #000; }
  /* Before it goes live: printable, with a line to write each answer on */
.bp-golive {
  margin-top: 2.5rem;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--amber);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  padding: 1.25rem 1.5rem 1.5rem;
}

.bp-golive h3 { font-size: var(--step-1); }

.bp-golive-intro {
  color: var(--slate);
  font-size: var(--step--1);
  margin-bottom: 0.75rem;
}

.golive-list {
  margin: 0;
  padding-left: 1.2rem;
}

.golive-list li { margin-bottom: 0.9rem; }

.golive-question { display: block; font-weight: 500; }

.golive-answer {
  display: block;
  border-bottom: 1px solid var(--rule);
  height: 1.6rem;
}

.golive-scope {
  margin-top: 0.5rem;
  border-top: 1px solid var(--rule-soft);
  padding-top: 0.75rem;
}

.bp-reflection { margin-top: 1rem; break-inside: avoid; }
  .access-tag { background: none; padding: 0; }
  .bp-byline { display: block; margin-top: 1rem; }
}
