/* ==========================================================================
   Watling Labs - Institutional Design System & Core Stylesheet
   Architecture: Vanilla CSS3, Grid/Flexbox, WCAG 2.2 AAA Contrast
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Institutional Palette */
  --color-brand-primary: #0a192f;
  --color-brand-deep: #050d1a;
  --color-brand-accent: #1e40af;
  --color-brand-accent-hover: #1d4ed8;
  --color-brand-light: #eff6ff;

  --color-surface-bg: #f8fafc;
  --color-surface-card: #ffffff;
  --color-surface-card-subtle: #f1f5f9;
  --color-surface-card-hover: #f8fafc;

  --color-border-subtle: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-border-accent: #93c5fd;

  --color-text-main: #0f172a;
  --color-text-muted: #475569;
  --color-text-light: #64748b;
  --color-text-inverse: #ffffff;

  /* Compliance & Severity Tokens */
  --color-severity-critical: #be123c;
  --color-severity-critical-bg: #fff1f2;
  --color-severity-critical-border: #fecdd3;

  --color-severity-high: #c2410c;
  --color-severity-high-bg: #fff7ed;
  --color-severity-high-border: #fed7aa;

  --color-severity-moderate: #b45309;
  --color-severity-moderate-bg: #fefce8;
  --color-severity-moderate-border: #fef08a;

  --color-severity-pass: #047857;
  --color-severity-pass-bg: #ecfdf5;
  --color-severity-pass-border: #a7f3d0;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --container-max: 1200px;
}

/* Reset & Accessibility Defaults */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text-main);
  background-color: var(--color-surface-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--color-brand-primary);
  color: #fff;
  padding: 0.75rem 1.25rem;
  z-index: 9999;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 1rem;
  outline: 3px solid var(--color-brand-accent);
}

a {
  color: var(--color-brand-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease-in-out;
}

a:hover {
  color: var(--color-brand-accent-hover);
}

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* Institutional Header Bar */
.gov-top-bar {
  background-color: var(--color-brand-deep);
  color: #94a3b8;
  font-size: 0.8125rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.gov-top-bar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.gov-top-bar .gov-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gov-top-bar .gov-badge-icon {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
}

.site-header {
  background-color: var(--color-brand-primary);
  color: var(--color-text-inverse);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: #fff;
}

.brand-symbol {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.5px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 0.75rem;
  color: #94a3b8;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease-in-out;
}

.nav-links a:hover, .nav-links a.active {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.08);
}

.nav-action-btn {
  background-color: #2563eb;
  color: #ffffff !important;
  font-weight: 600 !important;
  padding: 0.5rem 1rem !important;
  border-radius: var(--radius-md) !important;
  border: 1px solid #3b82f6;
}

.nav-action-btn:hover {
  background-color: #1d4ed8 !important;
}

.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
}

/* Hero Section */
.hero {
  background: linear-gradient(180deg, var(--color-brand-primary) 0%, #172554 100%);
  color: #ffffff;
  padding: 4.5rem 0 5rem;
  border-bottom: 1px solid var(--color-border-subtle);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-image: radial-gradient(circle at 80% 20%, rgba(59, 130, 246, 0.12) 0%, transparent 60%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 820px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #93c5fd;
  margin-bottom: 1.5rem;
}

.hero-pill-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #60a5fa;
}

.hero h1 {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.75px;
  margin-bottom: 1.25rem;
}

.hero p.lead {
  font-size: 1.1875rem;
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 2rem;
  max-width: 720px;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Button Component */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
}

.btn-primary:hover {
  background-color: #1d4ed8;
  color: #ffffff;
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--color-brand-primary);
  border-color: var(--color-border-strong);
}

.btn-secondary:hover {
  background-color: #f1f5f9;
  color: var(--color-brand-primary);
}

.btn-outline-white {
  background-color: transparent;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-outline-white:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.btn-bacs {
  background-color: #047857;
  color: #ffffff;
  border-color: #059669;
}

.btn-bacs:hover {
  background-color: #065f46;
  color: #ffffff;
}

.btn-block {
  width: 100%;
}

/* Section Common */
.section {
  padding: 4.5rem 0;
}

.section-header {
  margin-bottom: 3rem;
}

.section-header .section-eyebrow {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #2563eb;
  margin-bottom: 0.5rem;
}

.section-header h2 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--color-text-main);
  margin-bottom: 0.75rem;
}

.section-header p {
  font-size: 1.125rem;
  color: var(--color-text-muted);
  max-width: 720px;
}

/* Cards Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
}

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

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

/* Card Component */
.card {
  background-color: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-accent);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background-color: var(--color-brand-light);
  color: var(--color-brand-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text-main);
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.card-description {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  flex-grow: 1;
}

.card-meta {
  padding-top: 1rem;
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--color-text-light);
}

/* Pricing Cards */
.pricing-card {
  position: relative;
  overflow: hidden;
}

.pricing-card.featured {
  border: 2px solid #2563eb;
  box-shadow: var(--shadow-lg);
}

.pricing-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background-color: #dbeafe;
  color: #1e40af;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.price-display {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin: 1.25rem 0 1.5rem;
}

.price-currency {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-main);
}

.price-amount {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--color-text-main);
  line-height: 1;
}

.price-period {
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.feature-list {
  list-style: none;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

.feature-check {
  color: #059669;
  font-weight: bold;
  flex-shrink: 0;
}

/* Stats / Assurance Grid */
.stat-card {
  background-color: #ffffff;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
}

.stat-value {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--color-brand-primary);
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

.stat-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

/* Institutional Notice Box */
.notice-box {
  padding: 1.5rem;
  border-radius: var(--radius-md);
  border-left: 4px solid #2563eb;
  background-color: #f8fafc;
  margin: 1.5rem 0;
}

.notice-box.critical {
  border-left-color: var(--color-severity-critical);
  background-color: var(--color-severity-critical-bg);
}

.notice-box.warning {
  border-left-color: var(--color-severity-high);
  background-color: var(--color-severity-high-bg);
}

.notice-box.success {
  border-left-color: var(--color-severity-pass);
  background-color: var(--color-severity-pass-bg);
}

.notice-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-critical {
  background-color: var(--color-severity-critical-bg);
  color: var(--color-severity-critical);
  border: 1px solid var(--color-severity-critical-border);
}

.badge-high {
  background-color: var(--color-severity-high-bg);
  color: var(--color-severity-high);
  border: 1px solid var(--color-severity-high-border);
}

.badge-moderate {
  background-color: var(--color-severity-moderate-bg);
  color: var(--color-severity-moderate);
  border: 1px solid var(--color-severity-moderate-border);
}

.badge-pass {
  background-color: var(--color-severity-pass-bg);
  color: var(--color-severity-pass);
  border: 1px solid var(--color-severity-pass-border);
}

.badge-neutral {
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

/* Code Snippet Box */
.code-box {
  background-color: #0f172a;
  color: #f8fafc;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  overflow-x: auto;
  border: 1px solid #334155;
  margin: 1rem 0;
}

/* Table Utilities */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  background-color: #ffffff;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.table-custom {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9375rem;
}

.table-custom th {
  background-color: #f8fafc;
  padding: 0.875rem 1rem;
  font-weight: 600;
  color: #334155;
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table-custom td {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: middle;
}

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

.table-custom tr:hover td {
  background-color: #f8fafc;
}

/* Search Bar Component */
.search-wrapper {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: 0.875rem 1.25rem 0.875rem 3rem;
  font-size: 1rem;
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  color: var(--color-text-main);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
  outline: none;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 1.1rem;
  pointer-events: none;
}

.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: #ffffff;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  margin-top: 0.5rem;
  max-height: 380px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}

.search-results-dropdown.active {
  display: block;
}

.search-result-item {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.search-result-item:hover, .search-result-item:focus {
  background-color: #f8fafc;
  outline: none;
}

.search-result-name {
  font-weight: 600;
  color: var(--color-text-main);
  margin-bottom: 0.2rem;
}

.search-result-meta {
  font-size: 0.8125rem;
  color: var(--color-text-light);
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border-subtle);
  transform: translateY(20px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal-container {
  transform: translateY(0);
}

.modal-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.modal-close-btn:hover {
  color: #0f172a;
}

.modal-body {
  padding: 2rem;
}

.modal-footer {
  padding: 1.25rem 2rem;
  background-color: #f8fafc;
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.875rem;
  font-size: 0.9375rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--color-text-main);
}

.form-control:focus {
  border-color: #2563eb;
  outline: none;
}

/* Institutional Footer */
.site-footer {
  background-color: var(--color-brand-deep);
  color: #94a3b8;
  padding: 4.5rem 0 2.5rem;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.9375rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr;
  gap: 3rem;
  margin-bottom: 3.5rem;
}

.footer-col h4 {
  color: #ffffff;
  font-size: 0.9375rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  margin-bottom: 1.25rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.footer-links a {
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.15s;
}

.footer-links a:hover {
  color: #ffffff;
}

.footer-bottom {
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8125rem;
}

.footer-bottom-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.footer-bottom-links a {
  color: #94a3b8;
  text-decoration: none;
}

.footer-bottom-links a:hover {
  color: #ffffff;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.15rem;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .grid-4 {
    grid-template-columns: 1fr;
  }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--color-brand-primary);
    flex-direction: column;
    padding: 1.5rem;
    gap: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
  .nav-links.active {
    display: flex;
  }
  .mobile-nav-toggle {
    display: block;
  }
  .footer-grid {
    grid-template-columns: 1fr;
  }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}
