/* =================================================================
   TSP Mentor benchmark portal: shared brand stylesheet
   Loaded before each page's inline <style>, which may override.

   Kept deliberately in step with TSP Mentor Hub
   (github.com/independenteq/tsp-mentor-hub), because the benchmark is
   destined to merge into it. Every token below has a counterpart in the
   hub's tailwind.config.ts or src/app/globals.css, named the same way
   wherever a CSS variable can carry the name. When the hub's palette or
   geometry changes, change it here too, or the two drift apart and the
   merge turns into a redesign.

   The older token names (--border, --surface-2, --r-sm and friends) are
   kept as aliases so the pages' inline CSS keeps working. New work should
   prefer the hub names: --line, --raised, --radius-card.
   ================================================================= */

:root {
  /* ---- Primary palette (hub: colors.ethos etc.) ---- */
  --ethos:      #EBEEF2;   /* Primary background. Hub calls this canvas. */
  --clarity:    #D5EDF2;   /* Soft surface / info */
  --charcoal:   #404040;   /* Body text */
  --progress:   #70CFE8;   /* Accent: one moment per view */
  --strategic:  #8FC4D9;
  --foundation: #B6DBF2;
  --baseline:   #282827;   /* Near-black: buttons, headings */
  --mid-grey:   #848688;
  --white:      #FFFFFF;

  /* ---- Surfaces and rules (hub: canvas / surface / raised / line) ---- */
  --canvas:      #EBEEF2;
  --surface:     #FFFFFF;
  --raised:      #F7F9FB;
  --line:        #E1E5EA;
  --line-strong: #C9D0D8;

  /* ---- Brand neutrals (hub: colors.slate, brand greys not blue-greys) ---- */
  --slate-50:  #F7F9FB;
  --slate-100: #EBEEF2;
  --slate-200: #E1E5EA;
  --slate-300: #C9D0D8;
  --slate-400: #A6A9AB;
  --slate-500: #848688;
  --slate-600: #5F6163;
  --slate-700: #404040;
  --slate-800: #333333;
  --slate-900: #282827;

  /* ---- Interactive tint for links, focus and selected states ---- */
  --accent-50:  #F0F8FB;
  --accent-100: #D5EDF2;
  --accent-200: #B6DBF2;
  --accent-300: #8FC4D9;
  --accent-400: #70CFE8;
  --accent-500: #3E9FBF;
  --accent-600: #2B7F9C;
  --accent-700: #1F6680;
  --accent-800: #184F63;

  /* ---- Status, muted to sit with the brand palette ---- */
  --success:    #1A7A3F;
  --success-bg: #EAF6EE;
  --success-br: #B5DFC3;
  --danger:     #B31B1B;
  --danger-bg:  #FBEEEE;
  --danger-br:  #F2C4C4;
  --warn:       #8A6100;
  --warn-bg:    #FDF6E1;
  --warn-br:    #F2DD9A;

  /* ---- Legacy aliases, so existing page CSS keeps working ---- */
  --surface-2:  var(--raised);
  --border:     var(--line);
  --border-2:   var(--line);
  --muted:      var(--slate-400);

  /* ---- Type ---- */
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-eyebrow: 'Barlow', 'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --fs-xs:  11px;
  --fs-sm:  12px;
  --fs-md:  14px;
  --fs-lg:  16px;
  --fs-xl:  20px;
  --fs-2xl: 28px;
  --fs-3xl: 40px;

  /* ---- Spacing (4px grid) ---- */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* ---- Geometry. Squarer than the default web look: the brand is
          precise and geometric, an operator's interface, never bubbly.
          Mirrors the hub's borderRadius scale exactly. ---- */
  --radius-sm:    3px;
  --radius-md:    3px;
  --radius-lg:    4px;
  --radius-card:  6px;
  --radius-xl:    8px;

  --r-sm:   var(--radius-lg);    /* legacy alias: fields, small buttons */
  --r-md:   var(--radius-card);  /* legacy alias: cards */
  --r-lg:   var(--radius-xl);    /* legacy alias: large panels */
  --r-pill: var(--radius-md);    /* the brand does not do pills */

  /* ---- Shadow: two layers, barely there (hub: shadow-card / raised) ---- */
  --shadow-card:   0 1px 1px rgba(40, 40, 39, 0.03), 0 2px 6px -1px rgba(40, 40, 39, 0.05);
  --shadow-raised: 0 1px 1px rgba(40, 40, 39, 0.04), 0 8px 20px -6px rgba(40, 40, 39, 0.12);
  --shadow-1: 0 1px 2px rgba(40, 40, 39, 0.04);
  --shadow-2: var(--shadow-card);
  --shadow-3: var(--shadow-raised);

  /* ---- Motion ---- */
  --dur-fast: 150ms;
  --dur-med:  200ms;
  --dur-slow: 280ms;
  --ease:     cubic-bezier(0.22, 0.61, 0.36, 1);  /* hub: ease-soft */

  /* ---- Focus: the accent tint, not a cyan glow ---- */
  --focus-ring: 0 0 0 3px rgba(112, 207, 232, 0.20);
}

/* ---------- Global reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--charcoal);
  background: var(--canvas);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Inter's cleaner alternates: open digits, straight-sided 1, l with tail. */
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'ss01';
}

h1, h2, h3 { letter-spacing: -0.015em; }

/* Figures that line up column to column. Any table of numbers wants this. */
.tabular, table td, table th { font-variant-numeric: tabular-nums; }

::selection { background: var(--clarity); color: var(--baseline); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}

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

/* Eyebrow: Barlow, uppercase, letter-spaced. The brand's signature label. */
.eyebrow {
  font-family: var(--font-eyebrow);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mid-grey);
}

/* Page eyebrow: led by the square bullet in Progress cyan. This is each
   page's one cyan moment, so it is not used anywhere else on the page. */
.eyebrow-mark, .page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-eyebrow);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--charcoal);
  margin-bottom: 10px;
}
.eyebrow-mark::before, .page-eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--progress);
  flex: none;
}

/* Precision cross: the brand crosshair, used sparingly to mark focus. */
.precision-cross::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  vertical-align: middle;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath stroke='%2370CFE8' stroke-width='1' d='M5 0v10M0 5h10'/%3E%3Ccircle cx='5' cy='5' r='1' fill='%23282827'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

/* Square bullets everywhere, never round. */
ul.square { list-style-type: square; }
ul.square li::marker { color: var(--mid-grey); }

.brand-list { list-style: none; padding-left: 0; }
.brand-list li { padding-left: 18px; position: relative; margin-bottom: 6px; line-height: 1.55; }
.brand-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  background: var(--progress);
}

/* ---------- Brand textures ---------- */

/* The fading grid: the brand's background texture. Always faint. */
.brand-grid {
  background-image:
    linear-gradient(to right, rgba(64, 64, 64, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(64, 64, 64, 0.055) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: linear-gradient(135deg, #000 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
          mask-image: linear-gradient(135deg, #000 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
}

/* A faint grid band behind the top of a page, fading downwards. */
.page-grid {
  background-image:
    linear-gradient(to right, rgba(64, 64, 64, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(64, 64, 64, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: -1px -1px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
}

/* Dark hero panels: Baseline with a lift of Charcoal from the top right. */
.hero-panel {
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(255, 255, 255, 0.07) 0%, transparent 55%),
    linear-gradient(160deg, #343433 0%, #282827 55%, #222221 100%);
}

/* ---------- Focus ---------- */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent-400);
}

/* ---------- Buttons ----------
   Barlow, uppercase and letter-spaced, as the brand specifies. The press
   dip acknowledges a click before the page has time to respond. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  font-family: var(--font-eyebrow);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn:active:not(:disabled) { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(to bottom, #3a3a39, var(--baseline));
  color: var(--white);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10), 0 1px 2px rgba(40, 40, 39, 0.25);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(to bottom, #454544, #2f2f2e); }

.btn-ghost {
  background: var(--surface);
  color: var(--slate-700);
  border-color: rgba(201, 208, 216, 0.7);
  box-shadow: 0 1px 2px rgba(40, 40, 39, 0.05);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--raised);
  border-color: var(--line-strong);
  color: var(--baseline);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-br);
}
.btn-danger:hover:not(:disabled) { background: #FBE3E3; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--white);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1;
  color: var(--slate-600);
}
/* The brand's square bullet, in the badge's own colour. */
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: none;
  background: currentColor;
  opacity: 0.7;
}
.badge.accent { border-color: var(--accent-200); background: var(--accent-50);  color: var(--accent-700); }
.badge.green  { border-color: var(--success-br); background: var(--success-bg); color: var(--success); }
.badge.amber  { border-color: var(--warn-br);    background: var(--warn-bg);    color: var(--warn); }
.badge.red    { border-color: var(--danger-br);  background: var(--danger-bg);  color: var(--danger); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid rgba(225, 229, 234, 0.9);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

/* ---------- Fields ---------- */
.field-input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], textarea, select {
  font-family: inherit;
  font-size: var(--fs-md);
  color: var(--baseline);
  background: var(--white);
  border: 1px solid rgba(201, 208, 216, 0.7);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  box-shadow: inset 0 1px 1px rgba(40, 40, 39, 0.03);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--slate-400); }
input:hover, textarea:hover, select:hover { border-color: var(--line-strong); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-400);
  box-shadow: 0 0 0 3px rgba(112, 207, 232, 0.20);
}
input:disabled, textarea:disabled, select:disabled { opacity: 0.5; }

/* ---------- Tables ----------
   Header band in raised grey with a Barlow eyebrow, rows that respond to
   the cursor. Scanning a wide row is much easier when it does. */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.data-table th {
  border-bottom: 1px solid var(--line);
  background: rgba(247, 249, 251, 0.7);
  padding: 10px 16px;
  text-align: left;
  font-family: var(--font-eyebrow);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--mid-grey);
  white-space: nowrap;
}
.data-table td {
  border-bottom: 1px solid rgba(225, 229, 234, 0.7);
  padding: 13px 16px;
  color: var(--slate-700);
}
.data-table tbody tr { transition: background var(--dur-fast) var(--ease); }
.data-table tbody tr:hover { background: #F4F7F9; }
.data-table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  right: 20px;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  background: var(--baseline);
  color: var(--white);
  border-radius: var(--radius-lg);
  font-size: var(--fs-md);
  box-shadow: var(--shadow-raised);
  pointer-events: auto;
  animation: toast-in var(--dur-med) var(--ease);
  border-left: 3px solid var(--progress);
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.info    { border-left-color: var(--progress); }
.toast.leaving { animation: toast-out var(--dur-med) var(--ease) forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(-8px); } }

/* ---------- Loading ---------- */
.skeleton {
  display: block;
  background: linear-gradient(90deg, var(--line) 0%, var(--canvas) 50%, var(--line) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  animation: skeleton-sweep 1.4s ease-in-out infinite;
  color: transparent;
}
.skeleton-line { height: 12px; margin: 6px 0; }
.skeleton-block { height: 100px; }
@keyframes skeleton-sweep {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Pages settle in rather than snapping. Kept short so it never slows work. */
@keyframes settle {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.settle, .fade-in-on-load { animation: settle var(--dur-slow) var(--ease) both; }
@media (prefers-reduced-motion: reduce) {
  .settle, .fade-in-on-load { animation: none; }
}

/* Nav-link separator dot, replaces em dashes in header text */
.sep-dot::before { content: "\00b7"; margin: 0 6px; color: var(--slate-400); }

/* Phones and tablets: iOS zooms into any field under 16px, which jolts the
   page. Fields stay 16px on touch screens, whatever their class. */
@media (hover: none) and (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  textarea, select { font-size: 16px !important; }
}

@media print {
  .toast-container, .skeleton { display: none !important; }
}
