/* ============================================================================
   ThinkPattern — Share / link-out web pages
   Almanac design language ported to a responsive editorial web surface.
   Shared by story.html, perspective.html, actor.html.
   Tokens mirror hifi-tokens.jsx (FN / Field-Notebook = Almanac).
   ========================================================================== */

/* Fonts are loaded per-page via <link rel="preconnect"> + <link rel="stylesheet">
   (see any page head) — an @import here would chain html → css → fonts css and
   block first render. The shared URL requests Fraunces as a variable font with
   the ital + SOFT + WONK axes so headings can carry the app's wonky signature
   and quotes get the real italic cut (never synthesized). */

:root {
  --paper:   #efebde;
  --paper2:  #e2dccb;
  --ink:     #1f1a14;
  --ink2:    #3d362a;
  --muted:   #6a604f;
  --faint:   #b8b09a;
  --accent:  #b8862a;   /* ochre — decorative on paper */
  --accent-soft: #d9c598;
  --link:        #8a5e0e;  /* AA link text on paper */
  --link-pressed:#6a4509;
  --slate:   #3e5878;     /* mark only */

  --display: "Fraunces", Georgia, serif;
  --sans:    "Inter Tight", "Inter", system-ui, -apple-system, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  /* relation kinds */
  --r-ally:      #1f5a4e;
  --r-adversary: #a8341c;
  --r-authority: #5a4a8a;
  --r-dependent: #8a5418;
  --r-neutral:   #6a604f;

  --measure: 40rem;   /* reading column */
  --gutter: clamp(20px, 5vw, 48px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.5;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); text-decoration: none; }
a:active { color: var(--link-pressed); }
img { display: block; max-width: 100%; }

/* paper grain so large flats don't read flat */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg, rgba(31,26,20,0.012) 0 1px, transparent 1px 7px);
}

/* ---- type helpers ---- */
.tp-display { font-family: var(--display); line-height: 1.12; letter-spacing: -0.018em; font-weight: 600; }
/* Heading signature — Fraunces opsz60/SOFT50/WONK1, the same instance the app
   bakes as FrauncesWonkyDisplay. Applies to all heading sizes (mirrors the
   app's .tp-h rule); standfirsts, ledes, and pull quotes stay on default axes. */
.tp-display, .tp-brand-name, .tp-foot-word, .tp-title, .tp-gate-h, .tp-footer-cta-h,
.tp-stat-n, .tp-rel-name, .tp-sec-h, .tp-focus-topic,
.lp-h1, .lp-lenses-h, .lp-cell-n, .w-h1, .w-title, .w-wm b,
.doc h1, .doc h2, .nf h1 {
  font-variation-settings: "opsz" 60, "SOFT" 50, "WONK" 1;
}
.tp-cap { font-family: var(--sans); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; }
.tp-num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.tp-mono { font-family: var(--mono); }

.tp-rule { height: 1px; background: var(--ink); border: 0; margin: 0; }
.tp-rule-soft { height: 1px; background: var(--faint); border: 0; margin: 0; }

/* ============================================================================
   TOP BAR — sticky smart-banner / wordmark + open-in-app
   ========================================================================== */
.tp-topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  -webkit-backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--ink);
}
.tp-topbar-inner {
  padding: 11px var(--gutter);
  display: flex; align-items: center; gap: 14px;
}
.tp-brand { display: flex; align-items: center; gap: 5px; min-width: 0; }
.tp-brand svg, .tp-brand img { width: 26px; height: 26px; flex: 0 0 auto; }
.tp-brand-name { font-family: var(--display); font-weight: 600; font-size: 18px; letter-spacing: -0.014em; }
/* two-tone wordmark — Think (ink2) · Pattern (ochre); the ochre echoes the mark's pulli */
.tp-w1 { color: var(--ink2); }
.tp-w2 { color: var(--accent); }
.tp-topbar .tp-btn { margin-left: auto; flex: 0 0 auto; }

/* ============================================================================
   BUTTONS
   ========================================================================== */
.tp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-weight: 600; font-size: 15px;
  padding: 11px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
  text-align: center; white-space: nowrap;
}
.tp-btn:hover { transform: translateY(-1px); }
.tp-btn:active { transform: translateY(0); }
.tp-btn--ghost { background: transparent; color: var(--ink); }
.tp-btn--ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.tp-btn--accent { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.tp-btn--lg { font-size: 17px; padding: 15px 26px; }
.tp-btn--block { display: flex; width: 100%; }

/* store buttons — the in-brand pill (.tp-store) pairs with Apple's official
   badge (.tp-store-badge); both stand 40px tall so the row reads as one unit. */
.tp-stores { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tp-store {
  display: inline-flex; align-items: center; gap: 10px;
  box-sizing: border-box; height: 40px; padding: 0 14px;
  border: 1px solid var(--ink); border-radius: 4px; /* Almanac radii stay small (1-4 + pill) */
  background: var(--ink); color: var(--paper);
  transition: transform .12s ease;
}
.tp-store:hover { transform: translateY(-1px); color: var(--paper); }
.tp-store svg { width: 22px; height: 22px; flex: 0 0 auto; }
.tp-store-text { display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.tp-store-text small { font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }
.tp-store-text b { font-family: var(--display); font-weight: 600; font-size: 14px; white-space: nowrap; }

/* Apple's official "Download on the App Store" badge — fixed artwork, so it
   carries its own color and border; we only size it to the shared 40px height. */
.tp-store-badge { display: inline-flex; transition: transform .12s ease; }
.tp-store-badge:hover { transform: translateY(-1px); }
.tp-store-badge img { display: block; height: 40px; width: auto; }

/* Android isn't released — the Play pill is shown muted and non-interactive. */
.tp-store-soon {
  background: transparent; color: var(--muted); border-color: var(--faint);
  pointer-events: none;
}

/* ============================================================================
   ARTICLE LAYOUT
   ========================================================================== */
.tp-main { position: relative; z-index: 1; }
.tp-article {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(28px, 6vw, 56px) var(--gutter) 0;
}
/* lens badge — marks which surface this is (story / perspective / actor).
   Echoes the app's tab icons. Filled ink pill, paper glyph + label. */
.tp-lens-row { margin-bottom: 16px; }
.tp-lens {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px 7px; border-radius: 999px;
  background: var(--ink); border: 1px solid var(--ink);
}
.tp-lens svg { width: 15px; height: 15px; flex: 0 0 auto; color: var(--paper); }
.tp-lens span { font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--paper); }

.tp-kicker-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.tp-loc { display: inline-flex; align-items: center; gap: 6px; }
.tp-loc svg { width: 12px; height: 13px; flex: 0 0 auto; }

.tp-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(33px, 5.6vw, 50px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 14px 0 0;
  text-wrap: balance;
}
.tp-standfirst {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(19px, 2.6vw, 23px);
  line-height: 1.4;
  color: var(--ink2);
  margin: 18px 0 0;
  text-wrap: pretty;
}
.tp-byline {
  display: flex; align-items: center; gap: 10px;
  margin-top: 22px;
}
.tp-byline svg, .tp-byline img { width: 28px; height: 28px; flex: 0 0 auto; }
.tp-byline-name { font-weight: 600; font-size: 14px; }
.tp-byline-sub { font-size: 12px; color: var(--muted); }

.tp-body {
  margin-top: 26px;
  font-size: 18px;
  line-height: 1.62;
  color: var(--ink);
}
.tp-body p { margin: 0 0 1.1em; text-wrap: pretty; }

/* ============================================================================
   THE GATE — fade-out of decorative filler + conversion card
   ========================================================================== */
.tp-gate { position: relative; margin-top: 4px; }
.tp-gate-filler {
  position: relative;
  max-height: 280px; overflow: hidden;
  filter: blur(5px);
  opacity: 0.55;
  user-select: none; pointer-events: none;
  -webkit-user-select: none;
}
.tp-gate-filler p { margin: 0 0 1.1em; font-size: 18px; line-height: 1.62; color: var(--ink2); }
.tp-gate-fade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
  background: linear-gradient(to bottom, transparent 0%, var(--paper) 86%);
  pointer-events: none;
}
.tp-gate-card {
  position: relative;
  margin: -120px auto 0;
  max-width: 30rem;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: clamp(26px, 5vw, 38px) clamp(22px, 5vw, 34px);
  box-shadow: 0 14px 40px -22px rgba(31,26,20,0.5);
}
.tp-gate-mark { width: 40px; height: 40px; margin: 0 auto 14px; }
.tp-gate-h {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(24px, 4vw, 30px); line-height: 1.14; letter-spacing: -0.018em;
  margin: 0; text-wrap: balance;
}
.tp-gate-sub { color: var(--ink2); font-size: 16px; line-height: 1.5; margin: 12px auto 0; max-width: 24rem; }
.tp-gate-actions { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.tp-gate-actions .tp-stores { justify-content: center; }
.tp-gate-fine { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ============================================================================
   INSIDE STRIP — credibility / metered facts shown below the gate
   ========================================================================== */
.tp-inside {
  max-width: var(--measure); margin: clamp(32px, 6vw, 56px) auto 0;
  padding: 0 var(--gutter);
}
.tp-inside-head { display: flex; align-items: baseline; gap: 10px; }
.tp-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px; background: var(--faint);
  border: 1px solid var(--faint);
  margin-top: 14px;
}
.tp-stat { background: var(--paper); padding: 18px 16px; }
.tp-stat-n { font-family: var(--display); font-weight: 600; font-size: 34px; line-height: 1; letter-spacing: -0.02em; }
.tp-stat-l { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.3; }

/* chips (sources / relations / what's-inside) */
.tp-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tp-chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid color-mix(in srgb, var(--ink) 20%, transparent);
  border-radius: 999px; padding: 6px 13px;
  font-size: 13px; color: var(--ink2); background: transparent;
}
.tp-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }

/* linked actor pill — a published actor page behind the chip; dot + link
   color + lift are the tap affordance, plain mentions stay quiet */
.tp-chip-link { border-color: var(--ink); color: var(--link); font-weight: 600; transition: transform .12s ease; }
.tp-chip-link:hover { transform: translateY(-1px); color: var(--link-pressed); }

/* relation row mini-list */
.tp-rel { display: flex; flex-direction: column; margin-top: 12px; }
.tp-rel-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--faint);
}
.tp-rel-item:last-child { border-bottom: 0; }
.tp-rel-name { font-family: var(--display); font-weight: 600; font-size: 17px; }
.tp-rel-kind { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; }

/* ============================================================================
   ACTOR PORTRAIT HERO
   ========================================================================== */
.tp-portrait-wrap {
  max-width: var(--measure); margin: 0 auto;
  padding: clamp(24px, 5vw, 40px) var(--gutter) 0;
}
.tp-portrait {
  width: 168px; height: 168px; border-radius: 4px; overflow: hidden;
  position: relative; background: var(--paper2);
  border: 1px solid var(--ink);
}
.tp-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center 18%;
  filter: grayscale(0.5) sepia(0.32) contrast(1.05) saturate(0.85) brightness(0.98); }
.tp-portrait::after { content:''; position:absolute; inset:0; pointer-events:none;
  background: repeating-linear-gradient(45deg, rgba(31,26,20,0.06) 0 1px, transparent 1px 6px),
              linear-gradient(180deg, transparent 60%, rgba(31,26,20,0.10)); }

.tp-bio {
  display: inline-block; font-family: var(--display); font-weight: 600;
  font-size: 24px; letter-spacing: -0.01em; line-height: 1.1;
  color: #44403a;  /* dark gray — no per-value color (posture spectrum retired) */
  border-bottom: 2px solid currentColor; padding-bottom: 1px;
}
.tp-pull {
  margin-top: 20px; padding-left: 16px; border-left: 3px solid var(--accent);
  font-family: var(--display); font-weight: 500; font-size: clamp(19px, 2.6vw, 22px);
  line-height: 1.38; color: var(--ink); text-wrap: pretty;
}

/* actor SSR page — mirrors the app's ActorDetail composition */
.tp-actor-hero { margin-bottom: 22px; }
.tp-portrait-fallback { display: flex; align-items: center; justify-content: center; }
.tp-portrait-fallback span {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--slate); color: var(--paper);
  font-family: var(--display); font-weight: 600; font-size: 30px;
  display: flex; align-items: center; justify-content: center;
}
.tp-sec-h { font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: -0.014em; margin: 6px 0 4px; }
.tp-focus-row { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--faint); }
.tp-focus-row:last-child { border-bottom: 0; }
.tp-focus-num { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 3px; flex: 0 0 auto; }
.tp-focus-topic { font-family: var(--display); font-weight: 600; font-size: 18px; letter-spacing: -0.01em; }
.tp-focus-sum { font-size: 15px; line-height: 1.55; color: var(--ink2); margin: 5px 0 0; text-wrap: pretty; }
.tp-rel-row { padding: 14px 0; border-bottom: 1px solid var(--faint); }
.tp-rel-row:last-child { border-bottom: 0; }
.tp-rel-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tp-recency { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.tp-recency-now { color: var(--accent); }
.tp-rel-sum { font-size: 15px; line-height: 1.55; color: var(--ink2); margin: 6px 0 0; text-wrap: pretty; }

/* ============================================================================
   FOOTER
   ========================================================================== */
.tp-footer {
  position: relative; z-index: 1;
  margin-top: clamp(48px, 8vw, 88px);
  border-top: 1px solid var(--ink);
  background: var(--paper2);
}
.tp-footer-inner {
  padding: clamp(36px, 6vw, 60px) var(--gutter);
  display: flex; justify-content: space-between; gap: clamp(28px, 5vw, 56px); align-items: center;
}
.tp-footer-cta-h {
  font-family: var(--display); font-weight: 600; font-size: clamp(26px, 4vw, 36px);
  line-height: 1.12; letter-spacing: -0.02em; margin: 0; text-wrap: balance;
}
.tp-footer-cta-sub { color: var(--ink2); font-size: 16px; line-height: 1.5; margin: 12px 0 22px; max-width: 30rem; }
.tp-footer-brand { display: flex; align-items: center; gap: 6px; }
/* Left, to hang under the flex-start logo + wordmark in .tp-footer-brand. This
   was `right`, which every page then overrode inline to stop the copyright line
   drifting away from the mark above it. */
.tp-footer-copy { margin: 8px 0 0; font-size: 13px; color: var(--ink); text-align: left; }
.tp-foot-mark { width: 36px; height: 36px; flex: 0 0 auto; }
.tp-foot-word { font-family: var(--display); font-weight: 600; font-size: 27px; letter-spacing: -0.014em; }

/* ============================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .tp-brand-name { font-size: 17px; }
  .tp-topbar .tp-btn { padding: 9px 15px; font-size: 14px; }
  .tp-footer-inner { flex-direction: column; align-items: flex-start; }
  .tp-footer-brand { display: none; }
  .tp-footer-copy { display: block; }
  .tp-stats { grid-template-columns: 1fr 1fr; }
  .tp-gate-card { margin-top: -90px; }
}

/* loading + error states */
.tp-loading { max-width: var(--measure); margin: 0 auto; padding: 56px var(--gutter); }
.tp-skel { background: var(--paper2); border-radius: 4px; animation: tp-pulse 1.4s ease-in-out infinite; }
@keyframes tp-pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
