/* Operations pages: the dev outbox (Issue 111), and the sign-in and account pages
 * that follow it in Milestone 10.
 *
 * Loaded after tokens.css; every colour, radius and shadow is a token, so both
 * colour schemes come from the token blocks. Mobile first: one column, sized in rem,
 * widening to a reading measure. The `.ops-*` family is new rather than borrowed from
 * logs.css, which still has literal colours and no dark palette. */

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

body.ops-page {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

body.ops-page .logs-shell {
  width: min(100% - 2 * var(--shell-pad-x), 60rem);
  margin-inline: auto;
  padding-block: clamp(1.25rem, 0.8rem + 2vw, 2.5rem);
}

body.ops-page .logs-shell__header {
  margin-bottom: 1.25rem;
}

body.ops-page .logs-shell__eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

body.ops-page .logs-shell__title {
  margin: 0;
  font-size: clamp(1.4rem, 1.15rem + 1vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.ops-page a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

.ops-page a:hover {
  color: var(--accent-strong);
}

.ops-page :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------- signed-in bar */

/* "Signed in as … · Sign out" under a page title (Issue 112). The button looks like a
 * link but is a form submit, so sign-out is a POST with the CSRF token. */
.auth-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.auth-bar__form {
  display: inline;
  margin: 0;
}

.auth-bar__signout {
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  background: none;
  border: 0;
  cursor: pointer;
}

.auth-bar__signout:hover {
  color: var(--accent-strong);
}

/* ----------------------------------------------------------------- notices */

.ops-note {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
  background: var(--accent-tint);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius);
}

.ops-note--warning {
  color: var(--ink);
  background: var(--degraded-tint);
  border-color: color-mix(in srgb, var(--degraded) 35%, transparent);
}

.ops-note--error {
  color: var(--ink);
  background: var(--offline-tint);
  border-color: color-mix(in srgb, var(--offline) 35%, transparent);
}

.ops-note--success {
  color: var(--ink);
  background: var(--live-tint);
  border-color: color-mix(in srgb, var(--live) 35%, transparent);
}

.ops-note p {
  margin: 0;
}

.ops-note p + p {
  margin-top: 0.4rem;
}

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

.ops-card {
  margin-bottom: 1.25rem;
  padding: clamp(1rem, 0.75rem + 1vw, 1.5rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.ops-card__title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 650;
}

.ops-card__lead {
  margin: 0 0 1rem;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------- forms, buttons */

.ops-form {
  display: grid;
  gap: 1rem;
}

.ops-form--inline {
  grid-template-columns: 1fr;
  align-items: end;
}

@media (min-width: 40rem) {
  .ops-form--inline {
    grid-template-columns: 1fr auto;
  }
}

.ops-field {
  display: grid;
  gap: 0.35rem;
}

.ops-field__label {
  font-size: 0.9rem;
  font-weight: 600;
}

.ops-field__hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.ops-field__input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--ink-muted);
  border-radius: 10px;
}

.ops-field__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.ops-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.ops-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}

/* Scoped like .ops-page a, so a link drawn as a button keeps the button's colours. */
.ops-page .ops-btn--primary {
  color: var(--surface);
  background: var(--accent);
}

.ops-page .ops-btn--primary:hover {
  color: var(--surface);
  background: var(--accent-strong);
}

.ops-page .ops-btn--secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--ink-muted);
}

.ops-page .ops-btn--secondary:hover {
  color: var(--ink);
  background: var(--surface-sunken);
}

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

.ops-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.ops-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.ops-table th,
.ops-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}

.ops-table thead th {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--surface-sunken);
}

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

.ops-table__time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.ops-table__subject {
  overflow-wrap: anywhere;
}

/* Below 40rem the table becomes a list of labelled blocks, so nothing scrolls
 * sideways on a phone. The labels come from each cell's data-label. */
@media (max-width: 39.99rem) {
  .ops-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .ops-table,
  .ops-table tbody,
  .ops-table tr,
  .ops-table td {
    display: block;
  }

  .ops-table tr {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line-soft);
  }

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

  .ops-table td {
    padding: 0.2rem 0.85rem;
    border-bottom: 0;
  }

  .ops-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-muted);
  }
}

/* The actions under a list: a hint on one side, the button on the other. */
.ops-table-wrap + .ops-actions {
  justify-content: space-between;
  margin-top: 0.75rem;
}

.ops-chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-soft);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.ops-empty {
  margin: 0;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--ink-muted);
}

/* ------------------------------------------------------------- detail view */

.ops-back {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.ops-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
  font-size: 0.92rem;
}

.ops-meta dt {
  font-weight: 600;
  color: var(--ink-soft);
}

.ops-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.ops-pre {
  margin: 0;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.ops-frame {
  display: block;
  width: 100%;
  height: 32rem;
  /* The mail draws its own light frame; a light backdrop keeps it readable when the
   * page is dark. */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

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