/* ============================================================
   OSTYN VAULT — Design System (B+ Visual Identity)
   Synced with CRM globals.css — same tokens, same brand feel
   ============================================================ */

/* ===== Shape Font (Ostyn huislettertype) ===== */
@font-face {
  font-family: 'Shape';
  src: url('assets/fonts/Shape-Light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Shape';
  src: url('assets/fonts/Shape-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Shape';
  src: url('assets/fonts/Shape-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ===== Design Tokens (identical to CRM B+) ===== */

/* Dark mode (default) — warm undertone matching Ostyn brand */
:root {
  --font-shape: 'Shape', 'Calibri', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Surfaces — warm brown undertone, NOT cold gray */
  --surface-0: #0f0f0f;
  --surface-1: #1b1916;
  --surface-2: #252119;
  --surface-3: #302a22;
  --surface-4: #3d3529;

  /* Text */
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0a0;
  --text-muted: #757575;

  /* Brand colors — theme-invariant */
  --brand-black: #0f0f0f;
  --brand-ochre: #C19848;
  --brand-blue: #8bb2c2;
  --brand-green: #95a83b;
  --brand-rust: #bb614d;

  /* Borders */
  --border: #3d3529;
  --border-focus: #C19848;

  /* Shadows — ochre-tinted, warm */
  --shadow-sm: 0 1px 3px rgba(193, 152, 72, 0.04), 0 1px 2px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 12px rgba(193, 152, 72, 0.08), 0 2px 4px rgba(0, 0, 0, 0.16);
  --shadow-lg: 0 8px 24px rgba(193, 152, 72, 0.12), 0 4px 8px rgba(0, 0, 0, 0.2);

  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 24px;
}

/* Light mode — warm creme tint */
:root.light {
  --surface-0: #f7f5f2;
  --surface-1: #ffffff;
  --surface-2: #f5f2ed;
  --surface-3: #ede8e0;
  --surface-4: #ddd6ca;

  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-muted: #737373;

  --border: #ddd6ca;
}

/* ===== Base Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--surface-0);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
  font-size: 16px;
}

/* ===== Typography — Shape for headings, Inter for body ===== */
h1, h2, h3, h4 {
  font-family: var(--font-shape);
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 { font-size: 2rem; font-weight: 700; margin-bottom: var(--space-lg); }
h2 { font-size: 1.5rem; font-weight: 500; margin-bottom: var(--space-md); margin-top: var(--space-xl); }
h3 { font-size: 1.125rem; font-weight: 500; margin-bottom: var(--space-sm); margin-top: var(--space-lg); }
h4 { font-size: 1rem; font-weight: 500; margin-bottom: var(--space-sm); }

p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
  max-width: 72ch;
}

a {
  color: var(--brand-ochre);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

strong { font-weight: 600; color: var(--text-primary); }

/* ===== Layout ===== */
.vault-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}

.vault-header {
  grid-column: 1 / -1;
  background: var(--brand-black);
  color: #fff;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

/* Header ochre gradient line (B+ style) */
.vault-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand-ochre) 30%, var(--brand-ochre) 70%, transparent);
}

.vault-header-logo {
  height: 28px;
  width: auto;
}

.vault-header-title {
  font-family: var(--font-shape);
  font-weight: 300;
  font-size: 1.25rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-ochre);
}

.vault-header-search {
  margin-left: auto;
  max-width: 400px;
  flex: 1;
}

.vault-sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: var(--space-lg) 0;
  overflow-y: auto;
  position: sticky;
  top: 60px;
  height: calc(100dvh - 60px);
}

.vault-content {
  padding: var(--space-xl) var(--space-2xl);
  max-width: 960px;
  overflow-y: auto;
}

/* Mobile: stack layout */
@media (max-width: 768px) {
  .vault-layout {
    grid-template-columns: 1fr;
  }

  .vault-sidebar {
    display: none;
  }

  .vault-sidebar.open {
    display: block;
    position: fixed;
    inset: 60px 0 0 0;
    z-index: 90;
    width: 280px;
  }

  .vault-content {
    padding: var(--space-md);
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
}

/* ===== Sidebar Navigation ===== */
.nav-section {
  padding: 0 var(--space-md);
  margin-bottom: var(--space-lg);
}

.nav-section-title {
  font-family: var(--font-shape);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-sm) var(--space-md);
}

.nav-link {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.nav-link:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-link.active {
  background: var(--surface-3);
  color: var(--brand-ochre);
  font-weight: 500;
}

/* ===== Breadcrumbs ===== */
.breadcrumbs {
  display: flex;
  gap: var(--space-xs);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}
.breadcrumbs a {
  color: var(--text-muted);
}
.breadcrumbs a:hover {
  color: var(--brand-ochre);
}
.breadcrumbs .separator {
  color: var(--text-muted);
  user-select: none;
}

/* ===== B+ Card System ===== */

/* Hero Card — KPIs, featured content, spotlights */
.card-hero {
  background: linear-gradient(135deg, var(--surface-1) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-top: 2px solid var(--brand-ochre);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

/* Action Card — interactive items (topics, tools, procedures) */
.card-action {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  cursor: pointer;
}
.card-action:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(193, 152, 72, 0.2);
}
.card-action:active {
  transform: scale(0.98);
}

/* Info Card — secondary info, muted */
.card-info {
  background: color-mix(in srgb, var(--surface-1) 60%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

/* Accent gradient fills behind left-border cards */
.accent-fill-ochre { background: linear-gradient(90deg, rgba(193,152,72,0.05) 0%, transparent 40%); }
.accent-fill-rust { background: linear-gradient(90deg, rgba(187,97,77,0.05) 0%, transparent 40%); }
.accent-fill-blue { background: linear-gradient(90deg, rgba(139,178,194,0.05) 0%, transparent 40%); }
.accent-fill-green { background: linear-gradient(90deg, rgba(149,168,59,0.05) 0%, transparent 40%); }

/* Card with ochre accent border */
.card-accent {
  border-left: 3px solid var(--brand-ochre);
}

/* ===== Section Dividers ===== */
.section-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(193,152,72,0.15), transparent);
  margin: var(--space-xl) 0;
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-shape);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}
.section-header::before {
  content: '';
  width: 24px;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-ochre), transparent);
  flex-shrink: 0;
}
.section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

/* ===== Widget Header (gradient, B+ style) ===== */
.widget-header {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.widget-header h3 {
  font-family: var(--font-shape);
  font-weight: 500;
  margin: 0;
}

/* ===== Value Spotlight (editorial style) ===== */
.value-spotlight {
  border-left: 2px solid var(--brand-ochre);
  background: linear-gradient(90deg, rgba(193,152,72,0.04), transparent 50%);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-md) var(--space-lg);
}

/* ===== 3-Depth Content System ===== */

.depth {
  border-top: 1px solid var(--border);
}

.depth > summary {
  font-family: var(--font-shape);
  font-weight: 500;
  font-size: 1rem;
  padding: var(--space-md) 0;
  cursor: pointer;
  color: var(--text-primary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 48px;
  user-select: none;
  transition: color 0.15s;
}
.depth > summary:hover {
  color: var(--brand-ochre);
}

.depth > summary::before {
  content: '▸';
  font-size: 12px;
  color: var(--brand-ochre);
  transition: transform 0.2s;
}
.depth[open] > summary::before {
  transform: rotate(90deg);
}

.depth > summary::-webkit-details-marker {
  display: none;
}

.depth-content {
  padding: 0 0 var(--space-lg);
}

/* Depth badges */
.depth-badge {
  font-family: var(--font-shape);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-left: auto;
}
.depth-badge-commercial { background: rgba(193,152,72,0.15); color: var(--brand-ochre); }
.depth-badge-operational { background: rgba(139,178,194,0.15); color: var(--brand-blue); }
.depth-badge-technical { background: rgba(149,168,59,0.15); color: var(--brand-green); }

/* ===== Source Traceability ===== */
.sources {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}
.sources h4 {
  font-family: var(--font-shape);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.source-ref {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}
.source-ref-valid {
  border-left: 2px solid var(--brand-green);
}
.source-ref-expired {
  border-left: 2px solid var(--brand-rust);
}

.badge-expired {
  font-family: var(--font-shape);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(187,97,77,0.15);
  color: var(--brand-rust);
}

/* ===== Search (Pagefind) ===== */
.search-container {
  max-width: 640px;
  margin: 0 auto;
}

/* Filter pills — horizontal scrollable on mobile */
.filter-pills {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-sm) 0;
  scrollbar-width: none;
}
.filter-pills::-webkit-scrollbar { display: none; }

.filter-pill {
  min-height: 44px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
}
.filter-pill:hover {
  border-color: var(--brand-ochre);
  color: var(--text-primary);
}
.filter-pill.active {
  background: var(--brand-ochre);
  color: #fff;
  border-color: var(--brand-ochre);
}

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: var(--space-lg);
}
th {
  font-family: var(--font-shape);
  font-weight: 500;
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
tr:hover td {
  background: var(--surface-2);
}

/* ===== Utility Classes ===== */
.text-ochre { color: var(--brand-ochre); }
.text-blue { color: var(--brand-blue); }
.text-green { color: var(--brand-green); }
.text-rust { color: var(--brand-rust); }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--text-primary); }

.text-sm { font-size: 13px; }

.font-shape { font-family: var(--font-shape); }
.font-shape-light { font-family: var(--font-shape); font-weight: 300; }
.font-shape-bold { font-family: var(--font-shape); font-weight: 700; }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-md); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md); }

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== Empty State (B+ branded) ===== */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
}
.empty-state-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto var(--space-md);
  border-radius: var(--radius-md);
  background: rgba(193,152,72,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state h3 {
  font-family: var(--font-shape);
  margin-bottom: var(--space-sm);
}
.empty-state p {
  color: var(--text-muted);
  margin: 0 auto;
}

/* ===== Landing Page ===== */
.landing-hero {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  max-width: 640px;
  margin: 0 auto;
}
.landing-hero h1 {
  font-weight: 300;
  letter-spacing: 0.1em;
}
.landing-hero .search-input {
  width: 100%;
  max-width: 480px;
  height: 52px;
  padding: 0 var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font-body);
  margin-top: var(--space-lg);
  transition: border-color 0.2s;
}
.landing-hero .search-input:focus {
  outline: none;
  border-color: var(--brand-ochre);
  box-shadow: 0 0 0 1px var(--brand-ochre);
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  max-width: 800px;
  margin: var(--space-xl) auto;
}

/* ===== Mobile Hamburger ===== */
.vault-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.vault-hamburger:hover {
  background: var(--surface-2);
}
@media (max-width: 768px) {
  .vault-hamburger {
    display: flex;
  }
}

/* Mobile sidebar backdrop */
.vault-backdrop {
  position: fixed;
  inset: 60px 0 0 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 89;
}

/* ===== Profile Selector (header) ===== */
.profile-select {
  margin-left: auto;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  min-height: 32px;
}
.profile-select:focus {
  outline: none;
  border-color: var(--brand-ochre);
}

/* ===== Pagefind UI Theme Overrides ===== */
.pagefind-ui__search-input {
  background: var(--surface-1) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-pill) !important;
  font-family: var(--font-body) !important;
  font-size: 16px !important;
  height: 52px !important;
  padding: 0 var(--space-lg) !important;
}
.pagefind-ui__search-input:focus {
  outline: none !important;
  border-color: var(--brand-ochre) !important;
  box-shadow: 0 0 0 1px var(--brand-ochre) !important;
}
.pagefind-ui__search-input::placeholder {
  color: var(--text-muted) !important;
}
.pagefind-ui__result {
  border-top: 1px solid var(--border) !important;
  padding: var(--space-md) 0 !important;
}
.pagefind-ui__result-link {
  color: var(--brand-ochre) !important;
  font-family: var(--font-shape) !important;
  font-weight: 500 !important;
}
.pagefind-ui__result-excerpt {
  color: var(--text-secondary) !important;
}
.pagefind-ui__message {
  color: var(--text-muted) !important;
  font-family: var(--font-body) !important;
}
.pagefind-ui__button {
  background: var(--surface-2) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
}
.pagefind-ui__button:hover {
  border-color: var(--brand-ochre) !important;
}

/* ===== Focus & Accessibility ===== */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Touch targets minimum 44x44 (WCAG 2.5.5) */
button, a, summary, .filter-pill, .nav-link {
  min-height: 44px;
}

/* ===== iOS Safari specifics ===== */
@supports (-webkit-touch-callout: none) {
  input, select, textarea {
    font-size: max(1rem, 16px);
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== Print Styles ===== */
@media print {
  .vault-sidebar, .vault-header, .filter-pills { display: none !important; }

  body {
    font-family: var(--font-shape), 'Calibri', sans-serif;
    background: white !important;
    color: black !important;
    font-size: 11pt;
  }

  .vault-layout { display: block; }
  .vault-content { padding: 0; max-width: none; }

  @page {
    size: A4 portrait;
    margin: 15mm;
  }

  * { box-shadow: none !important; }

  .card-hero, .card-action, .card-info {
    background: white !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }

  .depth-operational, .depth-technical {
    border: 1px solid #ddd;
  }
  details[open] > .depth-content { display: block !important; }
}

/* ===== Scrollbar ===== */
@supports (scrollbar-width: thin) {
  .vault-sidebar, .vault-content {
    scrollbar-width: thin;
    scrollbar-color: var(--surface-4) transparent;
  }
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface-1); }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 3px; }
