/* Written against the theme contract only: colours, fonts, radius, spacing and base size all come from var(--…). */

html {
  font-size: var(--font-size);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  line-height: 1.25;
}

h1,
.app-title {
  margin: 0 0 calc(var(--space) / 2);
  font-size: 2rem;
}

/* The question heading looks like the browser's default h2 at any level. */
.question-title {
  margin: 0.83em 0;
  font-size: 1.5em;
}

.page {
  box-sizing: border-box;
  max-width: 40rem;
  margin: 0 auto;
  padding: calc(var(--space) * 2);
  overflow-wrap: anywhere;
}

.tagline,
.meta,
.hint,
.progress {
  color: var(--muted);
}

.tagline {
  margin-top: 0;
}

.back {
  margin: 0 0 var(--space);
  font-size: 0.875rem;
}

.plain {
  font-size: 1rem;
}

a {
  color: var(--accent);
}

/* Focus. Headings that script focuses (tabindex -1) show no ring unless :focus-visible applies. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[tabindex='-1']:focus:not(:focus-visible) {
  outline: none;
}

/* Buttons. The base style is the secondary (outline) button. */
button,
input {
  font: inherit;
  color: var(--text);
}

button {
  box-sizing: border-box;
  min-height: 44px;
  min-width: 44px;
  padding: var(--space);
  background: transparent;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

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

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: bold;
}

button.primary:hover {
  background: var(--accent);
  border-color: var(--text);
}

/* Text-style button: the "Change" control. */
button.quiet {
  padding: calc(var(--space) / 2) var(--space);
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  font-size: 0.875rem;
  text-decoration: underline;
}

button.quiet:hover {
  background: transparent;
  border-color: var(--border);
}

button.choice {
  background: var(--surface);
  border-width: 1px;
}

button.choice:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

button.choice:hover .hint {
  color: var(--accent-text);
}

input {
  box-sizing: border-box;
  min-height: 44px;
  max-width: 100%;
  margin-top: var(--space);
  padding: calc(var(--space) / 2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Question and choices. */
.choices {
  margin: 0;
  padding: 0;
  list-style: none;
}

.choice {
  display: block;
  width: 100%;
  height: 100%;
  text-align: left;
}

.choice .label {
  display: block;
  font-weight: bold;
}

.choice .hint {
  display: block;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 7.5rem), 1fr));
  align-items: stretch;
  gap: var(--space);
}

/* Tiles: pictogram over a short label; every tile in a row is as tall as the tallest. */
.tiles > li {
  display: flex;
}

.tiles .choice {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--space) / 2);
  padding: var(--space) calc(var(--space) / 2);
  text-align: center;
}

.tiles .choice .label {
  font-size: 0.9375rem;
  line-height: 1.25;
}

.icon {
  flex: none;
  width: 36px;
  height: 36px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

/* Filter box above the choices. */
.filter {
  margin-bottom: var(--space);
}

.filter-label {
  display: block;
  font-weight: bold;
}

.filter-input {
  display: block;
  width: 100%;
  margin-top: calc(var(--space) / 2);
}

.filter-status {
  min-height: 1.5em;
  margin: calc(var(--space) / 2) 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.step-hint {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
}

.progress {
  margin-bottom: calc(var(--space) / 2);
  font-size: 0.875rem;
}

.bar {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 6px;
  margin: 0 0 var(--space);
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--border) 30%, var(--surface));
  overflow: hidden;
}

.bar::-webkit-progress-bar {
  background: color-mix(in srgb, var(--border) 30%, var(--surface));
}

.bar::-webkit-progress-value {
  background: var(--accent);
}

.bar::-moz-progress-bar {
  background: var(--accent);
}

.notice {
  padding: var(--space);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Your answers: one row per step. */
.steps .plain {
  margin-bottom: calc(var(--space) / 2);
}

.step-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  padding: calc(var(--space) / 2) 0;
  border-bottom: 1px solid var(--border);
}

.step-text {
  min-width: 0;
}

.step-question,
.step-answer {
  display: block;
}

.step-question {
  color: var(--muted);
  font-size: 0.875rem;
}

.step-answer {
  font-weight: bold;
}

/* The result card. */
.stage {
  margin-top: calc(var(--space) * 2);
}

.card {
  box-sizing: border-box;
  margin-bottom: calc(var(--space) * 3);
  padding: calc(var(--space) * 1.5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 0.5rem solid var(--accent);
  border-radius: var(--radius);
}

.result-heading {
  margin: 0 0 var(--space);
}

.result-heading .lead {
  display: block;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-heading .outcome {
  display: block;
  font-size: 2rem;
}

.detail {
  margin: 0 0 var(--space);
}

.note {
  margin: var(--space) 0 0;
  padding: var(--space);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

/* Why: a quiet two-column definition list. */
.why .section-title,
.skipped .section-title {
  margin: 0 0 var(--space);
  font-size: 1rem;
}

.why {
  color: var(--text);
  font-size: 0.9375rem;
}

.why-list {
  margin: 0;
}

.row {
  display: grid;
  grid-template-columns: minmax(6rem, 10rem) 1fr;
  gap: var(--space);
  padding: var(--space) 0;
  border-top: 1px solid var(--border);
}

.row dt {
  color: var(--muted);
}

.row dd {
  margin: 0;
}

.row dd + dd {
  grid-column: 2;
}

.row p {
  margin: 0;
}

.matters {
  margin: 0;
  padding: 0;
  list-style: none;
}

.matters li {
  margin-bottom: calc(var(--space) / 2);
}

.matter-question {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
}

.matter-answer {
  display: block;
  font-weight: bold;
}

.source-title {
  font-weight: bold;
}

.meta {
  font-size: 0.875rem;
}

.skipped {
  margin-top: calc(var(--space) * 2);
  color: var(--muted);
  font-size: 0.875rem;
}

.skipped ul {
  margin: 0;
  padding-left: calc(var(--space) * 1.5);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space);
  margin-top: calc(var(--space) * 2);
}

.table-section {
  margin-top: calc(var(--space) * 2);
}

.table-region {
  margin-top: var(--space);
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  border-collapse: collapse;
  width: 100%;
}

caption {
  padding: var(--space);
  text-align: left;
  font-family: var(--font-heading);
  font-weight: bold;
}

th,
td {
  padding: calc(var(--space) / 2) var(--space);
  border-top: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: normal;
}

/* Footer. */
.footer {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--space) / 2) calc(var(--space) * 1.5);
  margin-top: calc(var(--space) * 3);
  padding-top: calc(var(--space) * 1.5);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

.footer p {
  margin: 0;
}

.footer-note {
  flex-basis: 100%;
}

/* Landing page. */
.landing {
  max-width: 56rem;
}

.hero {
  padding-top: var(--space);
}

.landing h1 {
  margin: 0 0 var(--space);
  font-size: clamp(2.5rem, 9vw, 4rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.lede {
  max-width: 38rem;
  margin: 0 0 calc(var(--space) * 2);
  font-size: 1.25rem;
}

.hero-figure {
  box-sizing: border-box;
  margin: 0;
  padding: calc(var(--space) * 1.5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
}

.diagram {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

.diagram.stacked {
  max-width: 20rem;
}

/* The picture takes every colour and font from the theme, so it follows light and dark. */
.dg-cell {
  fill: var(--bg);
  stroke: var(--border);
  stroke-width: 1.5;
}

.dg-head {
  fill: var(--accent);
  stroke: var(--accent);
}

.dg-line {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
  stroke-linecap: round;
}

.dg-arrow path {
  fill: none;
  stroke: var(--text);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dg-box {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 3;
}

.dg-tick circle {
  fill: var(--accent);
}

.dg-tick path {
  fill: none;
  stroke: var(--accent-text);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dg-phone {
  fill: var(--bg);
  stroke: var(--text);
  stroke-width: 3;
}

.dg-speaker {
  fill: var(--border);
}

.dg-button {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 2;
}

.dg-button.dg-primary {
  fill: var(--accent);
  stroke: var(--accent);
}

.dg-title,
.dg-text,
.dg-question,
.dg-button-text,
.dg-caption {
  fill: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
}

.dg-title {
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: bold;
}

.dg-question,
.dg-button-text {
  font-weight: bold;
}

.dg-button-text.dg-primary-text {
  fill: var(--accent-text);
}

.dg-caption {
  fill: var(--muted);
  font-size: 14px;
}

.section-heading {
  margin: calc(var(--space) * 3) 0 var(--space);
  font-size: 1.5rem;
}

.apps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: var(--space);
  margin: 0;
  padding: 0;
  list-style: none;
}

.apps > li {
  display: flex;
}

/* A card wears the app's own colours, fonts and radius (set on it by landing.ts). */
.app-card {
  box-sizing: border-box;
  display: block;
  flex: 1;
  padding: calc(var(--space) * 1.5);
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-left: 0.5rem solid var(--accent);
  border-radius: var(--radius);
  font-family: var(--font-body);
  text-decoration: none;
  transition: box-shadow 0.15s, transform 0.15s;
}

.app-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.card-title {
  margin: 0;
  color: inherit;
  font-family: var(--font-heading);
  font-size: 1.5rem;
}

.card-tagline {
  margin: calc(var(--space) / 2) 0 var(--space);
  color: var(--muted);
}

.card-preview {
  padding: var(--space);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 1rem);
}

.preview-question {
  margin: 0 0 calc(var(--space) / 2);
  font-size: 0.9375rem;
  font-weight: bold;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--space) / 2);
}

.chip {
  padding: 0.25rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 1rem);
  font-size: 0.875rem;
}

.list-card .chips {
  flex-direction: column;
}

.list-card .chip {
  border-radius: min(var(--radius), 0.5rem);
}

.playground-card {
  box-sizing: border-box;
  display: block;
  margin-top: calc(var(--space) * 2);
  padding: calc(var(--space) * 2);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.playground-card:hover {
  background: var(--accent);
  color: var(--accent-text);
}

.playground-card .card-title {
  font-size: 1.75rem;
}

.playground-card p {
  max-width: 40rem;
  margin: calc(var(--space) / 2) 0 0;
}

.files-note,
.new-app {
  margin: 0 0 var(--space);
}

.files {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--space);
  margin: 0 0 var(--space);
  padding: 0;
  list-style: none;
}

.files-app {
  padding: var(--space);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.files-name {
  display: block;
  margin-bottom: calc(var(--space) / 2);
  font-weight: bold;
}

.file-links {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--space) / 2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-links a {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 0.75rem);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.875rem;
}

code {
  padding: 0.125rem 0.375rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none;
}

@media (max-width: 36rem) {
  .row {
    grid-template-columns: 1fr;
    gap: calc(var(--space) / 4);
  }

  .row dd + dd {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .app-card:hover {
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* By hand (owner): keep the "Change" button on one line beside a long question. */
.step > button {
  flex-shrink: 0;
  white-space: nowrap;
}

/* By hand (owner, accessibility review): the stand-alone "All apps" link gets a 24 px target (WCAG 2.2, 2.5.8). */
.back a {
  display: inline-block;
  min-height: 24px;
  padding-block: 4px;
}
