/* =========================================================================
   MMA-DMS · Base + Shared Components
   ========================================================================= */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: 'ss01' on, 'cv11' on;
  min-height: 100vh;
  position: relative;
}

/* Subtle paper grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.1  0 0 0 0 0.08  0 0 0 0.035 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.6;
  z-index: 1;
  mix-blend-mode: multiply;
}

body > * { position: relative; z-index: 2; }

/* --- Typography --------------------------------------------------------- */

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink-2);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  margin: 0;
  font-variation-settings: 'SOFT' 30, 'WONK' 0, 'opsz' 60;
}

p { margin: 0; color: var(--graphite); }

a { color: var(--burgundy); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color var(--t-fast); }
a:hover { border-color: var(--burgundy); }

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: var(--ls-mono);
  font-feature-settings: 'calt' off;
}

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 500;
}

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

.rule--dotted {
  height: 0;
  border: 0;
  border-top: 1px dotted var(--mist);
}

.rule--heavy {
  height: 2px;
  background: var(--ink);
  border: 0;
}

/* --- Top bar ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-7);
  border-bottom: 1px solid var(--hairline);
  background: var(--paper);
  backdrop-filter: blur(8px);
}

.wordmark {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink-2);
  font-variation-settings: 'SOFT' 0, 'WONK' 1, 'opsz' 18;
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
}

.wordmark__dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--burgundy);
  border-radius: 50%;
  transform: translateY(-2px);
}

.wordmark__sub {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fog);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  border-left: 1px solid var(--hairline);
  padding-left: var(--sp-3);
  margin-left: var(--sp-2);
}

.topbar__nav {
  display: flex;
  gap: var(--sp-5);
  align-items: center;
}

.topbar__nav a {
  color: var(--graphite);
  font-size: var(--fs-sm);
  border: none;
  transition: color var(--t-fast);
}

.topbar__nav a:hover { color: var(--burgundy); }
.topbar__nav a.active { color: var(--ink); border-bottom: 1px solid var(--burgundy); padding-bottom: 2px; }

.topbar__user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* --- Avatar ------------------------------------------------------------- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.01em;
  border: 1px solid var(--hairline);
  text-transform: uppercase;
}

.avatar--sm { width: 24px; height: 24px; font-size: var(--fs-xs); }
.avatar--lg { width: 40px; height: 40px; font-size: var(--fs-md); }

/* --- Track badge -------------------------------------------------------- */

.track-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--paper);
  font-variation-settings: 'SOFT' 0, 'WONK' 0, 'opsz' 18;
  line-height: 1;
  box-shadow: var(--sh-sm), var(--sh-inset);
}

.track-badge--a { background: var(--track-a); }
.track-badge--b { background: var(--track-b); }
.track-badge--c { background: var(--track-c); }
.track-badge--d { background: var(--track-d); }
.track-badge--e { background: var(--track-e); }
.track-badge--f { background: var(--track-f); }

/* Track ribbon (A→F progress bar) */
.track-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
}

.track-ribbon__step {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--mist);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  color: var(--mist);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all var(--t-fast);
}

.track-ribbon__step--done {
  background: var(--sage);
  border-color: var(--sage);
  color: var(--paper);
}

.track-ribbon__step--active {
  background: var(--burgundy);
  border-color: var(--burgundy);
  color: var(--paper);
  box-shadow: 0 0 0 3px rgba(126, 42, 42, 0.15);
}

.track-ribbon__step--restart {
  background: var(--rust);
  border-color: var(--rust);
  color: var(--paper);
}

.track-ribbon__sep {
  width: 4px; height: 1px; background: var(--mist);
}

/* --- Tier badge --------------------------------------------------------- */

.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  font-weight: 500;
}

.tier-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tier-badge--1 { background: var(--tier-1-bg); color: var(--tier-1-fg); }
.tier-badge--2 { background: var(--tier-2-bg); color: var(--tier-2-fg); }
.tier-badge--3 { background: var(--tier-3-bg); color: var(--tier-3-fg); }
.tier-badge--4 { background: var(--tier-4-bg); color: var(--tier-4-fg); }

/* --- Status badge ------------------------------------------------------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fog);
}

.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fog);
  box-shadow: 0 0 0 2px rgba(0,0,0,0);
}

.status--pending .status__dot { background: var(--slate); }
.status--active .status__dot { background: var(--burgundy); box-shadow: 0 0 0 3px rgba(126,42,42,0.15); animation: pulse 2s var(--ease) infinite; }
.status--approved .status__dot { background: var(--sage); }
.status--restart .status__dot { background: var(--rust); }
.status--blocked .status__dot { background: var(--ink); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(126, 42, 42, 0.15); }
  50%      { box-shadow: 0 0 0 6px rgba(126, 42, 42, 0.05); }
}

/* --- Button ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all var(--t-fast);
  background: transparent;
  color: var(--ink);
}

.btn--primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn--primary:hover {
  background: var(--burgundy);
  border-color: var(--burgundy);
}

.btn--ghost {
  background: transparent;
  border-color: var(--hairline);
  color: var(--graphite);
}

.btn--ghost:hover { border-color: var(--ink); color: var(--ink); }

.btn--sm { padding: 6px 12px; font-size: var(--fs-xs); }

/* --- Card --------------------------------------------------------------- */

.card {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  transition: all var(--t-fast);
}

.card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }

/* --- Ticket card -------------------------------------------------------- */

.ticket-card {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--mist);
  border-radius: 2px;
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
}

.ticket-card:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-1px);
  border-left-color: var(--burgundy);
}

.ticket-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.ticket-card__id {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fog);
  letter-spacing: var(--ls-mono);
}

.ticket-card__title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  line-height: 1.25;
  color: var(--ink);
  font-weight: 400;
  font-variation-settings: 'SOFT' 30, 'opsz' 36;
  margin: 0;
}

.ticket-card__rationale {
  font-size: var(--fs-sm);
  color: var(--graphite);
  line-height: var(--lh-normal);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ticket-card__rationale::before {
  content: '"';
  font-family: var(--font-display);
  font-size: 1.5em;
  line-height: 0;
  vertical-align: -0.3em;
  color: var(--mist);
  margin-right: 0.15em;
}

.ticket-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px dotted var(--mist);
  font-size: var(--fs-xs);
  color: var(--fog);
}

.ticket-card__meta-left {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.ticket-card__badges {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

.ticket-card--locked {
  border-left-color: var(--brass);
  background: linear-gradient(135deg, var(--paper) 0%, var(--parchment) 100%);
}

.ticket-card--restart {
  border-left-color: var(--rust);
}

.ticket-card--approved {
  border-left-color: var(--sage);
  opacity: 0.9;
}

/* --- Lock icon (Active Reviewer) --------------------------------------- */

.lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 4px;
  background: var(--brass);
  color: var(--paper);
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.lock-badge::before {
  content: '◉';
  font-size: 10px;
  line-height: 1;
}

/* --- Decorative stamp --------------------------------------------------- */

.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2) var(--sp-4);
  border: 2px solid currentColor;
  color: var(--burgundy);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  transform: rotate(-4deg);
  opacity: 0.75;
  font-variation-settings: 'SOFT' 0, 'WONK' 1, 'opsz' 18;
}

.stamp--sage { color: var(--sage); }
.stamp--rust { color: var(--rust); }

/* --- Focus ring --------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--burgundy);
  outline-offset: 2px;
}

/* --- Scrollbar ---------------------------------------------------------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--mist); border-radius: var(--r-pill); border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--fog); }

/* --- Utilities ---------------------------------------------------------- */

.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;
}
