/* Founder Voice — Ren Matrix Newsletter
   Fonts: IBM Plex Mono, Libre Franklin, Newsreader — all SIL OFL 1.1.
   These are Google Fonts' own woff2 subset files, shipped unmodified: IBM Plex
   carries the Reserved Font Name "Plex", so re-subsetting them would breach
   OFL clause 3. Regenerate with scripts/extract_newsletter_fonts.py.
   See THIRD_PARTY_NOTICES.md. */

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-400-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-400-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-500-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-500-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-600-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-600-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/libre-franklin/libre-franklin-400to800-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/libre-franklin/libre-franklin-400to800-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 300 800;
  font-display: swap;
  src: url('../fonts/newsreader/newsreader-300to800-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 300 800;
  font-display: swap;
  src: url('../fonts/newsreader/newsreader-300to800-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('../fonts/newsreader/newsreader-300to800-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('../fonts/newsreader/newsreader-300to800-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------------
   Reader layout
   --------------------------------------------------------------- */

/* .section-tight's 64px top padding is tuned for sections that open with a
   heading; this page opens with a back-link, so the gap under the nav reads
   as dead space. Bottom padding stays, since the footer still needs room. */
.fv-section { padding-top: 28px; }

.fv-back { gap: 8px; box-shadow: var(--card-shadow); }
.fv-back i { transition: transform 0.2s ease; }
.fv-back:hover i { transform: translateX(-3px); }

.fv-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

/* The grid item is what sticks. `position: sticky` resolves against the nearest
   scrolling ancestor but is confined to its containing block, and a grid item
   sized by `align-items: start` is exactly as tall as its content — so a sticky
   nav nested inside it would have 0px of travel and scroll straight off. Making
   the column itself sticky lets it move within the full-height grid area. */
.fv-toc-col {
  position: sticky;
  top: 92px;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
}

/* Already positioned by its sticky parent; leave it in normal flow. */
.fv-toc { position: static; }
.fv-toc a { font-family: var(--font-body); }

.fv-toc-toggle { display: none; }

.fv-progress {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 2px;
  background: var(--line);
}
.fv-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--grad-main);
  transition: width 120ms linear;
}

/* The exported article sets min-height:100vh and page padding for its
   standalone document; inside the site chrome that would strand the footer
   below a blank screen. */
.fv-issue {
  min-height: 0 !important;
  padding: 28px !important;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
}
.fv-issue [id] { scroll-margin-top: 96px; }
.fv-issue img { max-width: 100%; height: auto; }

.fv-archive-card { display: flex; flex-direction: column; height: 100%; }
.fv-issue-label {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--violet-deep);
}

@media (max-width: 1099px) {
  .fv-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  /* Single column: the contents collapse behind a button, so nothing sticks. */
  .fv-toc-col {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
  .fv-toc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
  }
  .fv-toc { display: none; }
  .fv-toc.is-open { display: block; margin-bottom: 20px; }
  .fv-issue { padding: 16px !important; }
}

/* Each issue is a per-week export of fixed-width, inline-styled HTML (see
   newsletter_import.py), so it can't be made responsive from the template.
   But the section ids and the grid shapes below are part of the shared
   newsletter template itself (checked against both a real issue and the
   blank TEMPLATE export), so they hold across every future week even
   though the copy inside them changes. */
@media (max-width: 640px) {
  #cover-graphic { padding: 26px 20px 22px !important; }
  #cover-graphic h1 { font-size: 30px !important; }
  #cover-graphic div[style*="justify-content: space-between"] {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  #cover-graphic > div[style*="grid-template-columns: 1fr auto"] {
    grid-template-columns: 1fr !important;
  }
  #cover-graphic > div[style*="grid-template-columns: 1fr auto"] > div:last-child {
    margin-top: 20px;
  }
  #cover-graphic div[style*="display: flex; gap: 28px"] {
    flex-wrap: wrap;
    row-gap: 10px;
  }
  #catalysts div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  #signal-strength div[style*="grid-template-columns: 1fr 120px 56px"] {
    grid-template-columns: 1fr auto !important;
  }
  #top-stories { padding: 26px 20px !important; }
  #top-stories div[style*="gap: 22px"] {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  /* Quadrant Activity Snapshot: 4 cards in fixed DOM order Q3, Q4, Q1, Q2
     (see newsletter_import output). Stacked to one column, but read in
     Q4 -> Q3 -> Q2 -> Q1 order — most-connected/most-ethical quadrant first. */
  #quadrant-snapshot div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  #quadrant-snapshot div[style*="grid-template-columns: 1fr 1fr"] > div:nth-child(1) { order: 2; } /* Q3 */
  #quadrant-snapshot div[style*="grid-template-columns: 1fr 1fr"] > div:nth-child(2) { order: 1; } /* Q4 */
  #quadrant-snapshot div[style*="grid-template-columns: 1fr 1fr"] > div:nth-child(3) { order: 4; } /* Q1 */
  #quadrant-snapshot div[style*="grid-template-columns: 1fr 1fr"] > div:nth-child(4) { order: 3; } /* Q2 */

  /* Signal Strength's small quadrant chart: each card is explicitly placed
     with grid-column/grid-row (not source order) and shares borders with
     its neighbours to draw the 2x2 cross, so stacking needs both an order
     override and a plain border per card instead of the shared one. */
  #matrix-graphic { padding: 24px 16px 20px !important; }
  #matrix-graphic > div[style*="grid-template-columns: 18px 1fr 1fr 18px"] {
    grid-template-columns: 1fr !important;
    grid-template-rows: none !important;
    gap: 14px !important;
  }
  #matrix-graphic > div[style*="grid-template-columns: 18px 1fr 1fr 18px"] > div[style*="writing-mode"] {
    display: none !important;
  }
  #matrix-graphic div[style*="grid-column: 3; grid-row: 1;"] {
    grid-column: 1 !important; grid-row: auto !important; order: 1;
    border: 1px solid #E3DED1 !important; border-top: 3px solid #3A5697 !important;
  }
  #matrix-graphic div[style*="grid-column: 2; grid-row: 1;"] {
    grid-column: 1 !important; grid-row: auto !important; order: 2;
    border: 1px solid #E3DED1 !important; border-top: 3px solid #A73429 !important;
  }
  #matrix-graphic div[style*="grid-column: 3; grid-row: 2;"] {
    grid-column: 1 !important; grid-row: auto !important; order: 3;
    border: 1px solid #E3DED1 !important; border-top: 3px solid #33745A !important;
  }
  #matrix-graphic div[style*="grid-column: 2; grid-row: 2;"] {
    grid-column: 1 !important; grid-row: auto !important; order: 4;
    border: 1px solid #E3DED1 !important; border-top: 3px solid #A0761B !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fv-progress span { transition: none; }
}
