/* Interface styles. Values come from tokens.css, which is generated from the
 * OpenPencil design document — never hard-code a colour here.
 * Layout mirrors the designed screens in design/tei-interface.op. */

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

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.prose { white-space: pre-line; line-height: 1.6; }

a {
  color: inherit;
  text-decoration: none;
}

/* ------------------------------------------------------------------ nav */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 40px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.nav__left,
.nav__right {
  display: flex;
  align-items: center;
}

.nav__left {
  gap: 32px;
}

.nav__right {
  gap: 16px;
}

.nav__brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--primary);
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav__link {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.nav__link:hover {
  color: var(--foreground);
}

.nav__link.is-active {
  font-weight: 600;
  color: var(--foreground);
}

.nav__link.is-disabled {
  color: var(--muted-foreground);
  opacity: 0.55;
  cursor: default;
}

.nav__user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav__user-name {
  font-size: 13px;
  font-weight: 600;
}

.nav__user-role {
  font-size: 12px;
  color: var(--muted-foreground);
}

/* ----------------------------------------------------------------- page */

.page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 40px;
}

.page__header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.page__title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
}

.page__subtitle {
  margin: 0;
  font-size: 15px;
  color: var(--muted-foreground);
}

/* --------------------------------------------------------------- pills */

.pills {
  display: flex;
  gap: 8px;
}

.pill {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 500;
}

.pill.is-active {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
}

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

.card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

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

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

.table th {
  padding: 14px 20px;
  background: var(--muted);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-align: left;
}

.table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table__col--narrow {
  width: 150px;
}

/* Position of a row in a repeatable list. Real columns always follow it, so it
 * stays narrow and muted: it is a reference for the Manager, not data. */
.table__col--index,
.table__cell--index {
  width: 44px;
}

.table__cell--index {
  color: var(--muted-foreground);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.table__link {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.table__link:hover {
  text-decoration: underline;
}

.table__meta {
  display: block;
  font-size: 12px;
  color: var(--muted-foreground);
}

.table__muted {
  font-size: 13px;
  color: var(--muted-foreground);
}

.table__num {
  font-size: 14px;
  font-weight: 700;
}

/* -------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge--done {
  background: var(--status-done-bg);
  color: var(--status-done-fg);
}

.badge--pending {
  background: var(--status-pending-bg);
  color: var(--status-pending-fg);
}

.badge--none {
  background: var(--status-none-bg);
  color: var(--status-none-fg);
}

.badge--failed {
  background: var(--status-failed-bg);
  color: var(--status-failed-fg);
}

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn--primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn--block {
  width: 100%;
}

/* --------------------------------------------------------------- forms */

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

.field__input {
  display: block;
  width: 100%;
  height: 44px;
  margin-bottom: 18px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--foreground);
  font-family: inherit;
  font-size: 14px;
}

.field__input::placeholder {
  color: var(--muted-foreground);
}

/* --------------------------------------------------------------- login */

.login {
  display: flex;
  min-height: 100vh;
}

.login__brand {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 72px;
  background: var(--primary);
  color: var(--primary-foreground);
  position: relative;
  overflow: hidden;
}

/* Photograph cycle behind the brand copy, and the scrim that keeps that copy
 * legible over it. The panel keeps its --primary fill, so the first frame —
 * before any photograph has faded in — is the on-brand dark panel rather than
 * a white flash. */
.login__slides {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.login__slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  /* Six slides, six seconds each, staggered so exactly one is opaque at a time
   * and consecutive slides cross-fade. */
  animation: login-slide 36s ease-in-out infinite;
}

.login__slide:nth-child(1) {
  animation-delay: 0s;
}

.login__slide:nth-child(2) {
  animation-delay: 6s;
}

.login__slide:nth-child(3) {
  animation-delay: 12s;
}

.login__slide:nth-child(4) {
  animation-delay: 18s;
}

.login__slide:nth-child(5) {
  animation-delay: 24s;
}

.login__slide:nth-child(6) {
  animation-delay: 30s;
}

@keyframes login-slide {
  0% {
    opacity: 0;
  }

  3% {
    opacity: 1;
  }

  16.667% {
    opacity: 1;
  }

  19.667% {
    opacity: 0;
  }

  100% {
    opacity: 0;
  }
}

/* Strongest at the left edge, where the brand copy sits, and lighter towards
 * the form panel so the photograph is not flattened into a uniform grey.
 * Derived from --primary: this file never hard-codes a colour. */
.login__scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  /* Fallback first: an engine without color-mix() drops the gradient below,
   * and a solid brand fill degrades to exactly the flat panel the design
   * specifies, rather than leaving white copy over an unobscured photograph. */
  background: var(--primary);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--primary) 92%, transparent) 0%,
    color-mix(in srgb, var(--primary) 84%, transparent) 52%,
    color-mix(in srgb, var(--primary) 68%, transparent) 100%
  );
}

/* The copy has to sit above the slides and the scrim. */
.login__mark,
.login__title,
.login__text {
  position: relative;
  z-index: 2;
}

/* The cycle is decorative motion. When the user has asked the system for less
 * motion, one photograph stays put and nothing moves. */
@media (prefers-reduced-motion: reduce) {
  .login__slide {
    animation: none;
  }

  .login__slide:first-child {
    opacity: 1;
  }
}

.login__mark {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
}

.login__title {
  margin: 0;
  max-width: 22ch;
  font-size: 44px;
  font-weight: 700;
  line-height: 1.15;
}

.login__text {
  margin: 0;
  max-width: 46ch;
  font-size: 17px;
  line-height: 1.6;
}

.login__panel {
  display: flex;
  flex: 0 0 560px;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: 56px;
}

.login__card {
  display: block;
}

.login__card-title {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
}

.login__card-sub {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--muted-foreground);
}

.login__forgot {
  display: block;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted-foreground);
  text-align: center;
}

.login__forgot:hover {
  color: var(--foreground);
}

.login__note,
.login__credits {
  margin: 0;
  font-size: 12px;
  color: var(--muted-foreground);
  text-align: center;
}

.login__credits {
  font-size: 11px;
}

/* --------------------------------------------------------------- empty */

.empty {
  margin: 0;
  color: var(--muted-foreground);
}

/* ------------------------------------------------------- statement page */

.backlink {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.backlink:hover {
  color: var(--foreground);
}

.split {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.split__main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 20px;
}

.split__side {
  display: flex;
  flex: 0 0 380px;
  flex-direction: column;
  gap: 20px;
}

.card__title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.card__muted {
  margin: 12px 0;
  font-size: 13px;
  color: var(--muted-foreground);
}

.prose {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-line;
}

.row {
  margin: 0;
}

.mono {
  font-family: Menlo, Monaco, "Courier New", monospace;
  font-size: 13px;
}

.examples {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.examples__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--muted);
}

.examples__value {
  font-weight: 600;
}

.deflist {
  margin: 0;
}

.deflist__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.deflist dt {
  font-size: 13px;
  color: var(--muted-foreground);
}

.deflist dd {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

/* ------------------------------------------------------ submission form */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 140px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  cursor: pointer;
}

.dropzone__title {
  font-size: 14px;
  font-weight: 600;
}

.dropzone__hint {
  font-size: 12px;
  color: var(--muted-foreground);
}

.filechip {
  display: inline-block;
  margin: 16px 0 0;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.codearea {
  display: block;
  width: 100%;
  min-height: 220px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  color: var(--foreground);
  font-family: Menlo, Monaco, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.alert {
  margin: 0;
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}

.alert--pending {
  background: var(--status-pending-bg);
  color: var(--status-pending-fg);
}

.alert--failed {
  background: var(--status-failed-bg);
  color: var(--status-failed-fg);
}

.actions {
  display: flex;
  gap: 12px;
}

.btn--muted {
  background: var(--muted);
  color: var(--muted-foreground);
}

/* ---------------------------------------------------------- result page */

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.summary__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.summary__right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.summary__score {
  font-size: 28px;
  font-weight: 700;
}

.codeblock {
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  background: var(--muted);
  font-family: Menlo, Monaco, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* ------------------------------------------------------ manager surfaces */

.nav__context {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.page__header--row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 12px 16px;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.tab:hover {
  color: var(--foreground);
}

.tab.is-active {
  border-bottom-color: var(--primary);
  font-weight: 600;
  color: var(--foreground);
}

.alert--done {
  background: var(--status-done-bg);
  color: var(--status-done-fg);
}

.fieldpair {
  display: flex;
  gap: 16px;
}

.fieldpair > * {
  flex: 1;
}

.codearea--short {
  min-height: 120px;
}

.table--form td {
  padding: 8px 12px;
}

.table__col--action {
  width: 110px;
}

.field__input--flush {
  height: 36px;
  margin: 0;
  border-color: transparent;
  background: transparent;
}

.field__input--flush:focus {
  border-color: var(--ring);
  background: var(--background);
}

select.field__input--flush {
  appearance: none;
  padding-right: 8px;
}

.btn--small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.actions--spaced {
  margin-top: 16px;
}

/* ------------------------------------------------------------- panels */

.stats {
  display: flex;
  gap: 16px;
}

.statcard {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 20px;
}

.statcard__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-foreground);
}

.statcard__value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}

.panelhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
}

.card__title--flush {
  margin: 0;
}

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

.auditlist--plain {
  padding: 0;
}

.auditlist__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.auditlist--plain .auditlist__item {
  padding: 8px 0;
}

.auditlist__action {
  font-size: 13px;
  font-weight: 600;
}

.auditlist__meta {
  font-size: 12px;
  color: var(--muted-foreground);
}

.auditlist__more {
  display: block;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-foreground);
}

.auditlist__more:hover {
  color: var(--foreground);
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  font-size: 13px;
  font-weight: 600;
}

/* ------------------------------------------------------- conversations */

.section__title {
  margin: 8px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.threadlist {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.threadlist--plain .thread {
  padding: 12px 0;
  border: 0;
  border-radius: 0;
  border-top: 1px solid var(--border);
  background: transparent;
}

.thread__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.thread__title {
  font-size: 15px;
  font-weight: 600;
}

.thread__body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.thread__meta {
  font-size: 12px;
  color: var(--muted-foreground);
}

.thread__answer {
  padding: 12px;
  border-radius: 8px;
  background: var(--muted);
}

.thread__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

/* ------------------------------------------------------------- preview */

.preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: 8px;
  background: var(--muted);
}

.preview__kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--muted-foreground);
}

.preview__subject {
  font-size: 14px;
  font-weight: 600;
}

.preview__body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.preview__meta {
  font-size: 11px;
  color: var(--muted-foreground);
}

.integrationhead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.nav__logout {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted-foreground);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.nav__logout:hover {
  color: var(--foreground);
}

.feedback {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.7;
}

.table__link--closed {
  color: var(--muted-foreground);
  font-weight: 500;
}

@media print {
  .nav,
  .actions,
  .backlink {
    display: none;
  }
}

/* -------------------------------------------------------------- print */

.page--print {
  align-items: center;
}

.sheet {
  width: 760px;
  max-width: 100%;
  padding: 48px;
}

.sheet__kicker {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted-foreground);
}

.sheet__title {
  margin: 8px 0 24px;
  font-size: 28px;
  font-weight: 700;
}

.sheet__footer {
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted-foreground);
}

.rule {
  height: 1px;
  margin: 24px 0;
  border: 0;
  background: var(--border);
}
