/* ==========================================================================
   PROSERA — the registry, in daylight. Blue on dirty white: navy ink on
   warm paper, one azure signal, hairlines, mono instrument labels.
   ========================================================================== */

:root {
  --ground: #f1f0ea;
  --ground-2: #e9e8e0;
  --field: #faf9f4;
  --ink: #1b2a6b;
  --ink-strong: #131c4a;
  --mut: #4d5f7c;
  --azure: #3e6bff;
  --azure-deep: #2447c5;
  --navy: #1b2a6b;
  --line: rgba(27, 42, 107, 0.16);
  --line-strong: rgba(27, 42, 107, 0.32);
  /* live theme tokens — driven by the admin panel (theme-panel.js) */
  --font-sans: Archivo, sans-serif;
  --font-mono: "Geist Mono", monospace;
  --fs-body: 16px;
  --fs-label: 11px;
  --tracking-display: 0.02em;
  --weight-display: 800;
  --display-max: 11rem;
  --weight-headline: 700;
  --headline-max: 4.6rem;
  --radius-control: 2px;
  --mesh-dot: #6f7da8;
  --mesh-tint: #2447c5;
  --mesh-opacity: 0.85;
}

body { background: var(--ground); font-size: var(--fs-body); }

.text-soft { color: var(--mut); }
.text-body-strong { color: var(--ink); }
.stat-bg { background: color-mix(in srgb, var(--ground-2) 60%, transparent); }
.footer-bg { background: color-mix(in srgb, var(--ground) 95%, transparent); }

/* token-owned type — the panel retunes these live */
#hero-word {
  font-size: clamp(3.4rem, 11.5vw, var(--display-max));
  letter-spacing: var(--tracking-display);
  font-weight: var(--weight-display);
}
.section-title {
  font-size: clamp(2.2rem, 5.6vw, var(--headline-max));
  font-weight: var(--weight-headline);
  letter-spacing: -0.02em;
}
.meta-row, .hero-meta, .footer-meta, .badge, .entity-row .font-mono {
  font-size: var(--fs-label);
}
.badge, .btn, .f-input, .f-select { border-radius: var(--radius-control); }

/* ---------- skip to main link (WCAG 2.2 AA) ---------- */
.skip-link {
  position: absolute;
  top: -120px;
  left: 20px;
  z-index: 999;
  background: var(--ink);
  color: var(--ground);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 10px 16px;
  border-radius: var(--radius-control);
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 14px;
  outline: 3px solid var(--azure);
  outline-offset: 2px;
}

/* ---------- reading progress bar (motion / instrument) ---------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--azure);
  transform-origin: left center;
  transform: scaleX(0);
  z-index: 60;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

html { scroll-behavior: auto; }
html, body { overflow-x: clip; }

.container-x {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: 20px;
}
@media (min-width: 768px) {
  .container-x { padding-inline: 40px; }
}

/* ---------- the field (mesh canvas) ---------- */
#mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0.9;
}

/* sections after the hero sit under a veil: the mesh stays faintly
   present at each section's top edge, solid under the reading matter.
   The veil is a positioned pseudo — without this rule it paints ABOVE
   static content and washes text out (content only escaped when GSAP
   happened to leave an inline transform on it). Raise real content. */
.section-veil { position: relative; }
.section-veil > .container-x { position: relative; z-index: 1; }
.section-veil::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(241, 240, 234, 0) 0%,
    rgba(241, 240, 234, 0.66) 120px,
    rgba(241, 240, 234, 0.92) 260px,
    rgba(241, 240, 234, 0.92) 100%
  );
  pointer-events: none;
}

/* ---------- nav ---------- */
#site-nav {
  transition: background 0.35s ease, border-color 0.35s ease, backdrop-filter 0.35s ease;
  border-bottom: 1px solid transparent;
}
#site-nav.scrolled {
  background: rgba(241, 240, 234, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom-color: var(--line);
}

/* underline-grow links */
.u-link, .u-link-big {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 96%;
  background-repeat: no-repeat;
  transition: background-size 0.3s ease, color 0.3s ease;
  padding-bottom: 3px;
}
.u-link:hover, .u-link-big:hover { background-size: 100% 1px; }
.u-link-big:hover { color: var(--azure-deep); }

/* ---------- the instrument ring ---------- */
.o-ring { color: var(--ink); }
.o-ring circle {
  transform-origin: center;
  animation: ring-turn 16s linear infinite;
  transition: animation-duration 0.6s ease;
}
header:hover .o-ring circle,
.o-ring:hover circle {
  animation-duration: 8s;
}
@keyframes ring-turn { to { transform: rotate(330deg); } }

/* ---------- registry rows ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  white-space: nowrap;
}
.badge .status-dot { flex: none; }
.badge-live { color: var(--azure-deep); border-color: rgba(62, 107, 255, 0.45); }
.badge-dev, .badge-plan { color: var(--mut); }
.badge-plan { border-style: dashed; }

/* ---------- buttons (design-system v0.2) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 2px;
  padding: 0 22px;
  height: 42px;
  text-decoration: none;
  transition: background 0.25s cubic-bezier(0.22, 1, 0.36, 1), color 0.25s ease, transform 0.2s ease;
}
.btn-sm { height: 34px; padding: 0 16px; font-size: 11px; letter-spacing: 0.12em; }
.btn-primary { background: var(--ink); color: var(--ground); }
.btn-primary:hover { background: var(--ink-strong); color: var(--ground); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--ground-2); border-color: var(--ink); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(62, 107, 255, 0.28); }

.entity-row {
  position: relative;
  transition: background 0.35s cubic-bezier(0.22, 1, 0.36, 1), transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: background, transform;
}
.entity-row:hover {
  background: rgba(27, 42, 107, 0.045);
  transform: translateX(4px);
}
.entity-row .entity-arrow {
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), color 0.3s ease;
  display: inline-block;
}
.entity-row:hover .entity-arrow { transform: translateX(10px); color: var(--azure-deep); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--mut);
  display: inline-block;
}
.status-dot.status-live {
  background: var(--azure);
  border-color: var(--azure);
  animation: status-pulse 2.6s ease-in-out infinite;
}
@keyframes status-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(62, 107, 255, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(62, 107, 255, 0); }
}

/* ---------- meta rows / hairlines draw in ---------- */
.meta-row, .hero-meta {
  transform-origin: left center;
}

.scroll-arrow {
  display: inline-block;
  animation: arrow-bob 1.8s ease-in-out infinite;
}
@keyframes arrow-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ---------- stats ---------- */
.stat-cell { transition: background 0.3s ease; }
.stat-cell:hover { background: rgba(27, 42, 107, 0.04); }

/* ---------- browser surfaces ---------- */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: var(--ground); }
::-webkit-scrollbar-thumb { background: #c9c7bb; border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: #b3b1a3; }

:focus-visible {
  outline: 2px solid var(--azure);
  outline-offset: 3px;
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .o-ring circle { animation: none; }
  .status-dot.status-live { animation: none; }
  .scroll-arrow { animation: none; }
  #site-nav { transition: none; }
  * { scroll-behavior: auto !important; }
}

/* ---------- theme admin panel (theme-panel.js) ---------- */
#theme-toggle {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink);
  background: color-mix(in srgb, var(--field) 92%, transparent);
  border: 1px solid var(--line-strong); border-radius: 2px;
  padding: 8px 12px; cursor: pointer; backdrop-filter: blur(8px);
  transition: background 0.2s ease;
}
#theme-toggle:hover { background: var(--ground-2); }

#theme-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 90;
  width: min(340px, 92vw);
  background: color-mix(in srgb, var(--field) 96%, transparent);
  border-left: 1px solid var(--line-strong);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transform: translateX(105%); transition: transform 0.35s ease;
  overflow-y: auto; padding: 20px 20px 32px;
  font-size: 13px; color: var(--ink);
}
#theme-panel.open { transform: translateX(0); }
#theme-panel h3 {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--mut); margin: 22px 0 10px;
  border-top: 1px solid var(--line-strong); padding-top: 12px;
}
#theme-panel h3:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.tp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.tp-row label { font-size: 12.5px; }
.tp-row .tp-val { font-family: var(--font-mono); font-size: 11px; color: var(--mut); min-width: 52px; text-align: right; }
.tp-color { display: flex; align-items: center; gap: 8px; }
.tp-color input[type="color"] {
  width: 30px; height: 30px; border: 1px solid var(--line-strong);
  border-radius: 2px; background: none; padding: 2px; cursor: pointer;
}
.tp-color input[type="text"] {
  width: 86px; font-family: var(--font-mono); font-size: 11px; color: var(--ink);
  background: var(--field); border: 1px solid var(--line); border-radius: 2px; padding: 5px 7px;
}
.tp-row input[type="range"] { width: 130px; accent-color: var(--ink); }
.tp-row select {
  font-family: var(--font-sans); font-size: 12.5px; color: var(--ink);
  background: var(--field); border: 1px solid var(--line-strong);
  border-radius: 2px; padding: 5px 7px; max-width: 170px;
}
.tp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tp-actions button {
  flex: 1 1 auto; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ground); background: var(--ink);
  border: 0; border-radius: var(--radius-control); padding: 9px 12px; cursor: pointer;
}
.tp-actions button:hover { background: var(--ink-strong); }
.tp-actions button.tp-ghost { background: none; color: var(--ink); border: 1px solid var(--line-strong); }
#theme-panel textarea {
  width: 100%; min-height: 150px; margin-top: 10px; resize: vertical;
  font-family: var(--font-mono); font-size: 11px; line-height: 1.6; color: var(--ink);
  background: var(--ground); border: 1px dashed var(--line-strong); border-radius: 2px; padding: 10px;
}
#theme-panel .tp-note { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; color: var(--mut); line-height: 1.8; margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { #theme-panel { transition: none; } }

/* hairline utility used across the registry — navy-tinted, themeable */
.border-line { border-color: var(--line); }

/* ---------- contact form (registry grammar) ---------- */
.f-grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .f-grid { grid-template-columns: 1fr 1fr; } }
.f-label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mut);
  margin-bottom: 8px;
}
.f-input, .f-textarea {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: 11px 14px;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.f-textarea { resize: vertical; min-height: 120px; }
.f-input:focus, .f-textarea:focus {
  outline: none;
  border-color: var(--azure);
  box-shadow: 0 0 0 3px rgba(62, 107, 255, 0.28);
}
.f-input::placeholder { color: #626b87; }
.f-input[aria-invalid="true"], .f-textarea[aria-invalid="true"] { border-color: #b33636; }
.f-status { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.04em; color: var(--mut); min-height: 1.2em; }
.f-status.ok { color: #1f7a5c; }
.f-status.err { color: #b33636; }
.consent-row { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.6; color: var(--mut); cursor: pointer; }
.consent-row input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--ink); flex: none; cursor: pointer; }

/* ---------- entity register ---------- */
.entity-list { border-top: 1px solid var(--line); }
.entity-line {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.entity-line dt {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mut);
}
.entity-line dd { font-size: 15px; color: var(--ink); }

/* ---------- legal blocks ---------- */
.legal-block { border: 1px solid var(--line); border-radius: var(--radius-control); }
.legal-block + .legal-block { margin-top: 10px; }
.legal-block summary {
  cursor: pointer;
  list-style: none;
  padding: 15px 18px;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.legal-block summary::-webkit-details-marker { display: none; }
.legal-block summary::after { content: "+"; margin-left: auto; font-family: var(--font-mono); color: var(--mut); }
.legal-block[open] summary::after { content: "–"; }
.legal-block[open] summary { border-bottom: 1px solid var(--line); }
.legal-body { padding: 16px 18px 18px; font-size: 14px; line-height: 1.75; color: #4e5e80; display: grid; gap: 10px; }
.legal-body strong { color: var(--ink); }
.legal-body a { color: var(--azure-deep); }

/* ---------- prose rows for legal & compliance pages ---------- */
.prose-rows {
  border-top: 1px solid var(--line);
}
.prose-row {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 24px;
}
@media (max-width: 640px) {
  .prose-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 20px 0;
  }
}
.prose-row h2 {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mut);
  line-height: 1.6;
}
.prose-row p, .prose-row ul, .prose-row ol {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
}
.prose-row a {
  color: var(--azure-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}
.prose-row a:hover {
  color: var(--ink-strong);
}

/* breadcrumb nav */
.crumb-nav ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--mut);
}
.crumb-nav a {
  color: var(--mut);
  text-decoration: none;
  transition: color 0.2s ease;
}
.crumb-nav a:hover {
  color: var(--ink);
}

/* ---------- storage notice ---------- */
#storage-notice {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(430px, calc(100vw - 32px));
  background: color-mix(in srgb, var(--field) 94%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: 11px 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#storage-notice[hidden] { display: none; }
#storage-notice p { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.03em; line-height: 1.7; color: var(--mut); }
#storage-notice a { color: var(--azure-deep); }
#notice-ok {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--ground);
  border: 0;
  border-radius: var(--radius-control);
  padding: 7px 12px;
  cursor: pointer;
  flex: none;
}
@media (prefers-reduced-motion: reduce) { #storage-notice { transition: none; } }

/* ---------- legal hub + detail pages ---------- */
.crumb { display: inline-block; transition: color 0.25s ease; }
.crumb:hover { color: var(--ink); }

.page-title {
  font-size: clamp(2.6rem, 7vw, 6rem);
  font-weight: var(--weight-display);
  letter-spacing: -0.02em;
  line-height: 0.95;
  color: var(--ink-strong);
}
.page-intro { color: var(--mut); font-size: 17px; line-height: 1.7; }
.page-note { font-size: 13.5px; line-height: 1.7; color: var(--mut); }

.contact-strip {
  margin-top: 56px;
  border: 1px solid var(--line);
  background: var(--field);
  border-radius: var(--radius-control);
  padding: 26px 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 62rem;
}

/* cards */
.legal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  max-width: 62rem;
}
@media (max-width: 760px) { .legal-grid { grid-template-columns: 1fr; } }

.legal-card {
  --mx: 50%;
  --my: 50%;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 26px 26px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--ground);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.3s ease, background 0.3s ease;
}
.legal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(240px circle at var(--mx) var(--my), rgba(62, 107, 255, 0.07), transparent 72%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.legal-card:hover {
  transform: translateY(var(--hover-lift, -5px));
  border-color: var(--line-strong);
  background: var(--field);
}
.legal-card:hover::before { opacity: 1; }

.lc-top { display: flex; align-items: baseline; justify-content: space-between; }
.lc-num {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--mut);
  transition: color 0.3s ease;
}
.legal-card:hover .lc-num { color: var(--azure-deep); }
.lc-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mut);
}
.lc-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--ink-strong);
  margin-top: 8px;
}
.lc-desc { font-size: 14px; line-height: 1.7; color: var(--mut); flex: 1; }
.lc-go {
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.lc-go .arrow { display: inline-block; transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
.legal-card:hover .lc-go .arrow { transform: translateX(8px); }
.legal-card:focus-visible { outline: 2px solid var(--azure); outline-offset: 3px; }

/* entrance movement — progressively enhanced: visible by default, animated when js is ready */
.reveal {
  opacity: 1;
  transform: none;
}
html.js-ready .reveal:not(.in) {
  opacity: 0;
  transform: translateY(var(--reveal-offset, 20px));
}
.reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity var(--reveal-duration, 0.7s) cubic-bezier(0.22, 1, 0.36, 1),
              transform var(--reveal-duration, 0.7s) cubic-bezier(0.22, 1, 0.36, 1);
}
html.js-ready .legal-grid:not(.in) .legal-card { opacity: 0; transform: translateY(var(--reveal-offset, 24px)); }
.legal-card {
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.3s ease, background 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-progress { display: none; }
  .reveal, .legal-grid .legal-card { opacity: 1 !important; transform: none !important; }
  .legal-card, .legal-card::before, .lc-go .arrow, .crumb, .entity-row { transition: none !important; }
  .legal-card:hover, .entity-row:hover { transform: none !important; }
}


/* ---------- copy toast (email links) ---------- */
#copy-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  z-index: 120;
  background: var(--ink);
  color: var(--ground);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.06em;
  padding: 11px 16px;
  border-radius: var(--radius-control);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#copy-toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { #copy-toast { transition: none; } }
