/*
 * Shared design tokens + components for the launch portal (index.html, split-view.html).
 *
 * Palette source: World Wide Technology's own design tokens (harvested from wwt.com's
 * --bs-* custom properties) cross-checked against the ATC labdocs CDN skin
 * (atc-cdn.apps.wwtatc.com/css/labdocs-mkdocs.css, already referenced by labdocs/mkdocs.yml).
 * Every pairing below is contrast-verified against WCAG 2.2 AA (4.5:1 text, 3:1 non-text/UI).
 * Rejected after measuring: #0086ea as text (3.75:1), #ff5100 as text (3.27:1),
 * #ee282a on white (4.22:1), #a3a4b7 as a border (2.46:1), #008b5d as status text (4.33:1).
 */

:root {
  color-scheme: light;

  /* surfaces */
  --wwt-bg: #f7f7fc; /* --bs-gray-50 */
  --wwt-surface: #ffffff;
  --wwt-surface-2: #f0f0fa; /* --bs-gray-100 */

  /* ink */
  --wwt-ink: #0a0b19; /* --bs-black; headings, 18.30:1 on bg */
  --wwt-body: #4e4f5f; /* --bs-gray-400; prose, 7.54:1 on bg / 8.05:1 on surface */
  --wwt-navy: #1d1e48; /* --bs-navy-400; 15.77:1 on surface */

  /* brand blue */
  --wwt-blue: #006dc7; /* --bs-blue-500; 5.23:1 on surface, 4.90:1 on bg */
  --wwt-blue-deep: #00539b; /* hover/active, 7.75:1 on surface */
  --wwt-blue-pale: #e8f1fb; /* tint fills */

  /* accent -- fill/graphic only, never as text (3.27:1 on white fails 4.5:1) */
  --wwt-orange: #ff5100; /* --bs-orange-brand */

  /* status -- AA on white, and never the only signal (always paired with text/icon) */
  --wwt-ok: #00744d; /* --bs-green-500, 5.82:1 */
  --wwt-warn: #c33d04; /* --bs-orange-500, 5.26:1 */
  --wwt-danger: #a70c0c; /* --bs-maroon-500, 7.77:1 */

  /* lines -- meets 1.4.11's 3:1 (today's greys at 2.46:1 do not) */
  --wwt-rule: #8a8b9c; /* 3.36:1 on surface, 3.14:1 on bg */
  --wwt-rule-soft: #e4e4eb; /* decorative dividers only, not load-bearing */

  --wwt-font: "Hanken Grotesk", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  --wwt-mono: SFMono-Regular, ui-monospace, Consolas, "Liberation Mono", Menlo, Courier, monospace;

  --wwt-radius: 12px;
  --wwt-radius-sm: 8px;
  --wwt-topbar-height: 56px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--wwt-bg);
  color: var(--wwt-body);
  font-family: var(--wwt-font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  color: var(--wwt-ink);
  line-height: 1.25;
  font-weight: 700;
}

a {
  color: var(--wwt-blue);
}

a:hover {
  color: var(--wwt-blue-deep);
}

code,
pre {
  font-family: var(--wwt-mono);
}

/* Visually hidden but available to assistive tech -- never use display:none for this. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip links: off-screen until focused, then pinned to the top. */
.skip-link {
  position: absolute;
  top: -3rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--wwt-ink);
  color: #fff;
  border-radius: 0 0 var(--wwt-radius-sm) var(--wwt-radius-sm);
  text-decoration: none;
  font-weight: 600;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
}

/* One focus treatment, everywhere -- 3:1 against both surfaces (measured). */
:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--wwt-blue);
  outline-offset: 2px;
  border-radius: 2px;
}

.btn-primary:focus-visible {
  outline-color: var(--wwt-ink);
  box-shadow: 0 0 0 2px #fff;
}

/* Wordmark lockup -- typeset, no image file exists for this yet. */
.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  text-decoration: none;
  line-height: 1;
}

.wordmark:hover {
  text-decoration: none;
}

.wordmark__wwt {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--wwt-ink);
}

.wordmark__rule {
  width: 3px;
  height: 1.1em;
  background: var(--wwt-orange);
  border-radius: 1px;
}

.wordmark__label {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--wwt-body);
}

.btn {
  appearance: none;
  border: none;
  border-radius: var(--wwt-radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: default;
  opacity: 0.65;
}

.btn-primary {
  background: var(--wwt-blue);
  color: #fff;
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
}

.btn-primary:hover:not([aria-disabled="true"]) {
  background: var(--wwt-blue-deep);
}

.btn-secondary {
  background: var(--wwt-surface);
  color: var(--wwt-navy);
  border: 1px solid var(--wwt-rule);
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

.btn-secondary:hover {
  background: var(--wwt-surface-2);
}

/* Status line -- a live region, not just styled text. See index.html JS for the wiring. */
.status-line {
  font-size: 0.95rem;
  min-height: 1.5em;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.status-line[data-tone="ok"] {
  color: var(--wwt-ok);
}

.status-line[data-tone="warn"] {
  color: var(--wwt-warn);
}

.status-line[data-tone="danger"] {
  color: var(--wwt-danger);
}

.status-line__icon {
  font-weight: 700;
}

.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: wwt-spin 0.7s linear infinite;
  flex: none;
}

@keyframes wwt-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-right-color: currentColor;
    border-top-color: transparent;
  }

  .btn,
  .skip-link {
    transition: none;
  }
}

/* Segmented layout switch (split-view.html) -- native radios, no drag, full keyboard support. */
.layout-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  margin: 0;
  border: 1px solid var(--wwt-rule);
  border-radius: 999px;
  background: var(--wwt-surface);
}

.layout-switch input {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  /* deliberately not display:none -- must stay in the tab order and keyboard-operable */
}

.layout-switch label {
  min-width: 24px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--wwt-body);
  cursor: pointer;
  user-select: none;
}

.layout-switch input:checked + label {
  background: var(--wwt-blue);
  color: #fff;
}

.layout-switch input:focus-visible + label {
  outline: 3px solid var(--wwt-blue);
  outline-offset: 2px;
  border-radius: 999px;
}

/* ---------------------------------------------------------------------------
 * Admin dashboard (admin.html).
 *
 * Reuses the tokens above rather than introducing new colours -- every pairing
 * at the top of this file is already contrast-measured against WCAG 2.2 AA, and
 * a dashboard is exactly where "just this one grey" tends to creep in.
 *
 * State is never conveyed by colour alone (1.4.1): every badge carries a glyph
 * AND a distinct word, so it survives greyscale, colour blindness, and a
 * screen reader reading the cell aloud.
 * ------------------------------------------------------------------------- */

.admin-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.admin-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--wwt-surface);
  border-bottom: 1px solid var(--wwt-rule);
}

.admin-whoami {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.admin-card {
  background: var(--wwt-surface);
  border: 1px solid var(--wwt-rule-soft);
  border-radius: var(--wwt-radius);
  padding: 1.25rem;
  margin-block: 1.5rem;
}

.admin-card > h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.admin-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.admin-hint {
  font-size: 0.85rem;
  color: var(--wwt-body);
  margin: 0.25rem 0 0;
}

/*
 * Marks an audit actor that was self-declared via the shared admin key rather
 * than proven by Entra sign-in.
 *
 * `display: block` so it sits under the name instead of running on beside it,
 * and --wwt-warn (5.26:1 on surface) rather than a decorative grey: this is a
 * caveat on evidence, so it has to be legible. Colour is never the signal on its
 * own -- the element always carries the words "self-declared", per the same
 * text-and-not-just-colour rule the state pills follow.
 */
.admin-unverified {
  display: block;
  color: var(--wwt-warn);
  font-style: italic;
}

/* Separates the two unlock paths. Decorative only, hence rule-soft and aria-hidden
   by virtue of being an <hr> the two labelled sections already explain. */
.admin-unlock__or {
  border: 0;
  border-top: 1px solid var(--wwt-rule-soft);
  margin: 1.25rem 0;
}

/* Summary tiles. A definition list, because that is what these are. */
.admin-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.admin-tile {
  background: var(--wwt-surface-2);
  border-radius: var(--wwt-radius-sm);
  padding: 0.75rem 1rem;
}

.admin-tile dt {
  font-size: 0.8rem;
  color: var(--wwt-body);
}

.admin-tile dd {
  margin: 0.2rem 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--wwt-ink);
  font-variant-numeric: tabular-nums;
}

/* Wide tables scroll inside their own container; the page never scrolls sideways. */
.admin-tablewrap {
  overflow-x: auto;
  margin-top: 1rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table caption {
  text-align: left;
  font-size: 0.85rem;
  color: var(--wwt-body);
  padding-bottom: 0.5rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--wwt-rule-soft);
  vertical-align: top;
}

.admin-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--wwt-navy);
  border-bottom: 1px solid var(--wwt-rule);
  white-space: nowrap;
}

.admin-table tbody tr:hover {
  background: var(--wwt-surface-2);
}

.admin-table code {
  font-size: 0.85em;
}

.admin-nowrap {
  white-space: nowrap;
}

.admin-num {
  font-variant-numeric: tabular-nums;
}

/* State badge: glyph + word, never colour alone. */
.admin-state {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35em;
  font-weight: 600;
  white-space: nowrap;
}

.admin-state__glyph {
  font-weight: 700;
}

.admin-state[data-state="active"] {
  color: var(--wwt-ok);
}

.admin-state[data-state="unused"] {
  color: var(--wwt-body);
}

.admin-state[data-state="expired"],
.admin-state[data-state="force-expired"],
.admin-state[data-state="pending"] {
  color: var(--wwt-warn);
}

.admin-state[data-state="revoked"],
.admin-state[data-state="corrupt"] {
  color: var(--wwt-danger);
}

/* Row action buttons, kept to a 24px minimum target (2.5.8). */
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.admin-actions .btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  min-height: 24px;
}

.btn-danger {
  background: var(--wwt-surface);
  color: var(--wwt-danger);
  border: 1px solid var(--wwt-danger);
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

.btn-danger:hover {
  background: #fdeaea;
}

/* Dialogs, matching index.html's native <dialog> gate pattern. */
.admin-dialog {
  border: none;
  border-radius: var(--wwt-radius);
  padding: 0;
  max-width: 32rem;
  width: calc(100% - 2rem);
  color: var(--wwt-body);
}

.admin-dialog::backdrop {
  background: rgb(10 11 25 / 55%);
}

.admin-dialog__body {
  padding: 1.5rem;
}

.admin-dialog h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.admin-dialog label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--wwt-navy);
  margin-bottom: 0.3rem;
}

.admin-dialog input,
.admin-dialog textarea {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--wwt-rule);
  border-radius: var(--wwt-radius-sm);
  background: var(--wwt-surface);
  color: var(--wwt-ink);
}

.admin-dialog__row {
  margin-bottom: 1rem;
}

.admin-dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* A revealed code. Large and monospaced because it gets read aloud and retyped. */
.admin-code-reveal {
  font-family: var(--wwt-mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--wwt-ink);
  background: var(--wwt-blue-pale);
  border-radius: var(--wwt-radius-sm);
  padding: 0.75rem 1rem;
  word-break: break-all;
  user-select: all;
}

.admin-empty {
  color: var(--wwt-body);
  font-size: 0.9rem;
  padding: 1rem 0;
}

.admin-error {
  color: var(--wwt-danger);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Detail values in the status card: strings, not the tiles' big-number treatment. */
.admin-tile dd.admin-tile__text {
  font-size: 0.95rem;
  font-weight: 600;
}

/* A request's free-text reason: preserve the visitor's line breaks, cap the width
 * so one long note cannot push the action column off screen. */
.admin-notes {
  white-space: pre-wrap;
  max-width: 28rem;
}
