/* ============================================================
   VEERAA — impact report, web edition
   Loaded AFTER the leader's own stylesheet. Two jobs:

   1. Serve Vensfolk. The leader stylesheets ship an @font-face
      pointing at a local ./fonts/ folder that only exists in the
      design-system checkout; on the web the face is declared here
      once, from one file, for every report.
   2. Make the A4 sheet readable on a phone.

   Everything here is @media screen (or the action bar, which is
   explicitly hidden at print), so the printed PDF is byte-for-byte
   the design REPORT-DESIGN-RULES.md governs. Nothing in this file
   may leak into print.
   ============================================================ */

@font-face{
  font-family:"Vensfolk";
  src:url("/report-kit/fonts/vensfolk.woff2") format("woff2");
  font-weight:400; font-style:normal; font-display:swap;
}

/* SF Pro Display is served too, and for one reason: metric fidelity. Falling
   back to -apple-system looks close but sets text at slightly different
   widths, which reflows every paragraph and moved the printed content height
   by 100-250px per report — enough to break a baked single-page @page size.
   Subset to Latin these are 25-28KB each, not the 300KB the .otf files are. */
@font-face{
  font-family:"SF Pro Display";
  src:url("/report-kit/fonts/sfpro-regular.woff2") format("woff2");
  font-weight:400; font-style:normal; font-display:swap;
}
@font-face{
  font-family:"SF Pro Display";
  src:url("/report-kit/fonts/sfpro-medium.woff2") format("woff2");
  font-weight:500; font-style:normal; font-display:swap;
}
@font-face{
  font-family:"SF Pro Display";
  src:url("/report-kit/fonts/sfpro-bold.woff2") format("woff2");
  font-weight:700; font-style:normal; font-display:swap;
}

/* ------------------------------------------------------------
   Reader actions — share + download, in the Feedback band
   Quieter outline pills so the amber feedback CTA stays primary.
   Geometry copied from .feedback a.fb-link so they read as one set.
   ------------------------------------------------------------ */
.fb-actions{
  display:flex; flex-wrap:wrap; gap:10px; margin-top:16px;
}
.feedback .fb-action{
  display:inline-flex; align-items:center; gap:9px;
  font-family:var(--font-sans); font-size:12.5px; font-weight:600;
  letter-spacing:.02em; color:var(--cream);
  background:transparent; padding:10px 18px;
  border:1px solid rgba(252,240,221,.42); border-radius:999px;
  text-decoration:none; cursor:pointer;
  transition:background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.feedback .fb-action svg{ width:15px; height:15px; flex:none; }
.feedback .fb-action:hover{
  background:rgba(252,240,221,.12); border-color:rgba(252,240,221,.75);
}
.feedback .fb-action:focus-visible{
  outline:3px solid var(--amber); outline-offset:3px;
}
.feedback .fb-action[data-state="done"]{
  background:var(--mint,#D7FFE9); border-color:var(--mint,#D7FFE9);
  color:var(--forest,#1C423E);
}

/* Web-only chrome must never reach paper. */
@media print{
  .fb-actions{ display:none !important; }
}

/* ============================================================
   PHOTOGRAPHS SHOW THE WHOLE FRAME
   ============================================================
   Each .photo is given an inline aspect-ratio — usually 5/4 (1.25),
   sometimes 4/3.2 — and .photo img uses object-fit:cover. The
   photographs themselves run 1.49 to 1.76 wide. A wide group photo
   squeezed into a near-square box therefore loses 25-29% off its
   sides, and what it loses is people: a girl cut out of the right
   of augustina/producer-group, a woman in white off the left of
   khairunnisha/centre-meeting, both edges of banner-action.

   No amount of object-position fixes that. Repositioning chooses
   WHICH quarter of the frame is discarded; it cannot stop a 1.76
   photograph losing a quarter of itself inside a 1.25 box. The box
   has to match the picture, so here the box takes the picture's own
   ratio and nothing is cut.

   The cost, stated plainly: photo heights differ from the
   design-system original, and so from the signed-off PDF. That is
   unavoidable — it is the same fact as "nothing is cropped" — and
   the PDFs are regenerated so page and download agree.

   What must NOT come with it: touching any other grid. An earlier
   attempt at this also put `align-items:start` on .tri, which stopped
   the Wellbeing and Trust panels stretching to a common height and
   left the "impact on the wider community" box compacted and out of
   line with its neighbour. Only .photo-pair is restyled below — the
   one container whose cells hold nothing but photographs.
   verify_print.py checks .tri cell heights by name so that cannot
   come back unnoticed.

   Each box's real ratio is written onto it as --ar by
   report-kit/photo-pairs.py, replacing the hard-coded one. Re-run
   that script after changing an image.
   ============================================================ */
/* NO PERCENTAGE HEIGHTS. This is the Safari fix and it is the whole point
   of the shape below.

   The obvious way to write this is `aspect-ratio` on the box and
   `height:100%` on the image. Chrome resolves that; Safari does not —
   it treats a height derived from aspect-ratio as indefinite, so the
   percentage falls back to `auto`, the image renders at its natural
   size, overflows, and is clipped by overflow:hidden. The result is a
   picture drawn at full size and centre-cropped inside a
   correctly-sized box, which is what "the pictures are overly zoomed"
   was, all along. The original design has the same construction, which
   is why the reports looked wrong in Safari before any of this and
   right in Chrome throughout.

   So: no aspect-ratio on the box and no percentage on the image. The
   image sets its own height from its own width, and the box wraps it.
   Nothing is left for an engine to disagree about. */
.photo{ aspect-ratio:auto !important; }
.photo img{ width:100% !important; height:auto !important;
            object-fit:contain !important; display:block !important; }

/* ------------------------------------------------------------
   A PAIR SHARES ONE HEIGHT
   ------------------------------------------------------------
   Two photographs beside each other have to line up: equal
   height, no gap beneath the shorter one, and the row filled edge
   to edge. Equal columns cannot do that once each picture keeps
   its own shape — 1.49 next to 2.105 gives two different heights,
   which is the white space that appeared under Khairunnisha's and
   Augustina's pairs.

   Proportional widths at a common height do. For ratios r1, r2 in
   a row of width W with one gap g, a shared height h satisfies

       r1·h + r2·h = W − g      so   h = (W − g) / (r1 + r2)

   and each photo takes r·h. `flex-basis: 0` with `flex-grow: var(--ar)`
   is exactly that: widths come out proportional to the ratios, so
   every height lands on the same h and the row is filled exactly.

   Note this replaces the grid rather than aligning it. align-items
   would only move the gap around; it cannot make the heights equal.
   ------------------------------------------------------------ */
.photo-pair{
  display:flex !important;
  align-items:flex-start;
}
.photo-pair > .photo{
  flex-basis:0;
  flex-shrink:1;
  flex-grow:var(--ar,1);   /* also set inline by photo-pairs.py, see below */
  min-width:0;
}

/* ============================================================
   SAFARI DOES NOT GET TO RESIZE THE TEXT
   ============================================================
   iOS Safari's text autosizing inflates the font of text blocks it
   judges too wide to read, block by block. It is meant for desktop
   pages opened on a phone, and on these reports it does real damage:
   a full-width paragraph came out roughly 1.7x larger than a
   paragraph in one of the two-column .split sections beside a
   photograph. Same 14.5px in the stylesheet, visibly different sizes
   on screen, and the "About the leader" columns ended up the
   smallest text in the document.

   That is the non-uniformity, and no font-size change fixes it —
   whatever sizes we set, Safari re-scales some of them and not
   others. Pinning text-size-adjust is what makes the sizes below
   mean anything. It applies in both fit modes.

   This does NOT disable pinch-zoom; that is `user-scalable`, which
   fit-page.js deliberately leaves alone.

   @media screen because nothing in this file may reach paper.
   ============================================================ */
@media screen{
  html{ -webkit-text-size-adjust:100%; text-size-adjust:100%; }
}

/* ------------------------------------------------------------
   NOTHING ELSE OUTSIDE A MEDIA QUERY
   Everything that follows is inside @media screen with a width
   bound, so the printed page keeps the design's layout in every
   other respect.
   ------------------------------------------------------------ */

/* ============================================================
   PHONE AND SMALL TABLET
   The sheet is 794px (A4) inside 24px of desk padding, so below
   ~860px the reader would otherwise be scrolling sideways.

   doc-page uses open shadow DOM. Two facts make this reachable
   without forking the component:
     - custom properties inherit through the shadow boundary, so
       --doc-page-w/--doc-page-margin reach .sheet inside it;
     - outer-document rules on a host element beat that element's
       own :host rules, so min-width/padding/background give way.
   --mgn must move in step with --doc-page-margin: the leader
   stylesheets use calc(-1 * var(--mgn)) to pull the hero and
   feedback bands full-bleed out of the sheet's padding, and a
   mismatch leaves those bands short of the edge.
   ============================================================ */
@media screen and (max-width:860px){

  doc-page{
    --doc-page-w:100%;
    --doc-page-margin:20px;
    --mgn:20px;
    min-width:0;              /* beats :host{min-width:max-content} */
    padding:0;
    background:var(--paper);
  }

  /* ============================================================
     PHONE TYPE SCALE
     ============================================================
     The A4 design sets body text at 14.5px, read at arm's length on
     a 794px sheet. On a 390px screen held at reading distance that
     is small, and the supporting text around it — captions,
     footnotes, quote translations — runs 11 to 12.5px, which is
     where it stops being comfortable and starts being work.

     So the scale is rebuilt for the phone rather than inherited:
     body up to 15.5px, and
     everything that supports it moved up with it, so the document
     keeps its hierarchy instead of just getting bigger. The display
     headings come DOWN slightly — 31px and 35px were set against a
     794px measure and dominate a 350px one — which closes the gap
     from both ends. That is what "uniform" means here: the sizes
     stay in proportion to each other at the width they are read at.

     6 Nov 2026: the whole scale came down about 10% (body 17px ->
     15.5px, line-height 1.62 -> 1.55). At 17px, iOS's own body size,
     a report read as oversized on an iPhone, about six words to a
     line. Every size below moved together, so the proportions hold.

     What is deliberately NOT rescaled: anything inside a chart.
     Bar labels, isotype rows, donut slice labels and the NPS table
     are positioned against geometry the design fixes in pixels, and
     the cards already scroll at their designed width. Resizing that
     text moves labels off their marks. Chart TITLES are rescaled —
     they sit outside the scrolling region and read as prose.
     ============================================================ */
  doc-page{ font-size:15.5px; line-height:1.55; }

  /* Long unbroken words — Muzaffarpur, MGNREGA, a bare URL — have
     nowhere to go on a 350px measure and would otherwise push the
     sheet sideways. text-wrap:pretty (set per-element in the leader
     stylesheets) governs where lines break; this governs what
     happens when a single word cannot fit on one at all. */
  p, li, figcaption, dd, dt, blockquote, td, th{ overflow-wrap:break-word; }

  .lead{ font-size:16.5px; }
  h2{ font-size:25px; }
  .exec-hed{ font-size:26px; }
  h3{ font-size:18px; }
  .eyebrow{ font-size:12.5px; }

  /* The two bulleted lists that carry the findings and the plan. */
  ul.findings li,
  ul.ahead li{ font-size:15.5px; }

  figcaption{ font-size:13px; }
  .fnotes .fnote,
  .fnotes .fmark{ font-size:13px; }

  /* Chart titles and their n= count sit outside the scroll region. */
  .chart-title{ font-size:18px; }
  .chart-n{ font-size:12.5px; }

  /* Pull-quotes: the Hindi/local-language line and its translation.
     The translation was 12.5px and is the part most likely to be
     read slowly, so it moves the furthest. */
  .vq .hi,
  .panel-quote .hi{ font-size:17px; }
  .vq .en,
  .panel-quote .en{ font-size:14px; }
  .vq .attr,
  .panel-quote .attr{ font-size:12px; }
  .voices .vhead{ font-size:12px; }
  .panel .box-note{ font-size:12.5px; }
  .active-community .lab{ font-size:14px; }

  /* Targets card. It reflows to one column above rather than
     scrolling, so there is room for the larger sizes. */
  .tgt2-goal{ font-size:15.5px; }
  .tgt2-val{ font-size:17px; }
  .tgt2-note{ font-size:12.5px; }
  .tgt2-qual{ font-size:13px; }
  .tgt2-sub{ font-size:14px; }
  .tgt2-asof{ font-size:12.5px; }

  /* Hero. The name itself is handled by the clamp() below. */
  .hero .period,
  .hero .report-eyebrow{ font-size:12px; }
  .hero-tags .t .l{ font-size:11.5px; }
  .hero-tags .t .v{ font-size:15.5px; }

  /* Feedback band. */
  .feedback p{ font-size:15.5px; }
  .feedback .fb-label{ font-size:12px; }
  .feedback a.fb-link{ font-size:14.5px; }
  .feedback .fb-action{ font-size:13.5px; }

  /* ---- hero: name over portrait, never side by side ---- */
  .hero-grid{ grid-template-columns:1fr; gap:22px; }
  h1.hero-name,
  h1.hero-name.wide{
    font-size:clamp(32px,9.5vw,48px);
    white-space:normal;       /* .wide sets nowrap — guaranteed overflow */
    margin-bottom:20px;
  }
  /* ------------------------------------------------------------
     THE HERO PORTRAIT IS NOT A BANNER
     ------------------------------------------------------------
     Four of the five hero images are portraits — 560x746 (0.751) for
     Augustina, Khairunnisha and Sanjay, 560x996 (0.562) for Krishna —
     and Ajit's is a mild landscape at 1.157. The print design puts all
     of them in a 375x206 box beside the name, a 1.82 letterbox, and a
     hard crop reads as deliberate at that size next to a headline.

     Full-bleed on a phone it does not. A 0.751 portrait cropped to a
     1.6 box keeps 0.751/1.6 = 47% of its height, and Krishna's keeps
     35%. Blown up to the screen's full width that is not a crop, it is
     a face pressed against all four edges with the chin cut off.

     The fix is the one this file already applies to .photo: give the
     box the picture's shape instead of giving the picture the box's.
     Rather than hard-code five ratios in a shared stylesheet, the image
     is left to size itself — width and height auto, bounded by the
     column on one axis and by the viewport on the other — and the box
     shrink-wraps whatever comes out. No cropping, and no letterbox bars
     either, since the box is never wider than its contents.

     The height cap is what keeps a 0.562 portrait from taking 644px of
     an 844px screen before the reader reaches a word of the report.
     svh first, then vh: iOS resolves vh against the URL-bar-hidden
     viewport, which is taller than what the reader can actually see.

     transform:none stays, and still matters. krishna.css zooms its hero
     with scale(1.37) and a transform-origin tuned against the 375x206
     print box. Applied to a box of any other shape it pushes her face
     out of frame and overflows the overflow:hidden parent — on a 390px
     phone her hero was the top of her head and nothing else. Print
     keeps the transform; this rule is screen-only.
     ------------------------------------------------------------ */
  .hero-photo{
    height:auto; aspect-ratio:auto;
    width:fit-content; max-width:100%;
    margin-inline:auto;
  }
  .hero-photo img{
    width:auto; height:auto;
    max-width:100%;
    max-height:58vh;
    max-height:58svh;
    object-fit:contain; transform:none;
  }
  .hero .brandrow{ gap:14px; }
  .hero .brandrow img{ height:24px; }
  .hero-tags .t + .t{ padding-left:0; border-left:0; }
  .hero-tags .t{ padding-right:0; }

  /* ---- prose-level two-column layouts collapse ---- */
  .split,
  .split.map,
  .split.narrow-left,
  .split.photo-beside,
  .tri,
  .tgt2-row,
  .nps-grid,
  .donut-side,
  .ledger-head,
  .ledger-row,
  .ba{ grid-template-columns:1fr !important; gap:18px; }

  /* Before/after: the 46px arrow column between the two lists now
     points down the page rather than across it. */
  .ba .ba-arrow{ transform:rotate(90deg); justify-self:center; }

  /* ------------------------------------------------------------
     VOICES FROM THE COMMUNITY STACK
     ------------------------------------------------------------
     Two quotes side by side inside a full-bleed band leaves each about
     110px wide here. That is four or five words a line in Latin text and
     worse in Devanagari, where the Hindi original set nine lines deep
     against three for its English translation.

     The subgrid goes with the columns. It exists so the translations of
     two quotes sitting side by side start on the same line however
     unequal the quotes above them are; stacked, there is no neighbour to
     line up with, and keeping it would just impose one quote's row
     heights on the other. The divider rotates with the layout — a rule
     between columns becomes a rule between rows.
     ------------------------------------------------------------ */
  .voices .vgrid{ grid-template-columns:1fr; grid-template-rows:none; gap:22px; }
  .vq{ display:block; grid-row:auto; }
  .vq + .vq{
    padding-left:0; border-left:0;
    padding-top:22px; border-top:1px solid rgba(252,240,221,.22);
  }

  /* Floated photos and stat boxes read badly at this width. */
  .photo-float,
  .active-community.float{
    float:none !important; width:auto !important; margin:16px 0 !important;
  }

  /* A pair of photos stays a pair — they are small and read as one unit. */
  .photo-pair{ gap:10px; }

  /* ------------------------------------------------------------
     THE FULL-WIDTH PANEL IN A .tri MUST NOT COLLAPSE TO NOTHING
     ------------------------------------------------------------
     The leader stylesheets centre the wide panel in the three-up row
     with `.tri .tri-wide{ grid-column:1/-1; max-width:82%; margin:0 auto }`.
     On a 794px sheet that is a centred 82% panel. Here it produced a
     panel exactly 0px wide, and the Net Promoter Score card inside it
     rendered as a 46px sliver — the score, the table and the sentence
     explaining the low ratings all effectively gone from the report.

     Two rules combine to do it. `margin:0 auto` gives the grid item
     automatic inline margins, and an item with auto margins is sized to
     its contents rather than stretched to its track. `contain:inline-size`
     — set above, so a wide chart cannot widen the whole document — means
     the contents measure zero by definition. Content-sized box, zero
     content: zero width. Neither rule is wrong on its own, which is why
     this survived: it needs both, and only the phone layer adds the second.

     At this width there is no second column to be wide relative to, so
     the panel simply takes the row. That removes the auto margins and
     the collapse with them.
     ------------------------------------------------------------ */
  .tri .tri-wide{ max-width:none; margin:0; }

  /* ---- charts keep their designed geometry and scroll ----
     Reflowing ten bespoke chart types across five leaders would
     change what they say. A swipeable card does not. The title is
     left outside the scroll region so it wraps normally.

     `contain: inline-size` is load-bearing, not an optimisation.
     doc-page wraps the whole document in a <table class="frame">
     inside its shadow root (so thead/tfoot can repeat as page-margin
     spacers at print). A table sizes to the min-content width of its
     cells, so ANY wide descendant silently widens the entire
     document past the viewport — and because the sheet is
     width:100%, the result is not a scrollbar but text clipped off
     the right edge, which is worse and much easier to miss.
     overflow-x:auto alone does NOT stop that propagation; inline-size
     containment does, by making these boxes take their width from
     their container instead of their contents. Only then is the
     min-width below safe to state. */
  .chart-card,
  .panel,
  .tri-wide,
  .netw,
  .cloud{
    overflow-x:auto; -webkit-overflow-scrolling:touch;
    contain:inline-size;
  }

  .chart-card > :not(.chart-title):not(figcaption):not(.iso-head),
  .tri-wide table.nps,
  .netw > svg{ min-width:480px; }

  /* ------------------------------------------------------------
     …EXCEPT THE CHILDREN THAT ARE TEXT RATHER THAN PLOT
     ------------------------------------------------------------
     .chart-card is a frame, and not everything wearing it is a chart.
     The rule above cannot tell the two apart, so it put prose behind a
     horizontal swipe in four places:

       .chart-foot  the sentence under a plot. On the NPS card it is the
                    whole explanation of the low scores.
       .ledger      Krishna's volunteer quotes — "We get no money at
                    all…" / "…yet we work to keep the environment good."
                    Text in two columns; the right one was cut off.
       .ba          the before/after lists. These already stack above,
                    and the 480px floor was quietly cancelling that.
       .tgt2        the Targets card, handled in full further down.

     None of them plot anything. They are laid out in columns that the
     rules above already collapse, so the floor is not just unnecessary,
     it is actively undoing work done ten lines earlier.

     !important because the rule it overrides carries three pseudo-classes
     worth of specificity. Matching that with more :not()s would work and
     would be unreadable — and the next person adding a text-shaped card
     needs somewhere obvious to add it, which is here.
     ------------------------------------------------------------ */
  .chart-card > .chart-foot,
  .chart-card > .ledger,
  .chart-card > .ba,
  .chart-card.tgt2 > *{ min-width:0 !important; }

  /* A chart that continues past the card edge says so: the fill is painted
     with background-attachment:local, so it travels with the content and
     disappears once the reader has scrolled to the end. */
  .chart-card{
    background-image:linear-gradient(90deg,transparent,rgba(83,14,54,.10));
    background-repeat:no-repeat;
    background-position:right center;
    background-size:26px 100%;
    background-attachment:local;
  }

  /* ------------------------------------------------------------
     TARGETS IS NOT A CHART
     ------------------------------------------------------------
     .tgt2 wears the .chart-card class for its frame — the border, the
     radius, the padding — not because it is a diagram. The scroll rules
     above cannot tell the difference, so they gave it min-width:480px
     inside a ~350px card, and the goal sentences got clipped at the
     right edge: "Expand the sangathan's reach from 100 to 150 panc…".
     Prose behind a horizontal swipe, one sentence at a time.

     Nothing here needs the designed width. Each row is a sentence, a
     number and one progress bar, and the bar is a flex box with
     percentage segments that scales to whatever width it is handed. So
     this card reflows like the prose it is, and the swipe-fade goes
     with it — there is nothing left to swipe to.

     The 480px floor is lifted off its children with the other
     text-shaped cards above; this is the rest of the treatment.
     ------------------------------------------------------------ */
  .chart-card.tgt2{
    overflow-x:visible; contain:none; background-image:none;
  }

  /* Title over legend, both ranged left, rather than pushed apart. */
  .tgt2-head{ flex-direction:column; gap:16px; }
  .tgt2-legend{ text-align:left; }
  .tgt2-key{ justify-content:flex-start; }

  /* The goal now sits ABOVE its progress instead of beside it, so the
     rule that divided the two columns has no column to divide. */
  .tgt2-goal{ border-right:0; padding-right:0; margin-bottom:14px; }

  /* nowrap was safe against a 1.15fr column on a 794px sheet. At this
     width "111 / 150 panchayats" and its note have to be able to wrap. */
  .tgt2-val,
  .tgt2-note{ white-space:normal; }

  .hbar{ grid-template-columns:120px 1fr; }
  .iso-row{ grid-template-columns:26px 118px 40px minmax(0,1fr); }

  /* ---- feedback band ---- */
  .feedback{ grid-template-columns:1fr; gap:28px; }
  .feedback .fb-body{ padding-right:0; }
  .feedback .fb-mark{
    padding-left:0; border-left:0; align-items:flex-start;
    border-top:1px solid rgba(252,240,221,.28); padding-top:26px;
  }
  .fb-social{ justify-content:flex-start; }
  .feedback h3{ font-size:23px; }

  /* Figures and photo grids may break wherever they like now that
     there are no pages to break across. */
  figure{ margin-left:0; margin-right:0; }
}

/* Very narrow — a 320px iPhone SE still has to work.

   Note what is NOT here: an override collapsing .hbar to a single column.
   The bar rows live inside a chart card that is already 520px wide and
   scrolling, and their labels are right-aligned against the track. Stacking
   them puts each label at the far right of that 520px row — off the visible
   edge, so the chart loses its labels entirely and only the bars remain. */
@media screen and (max-width:400px){
  doc-page{ --doc-page-margin:14px; --mgn:14px; }
  /* The pair is a flex row now, so stacking it is a direction change —
     grid-template-columns would be silently ignored. */
  .photo-pair{ flex-direction:column; }
  .photo-pair > .photo{ flex:0 0 auto; }
  .fb-actions{ flex-direction:column; align-items:stretch; }
  .feedback .fb-action{ justify-content:center; }
}

/* ------------------------------------------------------------
   Wide screens: nothing changes. The desk-and-sheet view is the
   designed experience and the print geometry depends on it.
   ------------------------------------------------------------ */
