/* Doublespeak v9 — Case File / Court Docket.
   Aesthetic target: legal filing — In re People's Republic of China.
   IA: caption header + table of exhibits + case file overlay with FILED stamp.
   Positions us as prosecutor presenting evidence. Distinct from v2/v6 (editorial),
   v5/v7/v8 (data tools), v4 (cinematic). */

:root {
  --paper:        #f6f1e2;        /* ivory file-folder paper */
  --paper-2:      #fbf6e8;        /* lighter (case file inside) */
  --ink:          #050402;        /* deep black ink */
  --muted:        #5a5340;        /* fainter ink */
  --faint:        #948b75;        /* even fainter */
  --line:         #c5b993;        /* hairline */
  --line-strong:  #2a241a;        /* strong divider */
  --rule:         #050402;
  --stamp:        #b8231b;        /* official stamp red */
  --stamp-soft:   #f4d8d3;        /* stamp wash */

  --max:    1280px;
  --pad-x:  clamp(20px, 3.4vw, 56px);

  /* Classical serif for the legal voice. NOT Inter, NOT Helvetica. */
  --font-display: "Hoefler Text", "EB Garamond", "Garamond", "Times New Roman", Times, serif;
  --font-text:    "Iowan Old Style Text", Charter, Georgia, "Times New Roman", Times, serif;
  /* Mono = typewriter — appropriate for legal docs (not "lazy technical") */
  --font-mono:    "Courier", "Courier New", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga" on, "kern" on, "onum" on;
  padding-top: 52px;
  padding-bottom: 96px;
  min-height: 100vh;
  /* Subtle paper grain via radial-gradient noise */
  background-image:
    radial-gradient(circle at 25% 35%, rgba(120, 100, 60, 0.025) 0%, transparent 60%),
    radial-gradient(circle at 75% 65%, rgba(150, 120, 80, 0.02) 0%, transparent 50%);
  background-attachment: fixed;
}
a { color: var(--ink); text-decoration: none; }
button { font: inherit; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ===== Top + bottom bars ===== */
.bar {
  position: fixed; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center;
  background: var(--paper);
}
.bar-top {
  top: 0; height: 52px;
  padding: 0 clamp(16px, 2vw, 28px);
  border-bottom: 2px solid var(--rule);
  justify-content: space-between;
}
.bar-bottom {
  bottom: 0; min-height: 60px;
  padding: 8px clamp(16px, 2vw, 28px);
  border-top: 2px solid var(--rule);
  flex-direction: column; align-items: stretch; gap: 4px;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-style: italic; font-size: 13px; letter-spacing: 0.04em;
}
.brand-name {
  color: var(--ink); font-family: var(--font-display); font-weight: 700; font-style: italic;
  font-size: 17px; letter-spacing: 0.005em;
}
.bar-nav { display: none; }
.bar-status {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  color: var(--muted); text-transform: uppercase;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--stamp); }

.bar-bottom-skus {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em;
  color: var(--muted); text-transform: uppercase;
}
.bar-bottom-skus span::before { content: "▸ "; color: var(--stamp); }
.bar-bottom-form { display: flex; align-items: center; gap: 8px; width: 100%; }
#leadEmail {
  flex: 1 1 auto; min-width: 0;
  background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 9px 12px; font: 14px var(--font-mono); letter-spacing: 0.02em;
  outline: none;
}
#leadEmail:focus { border-color: var(--stamp); }
#leadEmail::placeholder { color: var(--faint); font-style: italic; }
.lead-submit {
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink);
  padding: 9px 18px; cursor: pointer;
  font: 700 12px var(--font-display); font-style: italic; letter-spacing: 0.04em; text-transform: uppercase;
  transition: background 0.15s;
}
.lead-submit:hover { background: var(--stamp); border-color: var(--stamp); }
.lead-qr {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong);
  width: 38px; height: 38px;
  display: grid; place-items: center;
  cursor: pointer; padding: 0;
}
.lead-qr svg { width: 18px; height: 18px; fill: currentColor; }
.lead-qr:hover { border-color: var(--stamp); color: var(--stamp); }
.bar-bottom-msg { font-family: var(--font-mono); font-size: 11px; color: var(--muted); min-height: 14px; }

.app-loading { padding: 60px 32px; color: var(--muted); font-family: var(--font-display); font-style: italic; font-size: 18px; }

/* ===== Main ===== */
#appMain {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(20px, 3vh, 36px) var(--pad-x);
}

/* ===== Caption header ===== */
.v9-caption {
  position: relative;
  padding-bottom: clamp(28px, 4vh, 48px);
  margin-bottom: clamp(28px, 4vh, 48px);
  border-bottom: 3px double var(--line-strong);
}

.v9-docket-strip {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: clamp(28px, 4vh, 44px);
}
.ds-court { color: var(--stamp); font-weight: 700; }
.ds-no { font-weight: 700; color: var(--ink); }

.v9-caption-body {
  text-align: center;
  max-width: 720px; margin: 0 auto;
  display: flex; flex-direction: column;
  gap: 12px;
}
.cap-line {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(15px, 1.2vw, 18px);
  letter-spacing: 0.06em; color: var(--muted);
}
.cap-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(36px, 4.6vw, 64px);
  letter-spacing: 0.02em; line-height: 1;
  text-transform: uppercase;
  color: var(--ink); margin: 6px 0;
  font-variant-caps: small-caps;
}
.cap-vs {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(20px, 1.6vw, 26px);
  color: var(--stamp);
  margin: 4px 0;
}
.cap-defendant {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(28px, 3.8vw, 52px);
  letter-spacing: 0.02em; line-height: 1.05;
  color: var(--ink);
  margin: 6px 0;
  text-transform: uppercase;
  font-variant-caps: small-caps;
}
.cap-defendant-sub {
  display: block;
  font-family: var(--font-display); font-style: italic;
  font-weight: 400; font-variant-caps: normal;
  font-size: clamp(15px, 1.3vw, 19px);
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  margin-top: 8px;
}
.cap-divider {
  width: 80px; height: 0;
  border-top: 1px solid var(--ink);
  margin: clamp(20px, 2.5vh, 32px) auto;
  position: relative;
}
.cap-divider::before, .cap-divider::after {
  content: "§";
  position: absolute; top: -10px;
  font-family: var(--font-display); color: var(--ink);
  font-size: 14px;
}
.cap-divider::before { left: -18px; }
.cap-divider::after  { right: -18px; }
.cap-charge {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(15px, 1.25vw, 19px);
  line-height: 1.5;
  color: var(--ink);
  margin: 0; max-width: 60ch; margin: 0 auto;
}
.cap-charge em { font-style: normal; font-weight: 600; }

/* Statement of facts */
.v9-statement {
  margin-top: clamp(28px, 4vh, 48px);
  max-width: 760px; margin-left: auto; margin-right: auto;
  border-top: 1px solid var(--line);
  padding-top: clamp(20px, 2.5vh, 28px);
}
.stmt-eyebrow {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--stamp); font-weight: 700;
  margin-bottom: 12px;
}
.stmt-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.stmt-list li {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px; align-items: baseline;
  font-family: var(--font-display);
  font-size: clamp(17px, 1.4vw, 22px);
  line-height: 1.45;
  color: var(--ink);
}
.stmt-no {
  font-family: var(--font-mono); font-weight: 700;
  font-size: 13px; color: var(--stamp);
  text-align: right;
  font-variant-numeric: oldstyle-nums;
}

/* ===== Docket / Table of Exhibits ===== */
.v9-docket {
  margin-top: clamp(28px, 4vh, 44px);
  border-top: 3px double var(--line-strong);
  padding-top: clamp(20px, 3vh, 32px);
}
.docket-header {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: clamp(20px, 2.6vh, 30px);
}
.docket-title {
  font-family: var(--font-display); font-weight: 700; font-style: italic;
  font-size: clamp(32px, 3.4vw, 50px);
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.005em;
}
.docket-meta {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  color: var(--muted); text-transform: uppercase;
}

.docket-thead, .exhibit-row {
  display: grid;
  grid-template-columns: 80px minmax(180px, 2fr) minmax(180px, 1.5fr) 100px minmax(140px, 1fr) 80px;
  gap: 16px;
  align-items: baseline;
  padding: 12px 8px;
}
.docket-thead {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted); font-weight: 700;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: rgba(184, 35, 27, 0.04);
}

.exhibit-row {
  border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, padding 0.15s;
  position: relative;
}
.exhibit-row:hover {
  background: var(--stamp-soft);
  padding-left: 16px; padding-right: 16px;
}
.exhibit-row.is-faded { opacity: 0.32; pointer-events: none; }
.exhibit-row.is-active {
  background: var(--ink);
  color: var(--paper);
}
.exhibit-row.is-active::before {
  content: "▸"; position: absolute; left: -16px; top: 12px;
  color: var(--stamp); font-family: var(--font-display); font-size: 18px; font-weight: 700;
}

.ex-no {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em;
  color: var(--stamp); font-weight: 700;
}
.exhibit-row.is-active .ex-no { color: var(--paper); }
.ex-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(15px, 1.3vw, 19px);
  color: var(--ink);
  letter-spacing: 0.005em;
  line-height: 1.25;
}
.exhibit-row.is-active .ex-title { color: var(--paper); }
.ex-jur {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(13px, 1vw, 15.5px);
  color: var(--muted);
  line-height: 1.3;
}
.exhibit-row.is-active .ex-jur { color: var(--paper); }
.ex-vol {
  font-family: var(--font-mono); font-size: 12.5px;
  color: var(--ink); text-align: right;
  font-variant-numeric: tabular-nums;
}
.ex-vol b { font-weight: 700; }
.exhibit-row.is-active .ex-vol { color: var(--paper); }
.ex-source {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(12.5px, 1vw, 15px);
  color: var(--muted);
  line-height: 1.3;
}
.exhibit-row.is-active .ex-source { color: var(--paper); }
.ex-status {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  color: var(--stamp); font-weight: 700;
  text-align: right;
}
.exhibit-row.is-active .ex-status { color: var(--paper); }
.exhibit-row:hover .ex-status::after { content: "▸"; margin-left: 2px; }

/* Role color accents on the EX. NO column */
.exhibit-row.role-seed .ex-no { color: #b8231b; }
.exhibit-row.role-lead .ex-no { color: #a17616; }
.exhibit-row.role-grss .ex-no { color: #2c5fa3; }
.exhibit-row.role-slnt .ex-no { color: #6a6256; }

/* ===== Case File overlay panel ===== */
.v9-casefile {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 16, 8, 0.62);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: clamp(16px, 4vh, 48px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.v9-casefile.is-open {
  opacity: 1;
  pointer-events: auto;
}
.v9-casefile[hidden] { display: grid; }

.v9-casefile::before {
  /* The case file paper itself wraps content */
  content: ""; display: none;
}

/* The actual case file paper container is a child wrapper */
.v9-casefile > * {
  position: relative;
}

.v9-casefile {
  /* Wrap children inside a paper sheet */
}
.v9-casefile {
  /* Use a gradient + box to act as the paper */
}

/* The cf-stamp + cf-close + cf-folio + .cluster-detail need to sit inside a paper container.
   We achieve this by making the .v9-casefile itself the paper, with max-width and inner padding. */
.v9-casefile {
  /* Override: act as a centered paper sheet */
  display: block;
  background: rgba(20, 16, 8, 0.62);
}
.v9-casefile.is-open {
  display: block;
}
.v9-casefile[hidden] { display: none; }

/* Use a wrapper class — but our content is appended directly. So style children directly */
.v9-casefile .cf-stamp,
.v9-casefile .cf-close,
.v9-casefile .cf-folio,
.v9-casefile .cluster-detail,
.v9-casefile .cf-loading {
  /* These all need to be inside a centered paper "card" */
  max-width: 880px;
  margin-left: auto; margin-right: auto;
  background: var(--paper-2);
  color: var(--ink);
  position: relative;
}
.v9-casefile .cf-loading {
  padding: 60px 40px;
  text-align: center;
  font-family: var(--font-display); font-style: italic; font-size: 20px;
  color: var(--muted);
  margin-top: 10vh;
  border: 2px solid var(--ink);
}
.v9-casefile .cf-error { color: var(--stamp); }

.v9-casefile .cf-folio {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 28px;
  border-bottom: 1px solid var(--ink);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
  font-weight: 700;
  margin-top: 0;
  border-top: 6px double var(--ink);
  border-left: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
}

.v9-casefile .cf-close {
  display: flex; justify-content: flex-end; align-items: center;
  background: var(--ink); color: var(--paper);
  border: 0; border-left: 2px solid var(--ink); border-right: 2px solid var(--ink);
  padding: 10px 28px;
  font: 700 11px var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s;
}
.v9-casefile .cf-close:hover { background: var(--stamp); }

.v9-casefile .cf-stamp {
  position: absolute;
  top: clamp(50px, 6vh, 90px); right: clamp(40px, 8vw, 100px);
  width: 180px; height: 180px;
  border: 4px solid var(--stamp);
  border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font-display); color: var(--stamp);
  text-transform: uppercase; letter-spacing: 0.06em;
  background: rgba(246, 241, 226, 0.4);
  transform: rotate(8deg);
  z-index: 10;
  pointer-events: none;
  animation: stamp-down 0.5s cubic-bezier(0.5, 0, 0.5, 1.5) 0.2s both;
}
@keyframes stamp-down {
  0%   { opacity: 0; transform: rotate(20deg) scale(2); }
  60%  { opacity: 1; transform: rotate(6deg) scale(0.94); }
  100% { opacity: 0.85; transform: rotate(8deg) scale(1); }
}
.cf-stamp .stamp-line { display: block; }
.cf-stamp .stamp-line-1 { font-weight: 700; font-size: 36px; line-height: 1; letter-spacing: 0.1em; }
.cf-stamp .stamp-line-2 { font-family: var(--font-mono); font-size: 13px; margin-top: 6px; letter-spacing: 0.14em; }
.cf-stamp .stamp-line-3 { font-family: var(--font-mono); font-size: 11px; margin-top: 4px; letter-spacing: 0.18em; }

/* The cluster-detail content rendered inside the case file wrapper */
.v9-casefile .cluster-detail {
  padding: clamp(28px, 4vh, 48px) clamp(28px, 4vw, 56px);
  border-left: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  border-bottom: 6px double var(--ink);
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  margin-bottom: 8vh;
}
.v9-casefile .cluster-back-wrap { display: none; }
.v9-casefile .cluster-banner-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px; margin-bottom: 18px;
}
.v9-casefile .cluster-banner-top .vol { color: var(--stamp); font-weight: 700; }
.v9-casefile .cluster-name {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(28px, 3.2vw, 48px); line-height: 1.05;
  color: var(--ink); margin: 0 0 14px;
  letter-spacing: 0.005em;
  max-width: 22ch;
  text-transform: uppercase;
  font-variant-caps: small-caps;
}
.v9-casefile .cluster-punch {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(17px, 1.4vw, 22px); line-height: 1.5;
  color: var(--ink);
  border-left: 3px solid var(--stamp);
  padding-left: 18px;
  margin: 0 0 22px;
  max-width: 60ch;
}
.v9-casefile .cluster-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  padding-top: 16px; gap: 14px;
}
.v9-casefile .cstat .v {
  display: block;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(22px, 2.4vw, 36px); line-height: 1;
  color: var(--ink); letter-spacing: -0.005em;
  font-variant-numeric: oldstyle-nums;
}
.v9-casefile .cstat .l {
  display: block; margin-top: 6px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em;
  color: var(--muted); text-transform: uppercase;
}

/* ===== Story drawer (L3) ===== */
.drawer { position: fixed; inset: 0; z-index: 300; display: none; }
.drawer[aria-hidden="false"] { display: block; }
.drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 16, 8, 0.55);
  backdrop-filter: blur(2px);
  border: 0; cursor: pointer;
}
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(720px, 92vw);
  background: var(--paper-2); color: var(--ink);
  overflow-y: auto;
  border-left: 2px solid var(--ink);
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.18);
}

/* ===== QR popover ===== */
.qr-popover { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center;
  background: rgba(20, 16, 8, 0.6); backdrop-filter: blur(2px); }
.qr-popover[hidden] { display: none; }
.qr-popover-card {
  background: var(--paper-2); color: var(--ink);
  border: 2px solid var(--ink);
  padding: 24px; max-width: 360px; text-align: center;
  font-family: var(--font-text);
}
.qr-popover-card strong { display: block; margin-bottom: 12px; font-family: var(--font-display); font-style: italic; font-size: 18px; }
.qr-canvas { width: 200px; height: 200px; margin: 0 auto 12px; background: white; }
.qr-close {
  margin-top: 14px; background: var(--ink); color: var(--paper);
  border: 0; padding: 8px 16px; cursor: pointer;
  font: 700 11px var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase;
}
.qr-close:hover { background: var(--stamp); }

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .docket-thead, .exhibit-row {
    grid-template-columns: 60px minmax(140px, 1.5fr) 80px minmax(120px, 1fr);
  }
  .docket-thead .ex-jur, .exhibit-row .ex-jur,
  .docket-thead .ex-status, .exhibit-row .ex-status,
  .docket-thead :nth-child(3), .exhibit-row :nth-child(3),
  .docket-thead :nth-child(6), .exhibit-row :nth-child(6) { display: none; }
  .v9-casefile .cf-stamp { width: 130px; height: 130px; right: 16px; top: 30px; }
  .cf-stamp .stamp-line-1 { font-size: 24px; }
}

/* end v9 */
