/* Biodiversity Dashboard: rarefaction (BTX-486, HANDOFF §1.3, §1.7). The switch in the control bar,
   its "richness only" note, the explainer modal, and the "rarefied" tag on the Diversity table's
   Species richness column. Tokens only (biodiversity_dashboard.css); sizes on the rem scale. Taken
   from the prototype's .rareswitch / .swbtn / .modalveil rules, restyled to the shell's pills. */

.bd .rareswitch{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;min-width:0;}
.bd .swbtn{width:36px;height:20px;border-radius:10px;background:var(--rule-strong);border:none;cursor:pointer;
  position:relative;padding:0;flex:none;}
.bd .swbtn .knob{position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--surface);
  transition:left .12s;box-shadow:0 1px 2px rgba(0,0,0,.25);}
.bd .swbtn.on{background:var(--teal);}
.bd .swbtn.on .knob{left:18px;}
.bd .swbtn:disabled{cursor:not-allowed;opacity:.45;}
.bd .swbtn:focus-visible{outline:2px solid var(--teal-2);outline-offset:2px;}
.bd .swlabel{font-family:var(--label);font-weight:500;font-size:0.82rem;color:var(--ink-2);min-width:1.6rem;}
.bd .swnote{font-family:var(--label);font-weight:500;font-size:0.62rem;letter-spacing:.06em;text-transform:uppercase;
  color:var(--amber-ink);background:color-mix(in srgb, var(--amber) 16%, var(--surface));border-radius:999px;
  padding:.18rem .55rem;white-space:nowrap;}
.bd .swnote.unavailable{color:var(--ink-3);background:var(--seg);}

/* The explainer. Fixed to the viewport; [hidden] must win over display:flex. */
.bd .modalveil{position:fixed;inset:0;background:rgba(10,12,8,.45);z-index:60;display:flex;
  align-items:center;justify-content:center;padding:1.2rem;}
.bd .modalveil[hidden]{display:none;}
.bd .modalcard{background:var(--surface);color:var(--ink);border-radius:18px;max-width:34rem;width:100%;
  padding:1.6rem 1.7rem;box-shadow:0 12px 40px rgba(0,0,0,.28);max-height:85vh;overflow:auto;}
.bd .modalcard h3{font-family:var(--display);font-weight:400;font-size:1.35rem;margin:0 0 .7rem;color:var(--ink);}
.bd .modalcard p{font-size:0.88rem;color:var(--ink-2);line-height:1.6;margin:0 0 .8rem;}
.bd .modalcard p:last-child{margin-bottom:0;}
.bd .modalcard h4{font-size:0.92rem;font-weight:600;color:var(--ink);margin:1.1rem 0 .4rem;}
.bd .modalcard strong{color:var(--ink);}
.bd .modalclose{float:right;border:none;background:var(--surface-2);color:var(--ink-2);width:26px;height:26px;
  border-radius:50%;cursor:pointer;font-size:0.88rem;font-family:var(--sans);margin:0 0 .4rem .6rem;}
.bd .modalclose:hover{background:var(--teal);color:var(--on-teal);}
.bd .modalclose:focus-visible{outline:2px solid var(--teal-2);outline-offset:2px;}
@media (max-width:640px){ .bd .modalcard{padding:1.2rem 1.1rem;} }

/* "rarefied" under the Species richness column label while the switch is on. */
.bd .divtable .rf{display:block;font-size:0.62rem;letter-spacing:0;text-transform:none;color:var(--amber-ink);font-weight:600;}
/* A phone: the button is a flex row, so the tag would sit beside the label and widen the column
   by its own width; at 375px that pushed the table past the viewport wherever the fallback font
   runs wide (Linux). A two-column grid puts the tag on a second line under the label, the arrow
   centred beside both, so turning rarefaction on never widens the table. */
@media (max-width:640px){
  .bd .divtable .sortbtn:has(.rf){display:inline-grid;grid-template-columns:auto auto;column-gap:.3rem;
    align-items:center;justify-items:center;}
  .bd .divtable .sortbtn .rf{grid-column:1;grid-row:2;}
  .bd .divtable .sortbtn:has(.rf) .arw{grid-column:2;grid-row:1 / span 2;}
}
