/* ============================================================================
   The Mercatus Memos — Data Desk
   Design language: editorial research-house. Warm ink base, paper text,
   evergreen accent (sustainability, no greenwashing), brass editorial hairline.
   Fraunces (display serif) · Hanken Grotesk (UI) · IBM Plex Mono (data)
   ============================================================================ */

:root {
  --bg:        #0c0e0c;
  --bg-2:      #101310;
  --panel:     #14181400;   /* base tint applied via layered bg below */
  --panel-bg:  #14181433;
  --card:      #14181e00;
  --surface:   #131712;
  --surface-2: #171c16;
  --surface-3: #1d2320;
  --line:       rgba(236,233,223,0.09);
  --line-2:     rgba(236,233,223,0.15);
  --text:      #ece9df;
  --muted:     #a6ac9d;
  --faint:     #767d6f;
  --accent:    #5bb98b;   /* evergreen */
  --accent-2:  #7fd0a6;
  --accent-dim: rgba(91,185,139,0.13);
  --brass:     #c7a96c;
  --brass-dim: rgba(199,169,108,0.14);
  --up:        #5cc08f;
  --up-dim:    rgba(92,192,143,0.14);
  --down:      #e07d5f;
  --down-dim:  rgba(224,125,95,0.15);

  /* categorical palette (revenue-mix bars, etc.) — brand-aligned, distinguishable */
  --cat-0: #5bb98b;  /* evergreen */
  --cat-1: #c7a96c;  /* brass */
  --cat-2: #6b9bd1;  /* slate blue */
  --cat-3: #d68a6a;  /* terracotta */
  --cat-4: #9d8bc4;  /* muted violet */
  --cat-5: #7cc4b8;  /* teal */

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
  --pad:  clamp(16px, 3vw, 26px);
  --maxw: 1200px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1200px 620px at 78% -8%, rgba(91,185,139,0.07), transparent 60%),
    radial-gradient(900px 520px at 6% 4%, rgba(199,169,108,0.05), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.55;
  font-size: 16px;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* subtle film grain for atmosphere */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); position: relative; z-index: 1; }

/* ------------------------------------------------------------------ masthead */
.masthead {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px) saturate(1.2);
  background: linear-gradient(to bottom, rgba(12,14,12,0.92), rgba(12,14,12,0.72));
  border-bottom: 1px solid var(--line);
}
.masthead .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 62px; gap: 16px;
}
.brand { display: flex; align-items: baseline; gap: 11px; flex: 0 0 auto; }
/* Isometric-rise mark — the same logo as the favicon, so the tab icon reads as the site's mark. */
.brand-mark { width: 30px; height: 30px; flex: 0 0 auto; align-self: center; color: var(--text); }
.brand-mark + .logo { border-left: 1px solid var(--line-2); padding-left: 11px; }
.brand .logo {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.brand .logo .the { font-style: italic; font-weight: 400; color: var(--muted); }
.brand .desk {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--brass);
  border-left: 1px solid var(--line-2); padding-left: 12px;
  white-space: nowrap;
}
.nav { display: flex; align-items: center; gap: 2px; }
.nav a {
  font-size: 13px; color: var(--muted); padding: 7px 10px; border-radius: 999px;
  letter-spacing: 0.02em; white-space: nowrap; transition: color .18s, background .18s;
}
.nav a:hover { color: var(--text); background: rgba(236,233,223,0.05); }
.nav a.active { color: var(--text); }
.nav a.sub {
  color: var(--accent-2); border: 1px solid rgba(91,185,139,0.32);
}
.nav a.sub:hover { background: var(--accent-dim); }
.nav a.sub::after { content: " ↗"; font-size: 11px; opacity: .8; }

/* ------------------------------------------------------------------ generic */
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--faint);
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.pos { color: var(--up); }
.neg { color: var(--down); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em;
  text-transform: uppercase; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted);
}
.badge.covered { color: var(--brass); border-color: rgba(199,169,108,0.4); background: var(--brass-dim); }
.badge.dot::before { content:""; width:6px; height:6px; border-radius:50%; background: currentColor; }

.card {
  background:
    linear-gradient(180deg, rgba(236,233,223,0.02), rgba(236,233,223,0) 40%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(16px, 2.4vw, 24px);
}
.card + .card { margin-top: 18px; }
.card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 14px;
}
.card-h h3 {
  font-family: var(--serif); font-weight: 500; font-size: 18px; margin: 0;
  letter-spacing: 0.01em;
}
.card-h .ai-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); border: 1px solid rgba(91,185,139,0.3); border-radius: 999px; padding: 3px 9px;
}
.ai-tag .spark { width:5px; height:5px; border-radius:50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* prose from AI markdown-lite */
.prose p { margin: 0 0 12px; color: #ded9cd; }
.prose p:last-child { margin-bottom: 0; }
.prose ul { margin: 4px 0 0; padding: 0; list-style: none; }
.prose li {
  position: relative; padding-left: 20px; margin-bottom: 11px; color: #ded9cd;
}
.prose li::before {
  content: ""; position: absolute; left: 3px; top: 10px;
  width: 6px; height: 6px; border-radius: 1px; background: var(--accent); transform: rotate(45deg);
}
.prose strong { color: var(--text); font-weight: 600; }

/* citations */
.cites { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.cites .lbl { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); align-self: center; margin-right: 2px; }
.cite {
  font-size: 12px; color: var(--muted); background: rgba(236,233,223,0.04);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: border-color .18s, color .18s;
}
.cite:hover { color: var(--text); border-color: var(--line-2); }

.footer {
  margin: 60px 0 40px; padding-top: 22px; border-top: 1px solid var(--line);
  color: var(--faint); font-size: 12.5px; line-height: 1.7;
}
.footer .disc { max-width: 720px; }
.footer a { color: var(--muted); border-bottom: 1px solid var(--line-2); }

/* skeleton / loading */
.skel { color: var(--faint); font-family: var(--mono); font-size: 13px; letter-spacing: .04em; }
@keyframes pulse { 0%,100%{opacity:.4} 50%{opacity:.85} }
.loading .skel { animation: pulse 1.4s ease-in-out infinite; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .6s cubic-bezier(.2,.7,.2,1) both; }

/* shared small segmented toggle */
.seg-toggle.sm { display: inline-flex; background: rgba(236,233,223,0.04); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg-toggle.sm button { font-family: var(--mono); font-size: 11px; color: var(--muted); background: none; border: 0; padding: 4px 11px; border-radius: 999px; cursor: pointer; transition: color .15s, background .15s; }
.seg-toggle.sm button:hover { color: var(--text); }
.seg-toggle.sm button.active { color: var(--bg); background: var(--text); }

/* masthead global search */
.mast-search { position: relative; flex: 0 1 210px; min-width: 0; }
@media (max-width: 1240px) { .brand .desk { display: none; } }   /* drop the tag before things crowd */
.mast-search input { width: 100%; background: rgba(236,233,223,0.05); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 7px 14px; font-family: var(--sans); font-size: 13px; outline: none; transition: border-color .15s, background .15s; }
.mast-search input:focus { border-color: var(--line-2); background: var(--surface); }
.mast-search input::placeholder { color: var(--faint); }
.ms-drop { display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 6px;
  box-shadow: 0 16px 40px rgba(0,0,0,.55); max-height: 62vh; overflow: auto; }
.ms-drop.open { display: block; }
.ms-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); }
.ms-item.hi { background: var(--surface-3); }
.ms-tk { font-family: var(--mono); font-size: 12.5px; color: var(--brass); min-width: 54px; }
.ms-tk::before { content: "$"; opacity: .7; }
.ms-nm { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.ms-cov { font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--brass); border: 1px solid rgba(199,169,108,.4); border-radius: 999px; padding: 2px 7px; }
.ms-sec { font-family: var(--mono); font-size: 10px; color: var(--faint); white-space: nowrap; }
@media (max-width: 880px) { .mast-search { display: none; } }

/* ===== left sidebar navigation ===== */
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 212px; z-index: 60; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%); border-right: 1px solid var(--line); padding: 20px 16px 16px; }
.sb-brand { display: block; margin-bottom: 26px; }
.sb-brand .logo { font-family: var(--serif); font-optical-sizing: auto; font-weight: 500; font-size: 20px; line-height: 1.1; letter-spacing: .01em; display: block; }
.sb-brand .logo .the { font-style: italic; font-weight: 400; color: var(--muted); }
.sb-brand .desk { font-family: var(--mono); font-size: 9px; letter-spacing: .22em; text-transform: uppercase; color: var(--brass); display: block; margin-top: 8px; }
.sb-nav { display: flex; flex-direction: column; gap: 18px; }
.sb-group { display: flex; flex-direction: column; gap: 2px; }
.sb-g { font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; padding-left: 10px; }
.sb-link { font-size: 14px; color: var(--muted); padding: 8px 10px; border-radius: var(--r-sm); transition: color .15s, background .15s; position: relative; }
.sb-link:hover { color: var(--text); background: rgba(236,233,223,0.04); }
.sb-link.active { color: var(--text); background: var(--accent-dim); }
.sb-link.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; background: var(--accent); border-radius: 2px; }
.sb-sub { margin-top: auto; font-family: var(--mono); font-size: 11.5px; color: var(--accent-2); border: 1px solid rgba(91,185,139,0.3); border-radius: 999px; padding: 8px 12px; text-align: center; transition: background .15s; }
.sb-sub:hover { background: var(--accent-dim); }

.sidebar { transition: transform .22s cubic-bezier(.2,.7,.2,1); }
body.has-sidebar { padding-left: 212px; transition: padding-left .22s cubic-bezier(.2,.7,.2,1); }
/* Research shows in the top bar on desktop; sidebar carries Tools */
.sidebar .sb-group.research { display: none; }
.sb-brand { display: none; }  /* brand lives in the top bar on desktop */
.sidebar .sb-nav { margin-top: 4px; }
/* collapsed (folded) desktop state */
body.sb-collapsed { padding-left: 0; }
body.sb-collapsed .sidebar { transform: translateX(-100%); }
.sb-toggle { display: inline-flex; align-items: center; background: none; border: 0; color: var(--muted); font-size: 19px; cursor: pointer; padding: 0 10px 0 0; transition: color .15s; }
.sb-toggle:hover { color: var(--text); }
@media (max-width: 900px) {
  body.has-sidebar { padding-left: 0; }
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 60px rgba(0,0,0,.6); z-index: 80; }
  .sidebar.open { transform: none; }
  .sidebar .sb-group.research { display: flex; }  /* full nav in the mobile drawer */
  .sb-brand { display: block; }                   /* brand in the mobile drawer */
  .masthead .nav { display: none; }               /* top research hidden on mobile */
}

/* ---------------------------------------------------------------- premium gating (UI) */
.prem-chip { font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; color: var(--brass);
  background: var(--brass-dim); border: 1px solid rgba(199,169,108,.4); border-radius: 999px;
  padding: 3px 9px; cursor: pointer; vertical-align: middle; white-space: nowrap; transition: background .15s; }
.prem-chip:hover { background: rgba(199,169,108,.22); }
.prem-pill { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--brass); border: 1px solid rgba(199,169,108,.4); border-radius: 999px; padding: 3px 9px; }
.prem-lock { position: relative; border-style: dashed; }
.prem-lock .card-h h3 { color: var(--muted); }
.prem-lock-msg { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin: 4px 0 12px; }
.prem-bullets { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 7px; }
.prem-bullets li { font-size: 13px; color: var(--text); padding-left: 22px; position: relative; }
.prem-bullets li::before { content: "▸"; position: absolute; left: 0; color: var(--accent-2); font-size: 11px; }
.prem-ic { width: 1em; height: 1em; vertical-align: -0.16em; margin-right: 5px; }
.prem-modal-badge svg { width: 24px; height: 24px; }
.prem-cta { display: inline-block; font-family: var(--mono); font-size: 12px; color: var(--accent-2);
  border: 1px solid rgba(91,185,139,0.35); border-radius: 999px; padding: 7px 14px; cursor: pointer; transition: background .15s; }
.prem-lock .prem-cta:hover, .prem-cta:hover { background: var(--accent-dim); }

.prem-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(6,8,7,.66); backdrop-filter: blur(3px); opacity: 0; transition: opacity .15s; padding: 20px; }
.prem-modal.open { opacity: 1; }
.prem-modal-card { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  padding: 28px 26px; max-width: 400px; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.6); }
.prem-modal-badge { width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--brass); background: var(--brass-dim); border: 1px solid rgba(199,169,108,.4); }
.prem-modal-card h3 { font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 0 0 8px; }
.prem-modal-card p { font-size: 14px; color: var(--muted); line-height: 1.55; margin: 0 0 20px; }
.prem-modal-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.cta-primary { display: inline-block; font-family: var(--mono); font-size: 13px; color: var(--bg); background: var(--accent);
  border-radius: 999px; padding: 10px 22px; text-decoration: none; }
.cta-primary:hover { background: var(--accent-2); }
.prem-modal-close { background: none; border: 0; color: var(--faint); font-size: 12.5px; cursor: pointer; }
.prem-modal-close:hover { color: var(--muted); }

/* premium pricing page */
.prem-banner { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  background: var(--brass-dim); border: 1px solid rgba(199,169,108,.35); border-radius: var(--r-lg); padding: 20px 24px; margin: 8px 0 32px; }
.pb-eyebrow { font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--brass); margin-bottom: 6px; }
.prem-banner p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.55; max-width: 620px; }
.prem-banner p b { color: var(--text); }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .plans { grid-template-columns: 1fr; } }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px; }
.plan.featured { border-color: rgba(199,169,108,.45); background: linear-gradient(180deg, var(--brass-dim), transparent 42%), var(--surface); }
.plan-h { display: flex; align-items: center; justify-content: space-between; }
.plan-h h2 { font-family: var(--serif); font-weight: 500; font-size: 24px; margin: 0; }
.plan-tag { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); }
.plan-tag.current { color: var(--accent-2); border-color: rgba(91,185,139,.4); }
.plan-tag.soon { color: var(--brass); border-color: rgba(199,169,108,.4); }
.plan-price { font-family: var(--mono); font-size: 30px; margin: 14px 0 18px; }
.plan-price span { font-size: 13px; color: var(--faint); }
.plan-feats { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 10px; }
.plan-feats li { font-size: 13.5px; color: var(--text); line-height: 1.45; padding-left: 22px; position: relative; }
.plan-feats li::before { content: "•"; position: absolute; left: 4px; color: var(--faint); }
.plan-disabled { font-family: var(--mono); font-size: 13px; color: var(--faint); background: var(--surface-3); border: 1px solid var(--line); border-radius: 999px; padding: 10px 20px; cursor: not-allowed; }
.plan-note { font-size: 11.5px; color: var(--faint); margin-top: 8px; }
