/* ============================================================
   Data projects page: lieflat/mono editorial chart cards.
   Method: monochromatic ladder, brightness encodes data,
   conclusion-driven headlines, capsule geometry, quartic-out
   staggered reveals. Gray tokens from the mono system:
   paper #F0EFEB · ink #1C1C1A · 7-step ladder between.
   Deviations from the reference spec, on purpose:
   - source lines use #8F8E88 (not #C6C5BF) to keep 9.5px
     text readable against the card paper (WCAG).
   - card titles/subtitles set in rem so they track the
     site's base size.
   ============================================================ */

.lf-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  margin-top: 34px;
}
.lf-grid > * { min-width: 0; }

.lf-card {
  background: #f0efeb;
  border: 1px solid #e3e2dc;
  border-radius: 24px;
  padding: 28px 28px 20px;
  max-width: 780px;
  cursor: pointer; /* click replays the entrance animation */
}
.lf-card.lf-span { max-width: none; }
.lf-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.lf-title {
  font-family: var(--font-body);
  font-size: 1.09rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.32;
  color: #1c1c1a;
  margin: 0 0 6px;
}
.lf-sub {
  font-size: 0.79rem;
  font-weight: 400;
  line-height: 1.55;
  color: #6a6963;
  margin: 0 0 18px;
}
.lf-key {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 3px;
  vertical-align: -1px;
  margin: 0 4px 0 2px;
}
.lf-plot { overflow-x: auto; }
.lf-plot svg { display: block; width: 100%; height: auto; min-width: 520px; }
.lf-span .lf-plot svg { min-width: 760px; }
.lf-src {
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8f8e88;
  margin: 14px 0 0;
  line-height: 1.6;
}
.lf-card svg text { font-family: var(--font-body); }
.lf-readout {
  font-size: 0.79rem;
  font-weight: 500;
  color: #6a6963;
  margin: 10px 0 0;
}
.lf-readout[hidden] { display: none; }

/* The single permitted dark card. */
.lf-dark { background: #1c1c1a; border-color: #1c1c1a; }
.lf-dark .lf-title { color: #f0efeb; }
.lf-dark .lf-sub { color: #b0afa9; }
.lf-dark .lf-src { color: #8f8e88; }

/* ---- Entrance animation system (quartic-out, staggered via
       inline transition-delay; scroll-reveal adds .in-view). ---- */
.lf-card svg .lf-x,
.lf-card svg .lf-xn {
  transform: scaleX(0);
  transform-box: fill-box;
  transform-origin: left center;
  transition: transform 0.9s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.lf-card svg .lf-xn { transform-origin: right center; }
.lf-card svg .lf-y {
  transform: scaleY(0);
  transform-box: fill-box;
  transform-origin: center bottom;
  transition: transform 0.9s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.lf-card svg .lf-pop {
  transform: scale(0);
  transform-box: fill-box;
  transform-origin: center center;
  transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.lf-card svg .lf-fade {
  opacity: 0;
  transition: opacity 0.6s ease;
}
.lf-card svg .lf-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.lf-card.in-view svg .lf-x,
.lf-card.in-view svg .lf-xn { transform: scaleX(1); }
.lf-card.in-view svg .lf-y { transform: scaleY(1); }
.lf-card.in-view svg .lf-pop { transform: scale(1); }
.lf-card.in-view svg .lf-fade { opacity: 1; }
.lf-card.in-view svg .lf-draw { stroke-dashoffset: 0; }

/* Instant reset between replays. */
.lf-replay-reset svg * { transition: none !important; }

/* Charts must be complete without JS and without motion. */
.no-js .lf-card svg .lf-x,
.no-js .lf-card svg .lf-xn { transform: scaleX(1); }
.no-js .lf-card svg .lf-y { transform: scaleY(1); }
.no-js .lf-card svg .lf-pop { transform: scale(1); }
.no-js .lf-card svg .lf-fade { opacity: 1; }
.no-js .lf-card svg .lf-draw { stroke-dashoffset: 0; }

@media (prefers-reduced-motion: reduce) {
  .lf-card svg .lf-x,
  .lf-card svg .lf-xn { transform: scaleX(1); transition: none; }
  .lf-card svg .lf-y { transform: scaleY(1); transition: none; }
  .lf-card svg .lf-pop { transform: scale(1); transition: none; }
  .lf-card svg .lf-fade { opacity: 1; transition: none; }
  .lf-card svg .lf-draw { stroke-dashoffset: 0; transition: none; }
  .lf-card { cursor: default; }
}

/* "Technical terms, translated" box on study pages. */
.terms-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 24px;
  max-width: 780px;
}
.terms-box h3 { font-size: 1.02rem; margin-bottom: 14px; }
.terms-box dl { margin: 0; }
.terms-box dt {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
}
.terms-box dd {
  margin: 2px 0 14px;
  color: var(--ink-soft);
  font-size: 0.93rem;
}
.terms-box dd:last-child { margin-bottom: 0; }

/* ---- Technical notes section on study pages ---- */
.tech-band {
  border-top: 3px solid var(--navy);
}
.table-scroll {
  overflow-x: auto;
  max-width: 780px;
  margin: 26px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tech-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.tech-table caption {
  text-align: left;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  padding: 16px 18px 4px;
}
.tech-table th {
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 12px 18px 8px;
  border-bottom: 1px solid var(--line);
}
.tech-table td {
  padding: 9px 18px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tech-table td:first-child { color: var(--ink); font-weight: 500; white-space: normal; }
.tech-table tr:last-child td { border-bottom: 0; }
.tech-table th.num, .tech-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tech-note {
  font-size: 0.84rem;
  color: var(--muted);
  max-width: 780px;
  margin: -14px 0 26px;
  padding: 0 2px;
}
.tech-h {
  font-size: 1.08rem;
  margin: 40px 0 10px;
}
.prose .tech-h:first-child { margin-top: 0; }
.prose code {
  background: var(--navy-soft);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.87em;
  color: var(--ink);
}
.tech-code {
  background: var(--navy-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 14px 0 18px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--ink);
  overflow-x: auto;
  max-width: 880px;
}

/* Model equations in the technical notes. */
.tech-eq {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 18px;
  margin: 14px 0 8px;
  overflow-x: auto;
  white-space: nowrap;
  max-width: 880px;
}
.tech-eq .rm { font-style: normal; }
.tech-eq sub, .tech-eq sup { font-size: 0.72em; }
.tech-eq-where {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 16px;
  max-width: 880px;
}

/* Academic-style reference list at the end of the technical notes. */
.ref-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-width: 780px;
}
.ref-list li {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-soft);
  padding-left: 1.7em;
  text-indent: -1.7em;
  margin-bottom: 10px;
  overflow-wrap: break-word;
}
.ref-list em { font-style: italic; }

/* Prev / next study links at the bottom of each study page. */
.study-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

/* Neighbourhood lookup widget (rentsafe page). */
.nbhd-widget { max-width: 560px; }
.nbhd-label {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.nbhd-widget input {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
}
.nbhd-result { margin-top: 14px; }
.nbhd-result.has-result {
  background: #f0efeb;
  border: 1px solid #e3e2dc;
  border-radius: 16px;
  padding: 18px 22px;
}
.nbhd-name {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1.05rem;
  color: #1c1c1a;
  margin: 0 0 8px;
}
.nbhd-result ul {
  margin: 0;
  padding-left: 18px;
  color: #4a4944;
  font-size: 0.95rem;
}
.nbhd-result li { margin-bottom: 4px; }
.nbhd-result li:last-child { margin-bottom: 0; }

/* Print buttons live in the hero chip row. */
button.stat-chip { cursor: pointer; font-family: var(--font-body); }
button.stat-chip:hover { border-color: var(--ink-soft); }

/* ---- Print: turn a study page into a clean brief. ---- */
@media print {
  .nav, .chapter-nav, .study-nav, .page-cta, footer, .skip-link,
  .lf-readout, .nbhd-widget, [data-print], .nav-toggle, noscript,
  .meta-row a[href="#technical"] { display: none !important; }
  body { background: #fff; }
  .research-hero { padding: 12px 0 4px; }
  section, .chapter { padding: 18px 0; }
  .lf-card, .terms-box, .q-card, .figure {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .lf-card { border: 1px solid #ddd; }
  .lf-card svg .lf-x,
  .lf-card svg .lf-xn { transform: scaleX(1) !important; transition: none !important; }
  .lf-card svg .lf-y { transform: scaleY(1) !important; transition: none !important; }
  .lf-card svg .lf-pop { transform: scale(1) !important; transition: none !important; }
  .lf-card svg .lf-fade { opacity: 1 !important; transition: none !important; }
  .lf-card svg .lf-draw { stroke-dashoffset: 0 !important; transition: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
  a { color: inherit; text-decoration: none; }
}

/* Claims-and-evidence page: job-posting phrases mapped to proof. */
.claims-group { max-width: 880px; margin-bottom: 44px; }
.claims-group h3 {
  font-size: 1.05rem;
  margin-bottom: 6px;
}
.claims-group dl { margin: 0; }
.claim {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding: 13px 0;
}
.claim dt {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.97rem;
  color: var(--ink);
}
.claim dd {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
}
@media (max-width: 720px) {
  .claim { grid-template-columns: 1fr; gap: 4px; }
}

/* Pre-flight checklist rule cards. */
.rule-card {
  background: #f0efeb;
  border: 1px solid #e3e2dc;
  border-radius: 24px;
  padding: 26px 28px;
  max-width: 780px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 20px;
}
.rule-num {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 2.1rem;
  letter-spacing: -0.02em;
  color: #b0afa9;
  line-height: 1;
}
.rule-card h3 {
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.09rem;
  color: #1c1c1a;
  margin: 4px 0 8px;
}
.rule-card p { color: #4a4944; font-size: 0.94rem; margin: 0 0 8px; }
.rule-card p:last-child { margin-bottom: 0; }
.rule-habit {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8f8e88;
}
@media (max-width: 600px) {
  .rule-card { grid-template-columns: 1fr; gap: 6px; }
}

/* Methods map rows. */
.map-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding: 16px 0;
  max-width: 880px;
}
.map-if {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
}
.map-if .map-then {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.93rem;
  color: var(--ink-soft);
  margin-top: 4px;
}
.map-method {
  display: inline-block;
  background: #1c1c1a;
  color: #f0efeb;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  border-radius: 999px;
  padding: 8px 16px;
  white-space: nowrap;
}
a.map-method:hover { background: var(--accent-deep); color: #fff; text-decoration: none; }
@media (max-width: 640px) {
  .map-row { grid-template-columns: 1fr; gap: 8px; }
}

/* Role-based entry points on the hub. */
.routes {
  max-width: 880px;
  margin: 0 0 44px;
}
.route {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 11px 0;
}
.route .route-role {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 250px;
}
.route a.tool { text-decoration: none; }
.route a.tool:hover { background: var(--accent-soft); color: var(--accent-deep); }

/* Method tag on hub cards: which statistical family the study uses. */
.lf-method {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8f8e88;
  margin-bottom: 4px;
}

/* Data-freshness line under the method tag. */
.lf-fresh {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: #b0afa9;
  margin-bottom: 12px;
}

/* Mandarin introduction inside the contact card. */
.contact-zh {
  margin: 26px auto 0;
  max-width: 560px;
  font-size: 0.92rem;
  line-height: 1.8;
  color: #c3ccd9;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 20px;
}

/* Five-study teaser cards on the home page reuse .ability-card;
   the stat line inside them gets the mono treatment. */
.lf-stat {
  font-family: var(--font-body);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #1c1c1a;
  display: block;
  margin: 10px 0 6px;
}
