/* AIH content review. Walnut-and-gold tokens from lib/src/design/aih_tokens.dart
   (AihStyles.letter palette, AihRadius, AihSpace). Light theme only. */

@font-face {
  font-family: 'Instrument Sans';
  src: url('/assets/fonts/InstrumentSans-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans';
  src: url('/assets/fonts/InstrumentSans-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans';
  src: url('/assets/fonts/InstrumentSans-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans';
  src: url('/assets/fonts/InstrumentSans-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* Colour (AihStyles.letter) */
  --bg: #fdfcfa;
  --surface: #ffffff;
  --sunken: #f6f4f2;
  --cream: #f5f3f1;
  --ink: #211d19;
  --ink-2: #3a332c;
  --muted: #5c554d;
  --faint: #6e665d;
  --line: #e7e2dc;
  --line-strong: #d9d2c9;
  --field: #8c8478;
  --walnut: #5f4134;
  --walnut-deep: #3b271b;
  --gold: #a88a4e; /* decorative only: no text, no controls */
  --accent: #7e6538;
  --accent-tint: #f4eee2;
  --accent-line: #d8c59c;
  --ok: #2c6542;
  --ok-tint: #e8f2ea;
  --warn: #8a4b00;
  --warn-tint: #fbf0e1;
  --stop: #9b2c2c;
  --stop-tint: #fbeae8;
  --primary: #211d19;
  --primary-hover: #3a332c;
  --focus: #5f4134;

  /* Radius (AihRadius) */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Space (AihSpace, strict 4/8) */
  --s4: 4px;
  --s8: 8px;
  --s12: 12px;
  --s16: 16px;
  --s20: 20px;
  --s24: 24px;
  --s32: 32px;
  --s40: 40px;
  --s48: 48px;
  --s64: 64px;

  --page: 16px;
  --measure: 960px;
  --shadow-1: 0 1px 2px rgba(33, 29, 25, 0.05);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 72px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 32px;
}
h2 {
  font-size: 24px;
}
h3,
.h3 {
  font-size: 20px;
}
h4 {
  font-size: 18px;
}
p {
  margin: 0;
}

a {
  color: var(--walnut);
  text-underline-offset: 3px;
}
a:hover {
  color: var(--walnut-deep);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: var(--s16);
  top: var(--s8);
  z-index: 20;
  background: var(--surface);
  padding: var(--s8) var(--s12);
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.hint {
  font-size: 14px;
  color: var(--faint);
}
.label {
  color: var(--muted);
}
.num {
  font-variant-numeric: tabular-nums;
}
.loading,
.empty {
  color: var(--muted);
  font-size: 15px;
}

/* ------------------------------------------------------------ top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(253, 252, 250, 0.96);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--s8) var(--page);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s12);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--s8);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  min-width: 0;
}
.brand img {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--walnut); /* the logo is light ink on a clear ground */
}
.topnav {
  display: flex;
  align-items: center;
  gap: var(--s8);
  font-size: 15px;
  flex-shrink: 0;
}

/* ------------------------------------------------------------ layout */

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--s24) var(--page) var(--s64);
  display: flex;
  flex-direction: column;
  gap: var(--s32);
  outline: none;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: var(--s12);
}
.lead {
  font-size: 18px;
  color: var(--ink-2);
}
.how {
  margin: 0;
  padding-left: var(--s20);
  display: grid;
  gap: var(--s4);
  color: var(--ink-2);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s8);
}

.jump {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s8) var(--s16);
  font-size: 15px;
}

/* ------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s20) var(--s16);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.cards {
  display: flex;
  flex-direction: column;
  gap: var(--s16);
}

.section {
  display: flex;
  flex-direction: column;
  gap: var(--s20);
}

.band {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--walnut-deep);
  min-height: 128px;
  display: flex;
  align-items: flex-end;
}
.band-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.band::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(33, 22, 15, 0.25) 0%, rgba(33, 22, 15, 0.82) 100%);
}
.band-text {
  position: relative;
  z-index: 1;
  display: flex;
  gap: var(--s12);
  align-items: flex-start;
  padding: var(--s20) var(--s16);
  color: #fffdf8;
}
.band-text h2 {
  color: #ffffff;
}
.band-text p {
  margin-top: var(--s4);
  color: #f2ebe0;
  font-size: 15px;
}
.band-number {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  border: 1px solid var(--gold);
  display: grid;
  place-items: center;
  font-weight: 600;
  color: #ffffff;
}

/* An item: its screen on the left, the questions on the right. On a phone the
   screen sits beside the title and the first paragraph; the rest uses the full
   width. */
.item {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  column-gap: var(--s12);
  row-gap: var(--s16);
  align-items: start;
}
.item.status-verified {
  border-left: 4px solid var(--ok);
}
.item.status-needs_change {
  border-left: 4px solid var(--warn);
}
.item-shot {
  grid-column: 1;
  grid-row: 1 / span 2;
  margin: 0;
  display: grid;
  gap: var(--s4);
}
.item-shot figcaption {
  font-size: 12px;
}
.shot-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  cursor: zoom-in;
}
.shot-button img {
  width: 100%;
}
.item-body {
  display: contents;
}
.item-body > * {
  grid-column: 1 / -1;
}
.item-body > .item-head,
.item-body > .beside {
  grid-column: 2;
}
.item-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s8) var(--s12);
}
.item-head > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.item-title {
  font-size: 18px;
}
.pill {
  display: inline-block;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  padding: 2px var(--s8);
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--sunken);
  color: var(--muted);
  white-space: nowrap;
}
.pill-verified,
.pill-answered {
  background: var(--ok-tint);
  color: var(--ok);
  border-color: transparent;
}
.pill-needs_change,
.pill-open {
  background: var(--warn-tint);
  color: var(--warn);
  border-color: transparent;
}

.tag {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px var(--s8);
  border-radius: var(--r-xs);
  background: var(--accent-tint);
  color: var(--accent);
}
.tag-decision {
  background: var(--sunken);
  color: var(--ink-2);
}

.placeholder {
  font-weight: 600;
  color: var(--stop);
  background: var(--stop-tint);
  border: 1px dashed var(--stop);
  border-radius: var(--r-md);
  padding: var(--s12);
  overflow-wrap: anywhere;
}
.question {
  font-weight: 600;
  font-size: 17px;
}
.current {
  background: var(--accent-tint);
  border-radius: var(--r-md);
  padding: var(--s12);
  display: grid;
  gap: var(--s4);
}
/* The portal's own words */
.wording {
  background: var(--sunken);
  border-radius: var(--r-md);
  border-left: 3px solid var(--gold);
  padding: var(--s12) var(--s16);
  display: grid;
  gap: var(--s8);
}
.lines {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--s12);
}
.lines li {
  display: grid;
  gap: 2px;
}
.line-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.lines q {
  quotes: '\201C' '\201D';
  color: var(--ink);
  overflow-wrap: anywhere;
}

.says-more summary {
  cursor: pointer;
  color: var(--walnut);
  font-weight: 600;
  width: fit-content;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s8);
}
.choices {
  display: grid;
  gap: var(--s8);
}

/* The screen at full size */
.lightbox {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
}
.lightbox::backdrop {
  background: rgba(33, 22, 15, 0.78);
}
.lightbox-inner {
  display: grid;
  gap: var(--s12);
  justify-items: center;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s16);
}
.lightbox-img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.lightbox-caption {
  max-width: 380px;
  font-size: 14px;
  color: var(--ink-2);
  text-align: center;
}

/* ------------------------------------------------------------ controls */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  border-radius: var(--r-pill);
  padding: 10px var(--s20);
  min-height: 44px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s8);
}
.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}
.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: #ffffff;
}
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-quiet {
  background: transparent;
  color: var(--walnut);
  padding: var(--s8) var(--s12);
  min-height: 40px;
}
.btn-quiet:hover {
  background: var(--sunken);
}
.btn-block {
  width: 100%;
}

.status-control {
  display: grid;
  gap: var(--s8);
}
.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  padding: 3px;
  background: var(--sunken);
  gap: 3px;
}
.seg {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: 40px;
  padding: var(--s4) var(--s8);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.seg:hover {
  background: var(--surface);
}
.seg[aria-pressed='true'] {
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong);
}
.seg-verified[aria-pressed='true'] {
  background: var(--ok-tint);
  color: var(--ok);
  box-shadow: 0 0 0 1px var(--ok);
}
.seg-needs_change[aria-pressed='true'] {
  background: var(--warn-tint);
  color: var(--warn);
  box-shadow: 0 0 0 1px var(--warn);
}

.filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s8);
}
.chip {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  min-height: 36px;
  padding: var(--s4) var(--s12);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.chip[aria-pressed='true'] {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

label {
  font-weight: 600;
  font-size: 15px;
}
input[type='text'],
input[type='password'],
textarea {
  font: inherit;
  width: 100%;
  min-width: 0;
  padding: 10px var(--s12);
  border: 1px solid var(--field);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
}
textarea {
  resize: vertical;
  min-height: 88px;
}
.text-form,
.name-form {
  display: grid;
  gap: var(--s8);
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s8) var(--s12);
}
.name-form .form-row input {
  flex: 1 1 200px;
}
.feedback {
  font-size: 14px;
  color: var(--stop);
}
.feedback:empty {
  display: none;
}

.name-card {
  display: grid;
  gap: var(--s12);
  border-color: var(--accent-line);
  background: var(--accent-tint);
}
.name-card.is-set {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s8);
  padding: var(--s12) var(--s16);
}

/* ------------------------------------------------------------ threads */

.comments {
  display: grid;
  gap: var(--s8);
}
.thread {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--s8);
}
.thread li {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s8) var(--s12);
  display: grid;
  gap: var(--s4);
}
.thread .meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4) var(--s8);
  align-items: baseline;
}
.thread .who {
  font-weight: 600;
}
.thread time {
  font-size: 13px;
  color: var(--faint);
}
.thread .body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.thread-status {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s4) var(--s8);
  font-size: 14px;
  background: var(--sunken);
  border-style: dashed !important;
}

.foot {
  display: grid;
  gap: var(--s8);
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid var(--line);
  padding-top: var(--s16);
}

/* ------------------------------------------------------------ admin tables */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  margin-top: var(--s12);
}
.table th {
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line-strong);
  padding: var(--s8);
}
.table td {
  border-bottom: 1px solid var(--line);
  padding: var(--s8);
  vertical-align: top;
  overflow-wrap: anywhere;
}
.table .pre {
  white-space: pre-wrap;
}

@media (max-width: 719px) {
  .table thead {
    position: absolute;
    left: -9999px;
  }
  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }
  .table tr {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--s8) var(--s12);
    margin-bottom: var(--s8);
  }
  .table td {
    border: 0;
    padding: 2px 0;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: var(--s8);
  }
  .table td::before {
    content: attr(data-label);
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
  }
}

/* ------------------------------------------------------------ sign-in */

.login-body {
  min-height: 100vh;
}
.login {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: var(--s64) var(--page) var(--s32);
}
.login-band {
  position: absolute;
  inset: 0 0 auto 0;
  height: 240px;
  overflow: hidden;
}
.login-band img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  display: grid;
  gap: var(--s12);
  padding: var(--s32) var(--s24);
}
.login-logo {
  width: 88px;
  height: 88px;
  border-radius: var(--r-lg);
  background: var(--walnut); /* the logo is light ink on a clear ground */
  justify-self: start;
}
.login-card h1 {
  font-size: 28px;
}

/* ------------------------------------------------------------ wide screens */

@media (min-width: 720px) {
  :root {
    --page: 32px;
  }
  .page {
    padding-top: var(--s40);
  }
  h1 {
    font-size: 40px;
  }
  .card {
    padding: var(--s24);
  }
  .band {
    min-height: 168px;
  }
  .band-text {
    padding: var(--s24);
  }
  .item {
    grid-template-columns: 220px minmax(0, 1fr);
    column-gap: var(--s24);
  }
  .item-shot {
    grid-row: 1;
    position: sticky;
    top: 80px;
  }
  .item-body {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: var(--s16);
    min-width: 0;
  }
  .item-title {
    font-size: 20px;
  }
  .item .wording {
    padding: var(--s16) var(--s20);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
