/*
 * Ordalis shared component stylesheet.
 * Import this on every HTML page. Page-specific overrides go into
 * /assets/pages/<page>.css or a trailing <style> block.
 *
 *   <link rel="stylesheet" href="/assets/ordalis.css">
 *
 * Drops tokens.css first so every component resolves `var(--*)` correctly.
 */

@import url('/assets/tokens.css');

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

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

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
  font-weight: var(--fw-semibold);
}

p { margin: 0; }

::selection {
  background: var(--accent-glow-strong);
  color: var(--text-primary);
}

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Skip-to-content link for keyboard users. */
.skip-to-content {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 2000;
  padding: var(--sp-3) var(--sp-5);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--elev-3);
  color: var(--text-primary);
  font-weight: var(--fw-medium);
}
.skip-to-content:focus { left: var(--sp-5); top: var(--sp-5); }

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== LAYOUT PRIMITIVES ===== */
.container      { width: 100%; max-width: var(--container-xl); margin: 0 auto; padding: 0 var(--sp-6); }
.container-sm   { width: 100%; max-width: var(--container-sm); margin: 0 auto; padding: 0 var(--sp-6); }
.container-md   { width: 100%; max-width: var(--container-md); margin: 0 auto; padding: 0 var(--sp-6); }
.container-lg   { width: 100%; max-width: var(--container-lg); margin: 0 auto; padding: 0 var(--sp-6); }
.container-wide { width: 100%; max-width: var(--container-2xl); margin: 0 auto; padding: 0 var(--sp-6); }

.section         { padding: var(--sp-11) 0; }
.section-sm      { padding: var(--sp-8) 0; }
.section-lg      { padding: var(--sp-13) 0; }
.section-divider { border-top: 1px solid var(--border); }
.section-muted   { background: var(--bg-secondary); }

.section-header  { max-width: 640px; margin-bottom: var(--sp-8); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}
.section-title {
  font-size: clamp(var(--fs-2xl), 3.4vw, var(--fs-4xl));
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  margin: 0 0 var(--sp-4);
  color: var(--text-primary);
}
.section-lead {
  font-size: var(--fs-md);
  color: var(--text-secondary);
  line-height: var(--lh-relaxed);
  max-width: 640px;
  margin: 0;
}

/* ===== TYPOGRAPHY HELPERS ===== */
.display    { font-family: var(--font-display); letter-spacing: -0.015em; line-height: 1.05; }
.mono       { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.lead       { font-size: var(--fs-md); color: var(--text-secondary); line-height: var(--lh-relaxed); }

/* ===== NAV ===== */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  height: var(--nav-height);
  padding: 0 var(--sp-6);
  background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.nav-brand:hover { color: var(--text-primary); }
.nav-brand-mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
}
.nav-brand-mark img, .nav-brand-mark svg { width: 100%; height: 100%; object-fit: contain; }
.nav-brand-text span { color: var(--text-muted); }

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  list-style: none;
}
.nav-links a {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--text-primary); }

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

.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  cursor: pointer;
}
.nav-toggle:hover { border-color: var(--border-strong); }

/* Collapse the inline nav at tablet + below. Previously this broke at 767px and
   left the full nav visible at 768px, where it overflowed by ~8 px because the
   logo + 5 links + two CTAs together exceeded 768 px of horizontal space. */
@media (max-width: 1023px) {
  .nav-links  { display: none; }
  .nav-toggle { display: inline-flex; }
  .nav-cta .btn-ghost { display: none; }
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-5);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:hover          { border-color: var(--border-strong); background: var(--bg-card-hover); color: var(--text-primary); }
.btn:active         { transform: translateY(1px); }
.btn:disabled       { opacity: 0.55; cursor: not-allowed; }
.btn svg            { width: 16px; height: 16px; }

.btn-primary        { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }
.btn-primary:hover  { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--text-on-accent); box-shadow: 0 4px 16px var(--accent-glow-strong); }

.btn-ghost          { background: transparent; border-color: var(--border); color: var(--text-primary); }
.btn-ghost:hover    { background: var(--bg-secondary); border-color: var(--border-strong); color: var(--text-primary); }

.btn-link           { background: transparent; border-color: transparent; color: var(--accent); padding-left: 0; padding-right: 0; }
.btn-link:hover     { color: var(--accent-hover); background: transparent; border-color: transparent; text-decoration: underline; }

.btn-danger         { background: var(--error); border-color: var(--error); color: var(--text-on-accent); }
.btn-danger:hover   { background: color-mix(in srgb, var(--error) 85%, black); border-color: color-mix(in srgb, var(--error) 85%, black); color: var(--text-on-accent); }

.btn-sm  { padding: 6px var(--sp-3); font-size: var(--fs-xs); }
.btn-lg  { padding: 14px var(--sp-7); font-size: var(--fs-base); border-radius: var(--r-md); }
.btn-xl  { padding: 18px var(--sp-8); font-size: var(--fs-md); border-radius: var(--r-md); font-weight: var(--fw-semibold); }
.btn-block { width: 100%; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-6);
}
.card-elevated    { box-shadow: var(--elev-2); }
.card-interactive { cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.card-interactive:hover { border-color: var(--accent); box-shadow: var(--elev-3); transform: translateY(-2px); }

.card-title    { font-size: var(--fs-md); font-weight: var(--fw-semibold); margin: 0 0 var(--sp-2); }
.card-subtitle { font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }
.card-meta     { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-muted); }

/* ===== BADGES / CHIPS ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 10px;
  border-radius: var(--r-full);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.badge-success, .badge.good       { background: var(--success-bg); color: var(--success); }
.badge-warning, .badge.warn       { background: var(--warning-bg); color: var(--warning); }
.badge-error,   .badge.bad        { background: var(--error-bg);   color: var(--error); }
.badge-info,    .badge.info       { background: var(--info-bg);    color: var(--info); }
.badge-pending, .badge.pending    { background: var(--bg-tertiary); color: var(--text-muted); }
.badge-accent                      { background: var(--accent-glow); color: var(--accent); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
}

/* ===== FORMS ===== */
.form-group    { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.form-row      { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-group label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}
.form-hint     { font-size: var(--fs-xs); color: var(--text-muted); }
.form-error    { color: var(--error); font-size: var(--fs-sm); min-height: 20px; }

.input, .select, .textarea {
  width: 100%;
  padding: 10px var(--sp-3);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input:hover, .select:hover, .textarea:hover   { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus   {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.textarea       { min-height: 96px; resize: vertical; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-bg);
}

/* ===== TABLES ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.table th, .table td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-secondary);
}
.table tr:last-child td     { border-bottom: none; }
.table-striped tbody tr:nth-child(even) td { background: var(--bg-secondary); }
.table-compact th, .table-compact td { padding: var(--sp-2) var(--sp-3); }

/* ===== CODE ===== */
.inline-code, code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 1px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text-primary);
}
.code-block {
  display: block;
  width: 100%;
  padding: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow-x: auto;
  white-space: pre;
}

/* ===== CALLOUTS ===== */
.callout {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--r-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
}
.callout-title { font-weight: var(--fw-semibold); margin: 0 0 2px; }
.callout-info    { border-left-color: var(--accent);  background: var(--info-bg); }
.callout-success { border-left-color: var(--success); background: var(--success-bg); }
.callout-warn    { border-left-color: var(--warning); background: var(--warning-bg); }
.callout-danger  { border-left-color: var(--error);   background: var(--error-bg); }

/* ===== COMPLIANCE PILL ROW ===== */
.trust-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--sp-3) var(--sp-6);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}
.trust-strip > *   { display: inline-flex; align-items: center; gap: var(--sp-2); }
.trust-strip a     { color: var(--text-secondary); }
.trust-strip a:hover { color: var(--text-primary); }

/* ===== FOOTER ===== */
.site-footer {
  padding: var(--sp-11) 0 var(--sp-8);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}
.site-footer-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, 1fr);
  gap: var(--sp-7);
}
.site-footer h4 {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 var(--sp-4);
}
.site-footer ul   { list-style: none; display: flex; flex-direction: column; gap: var(--sp-2); }
.site-footer a    { color: var(--text-secondary); }
.site-footer a:hover { color: var(--text-primary); }
.site-footer-bottom {
  margin-top: var(--sp-9);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
@media (max-width: 767px) {
  .site-footer-grid { grid-template-columns: 1fr 1fr; }
  .site-footer-grid > :first-child { grid-column: 1 / -1; }
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: var(--sp-3) var(--sp-5);
  background: var(--gray-900);
  color: #fff;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  box-shadow: var(--elev-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease-out), transform var(--dur-med) var(--ease-out);
  z-index: 2000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== UTILITIES ===== */
.u-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.u-hide-sm { @media (max-width: 639px) { display: none !important; } }
.u-hide-md { @media (max-width: 767px) { display: none !important; } }

/* ===== RESPONSIVE TYPE ===== */
@media (max-width: 639px) {
  .section, .section-sm, .section-lg { padding-inline: var(--sp-4); }
  .form-row  { grid-template-columns: 1fr; }
}
