/* ==========================================================================
   Ontic Embedding Harness — Shared Base Styles
   Imported by all pages: index.html, api-docs.html, pipeline.html
   ========================================================================== */

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; border-color: hsl(var(--border)); }

/* === Skip Link === */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  padding: 0.5rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: top var(--t-fast);
}
.skip-link:focus {
  top: 0.75rem;
}

/* === Design Tokens (Light) === */
:root {
  --ontic-blue:           208 89% 38%;
  --ontic-gray:           0 0% 48%;
  --ontic-dark-gray:      0 0% 29%;

  --background:           0 0% 100%;
  --foreground:           0 0% 29%;
  --background-muted:     0 0% 96%;
  --foreground-muted:     0 0% 48%;
  --card:                 0 0% 100%;
  --card-foreground:      0 0% 6%;
  --primary:              208 89% 38%;
  --primary-foreground:   0 0% 98%;
  --secondary:            0 0% 96%;
  --secondary-foreground: 0 0% 29%;
  --destructive:          0 84% 60%;
  --destructive-fg:       0 0% 98%;
  --border:               0 0% 88%;
  --input:                0 0% 88%;
  --ring:                 208 89% 38%;
  --surface:              0 0% 98%;
  --success:              142 76% 36%;
  --success-fg:           142 76% 28%;
  --radius:               0.75rem;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --ease:   cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 150ms var(--ease);
  --t-base: 200ms var(--ease);
}

/* === Dark Mode === */
.dark {
  --background:           0 0% 7%;
  --foreground:           0 0% 95%;
  --background-muted:     0 0% 14%;
  --foreground-muted:     0 0% 65%;
  --card:                 0 0% 9%;
  --card-foreground:      0 0% 95%;
  --primary:              208 89% 58%;
  --primary-foreground:   0 0% 9%;
  --secondary:            0 0% 14%;
  --secondary-foreground: 0 0% 95%;
  --border:               0 0% 20%;
  --input:                0 0% 20%;
  --ring:                 208 89% 58%;
  --surface:              0 0% 11%;
}

/* === Base Typography === */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-feature-settings: 'kern' 1, 'liga' 1;
  letter-spacing: -0.011em;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background-color: hsl(var(--primary) / 0.2); color: hsl(var(--foreground)); }
:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }

/* === Layout === */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
}

@media (min-width: 640px)  { .container { padding: 0 1.5rem; } }
@media (min-width: 768px)  { .container { padding: 0 2rem; } }

/* === Header === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid hsl(var(--border));
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-text {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(0.875rem, 0.825rem + 0.25vw, 1rem);
  font-weight: 600;
  color: hsl(var(--foreground));
  letter-spacing: -0.025em;
  text-decoration: none;
}

.logo-text .logo-mark {
  width: 1.375rem;
  height: 1.375rem;
  flex-shrink: 0;
}

.logo-text span { color: hsl(var(--primary)); }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  font-weight: 600;
  padding: 0.125rem 0.625rem;
  font-size: clamp(0.625rem, 0.6rem + 0.1vw, 0.6875rem);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.header-nav a {
  font-size: clamp(0.8125rem, 0.775rem + 0.19vw, 0.875rem);
  font-weight: 500;
  color: hsl(var(--foreground) / 0.7);
  text-decoration: none;
  padding: 0.375rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  transition: color var(--t-fast), background-color var(--t-fast);
}

.header-nav a:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--secondary));
}

.header-nav a.active {
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.08);
}

.btn-theme {
  background: none;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: hsl(var(--foreground-muted));
  transition: color var(--t-fast), background-color var(--t-fast);
}

.btn-theme:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }
.btn-theme svg { width: 1rem; height: 1rem; }

.mobile-clear-key {
  display: none;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground-muted));
  border-radius: calc(var(--radius) - 2px);
  height: 2.25rem;
  padding: 0 0.6rem;
  font-family: var(--font-sans);
  font-size: clamp(0.75rem, 0.725rem + 0.12vw, 0.8125rem);
  cursor: pointer;
  transition: color var(--t-fast), background-color var(--t-fast);
}

.mobile-clear-key:hover {
  color: hsl(var(--destructive));
  background: hsl(var(--secondary));
}

/* === Page Shell === */
.page { padding: 2rem 0 4rem; flex: 1; }

.page-title {
  font-size: clamp(1.5rem, 1.25rem + 0.78vw, 1.875rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}

.page-desc {
  font-size: clamp(0.8125rem, 0.775rem + 0.19vw, 0.875rem);
  color: hsl(var(--foreground-muted));
  margin-bottom: 2rem;
}

.page-desc a { color: hsl(var(--primary)); text-decoration: none; }
.page-desc a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* === Cards === */
.card {
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  margin-bottom: 1.25rem;
}

.card-header {
  padding: 1.25rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-title {
  font-size: clamp(0.875rem, 0.85rem + 0.12vw, 0.9375rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-desc {
  font-size: clamp(0.75rem, 0.725rem + 0.12vw, 0.8125rem);
  color: hsl(var(--foreground-muted));
}

.card-body {
  padding: 1rem 1.5rem 1.25rem;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  font-family: var(--font-sans);
  font-size: clamp(0.8125rem, 0.775rem + 0.19vw, 0.875rem);
  font-weight: 500;
  cursor: pointer;
  border: none;
  height: 2.5rem;
  padding: 0 1rem;
  transition: color var(--t-base), background-color var(--t-base), opacity var(--t-base);
}

.btn:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover { background: hsl(var(--primary) / 0.9); }

.btn-outline { background: hsl(var(--background)); color: hsl(var(--foreground)); border: 1px solid hsl(var(--border)); }
.btn-outline:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }

.btn-ghost { background: transparent; color: hsl(var(--foreground-muted)); }
.btn-ghost:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }

.btn-row { display: flex; gap: 0.75rem; align-items: center; }

/* === Code Blocks === */
pre, .code-preview {
  background: hsl(0 0% 6%);
  color: hsl(0 0% 92%);
  border: 1px solid hsl(0 0% 16%);
  border-radius: calc(var(--radius) - 2px);
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: clamp(0.6875rem, 0.65rem + 0.19vw, 0.75rem);
  line-height: 1.6;
  overflow-x: auto;
}

pre { margin-bottom: 1rem; }

.code-preview {
  max-height: 450px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

pre .comment { color: hsl(0 0% 52%); }
pre .key     { color: hsl(208 89% 65%); }
pre .string  { color: hsl(142 60% 60%); }
pre .number  { color: hsl(30 80% 65%); }

/* === Tables === */
.params {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.75rem, 0.725rem + 0.12vw, 0.8125rem);
}

.params th {
  text-align: left;
  font-weight: 500;
  color: hsl(var(--foreground-muted));
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
}

.params td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border) / 0.5);
  vertical-align: top;
}

.params code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  background: hsl(var(--background-muted));
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.params .required {
  color: hsl(0 84% 60%);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* === Footer === */
.site-footer {
  border-top: 1px solid hsl(var(--border));
  padding: 2rem 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: clamp(0.6875rem, 0.65rem + 0.19vw, 0.75rem);
  color: hsl(var(--foreground-muted));
}

.footer-inner a { color: hsl(var(--primary)); text-decoration: none; }
.footer-inner a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* === Status === */
.status-msg {
  font-size: clamp(0.8125rem, 0.775rem + 0.19vw, 0.875rem);
  color: hsl(var(--foreground-muted));
}

.status-msg.error   { color: hsl(var(--destructive)); }
.status-msg.success { color: hsl(var(--success)); }

/* === Spinner === */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid hsl(var(--foreground-muted) / 0.3);
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.375rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === Mobile Nav === */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: hsl(var(--foreground-muted));
  transition: color var(--t-fast), background-color var(--t-fast);
}
.mobile-nav-toggle:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }
.mobile-nav-toggle svg { width: 1rem; height: 1rem; }

.mobile-nav {
  display: none;
  position: absolute;
  top: 3.5rem;
  left: 0;
  right: 0;
  background: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
  padding: 0.5rem 1rem 0.75rem;
  z-index: 49;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.08);
}
.mobile-nav.open { display: flex; flex-direction: column; gap: 0.125rem; }
.mobile-nav a {
  display: block;
  font-size: clamp(0.8125rem, 0.775rem + 0.19vw, 0.875rem);
  font-weight: 500;
  color: hsl(var(--foreground) / 0.7);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  transition: color var(--t-fast), background-color var(--t-fast);
}
.mobile-nav a:hover { color: hsl(var(--foreground)); background: hsl(var(--secondary)); }
.mobile-nav a.active { color: hsl(var(--primary)); background: hsl(var(--primary) / 0.08); }

/* === Responsive === */
@media (max-width: 640px) {
  .page { padding: 1.25rem 0 2rem; }
  .card-header, .card-body { padding-left: 1rem; padding-right: 1rem; }
  .header-nav { display: none; }
  .mobile-nav-toggle { display: flex; }
  .mobile-clear-key.show { display: inline-flex; align-items: center; }
  .hero-features { grid-template-columns: 1fr; }
  .hero-steps { flex-direction: column; gap: 1.5rem; }
  .hero-steps .step-arrow { display: none; }
  .key-gate-card { padding: 1.5rem; }
  .key-input-row { flex-direction: column; }
  .key-input-row .input-field { max-width: none; }
}

/* === Hero === */
.hero {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid hsl(var(--border));
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, hsl(var(--primary) / 0.06), transparent);
}

.hero-title {
  font-size: clamp(1.75rem, 1.5rem + 1vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.hero-title span { color: hsl(var(--primary)); }

.hero-tagline {
  font-size: clamp(0.875rem, 0.825rem + 0.25vw, 1rem);
  color: hsl(var(--foreground-muted));
  line-height: 1.6;
  max-width: 600px;
  margin-bottom: 2rem;
}

.hero-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.hero-feature {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}

.hero-feature-icon {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
}

.hero-feature-icon svg { width: 1rem; height: 1rem; }

.hero-feature-text h3 {
  font-size: clamp(0.8125rem, 0.775rem + 0.19vw, 0.875rem);
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.hero-feature-text p {
  font-size: clamp(0.75rem, 0.725rem + 0.12vw, 0.8125rem);
  color: hsl(var(--foreground-muted));
  line-height: 1.5;
}

/* How it works steps */
.hero-steps-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--foreground-muted));
  margin-bottom: 0.75rem;
}

.hero-steps {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(0.8125rem, 0.775rem + 0.19vw, 0.875rem);
}

.step-num {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-radius: 50%;
  font-size: 0.6875rem;
  font-weight: 700;
}

.step-text {
  font-weight: 500;
  color: hsl(var(--foreground));
}

.step-arrow {
  color: hsl(var(--foreground-muted));
  font-size: 0.75rem;
}

/* Supported formats */
.hero-formats {
  font-size: clamp(0.75rem, 0.725rem + 0.12vw, 0.8125rem);
  color: hsl(var(--foreground-muted));
  margin-bottom: 2.5rem;
}

.hero-formats code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  background: hsl(var(--background-muted));
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  margin: 0 0.125rem;
}

/* === Key Gate === */
.key-gate-card {
  max-width: 520px;
  padding: 2rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.06);
}

.key-gate-title {
  font-size: clamp(0.875rem, 0.85rem + 0.12vw, 0.9375rem);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.key-gate-desc {
  font-size: clamp(0.75rem, 0.725rem + 0.12vw, 0.8125rem);
  color: hsl(var(--foreground-muted));
  margin-bottom: 1rem;
}

.key-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.key-input-row .input-field {
  flex: 1;
  max-width: 340px;
  height: 2.5rem;
  font-family: var(--font-mono);
  font-size: clamp(0.8125rem, 0.775rem + 0.19vw, 0.875rem);
}

.key-gate-error {
  font-size: clamp(0.75rem, 0.725rem + 0.12vw, 0.8125rem);
  color: hsl(var(--destructive));
  margin-top: 0.5rem;
  display: none;
}

/* === App lock state === */
#appSection { display: none; }
#appSection.unlocked { display: block; animation: fade-up 0.35s ease-out; }

/* Header clear-key link */
.header-nav .clear-key {
  font-size: clamp(0.75rem, 0.725rem + 0.12vw, 0.8125rem);
  color: hsl(var(--foreground-muted));
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-sans);
  padding: 0.375rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  transition: color var(--t-fast), background-color var(--t-fast);
  display: none;
}

.header-nav .clear-key:hover {
  color: hsl(var(--destructive));
  background: hsl(var(--secondary));
}
