/* Juris — Legal Intelligence OS
   Design tokens */

:root {
  /* Palette */
  --paper:      #faf7f2;
  --parchment:  #f0ebe1;
  --ink:        #1a1714;
  --ink-soft:   #4a4540;
  --ink-mute:   #7a7470;
  --rule:       #d9d3c7;
  --rule-soft:  #e8e2d4;
  --seal:       #8b1a1a;
  --gold:       #a0782b;
  --leather:    #2d3e2a;

  /* Semantic */
  --bg:         var(--paper);
  --bg-2:       var(--parchment);
  --fg:         var(--ink);
  --fg-2:       var(--ink-soft);
  --fg-3:       var(--ink-mute);
  --border:     var(--rule);
  --border-soft:var(--rule-soft);
  --accent:     var(--seal);

  /* Type */
  --serif: "Merriweather", "Times New Roman", Georgia, serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:  "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  /* Type scale */
  --fs-display: 56px;  --lh-display: 60px;
  --fs-h1: 40px;       --lh-h1: 48px;
  --fs-h2: 28px;       --lh-h2: 36px;
  --fs-h3: 20px;       --lh-h3: 28px;
  --fs-body: 15px;     --lh-body: 24px;
  --fs-small: 13px;    --lh-small: 20px;
  --fs-micro: 11px;    --lh-micro: 16px;

  /* Spacing */
  --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;  --s8: 64px; --s9: 96px;

  /* Radii — very small, almost square */
  --r1: 2px; --r2: 4px;

  /* Motion */
  --ease: cubic-bezier(.2,.6,.2,1);
  --dur: 160ms;

  /* Shadow — only for floating */
  --shadow-card: 0 8px 24px rgba(26,23,20,.04);
  --shadow-pop:  0 12px 40px rgba(26,23,20,.10);

  /* Layout */
  --page-max: 1280px;
  --gutter: 32px;
}

/* Leather / dark accent mode */
[data-theme="leather"] {
  --bg: #1f1b16;
  --bg-2: #2a241d;
  --fg: #f0ebe1;
  --fg-2: #c8bfae;
  --fg-3: #8a8272;
  --border: #3a3329;
  --border-soft: #2f2920;
}

[data-accent="gilt"] { --accent: var(--gold); }

/* Base reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--fg);
  background: var(--bg);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin: 0;
}
p { margin: 0; color: var(--fg-2); }
a { color: inherit; text-decoration: none; transition: color var(--dur) var(--ease); }
button { font-family: inherit; cursor: pointer; }
img, svg { display: block; }

/* Paper texture — very subtle grid */
.paper-bg {
  background-image:
    linear-gradient(to right, rgba(26,23,20,.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(26,23,20,.025) 1px, transparent 1px);
  background-size: 48px 48px;
}
.paper-noise {
  position: relative;
}
.paper-noise::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.09 0 0 0 0 0.08 0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: .5;
  pointer-events: none;
  mix-blend-mode: multiply;
}

/* Container */
.container {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
@media (max-width: 768px) {
  .container { padding: 0 20px; }
}

/* Rule line */
.rule { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* ===== TOP NAV ===== */
.topnav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  display: flex; align-items: center; gap: var(--s6);
  height: 68px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
}
.brand-mark {
  width: 32px; height: 32px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  font-weight: 900;
  font-size: 20px;
  display: grid; place-items: center;
  letter-spacing: 0;
}
[data-theme="leather"] .brand-mark { background: var(--paper); color: var(--ink); }
.brand-word {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.brand-sub {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-top: 3px;
  line-height: 1;
}
.nav-links {
  display: flex; align-items: center; gap: var(--s6);
  margin-left: auto;
  font-size: 14px;
}
.nav-links a {
  color: var(--fg-2);
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.nav-links a:hover, .nav-links a.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}
.nav-login {
  border: 1px solid var(--border);
  padding: 8px 14px !important;
  border-radius: var(--r1);
  font-weight: 500;
}
.nav-login:hover { background: var(--bg-2); border-color: var(--fg-3) !important; }

.lang-switch {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px;
  color: var(--fg-3);
  border: 1px solid var(--border);
  padding: 6px 10px;
  cursor: pointer;
  background: transparent;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  border-radius: var(--r1);
}
.lang-switch:hover { border-color: var(--fg-3); color: var(--fg); }

.hamburger { display: none; }
@media (max-width: 900px) {
  .nav-links { display: none; }
  .hamburger {
    display: grid; place-items: center;
    margin-left: auto;
    width: 40px; height: 40px;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: var(--r1);
  }
  .brand-sub { display: none; }
}

/* Mobile drawer */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(26,23,20,.5);
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 320px; max-width: 90vw;
  background: var(--bg);
  z-index: 101;
  transform: translateX(100%);
  transition: transform var(--dur) var(--ease);
  border-left: 1px solid var(--border);
  padding: 24px;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--r1);
  transition: all var(--dur) var(--ease);
}
.btn:hover { background: #000; }
[data-theme="leather"] .btn { background: var(--paper); color: var(--ink); border-color: var(--paper); }

.btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--fg); background: var(--bg-2); }

.btn-seal {
  background: var(--seal);
  border-color: var(--seal);
  color: var(--paper);
}
.btn-seal:hover { background: #6d1414; }

/* Eyebrow — smallcaps tracking */
.eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: inline-flex; align-items: center; gap: 10px;
}
.eyebrow::before {
  content: ""; width: 24px; height: 1px; background: var(--fg-3);
}
.eyebrow.no-rule::before { display: none; }

/* Hairline tag */
.tag {
  display: inline-flex; align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r1);
  color: var(--fg-2);
  text-transform: uppercase;
}
.tag-seal { border-color: var(--seal); color: var(--seal); }
.tag-gold { border-color: var(--gold); color: var(--gold); }
.tag-leather { border-color: var(--leather); color: var(--leather); background: rgba(45,62,42,.05); }

/* Status dot */
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-pulse {
  position: relative;
}
.dot-pulse::after {
  content: ""; position: absolute; inset: -4px;
  border: 1px solid currentColor;
  border-radius: 50%;
  animation: pulse 1.8s var(--ease) infinite;
  opacity: 0;
}
@keyframes pulse {
  0% { transform: scale(.6); opacity: .8; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Section header — editorial */
.section-head {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--s7);
  padding-top: var(--s8);
  padding-bottom: var(--s6);
  border-top: 1px solid var(--border);
}
.section-head .n {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-3);
  letter-spacing: 0.06em;
}
.section-head h2 {
  font-size: var(--fs-h1);
  line-height: 1.08;
  margin-top: 14px;
}
.section-head .lede {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 30px;
  color: var(--fg-2);
  margin-top: var(--s2);
}
@media (max-width: 768px) {
  .section-head { grid-template-columns: 1fr; gap: var(--s3); }
  .section-head h2 { font-size: 32px; }
}

/* Footer */
.footer {
  background: var(--ink);
  color: var(--parchment);
  border-top: 6px solid var(--seal);
  padding: var(--s8) 0 var(--s6);
  margin-top: var(--s9);
}
.footer h4 {
  font-family: var(--sans);
  color: var(--parchment);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: var(--s3);
}
.footer a { color: #c8bfae; display: block; padding: 4px 0; font-size: 14px; }
.footer a:hover { color: var(--paper); }
.footer .wordmark { font-family: var(--serif); font-size: 32px; color: var(--paper); font-weight: 700; letter-spacing: -0.02em; }
.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: var(--s7);
}
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--s5); }
}
.footer-meta {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid #3a3329;
  margin-top: var(--s7); padding-top: var(--s4);
  font-size: 12px; color: #8a8272;
  font-family: var(--mono);
}

/* Utility */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mono { font-family: var(--mono); }
.serif { font-family: var(--serif); }
.muted { color: var(--fg-3); }
.soft { color: var(--fg-2); }
.num { font-variant-numeric: tabular-nums; }

/* Prototype frame helpers */
.page-switcher {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 40;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 8px;
  display: flex; gap: 4px;
  border-radius: var(--r1);
}
.page-switcher a {
  padding: 6px 10px;
  color: var(--fg-2);
  border-radius: var(--r1);
  text-transform: uppercase;
}
.page-switcher a:hover { background: var(--bg-2); color: var(--fg); }
.page-switcher a.active { background: var(--ink); color: var(--paper); }
[data-theme="leather"] .page-switcher a.active { background: var(--paper); color: var(--ink); }

/* Tweaks panel */
.tweaks-panel {
  position: fixed; bottom: 70px; right: 20px;
  z-index: 41;
  width: 260px;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  padding: 16px;
  font-size: 13px;
  display: none;
  border-radius: var(--r1);
}
.tweaks-panel.open { display: block; }
.tweaks-panel h4 {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 10px;
}
.tweaks-row { display: flex; gap: 6px; margin-bottom: 14px; }
.tweaks-row button {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-2);
  font-size: 12px;
  border-radius: var(--r1);
  transition: all var(--dur) var(--ease);
}
.tweaks-row button.on {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
[data-theme="leather"] .tweaks-row button.on { background: var(--paper); color: var(--ink); border-color: var(--paper); }

/* ===== Citation links + modal (mock-norms.js) ===== */
.cite-link, a[data-cite], .citation[data-cite] {
  color: var(--seal);
  border-bottom: 1px solid var(--seal);
  padding-bottom: 1px;
  cursor: pointer;
  text-decoration: none;
}
.cite-link:hover, a[data-cite]:hover, .citation[data-cite]:hover {
  border-bottom-style: dashed;
}

.cite-modal-veil {
  position: fixed; inset: 0;
  background: rgba(26, 23, 20, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 200;
  padding: 24px;
}
.cite-modal-veil.open { display: flex; }
.cite-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--r2);
  display: flex; flex-direction: column;
}
.cite-modal-head {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.cite-modal-doc {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}
.cite-modal-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0;
}
.cite-modal-close {
  border: 0; background: transparent;
  width: 32px; height: 32px;
  color: var(--fg-3);
  cursor: pointer;
  display: grid; place-items: center;
  border-radius: var(--r1);
  flex-shrink: 0;
}
.cite-modal-close:hover { background: var(--bg-2); color: var(--fg); }

.cite-modal-body {
  padding: 24px 28px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
}
.cite-modal-body p { margin: 0 0 14px; }
.cite-modal-body p:last-child { margin-bottom: 0; }
.cite-modal-body strong { background: rgba(160, 120, 43, 0.12); padding: 2px 4px; border-radius: 2px; }

.cite-modal-source {
  padding: 10px 28px 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-3);
  border-bottom: 1px solid var(--border-soft);
}
.cite-modal-related {
  padding: 14px 28px;
  font-size: 13px;
  color: var(--fg-2);
}
.cite-modal-related:empty { display: none; }
.cite-modal-related .related-label {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--fg-3);
  margin-right: 8px;
}

.cite-modal-actions {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  background: var(--bg-2);
}
.cite-modal-actions-left, .cite-modal-actions-right { display: flex; gap: 8px; flex-wrap: wrap; }

.cite-action {
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-2);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--r1);
  display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--dur) var(--ease);
}
.cite-action:hover { border-color: var(--ink); color: var(--ink); background: var(--bg); }
.cite-action[data-action="open-pdf"] {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.cite-action[data-action="open-pdf"]:hover { background: var(--seal); border-color: var(--seal); color: var(--paper); }

.cite-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: var(--r1);
  font-size: 13px;
  font-family: var(--sans);
  box-shadow: var(--shadow-pop);
  z-index: 250;
  opacity: 0;
  transition: all 200ms var(--ease);
  pointer-events: none;
}
.cite-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 540px) {
  .cite-modal-head, .cite-modal-body, .cite-modal-source, .cite-modal-related, .cite-modal-actions {
    padding-left: 18px; padding-right: 18px;
  }
  .cite-modal-title { font-size: 18px; }
  .cite-modal-actions-left, .cite-modal-actions-right { flex: 1; }
  .cite-action span { display: none; }
}

/* Print: hide modal, hide page-switcher, normal page printing */
@media print {
  .cite-modal-veil, .page-switcher, .tweaks-panel, .cite-toast { display: none !important; }
}

