/* Styles for the parts added after app.css: image comparer, known-example pair, "Do first" list, dot plot key.
   Tokens come from app.css. Motion sits in the no-preference block at the end; every final state holds without it. */

/* --pos is the divider position of the comparer. Registered as a percentage so the entry sweep can interpolate it. */
@property --pos{syntax:"<percentage>";inherits:true;initial-value:50%}

/* Cards that hold an image: 10px padding makes the 6px image radius concentric with the 16px panel radius.
   Text inside is set in 6px more, so it lines up with the 16px padding of the other cards. */
.pair-card,.blk.pair-blk{padding:10px}
.pair-card>.card-head{margin:6px 6px 10px}
.pair-card>.card-head .mono:first-child{color:var(--ink)}
.pair-card>.note{margin:8px 6px 6px}
.blk.pair-blk>.mono{margin:6px 6px 10px}
.blk.pair-blk>.note{margin:10px 6px 6px}

/* Comparer: two stacked images in a square. The satellite image is on top and clipped from the left at --pos.
   A native range input covers the box, invisible but focusable, and sets --pos. */
.cmp{position:relative;aspect-ratio:1;border-radius:6px;overflow:hidden;background:var(--raised);--pos:50%}
.cmp img{position:absolute;inset:0;display:block;width:100%;height:100%;object-fit:cover;border-radius:6px;outline:1px solid rgba(255,255,255,.1);outline-offset:-1px;-webkit-user-drag:none;user-select:none}
.cmp-s{clip-path:inset(0 0 0 var(--pos));image-rendering:pixelated}
/* Each corner tag is clipped with its own image, so a tag never sits on the other image. */
.cmp-over{position:absolute;inset:0;pointer-events:none}
.cmp-over-a{clip-path:inset(0 calc(100% - var(--pos)) 0 0)}
.cmp-over-s{clip-path:inset(0 0 0 var(--pos))}
.cmp-tag{position:absolute;bottom:8px;padding:3px 6px;border-radius:4px;background:rgba(10,15,12,.78);color:var(--ink);white-space:nowrap}
.cmp-over-a .cmp-tag{left:8px}
.cmp-over-s .cmp-tag{right:8px}
/* Handle: a full-size layer moved by transform, with the 2px line and a grip drawn at its left edge. */
.cmp-line{position:absolute;inset:0;pointer-events:none;transform:translateX(var(--pos))}
.cmp-line::before{content:"";position:absolute;top:0;bottom:0;left:-1px;width:2px;background:var(--ink);box-shadow:0 0 0 1px rgba(10,15,12,.4)}
.cmp-line::after{content:"";position:absolute;top:50%;left:-13px;width:26px;height:26px;margin-top:-13px;border-radius:50%;background:var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230A0F0C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 4.5 2.5 8 6 11.5M10 4.5 13.5 8 10 11.5'/%3E%3C/svg%3E") center/16px no-repeat;box-shadow:0 1px 2px rgba(0,0,0,.4),0 4px 12px rgba(0,0,0,.35)}
.cmp input[type=range]{position:absolute;inset:0;width:100%;height:100%;margin:0;padding:0;opacity:0;cursor:ew-resize;-webkit-appearance:none;appearance:none;background:transparent;touch-action:pan-y}
/* A 2px thumb keeps the value under the pointer: a wide thumb would offset it near the edges. */
.cmp input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:2px;height:100%}
.cmp input[type=range]::-moz-range-thumb{width:2px;height:100%;border:0}
.cmp:hover .cmp-line::after{background-color:var(--gorse-bright)}
/* The input is invisible, so the box carries its focus ring. */
.cmp:focus-within,.cmp:has(input:focus-visible){outline:2px solid var(--gorse);outline-offset:2px}

/* Key and value rows under the comparer */
.kvs{margin:10px 6px 0}
.kvs>div{display:flex;justify-content:space-between;align-items:baseline;gap:var(--s-3);padding:7px 0;box-shadow:inset 0 -1px 0 var(--ring)}
.kvs>div:last-child{box-shadow:none}
.kvs dt,.kvs dd{margin:0;font-size:.8125rem;line-height:1.3}
.kvs dt{color:var(--ink-2)}
.kvs dd{color:var(--ink);font-weight:500;text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}
/* Short screens: the comparer gives up width so the whole card fits its slot (viewport minus 220px) without scrolling. */
@media (max-height:780px){.pair-card .cmp-wrap{width:min(100%,calc(100vh - 440px));margin-inline:auto}}
/* The pair chapter shows the bright satellite layer edge to edge, so the scrim under the caption is stronger there. */
body[data-mode="story"][data-card="pair"] .scrim-bottom{height:58vh;background:linear-gradient(0deg,rgba(10,15,12,.92),rgba(10,15,12,.66) 55%,rgba(10,15,12,0))}

/* Evidence: the two example images side by side */
.pair{display:grid;grid-template-columns:1fr 1fr;gap:10px;max-width:30rem}
.pair figure{margin:0;min-width:0}
.pair img{display:block;width:100%;height:auto;aspect-ratio:1;border-radius:6px;background:var(--raised);outline:1px solid rgba(255,255,255,.1);outline-offset:-1px}
.pair img.px{image-rendering:pixelated}
.pair figcaption{margin:8px 6px 0;color:var(--ink)}

/* "Do first" card: urgency key, then one row per unit.
   With data/route.json the same card holds the route instead (story.js): its rows and short-screen rule are in route.css. */
#actionsCard>.mono{display:block;margin-bottom:var(--s-2)}
.tri-key{margin:0}
.chart-legend .tri-rest{color:var(--ink-2)}
.tri-sw{display:inline-block;width:10px;height:10px;border-radius:2px;flex:none}
.acts li{padding:10px 0;box-shadow:inset 0 -1px 0 var(--ring)}
.acts li:last-child{box-shadow:none}
.act-head{display:flex;justify-content:space-between;align-items:baseline;gap:var(--s-2)}
.act-head b{display:inline-flex;align-items:center;gap:8px;font:600 .875rem/1.3 var(--font-sans);font-variant-numeric:tabular-nums}
.act-head span{font-size:.8125rem;color:var(--ink-2);white-space:nowrap;font-variant-numeric:tabular-nums}
.acts p{margin-top:2px;font-size:.8125rem;line-height:1.4;color:var(--ink);text-wrap:pretty}
/* `why` stays whole; `how` can run to three sentences, so it holds at two lines (full text in its title). */
.acts .act-how{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden;color:var(--ink-2)}
#actionsCard>.note{margin-top:var(--s-1)}

/* Dot plot: round key swatches. Verdict card: the plot sits between the headline and the lines. */
.chart-legend i.dt{border-radius:50%}
/* The plot scales with its block. In a full-width block it stops at 52rem so labels stay near body size. */
.chart.auc{max-width:52rem}
.verdict-h+.sect{margin-top:0}
.sect+.lines{margin-top:var(--s-3)}

/* "Do first" and verdict cards: the head and the foot keep their height. The list between them takes what is left of the slot
   and scrolls inside the card when that is not enough, so the note or the button at the foot stays in view. */
#actionsCard,#verdictCard{display:flex;flex-direction:column}
#actionsCard>*,#verdictCard>*{flex:none}
#actionsCard>.acts,#verdictCard>.lines{flex:0 1 auto;min-height:4.5rem;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--ink-3) transparent}
#verdictCard>.mono{margin-bottom:var(--s-1)}

/* Story, "Before anyone acts.": the card keeps the unit's name, tier, reason and its checks, which are the subject of the chapter.
   The measurements, the method votes and the flower index stay in Explore: with them the card is 1024px tall and no slot holds it. */
body[data-mode="story"] #clusterCard>.sect:not(:has(.checks)){display:none}
body[data-mode="story"] #clusterCard .checks li{padding:7px 0}

/* Short screens. The slot is the viewport minus 220px, and the three cards drop detail in steps so nothing needs a scroll.
   840px and less (a maximised window on a 960px screen): the verdict drops its last line and the checks close up.
   800px and less (1280 x 720): `how` holds at one line, the verdict keeps two lines and drops the note under the plot,
   and the checks show their names without the explanations. */
@media (max-height:840px){
  #verdictCard>.lines li:nth-child(n+4){display:none}
  body[data-mode="story"] #clusterCard .checks li{padding:4px 0}
}
@media (max-height:800px){
  .acts li{padding:8px 0}
  .acts .act-how{-webkit-line-clamp:1;line-clamp:1}
  #verdictCard>.lines li:nth-child(n+3),#verdictCard .sect .note{display:none}
  body[data-mode="story"] #clusterCard .checks li{padding:7px 0}
  body[data-mode="story"] #clusterCard .checks span{display:none}
}
/* 700px and less (a maximised window on a 768px laptop): the verdict is the headline, the plot and the button. */
@media (max-height:700px){
  #verdictCard>.lines{display:none}
}

/* Entry sweep of the comparer: the divider moves once from the right edge to its resting place.
   Only clip-path and transform change, both through --pos. */
@keyframes cmp-in{from{--pos:100%}}
@media (prefers-reduced-motion:no-preference){
  .cmp.is-intro{animation:cmp-in 900ms var(--ease) 360ms backwards}
}

@media (forced-colors:active){
  .cmp-line::before,.cmp-line::after{background-color:CanvasText}
  .cmp-tag{border:1px solid CanvasText}
}
