/*
  Alina Security operator portal -- design tokens and shell.

  Direction: a calm operations handover board. Warm paper, deep ink,
  restrained green; amber and red are reserved for attention only, and never
  used alone -- every status also carries a text label or glyph.

  Signature element: the Duty Line, a live Singapore-time handover sequence
  through today's briefing, acknowledgement, start and completion milestones,
  grouped as Earlier / Now / Next / Later at every width.
*/

:root {
  /* Color: warm paper, deep ink, restrained green */
  --color-bg: #f3ecdd;
  --color-surface: #fffdf7;
  --color-surface-sunken: #eae1cb;
  --color-ink: #2b2419;
  --color-ink-muted: #6b6154;
  --color-rule: #d9cba9;
  --color-rule-strong: #b9a97e;
  --color-green: #2f5d46;
  --color-green-strong: #234636;
  --color-green-soft: #e1eee3;
  --color-amber: #8a5a12;
  --color-amber-soft: #f3e6ce;
  --color-red: #9b2f26;
  --color-red-soft: #f5e1de;
  --color-focus: #234636;
  --color-shadow: 43 33 15;

  /* Typography: a characterful serif for display, a humanist sans for the
     working surface, a monospace for exact times and codes. None of these
     are Inter, Roboto, Arial, or a bare system stack. */
  --font-display: "Iowan Old Style", "Sitka Display", Georgia, "Times New Roman", serif;
  --font-body: "Seravek", "Segoe UI Variable Text", "Noto Sans", "Helvetica Neue", sans-serif;
  --font-mono: "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  --text-xs: 0.75rem;
  --leading-xs: 1.35;
  --text-sm: 0.875rem;
  --leading-sm: 1.45;
  --text-base: 1rem;
  --leading-base: 1.55;
  --text-lg: 1.1875rem;
  --leading-lg: 1.4;
  --text-xl: 1.5rem;
  --leading-xl: 1.25;
  --text-2xl: 2rem;
  --leading-2xl: 1.15;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /* Shape and depth */
  --radius-sm: 4px;
  --radius-md: 10px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgb(var(--color-shadow) / 0.14);
  --shadow-md: 0 6px 20px rgb(var(--color-shadow) / 0.16);

  /* Motion */
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-base: 0ms;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--color-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--color-ink);
  margin: 0 0 var(--space-2);
}

h1 { font-size: var(--text-2xl); line-height: var(--leading-2xl); }
h2 { font-size: var(--text-xl); line-height: var(--leading-xl); }
h3 { font-size: var(--text-lg); line-height: var(--leading-lg); }

p { margin: 0 0 var(--space-3); color: var(--color-ink); }

a {
  color: var(--color-green-strong);
  text-underline-offset: 0.15em;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; overflow-wrap: break-word; }

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

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -3rem;
  background: var(--color-ink);
  color: var(--color-surface);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  z-index: 100;
  transition: top var(--duration-fast) var(--ease-out);
}
.skip-link:focus {
  top: var(--space-3);
}

/* Visually hidden but still reachable by assistive tech: the live
   announcement region the shell's minimal JavaScript writes into. */
.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;
}

/* ---------- App shell ---------- */

.shell-header {
  border-bottom: 1px solid var(--color-rule);
  background: var(--color-surface);
}

.shell-header__bar {
  max-width: 76rem;
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--color-green-strong);
  white-space: nowrap;
}

.wordmark__agency {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  /* Break out of the wordmark's own nowrap: an agency name is operator
     content with no length guarantee, and must wrap onto its own line at
     narrow widths instead of forcing the header into horizontal scroll. */
  white-space: normal;
}

.primary-nav {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-left: auto;
}

.primary-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-ink-muted);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  border: 1px solid transparent;
}

.primary-nav a:hover {
  color: var(--color-green-strong);
  background: var(--color-green-soft);
}

.primary-nav a[aria-current="page"] {
  color: var(--color-green-strong);
  background: var(--color-green-soft);
  border-color: var(--color-rule-strong);
}

.session-form {
  margin: 0;
}

.button-quiet {
  min-height: 44px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  /* Sits on the header bar's own surface color, so the border is the only
     thing that makes this read as a button rather than plain header text:
     it needs the 3:1 non-text contrast a merely decorative rule would not. */
  border: 1px solid var(--color-ink-muted);
  background: var(--color-surface);
  color: var(--color-ink-muted);
  font: inherit;
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
}
.button-quiet:hover { color: var(--color-ink); border-color: var(--color-ink); }

.shell-main {
  max-width: 76rem;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-8);
}

.page-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.page-heading__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.page-heading__date {
  font-family: var(--font-mono);
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
}

/* ---------- Duty Line (signature element) ---------- */

.queue-grid--today {
  align-items: start;
}

.queue-grid--today .delta-row {
  align-self: stretch;
}

.duty-line {
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-4) var(--space-4);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.duty-line__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.duty-line__now {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-green-strong);
  background: var(--color-green-soft);
  border-radius: 999px;
  padding: var(--space-1) var(--space-3);
}

.duty-card__detail {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  margin-top: var(--space-1);
  overflow-wrap: break-word;
}

.duty-line__empty {
  margin-top: var(--space-6);
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
}

.duty-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.duty-cards__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.duty-cards__group-label {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-ink-muted);
}

.duty-cards__group-label--now {
  color: var(--color-green-strong);
}

.duty-cards__group-empty {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
}

.duty-card {
  flex: 1;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--color-surface-sunken);
}

.duty-card__label {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink);
  text-decoration: none;
  margin-bottom: var(--space-1);
}

.duty-card__label:hover {
  color: var(--color-green-strong);
  text-decoration: underline;
}

.duty-card__state {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

@media (min-width: 768px) {
  .duty-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .duty-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---------- Empty / status states ---------- */

.empty-state {
  background: var(--color-surface);
  border: 1px dashed var(--color-rule-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  text-align: left;
  color: var(--color-ink-muted);
}

.empty-state h2 {
  color: var(--color-ink);
}

/* ---------- Access / recovery pages (no shell chrome) ---------- */

.access-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.access-card {
  width: 100%;
  max-width: 26rem;
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-8) var(--space-6);
}

.access-card__mark {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-green-strong);
  font-size: var(--text-lg);
  margin-bottom: var(--space-4);
}

.button-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: none;
  background: var(--color-green);
  color: var(--color-surface);
  font: inherit;
  font-weight: 700;
  font-size: var(--text-base);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
.button-primary:hover { background: var(--color-green-strong); }

.access-card .button-primary { margin-top: var(--space-4); }

.access-note {
  font-size: var(--text-xs);
  color: var(--color-ink-muted);
  margin-top: var(--space-3);
}

/* ---------- Shared record components ---------- */

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.form-actions .button-primary,
.button-primary--auto {
  width: auto;
  min-width: 10rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 28px;
  padding: var(--space-1) var(--space-3);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.status-pill--open,
.status-pill--report-ready {
  background: var(--color-green-soft);
  color: var(--color-green-strong);
  border-color: var(--color-green-strong);
}

.status-pill--covered {
  background: var(--color-green-soft);
  color: var(--color-green-strong);
}

.status-pill--urgent {
  background: var(--color-red-soft);
  color: var(--color-red);
  border-color: var(--color-red);
}

.status-pill--uncovered {
  background: var(--color-red-soft);
  color: var(--color-red);
}

.status-pill--stale,
.status-pill--report-needed {
  background: var(--color-amber-soft);
  color: var(--color-amber);
  border-color: var(--color-amber);
}

.status-pill--pending {
  background: var(--color-amber-soft);
  color: var(--color-amber);
}

.status-pill--resolved {
  background: var(--color-surface-sunken);
  color: var(--color-ink-muted);
  border-color: var(--color-rule-strong);
}

.status-pill--neutral {
  background: var(--color-surface-sunken);
  color: var(--color-ink-muted);
}

p.status-pill {
  white-space: normal;
  text-align: left;
  height: auto;
}

.fact-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--space-3) var(--space-4);
  margin: 0;
}

.fact-list dt {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-ink-muted);
}

.fact-list dd {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
}

.fact-list__wide {
  grid-column: 1 / -1;
}

/* ---------- Responsive rhythm ---------- */

@media (min-width: 768px) {
  .shell-main { padding-top: var(--space-8); }
}

@media (max-width: 400px) {
  .shell-header__bar,
  .shell-main {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }
}
