/* One Engineering — shared design system.
 * Loaded on every page (marketing shell, homepage and the app) so the whole site is one product:
 * the same tokens, the same spacing and type rhythm, the same focus, selection and motion behaviour.
 * Token VALUES match what the app and marketing already use — this centralises them and adds the
 * scale, elevation, focus and motion pieces that were missing or defined per-page. It deliberately
 * does not restyle existing components (that stays in each page's CSS); it sets the shared foundation. */

:root {
  /* brand palette (canonical) */
  --paper: #F3F0E8; --charcoal: #14181A; --steel: #4A6867; --steel-light: #7B9997;
  --brass: #C9A66B; --brass-light: #DEC08C; --brick: #8B4B3B; --ok: #3f6152;
  /* semantic surface + text (light) */
  --bg: var(--paper); --fg: var(--charcoal); --fg-soft: #55594f;
  --panel: #e9e5d9; --panel-raised: #ffffff; --line: #d8d3c4; --line-soft: #e6e2d6;
  /* elevation (matches the app + homepage) */
  --shadow-sm: 0 1px 2px rgba(20,24,26,.05); --shadow-md: 0 4px 14px rgba(20,24,26,.07); --shadow-lg: 0 14px 36px rgba(20,24,26,.12);
  /* radius — one scale, with the aliases both the app (--radius-sm) and marketing (--r) already use */
  --radius-xs: 6px; --radius-sm: 8px; --radius: 10px; --radius-lg: 14px; --radius-xl: 20px; --radius-pill: 999px;
  --r: var(--radius); --r-lg: var(--radius-lg); --radius-md: var(--radius);
  /* spacing scale (4px base) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  /* type scale */
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 15px; --fs-md: 17px; --fs-lg: 20px; --fs-xl: 26px; --fs-2xl: 32px; --fs-3xl: 42px;
  --font-sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-serif: 'Roboto Slab', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  /* interaction */
  --focus: var(--brass); --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--brass);
  --ease: cubic-bezier(.4, 0, .2, 1); --t-fast: .12s; --t: .18s; --t-slow: .3s;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10130F; --fg: #EDE9DD; --fg-soft: #a8a89c; --steel: #7B9997; --ok: #7fb59a; --brick: #d08a76;
    --panel: #1A1F1A; --panel-raised: #1F251F; --line: #2c322b; --line-soft: #232922;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow-md: 0 4px 14px rgba(0,0,0,.35); --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #10130F; --fg: #EDE9DD; --fg-soft: #a8a89c; --steel: #7B9997; --ok: #7fb59a; --brick: #d08a76;
  --panel: #1A1F1A; --panel-raised: #1F251F; --line: #2c322b; --line-soft: #232922;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow-md: 0 4px 14px rgba(0,0,0,.35); --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
}

/* --- site-wide foundation (improves every page without restyling its components) --- */

/* Accessibility: a visible, on-brand focus ring for keyboard users (never for mouse clicks). */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
/* Text selection in the brand colour. */
::selection { background: color-mix(in srgb, var(--brass) 32%, transparent); }

/* Skip-to-content link: hidden until a keyboard user tabs to it. */
.skip-link {
  position: fixed; top: -64px; left: 12px; z-index: 3000;
  background: var(--brass); color: #14181A; font-weight: 700; text-decoration: none;
  padding: 10px 16px; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-md); transition: top var(--t) var(--ease);
}
.skip-link:focus { top: 0; }

/* Comfortable touch targets on touch devices (keeps small inline icon buttons from being too fiddly). */
@media (pointer: coarse) {
  .t-top nav a, .mobile-tab, .t-btn, .btn { min-height: 44px; }
  .t-top nav a, .t-btn { display: inline-flex; align-items: center; }
}

/* Respect reduced-motion: switch animations and smooth scrolling off. */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Consistent "where am I" state for the marketing top nav. */
.t-top nav a[aria-current="page"] { color: var(--fg); font-weight: 600; }
.t-top nav a[aria-current="page"]::after {
  content: ""; display: block; height: 2px; border-radius: 2px;
  background: var(--brass); margin-top: 3px;
}

/* Consistent, subtle interaction polish across the marketing pages (these hover states
 * weren't defined before, so this adds a uniform "premium" feel without restyling layouts). */
.t-hub a, a.s-card, .t-card { transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease); }
.t-hub a:hover, a.s-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--brass) 50%, var(--line)); }
.t-btn { transition: transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease), filter var(--t) var(--ease); }
.t-btn:hover { box-shadow: var(--shadow-sm); }
.t-btn:active { transform: translateY(1px); }
.t-top nav a:not(.t-btn) { transition: color var(--t) var(--ease); }
.t-top nav a:not(.t-btn):hover { color: var(--fg); }

/* ===================================================================================
 * Shared component layer (P2). Namespaced oe-* classes so they never collide with a
 * page's own styles — a page opts in by using them. They give the platform one set of
 * buttons, inputs, cards, badges, tables and — the pieces that were missing before —
 * empty / loading / error / skeleton states, toasts and dialogs, all theme-aware.
 * =================================================================================== */

/* Detail level (P11) — progressive disclosure driven by <html data-level>.
 * .oe-advanced-only shows only in detailed mode; .oe-simple-only only in simple.
 * With no level set, behave as detailed (show advanced, hide simple-only). */
:root[data-level="simple"] .oe-advanced-only { display: none !important; }
:root[data-level="detailed"] .oe-simple-only { display: none !important; }
:root:not([data-level="simple"]) .oe-simple-only { display: none !important; }

/* Buttons */
.oe-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1; padding: 10px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-raised); color: var(--fg); cursor: pointer; text-decoration: none; transition: transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease), filter var(--t) var(--ease); }
.oe-btn:hover { border-color: var(--brass); box-shadow: var(--shadow-sm); }
.oe-btn:active { transform: translateY(1px); }
.oe-btn[disabled], .oe-btn:disabled { opacity: .5; cursor: not-allowed; }
.oe-btn-primary { background: var(--brass); border-color: var(--brass); color: #14181A; }
.oe-btn-primary:hover { filter: brightness(1.05); }
.oe-btn-ghost { background: transparent; border-color: transparent; }
.oe-btn-ghost:hover { background: var(--panel); border-color: transparent; box-shadow: none; }
.oe-btn-danger { border-color: color-mix(in srgb, var(--brick) 55%, var(--line)); color: var(--brick); }
.oe-btn-sm { padding: 6px 12px; font-size: var(--fs-xs); }
.oe-btn-lg { padding: 13px 22px; font-size: var(--fs-base); }

/* Inputs */
.oe-field { display: flex; flex-direction: column; gap: 5px; }
.oe-label { font-size: var(--fs-xs); font-weight: 600; color: var(--fg-soft); }
.oe-input, .oe-select, .oe-textarea { font: inherit; font-size: var(--fs-sm); padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-raised); color: var(--fg); width: 100%; min-width: 0; }
.oe-input:focus, .oe-select:focus, .oe-textarea:focus { border-color: var(--brass); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 22%, transparent); }
.oe-input[aria-invalid="true"], .oe-select[aria-invalid="true"] { border-color: var(--brick); }
.oe-hint { font-size: var(--fs-xs); color: var(--fg-soft); }
.oe-hint-error { color: var(--brick); }

/* Card */
.oe-card { background: var(--panel-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--sp-5); box-shadow: var(--shadow-sm); }
.oe-card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.oe-card-head h2, .oe-card-head h3 { margin: 0; font-size: var(--fs-md); }

/* Badges / status pills */
.oe-badge { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 700; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--panel); border: 1px solid var(--line); color: var(--fg-soft); white-space: nowrap; }
.oe-badge-ok { background: color-mix(in srgb, var(--ok) 20%, transparent); border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: var(--fg); }
.oe-badge-warn { background: color-mix(in srgb, var(--brass) 20%, transparent); border-color: color-mix(in srgb, var(--brass) 45%, transparent); color: var(--fg); }
.oe-badge-danger { background: color-mix(in srgb, var(--brick) 18%, transparent); border-color: color-mix(in srgb, var(--brick) 40%, transparent); color: var(--fg); }

/* Tables */
.oe-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.oe-table th, .oe-table td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.oe-table th { font-size: var(--fs-xs); font-weight: 700; color: var(--fg-soft); text-transform: uppercase; letter-spacing: .5px; }
.oe-table tbody tr:hover { background: var(--panel); }

/* Empty / loading / error states — the pieces most pages were missing */
.oe-empty { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--fg-soft); border: 1px dashed var(--line); border-radius: var(--radius-lg); }
.oe-empty-icon { font-size: 30px; opacity: .55; margin-bottom: var(--sp-2); }
.oe-empty h3 { margin: 0 0 var(--sp-1); font-size: var(--fs-md); color: var(--fg); }
.oe-error { border: 1px solid color-mix(in srgb, var(--brick) 45%, var(--line)); background: color-mix(in srgb, var(--brick) 8%, var(--panel-raised)); color: var(--fg); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); }
.oe-error h3 { margin: 0 0 4px; font-size: var(--fs-sm); color: var(--brick); }
.oe-loading { display: inline-flex; align-items: center; gap: 9px; color: var(--fg-soft); font-size: var(--fs-sm); }
.oe-spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--brass); border-radius: 50%; animation: oe-spin .7s linear infinite; }
@keyframes oe-spin { to { transform: rotate(360deg); } }
/* Skeletons for content that is loading */
.oe-skel { background: linear-gradient(90deg, var(--panel) 25%, var(--line-soft) 37%, var(--panel) 63%); background-size: 400% 100%; animation: oe-shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
.oe-skel-line { height: 12px; margin: 8px 0; }
@keyframes oe-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .oe-spinner, .oe-skel { animation: none; } }

/* Toast — transient confirmation, bottom-centre, above the fold */
.oe-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 2000; background: var(--charcoal); color: #fff; font-size: var(--fs-sm); font-weight: 600; padding: 11px 18px; border-radius: var(--radius-pill); box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }
:root[data-theme="dark"] .oe-toast, :root:not([data-theme="light"]) .oe-toast { background: var(--panel-raised); color: var(--fg); border: 1px solid var(--line); }

/* Dialog — a centred modal surface + scrim (pair with <dialog> or a div) */
.oe-scrim { position: fixed; inset: 0; z-index: 1900; background: rgba(20,24,26,.45); display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.oe-dialog { background: var(--panel-raised); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--sp-5); width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.oe-dialog h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-lg); }
.oe-dialog-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-4); flex-wrap: wrap; }
