/* cgtovey.com — design system
 *
 * Aesthetic goal: Anthropic / Linear / Stripe — calm, confident, restrained.
 * Off-white background, near-black text, single muted accent for interaction.
 * No heavy shadows, no gradients, no fluffy animations.
 *
 * Type stack favors locally installed Inter when available (most designers and
 * developers have it). Falls back to the OS system UI font (SF Pro on macOS,
 * Segoe UI Variable on Windows 11, Roboto on Android) — all excellent.
 * Keeps the site lightning-fast (no font request).
 */

:root {
  /* Color palette */
  --bg:        #FAFAF7;   /* warm off-white */
  --fg:        #1A1A1A;   /* near-black for body text — 16:1 contrast on bg */
  --fg-muted:  #6B6B6B;   /* muted body text — 5.7:1 contrast on bg (WCAG AA) */
  --fg-soft:   #2D2D2D;   /* slightly softer than fg, used for headings */
  --border:    #E5E5E0;   /* hairline border */
  --border-strong: #C8C8BF;
  --accent:        #15803D;   /* forest green — brand wordmark + tile borders + focus */
  --accent-strong: #14532D;   /* darker green for hover/active states */

  /* Type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-feat: "cv02", "cv03", "cv04", "cv11";  /* Inter character variants for crispness */

  /* Layout */
  --max-width: 720px;
  --max-width-wide: 960px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --space-6: 4rem;
  --space-7: 6rem;

  /* Motion */
  --tx-fast:  120ms cubic-bezier(0.4, 0, 0.2, 1);
  --tx-base:  180ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  :root { --tx-fast: 0ms; --tx-base: 0ms; }
}

/* --- Reset / base ----------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-feature-settings: var(--font-feat);
  font-size: 17px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

@media (min-width: 640px) {
  body { font-size: 18px; }
}

/* Headings — tighter line-height, slightly softer color */
h1, h2, h3, h4 {
  color: var(--fg-soft);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 var(--space-3);
}

p { margin: 0 0 var(--space-3); }

a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: text-decoration-color var(--tx-fast), color var(--tx-fast);
}
a:hover { text-decoration-color: var(--fg); }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --- Layout primitives ----------------------------------------------------------- */

.site-header,
.site-main,
.site-footer {
  width: 100%;
  margin: 0 auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
  max-width: calc(var(--max-width-wide) + var(--space-4) * 2);
}

.site-header {
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.005em;
  color: var(--accent);
  text-decoration: none;
  transition: color var(--tx-fast);
}
.site-brand:hover { color: var(--accent-strong); }

.site-main {
  padding-top: var(--space-6);
  padding-bottom: var(--space-7);
}

@media (min-width: 640px) {
  .site-main {
    padding-top: var(--space-7);
    padding-bottom: calc(var(--space-7) + var(--space-5));
  }
}

.site-footer {
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
  padding-bottom: var(--space-5);
  color: var(--fg-muted);
  font-size: 0.875rem;
}
.site-footer p { margin: 0; }

/* --- Hero ------------------------------------------------------------------------- */

.hero {
  max-width: var(--max-width);
  margin: 0 auto var(--space-6);
}

.hero-tagline {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0 0 var(--space-3);
  color: var(--fg);
}

.hero-sub-tagline {
  font-size: clamp(1.05rem, 2vw, 1.2rem);
  color: var(--fg-muted);
  margin: 0;
  max-width: 50ch;
}

/* --- Tile grid -------------------------------------------------------------------- */

.tile-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
  margin: 0 auto;
  max-width: var(--max-width-wide);
}

@media (min-width: 640px) {
  .tile-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
  }
}

.tile {
  display: block;
  padding: var(--space-4) var(--space-4);
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--tx-base), transform var(--tx-base);
}

.tile:hover,
.tile:focus-visible {
  border-color: var(--accent-strong);
  transform: translateY(-1px);
  text-decoration: none;
}

.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.tile-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 var(--space-1);
  color: var(--fg);
  letter-spacing: -0.01em;
}

.tile-subtitle {
  font-size: 0.95rem;
  color: var(--fg-muted);
  margin: 0;
  line-height: 1.5;
}

/* No visible lock icon for protected tiles by default — auth happens at the edge.
 * Reserved class in case we want to add one later. */
.tile-protected { /* intentionally empty */ }

/* --- Sub-page header (used on /portfolio-reports/ and other inner pages) -------- */

.page-header {
  max-width: var(--max-width);
  margin: 0 auto var(--space-5);
}

.page-title {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 var(--space-2);
  color: var(--fg);
}

.page-lede {
  color: var(--fg-muted);
  font-size: clamp(1rem, 1.5vw, 1.1rem);
  margin: 0;
  max-width: 60ch;
}

/* --- A11y utility ----------------------------------------------------------------- */

.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;
}

/* --- Reports index ---------------------------------------------------------------- */

.report-index {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Search / filter box (P2-7) — single text input above the ticker list.
   Hairline border, accent focus ring, mixed-case placeholder, monospace-ish
   alignment via `tnum` so partial matches feel ledger-like.  */
.report-search {
  margin: 0 0 var(--space-4);
}

.report-search input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.6em 0.85em;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  transition: border-color var(--tx-fast), box-shadow var(--tx-fast);
  -webkit-appearance: none;
}

.report-search input[type="search"]::placeholder {
  color: var(--fg-muted);
}

.report-search input[type="search"]:hover {
  border-color: var(--accent);
}

.report-search input[type="search"]:focus,
.report-search input[type="search"]:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.report-search-hint {
  margin: var(--space-1) 0 0;
  min-height: 1.2em;
  font-size: 0.8125rem;
  color: var(--fg-muted);
  font-feature-settings: "tnum";
}

.ticker-row {
  border-top: 1px solid var(--border);
  padding: var(--space-4) 0;
}

.ticker-row:last-child {
  border-bottom: 1px solid var(--border);
}

.ticker-row-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.ticker-symbol {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-feature-settings: "tnum";   /* tabular figures keep tickers aligned */
  color: var(--fg);
}

.ticker-meta {
  margin-left: auto;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 1.4rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  line-height: 1;
}

.badge-new {
  color: var(--accent-strong);
  background: #E7F3EC;
  border: 1px solid var(--accent);
}

.badge-earnings {
  color: #5b3a06;
  background: #FBF1DC;
  border: 1px solid #E2C271;
  margin-left: var(--space-2);
}

/* Rating row in the per-report header (below the title + date line) */
.report-rating-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.report-rating-pill {
  display: inline-flex;
  align-items: center;
  height: 1.6rem;
  padding: 0 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  line-height: 1;
}
.report-rating-pill.rating-buy,
.report-rating-pill.rating-overweight,
.report-rating-pill.rating-accumulate {
  color: #1f7a3a;
  background: rgba(31,122,58,0.06);
}
.report-rating-pill.rating-hold,
.report-rating-pill.rating-neutral,
.report-rating-pill.rating-market-perform {
  color: #8a6d1c;
  background: rgba(138,109,28,0.06);
}
.report-rating-pill.rating-sell,
.report-rating-pill.rating-underweight,
.report-rating-pill.rating-reduce {
  color: #b8341d;
  background: rgba(184,52,29,0.06);
}

.report-rating-pt {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--fg-soft);
  letter-spacing: -0.005em;
}

/* Inline images / charts inside report prose. Keep simple — no shadow. */
.report-prose img {
  max-width: 100%;
  height: auto;
  margin: var(--space-3) auto;
  display: block;
}

.ticker-reports {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ticker-reports li {
  margin: 0;
}

.report-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  color: var(--fg);
  text-decoration: none;
  border-radius: 4px;
  transition: color var(--tx-fast);
}

.report-link:hover {
  text-decoration: none;
  color: var(--accent-strong);
}

.report-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.report-link-date {
  font-size: 0.95rem;
  color: var(--fg-muted);
}

.report-link:hover .report-link-date {
  color: var(--fg-soft);
}

.report-link-arrow {
  color: var(--accent);
  font-size: 0.95rem;
  transition: transform var(--tx-fast);
}

.report-link:hover .report-link-arrow {
  transform: translateX(2px);
}

.empty-state {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-5) 0;
  color: var(--fg-muted);
  text-align: center;
}

/* --- Error page ------------------------------------------------------------------- */

.error-page {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: left;
}

.error-page h1 {
  font-size: clamp(2rem, 5vw, 2.5rem);
  margin-bottom: var(--space-3);
}

.error-page p {
  color: var(--fg-muted);
  font-size: 1.05rem;
}

/* --- Per-report page (P2-5) -------------------------------------------------------
 *
 * Built on top of the system tokens — no new colors, no uppercase labels, no
 * heavy effects. Optional TOC sidebar at ≥960px; collapses to a single column
 * below that. Conforms to the tovey-website-style design system.
 */

.report-breadcrumb {
  margin: 0 auto var(--space-3);
  font-size: 0.875rem;
  color: var(--fg-muted);
}

.report-breadcrumb ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
}

.report-breadcrumb li + li::before {
  content: "/";
  margin-right: 0.4em;
  color: var(--border-strong);
}

.report-breadcrumb a {
  color: var(--fg-muted);
  text-decoration: none;
  transition: color var(--tx-fast);
}

.report-breadcrumb a:hover { color: var(--accent-strong); }

.report-breadcrumb a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.report-header {
  margin: 0 auto var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

/* Match .page-title scale + weight — one title style across the system. */
.report-title {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
  color: var(--fg);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
}

.report-ticker {
  font-feature-settings: "tnum";
}

.report-subtitle {
  color: var(--fg-muted);
  font-weight: 400;
  font-size: 0.7em;
  letter-spacing: -0.005em;
}

.report-meta {
  margin: var(--space-2) 0 0;
  color: var(--fg-muted);
  font-size: 0.9375rem;
}

.report-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

@media (min-width: 960px) {
  .report-layout {
    grid-template-columns: 200px minmax(0, 1fr);
    gap: var(--space-6);
  }
  /* When there's no sidebar TOC (long-form / earnings reports), drop the
     reserved 200px column so the article occupies the full measure rather
     than being squeezed into the left rail. */
  .report-layout--full {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- TOC sidebar ------------------------------------------------------------------ */

.report-toc {
  font-size: 0.875rem;
  align-self: start;
  border-left: 1px solid var(--border);
  padding-left: var(--space-3);
}

@media (min-width: 960px) {
  .report-toc {
    position: sticky;
    top: var(--space-3);
    max-height: calc(100vh - var(--space-5));
    overflow-y: auto;
  }
}

.report-toc-heading {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--fg-soft);
  margin: 0 0 var(--space-2);
}

.report-toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4em;
}

.report-toc a {
  color: var(--fg-muted);
  text-decoration: none;
  display: block;
  line-height: 1.4;
  transition: color var(--tx-fast);
}

.report-toc a:hover { color: var(--accent-strong); }

.report-toc a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
  color: var(--accent-strong);
}

/* --- Prose body — the converted Markdown ----------------------------------------- */

.report-prose {
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--fg);
  word-wrap: break-word;
}

/* Headings — H1 has already been hoisted into .report-header by the engine,
   so .report-prose H1 should be rare. We still style it defensively. */
.report-prose h1,
.report-prose h2,
.report-prose h3,
.report-prose h4 {
  color: var(--fg-soft);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-top: var(--space-5);
  margin-bottom: var(--space-3);
  scroll-margin-top: var(--space-4);
}

.report-prose > :first-child { margin-top: 0; }

.report-prose h1 { font-size: 1.875rem; }
.report-prose h2 {
  font-size: 1.5rem;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--border);
}
.report-prose h3 { font-size: 1.1875rem; font-weight: 600; }
.report-prose h4 { font-size: 1.0625rem; font-weight: 600; color: var(--fg-muted); }
/* h5/h6 appear in agent sub-sections (demoted from H3/H4 by the build pipeline) */
.report-prose h5 { font-size: 1rem; font-weight: 600; color: var(--fg-muted); }
.report-prose h6 { font-size: 0.9375rem; font-weight: 500; color: var(--fg-muted); }

.report-prose p { margin: 0 0 var(--space-3); }

.report-prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
  transition: color var(--tx-fast), text-decoration-color var(--tx-fast);
}
.report-prose a:hover { color: var(--accent-strong); text-decoration-color: var(--accent); }
.report-prose a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.report-prose strong { font-weight: 600; color: var(--fg-soft); }
.report-prose em     { font-style: italic; }

.report-prose ul,
.report-prose ol { margin: 0 0 var(--space-3); padding-left: 1.4em; }
.report-prose li { margin-bottom: 0.4em; }
.report-prose li > p:last-child { margin-bottom: 0; }

.report-prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-5) 0;
}

/* Border-only blockquote (no fill) — keeps the accent restrained, and stays
   correct regardless of the per-site --accent value when this design is
   reused on other Tovey sites. */
.report-prose blockquote {
  margin: var(--space-3) 0;
  padding: 0 0 0 1em;
  border-left: 3px solid var(--accent);
  color: var(--fg-soft);
}
.report-prose blockquote p:last-child { margin-bottom: 0; }

.report-prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.04);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.report-prose pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
  background: #F4F4EE;
  padding: var(--space-3);
  border-radius: 4px;
  overflow-x: auto;
  margin: var(--space-3) 0;
  line-height: 1.5;
}
.report-prose pre code { background: transparent; padding: 0; }

/* Tables — heavy use in the trader reports. Keep them readable on mobile by
   allowing horizontal scroll inside a wrapper. */
.report-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-3) 0;
  font-size: 0.9375rem;
  display: block;
  overflow-x: auto;
}

.report-prose thead { background: rgba(0, 0, 0, 0.025); }
.report-prose th,
.report-prose td {
  text-align: left;
  padding: 0.55em 0.85em;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.report-prose th { font-weight: 600; color: var(--fg-soft); }
.report-prose tr:last-child td { border-bottom: none; }

/* Plain-text fallback (e.g. unsupported source extensions) */
.report-prose .report-plaintext {
  white-space: pre-wrap;
  font-size: 0.875rem;
}

/* --- Major-section accordion ------------------------------------------------------- */

/* Each Roman-numeral H2 (e.g. "I. Analyst Team Reports") gets wrapped by
   markdown_to_html._wrap_major_sections_in_details into <details class="report-section">.
   Server-side default: every section closed except the last. Client-side JS in
   report.html.j2 restores per-URL open state from localStorage. */

.report-prose .report-section {
  margin: 0;
  border: 0;
}

/* Hide the native disclosure triangle on every browser */
.report-prose .report-section-summary {
  list-style: none;
  cursor: pointer;
  outline: none;
  /* The H2 inside the summary keeps its own border-bottom; no extra padding here. */
}
.report-prose .report-section-summary::-webkit-details-marker { display: none; }
.report-prose .report-section-summary::marker { content: ""; }

/* The summary's H1 (post-2026-05-05 build; H2 for older builds) keeps its
   existing report-prose heading styling — same size, same border-bottom,
   same margins. We just need to keep the chevron next to the heading text
   without breaking the heading's block layout. */
.report-prose .report-section-summary h1,
.report-prose .report-section-summary h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

/* Chevron — borrowed weight from the heading itself so it never out-shouts
   the title. Rotates 180° when the section is open. */
.report-prose .report-section-summary h1::after,
.report-prose .report-section-summary h2::after {
  content: "";
  flex: 0 0 0.7em;
  width: 0.7em;
  height: 0.7em;
  margin-left: auto;
  border-right: 2px solid var(--fg-muted);
  border-bottom: 2px solid var(--fg-muted);
  transform: rotate(45deg) translateY(-0.18em);
  transition: transform var(--tx-fast);
  flex-shrink: 0;
}
.report-prose .report-section[open] > .report-section-summary h1::after,
.report-prose .report-section[open] > .report-section-summary h2::after {
  transform: rotate(-135deg) translateY(0.05em);
}

.report-prose .report-section-summary:hover h1,
.report-prose .report-section-summary:hover h2 { color: var(--accent-strong); }
.report-prose .report-section-summary:hover h1::after,
.report-prose .report-section-summary:hover h2::after {
  border-color: var(--accent-strong);
}
.report-prose .report-section-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Body content of an open section — keeps the same vertical rhythm as
   un-wrapped report-prose flows, plus a touch of left padding so it sits
   visually under the heading without dragging out a new column. */
.report-prose .report-section-body {
  margin-bottom: var(--space-4);
}
.report-prose .report-section-body > :first-child { margin-top: var(--space-3); }

/* Avoid double border between adjacent collapsed sections */
.report-prose .report-section + .report-section .report-section-summary h1,
.report-prose .report-section + .report-section .report-section-summary h2 {
  margin-top: var(--space-3);
}

/* --- Footer nav ------------------------------------------------------------------- */

.report-footer-nav {
  margin: var(--space-6) auto 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.report-back {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  transition: color var(--tx-fast);
}
.report-back:hover { color: var(--accent-strong); }
.report-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
  color: var(--accent-strong);
}

/* --- Print ------------------------------------------------------------------------ */

@media print {
  body { background: white; color: black; font-size: 12pt; }
  .site-header, .site-footer, .tile-grid,
  .report-toc, .report-breadcrumb, .report-footer-nav { display: none; }
  .report-layout { display: block; }
  .report-prose blockquote { background: none; }
}
