/* ============================================================
   Guide School — Component CSS
   Implements §5 of the spec. Import after design-tokens.css.
   ============================================================ */

/* ──────────────────────────────────────────────────────────
   Mockup chrome — used by every component & screen demo file
   so the design output reads consistently.
   ────────────────────────────────────────────────────────── */

.mockup-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-8) var(--space-16);
}
.mockup-shell.wide { max-width: 1440px; }
.mockup-shell.narrow { max-width: 960px; }

.mockup-meta {
  border-bottom: 1px solid var(--ink-100);
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-10);
}
.mockup-eyebrow {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-500);
  margin: 0 0 var(--space-2);
}
.mockup-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-3xl);
  line-height: var(--lh-3xl);
  letter-spacing: var(--tracking-tight);
  color: var(--ink-900);
  margin: 0 0 var(--space-3);
  font-weight: 400;
}
.mockup-blurb {
  font-size: var(--text-base);
  color: var(--ink-500);
  max-width: 60ch;
  margin: 0;
  text-wrap: pretty;
}
.mockup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.mockup-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--paper-100);
  color: var(--ink-700);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}

.mockup-section {
  margin-top: var(--space-12);
}
.mockup-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--ink-100);
  padding-bottom: var(--space-3);
}
.mockup-section-title {
  font-size: var(--text-xl);
  line-height: var(--lh-xl);
  font-weight: 600;
  color: var(--ink-900);
  margin: 0;
  letter-spacing: var(--tracking-tight);
}
.mockup-section-hint {
  font-size: var(--text-sm);
  color: var(--ink-500);
  margin: 0;
}

.state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-6);
}
.state-cell {
  background: var(--paper-base);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 120px;
  position: relative;
}
.state-cell.checker {
  background-image:
    linear-gradient(45deg, var(--paper-100) 25%, transparent 25%),
    linear-gradient(-45deg, var(--paper-100) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--paper-100) 75%),
    linear-gradient(-45deg, transparent 75%, var(--paper-100) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}
.state-label {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-500);
  font-weight: 500;
  margin: 0;
}
.state-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ──────────────────────────────────────────────────────────
   5.1  BUTTONS
   ────────────────────────────────────────────────────────── */

.btn {
  --btn-h: 36px;
  --btn-px: var(--space-4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-h);
  padding: 0 var(--btn-px);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.btn:focus-visible { box-shadow: var(--shadow-focus); }
.btn [data-lucide] { width: 16px; height: 16px; }

.btn.sm { --btn-h: 28px; --btn-px: var(--space-3); font-size: var(--text-xs); }
.btn.lg { --btn-h: 44px; --btn-px: var(--space-5); font-size: var(--text-base); }

/* Primary */
.btn-primary {
  background: var(--accent-600);
  color: var(--paper-base);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--accent-700); }
.btn-primary:active { background: var(--accent-700); transform: translateY(1px); }
.btn-primary[disabled], .btn-primary.is-disabled {
  background: var(--ink-200); color: var(--ink-500); cursor: not-allowed; box-shadow: none;
}

/* Secondary */
.btn-secondary {
  background: var(--paper-base);
  border-color: var(--ink-200);
  color: var(--ink-800);
}
.btn-secondary:hover { background: var(--paper-100); border-color: var(--ink-300); }
.btn-secondary:active { background: var(--paper-200); }
.btn-secondary[disabled] { color: var(--ink-300); cursor: not-allowed; }

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--ink-700);
}
.btn-ghost:hover { background: var(--paper-100); color: var(--ink-900); }
.btn-ghost:active { background: var(--paper-200); }

/* Danger */
.btn-danger {
  background: var(--red-600);
  color: var(--paper-base);
}
.btn-danger:hover { background: #B91C1C; }
.btn-danger:active { background: #991B1B; }

/* Link */
.btn-link {
  background: transparent;
  color: var(--accent-600);
  height: auto;
  padding: 0;
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }

/* Icon-only */
.btn-icon { padding: 0; width: var(--btn-h); }

/* Loading */
.btn .spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ──────────────────────────────────────────────────────────
   5.2  INPUT FIELDS
   ────────────────────────────────────────────────────────── */

.field { display: block; }
.field + .field { margin-top: var(--space-5); }

.field-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-700);
  margin-bottom: var(--space-2);
}
.field-label .req { color: var(--accent-600); }

.input, .textarea, .select-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh-base);
  color: var(--ink-800);
  background: var(--paper-base);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-300); }
.input.lg, .select-trigger.lg { height: 40px; }
.textarea {
  min-height: 96px;
  padding: var(--space-3);
  height: auto;
  resize: vertical;
}
.input:hover, .textarea:hover, .select-trigger:hover { border-color: var(--ink-300); }
.input:focus, .textarea:focus, .select-trigger:focus {
  outline: none;
  border-color: var(--accent-600);
  box-shadow: var(--shadow-focus);
}
.input[disabled], .textarea[disabled] {
  background: var(--paper-100);
  color: var(--ink-300);
  cursor: not-allowed;
}
.input[readonly] { background: var(--paper-50); }

.field.has-error .input,
.field.has-error .textarea,
.field.has-error .select-trigger { border-color: var(--red-600); }
.field.has-error .field-help { color: var(--red-600); }

.field-help {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  line-height: var(--lh-xs);
  color: var(--ink-500);
  margin-top: var(--space-2);
}
.field-help [data-lucide] { width: 12px; height: 12px; }

/* Input with prefix icon (e.g. search) */
.input-wrap { position: relative; }
.input-wrap .input { padding-left: 36px; }
.input-wrap .input-prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-500);
  pointer-events: none;
}
.input-wrap .input-prefix [data-lucide] { width: 16px; height: 16px; }
.input-wrap .input-suffix {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 4px;
}

/* ──────────────────────────────────────────────────────────
   5.3  CARDS
   ────────────────────────────────────────────────────────── */

.card {
  background: var(--paper-base);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.card.elevated { border: none; box-shadow: var(--shadow-sm); }
.card.interactive {
  transition: transform var(--duration-base) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out);
  cursor: pointer;
}
.card.interactive:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--ink-200);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin: calc(var(--space-6) * -1) calc(var(--space-6) * -1) var(--space-6);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--ink-100);
}
.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--ink-900);
  margin: 0;
  line-height: var(--lh-lg);
}
.card-subtitle {
  font-size: var(--text-sm);
  color: var(--ink-500);
  margin: 2px 0 0;
}
.card-footer {
  margin: var(--space-6) calc(var(--space-6) * -1) calc(var(--space-6) * -1);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--ink-100);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ──────────────────────────────────────────────────────────
   5.4  TABLE
   ────────────────────────────────────────────────────────── */

.gs-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper-base);
  font-size: var(--text-sm);
}
.gs-table thead th {
  background: var(--paper-50);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-500);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--ink-100);
  white-space: nowrap;
}
.gs-table thead th.sortable { cursor: pointer; user-select: none; }
.gs-table thead th.sortable:hover { color: var(--ink-700); }
.gs-table thead th .sort-icon {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 4px;
  opacity: 0.4;
}
.gs-table thead th.sorted .sort-icon { opacity: 1; color: var(--accent-600); }

.gs-table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--ink-100);
  color: var(--ink-800);
  vertical-align: middle;
}
.gs-table tbody tr { transition: background-color var(--duration-fast) var(--ease-out); }
.gs-table tbody tr:hover { background: var(--paper-100); }
.gs-table tbody tr.selected {
  background: var(--accent-50);
  box-shadow: inset 3px 0 0 var(--accent-600);
}

.gs-table.compact tbody td,
.gs-table.compact thead th { padding: var(--space-2) var(--space-4); }
.gs-table.relaxed tbody td { padding: var(--space-4) var(--space-4); }

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

/* Table wrapper to give the rounded shell */
.table-wrap {
  background: var(--paper-base);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ──────────────────────────────────────────────────────────
   5.5  TABS
   ────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--ink-100);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-500);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.tab:hover { color: var(--ink-800); }
.tab.active {
  color: var(--ink-900);
  border-bottom-color: var(--accent-600);
}
.tab .tab-count {
  background: var(--ink-100);
  color: var(--ink-700);
  font-size: var(--text-xs);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 500;
}
.tab.active .tab-count { background: var(--accent-100); color: var(--accent-600); }

/* ──────────────────────────────────────────────────────────
   5.6  MODAL
   ────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 20, 25, 0.40);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  z-index: 50;
}
.modal {
  background: var(--paper-base);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 560px;
  width: calc(100% - var(--space-8));
  overflow: hidden;
  animation: modalIn var(--duration-base) var(--ease-out);
}
.modal.md { max-width: 720px; }
.modal.lg { max-width: 960px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--ink-100);
  gap: var(--space-4);
}
.modal-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--ink-900);
  margin: 0;
  letter-spacing: var(--tracking-tight);
}
.modal-subtitle { font-size: var(--text-sm); color: var(--ink-500); margin: 4px 0 0; }
.modal-body { padding: var(--space-6); max-height: 60vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--ink-100);
}

/* ──────────────────────────────────────────────────────────
   5.7  TOOLTIP
   ────────────────────────────────────────────────────────── */

.tooltip {
  position: relative; display: inline-flex;
}
.tooltip-bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-900);
  color: var(--paper-base);
  font-size: var(--text-xs);
  line-height: var(--lh-xs);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  max-width: 280px;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}
.tooltip-bubble::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--ink-900);
}

/* ──────────────────────────────────────────────────────────
   5.8  BADGE / PILL
   ────────────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  line-height: var(--lh-xs);
  white-space: nowrap;
}
.pill [data-lucide] { width: 12px; height: 12px; }

.pill-success  { background: var(--green-100);  color: var(--green-600); }
.pill-warning  { background: var(--amber-100);  color: var(--amber-600); }
.pill-error    { background: var(--red-100);    color: var(--red-600); }
.pill-info     { background: var(--blue-100);   color: var(--blue-600); }
.pill-accent   { background: var(--accent-100); color: var(--accent-600); }
.pill-neutral  { background: var(--paper-100);  color: var(--ink-700); }

/* Verdict pills (mastery) */
.verdict { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); font-weight: 500; padding: 2px var(--space-3); border-radius: var(--radius-full); }
.verdict::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.verdict-excelling { background: var(--green-100);  color: var(--green-600); }
.verdict-ontrack   { background: var(--accent-100); color: var(--accent-600); }
.verdict-watch     { background: var(--amber-100); color: var(--amber-600); }
.verdict-behind    { background: var(--red-100);   color: var(--red-600); }
.verdict-prelaunch { background: var(--ink-100);   color: var(--ink-500); }

/* Counter badge */
.counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  background: var(--accent-600);
  color: var(--paper-base);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* Tag */
.tag {
  display: inline-flex;
  background: var(--paper-100);
  color: var(--ink-700);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}

/* ──────────────────────────────────────────────────────────
   5.9  TOAST
   ────────────────────────────────────────────────────────── */

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--paper-base);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  max-width: 400px;
  width: 400px;
}
.toast-icon {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
}
.toast-icon.success { color: var(--green-600); }
.toast-icon.warning { color: var(--amber-600); }
.toast-icon.error   { color: var(--red-600); }
.toast-icon.info    { color: var(--blue-600); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: var(--text-sm); font-weight: 600; color: var(--ink-900); margin: 0 0 2px; }
.toast-msg { font-size: var(--text-sm); color: var(--ink-700); margin: 0; }
.toast-close { background: none; border: none; color: var(--ink-500); cursor: pointer; padding: 0; }

/* ──────────────────────────────────────────────────────────
   NAV (5.11)
   ────────────────────────────────────────────────────────── */

.topbar {
  height: 56px;
  background: var(--paper-base);
  border-bottom: 1px solid var(--ink-100);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
}
.wordmark {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--ink-900);
  text-decoration: none;
}
.wordmark .dot { color: var(--accent-600); }
.topbar-breadcrumb {
  color: var(--ink-500);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.topbar-breadcrumb::before {
  content: '/';
  color: var(--ink-300);
}
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); }

.avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  background: var(--paper-100);
  color: var(--ink-700);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0;
  flex: 0 0 auto;
  text-transform: uppercase;
}
.avatar.lg  { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar.xl  { width: 64px; height: 64px; font-size: var(--text-lg); }
.avatar-color-1 { background: #FEF3C7; color: #92400E; }
.avatar-color-2 { background: #CCFBF1; color: #115E59; }
.avatar-color-3 { background: #DBEAFE; color: #1E40AF; }
.avatar-color-4 { background: #FCE7F3; color: #9F1239; }
.avatar-color-5 { background: #E0E7FF; color: #3730A3; }
.avatar-color-6 { background: #DCFCE7; color: #166534; }
.avatar-color-7 { background: #FEE2E2; color: #991B1B; }
.avatar-color-8 { background: #F5F4EE; color: #374151; }

/* ──────────────────────────────────────────────────────────
   PAGE HEADER (used on most screens)
   ────────────────────────────────────────────────────────── */
.page-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-8) var(--space-12);
}
.page-shell.wide   { max-width: 1440px; }
.page-shell.narrow { max-width: 960px; }
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}
.page-title {
  font-size: var(--text-3xl);
  line-height: var(--lh-3xl);
  font-weight: 600;
  color: var(--ink-900);
  margin: 0;
  letter-spacing: var(--tracking-tight);
}
.page-subtitle {
  font-size: var(--text-base);
  color: var(--ink-500);
  margin: var(--space-2) 0 0;
}
.eyebrow {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink-500);
  margin: 0 0 var(--space-2);
}

/* ──────────────────────────────────────────────────────────
   SKELETON / LOADING
   ────────────────────────────────────────────────────────── */
.skel {
  background: linear-gradient(90deg, var(--paper-100) 0%, var(--paper-200) 50%, var(--paper-100) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skel {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ──────────────────────────────────────────────────────────
   UTILITY
   ────────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: var(--space-3); }
.row.tight { gap: var(--space-2); }
.row.spread { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: var(--space-3); }
.muted { color: var(--ink-500); }
.mono { font-family: var(--font-mono); font-size: var(--text-xs); }
.divider { border: none; border-top: 1px solid var(--ink-100); margin: var(--space-8) 0; }
.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;
}
