/* InstantPalette - color blindness simulator (layer 5, this page only)
   Load order: tokens.css -> base.css -> site.css -> tools.css -> color-blindness-simulator.css

   Only what this tool needs: the vision-type radios, the palette rows, the compare stage, the five-type grid, the
   drop zone and the problem pairs. Panels, buttons, sliders and segmented controls come from tools.css. */

/* ================= Controls ================= */
.cvd-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.cvd-type {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  min-height: 50px; padding: 6px 10px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--ground); color: var(--ink-1);
  text-align: left;
}
.cvd-type:last-child { grid-column: 1 / -1; }
.cvd-type b { font: 500 14px/1.2 var(--f-sans); }
.cvd-type span { font: 400 12px/1.3 var(--f-sans); color: var(--ink-2); }
.cvd-type[aria-checked="true"] { border-color: var(--ink-1); box-shadow: inset 0 0 0 1px var(--ink-1); background: var(--raised); }
.cvd-type[aria-checked="true"] b { font-weight: 700; }
@media (hover: hover) and (pointer: fine) { .cvd-type:hover { border-color: var(--ink-1); } }
/* One wide column (between the phone and the two-column workspace): the five types fit one row */
@container tpage (min-width: 600px) and (max-width: 689.98px) {
  .cvd-types { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .cvd-type { padding: 6px 8px; }
  .cvd-type:last-child { grid-column: auto; }
}
.trange:disabled { opacity: .45; }
.cvd-exp { display: flex; flex-wrap: wrap; gap: 8px; }
.cvd-exp .tprimary { flex: 1 0 100%; }
.cvd-exp .btn-o { flex: 1 1 auto; min-height: 44px; }
.cvd-imgs { display: flex; flex-wrap: wrap; gap: 8px; }
.cvd-imgs .btn-o { min-height: 44px; }

/* The controls stay beside a long problem list */
@media (min-height: 760px) {
  @container tpage (min-width: 690px) { .cvd-side { position: sticky; top: 12px; } }
}

/* ================= Palette rows ================= */
.cvd-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cvd-row-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 5px; font: 500 14px/18px var(--f-sans); }
.cvd-row-h > span:first-child { display: inline-flex; align-items: center; gap: 4px; }
.cvd-row-h .i { width: 16px; height: 16px; stroke-width: 2.4; }
.cvd-row.is-on .cvd-row-h { font-weight: 700; }
.cvd-row-c { font: 400 12px/18px var(--f-sans); color: var(--ink-2); text-align: right; }
.cvd-sw { list-style: none; margin: 0; padding: 0; display: flex; border-radius: var(--r-sm); }
.cvd-row.is-on .cvd-sw { outline: 2px solid var(--ink-1); outline-offset: 2px; }
.cvd-sw li {
  container-type: inline-size;
  flex: 1 1 0; min-width: 0; min-height: 52px;
  display: grid; align-items: center;
  background: var(--sw); color: var(--ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink-1) 12%, transparent);
}
.cvd-sw li:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.cvd-sw li:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.cvd-sw span { justify-self: center; font: 500 12px/1 var(--f-mono); font-stretch: 75%; white-space: nowrap; }
/* Too narrow for a code: it reads downwards, so every swatch keeps its hex */
@container (max-width: 61px) { .cvd-sw span { writing-mode: vertical-rl; margin: 6px 0; } }

/* ================= Compare stage ================= */
.cvd-cmp { --ar: 1.6; width: min(100%, max(240px, 58vh * var(--ar))); margin: 0 auto; }
.cvd-tags { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 6px; font: 500 13px/1.3 var(--f-sans); }
.cvd-stage {
  --split: 50%;
  position: relative;
  aspect-ratio: var(--ar);
  border-radius: var(--r);
  background: var(--sunken);
  box-shadow: 0 0 0 1px var(--line-2);
  cursor: ew-resize; touch-action: pan-y;
  -webkit-user-select: none; user-select: none;
}
.cvd-layer { position: absolute; inset: 0; border-radius: var(--r); overflow: hidden; pointer-events: none; }
.cvd-layer > svg, .cvd-layer > canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.cvd-over { clip-path: inset(0 calc(100% - var(--split)) 0 0); }
/* The handle: a 2px line with a white-on-black rim, and a 44px grip */
.cvd-split {
  position: absolute; top: 0; bottom: 0; left: var(--split); width: 44px;
  transform: translateX(-50%);
  display: grid; place-items: center;
}
.cvd-split::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; transform: translateX(-50%);
  background: #FFF; box-shadow: 0 0 0 1px #000;
}
.cvd-grip {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--raised); color: var(--ink-1);
  box-shadow: 0 0 0 2px var(--ink-1), 0 0 0 4px var(--raised);
}
.cvd-grip .i { width: 22px; height: 22px; }
.cvd-split:focus-visible { outline: none; }
.cvd-split:focus-visible .cvd-grip { box-shadow: 0 0 0 2px var(--ink-1), 0 0 0 4px var(--raised), 0 0 0 7px var(--ink-1), 0 0 0 9px var(--raised); }

/* ================= All types ================= */
.cvd-all { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 12px; }
.cvd-all li { grid-column: span 2; min-width: 0; }
.cvd-all li:nth-child(-n+2) { grid-column: span 3; }
.cvd-pic { --ar: 1.6; aspect-ratio: var(--ar); border-radius: var(--r-sm); background: var(--sunken); box-shadow: 0 0 0 1px var(--line-2); }
.cvd-pic > svg, .cvd-pic > canvas { display: block; width: 100%; height: 100%; border-radius: var(--r-sm); object-fit: contain; }
.cvd-all .is-on .cvd-pic { outline: 2px solid var(--ink-1); outline-offset: 2px; }
.cvd-cap { margin: 7px 0 0; font: 500 13px/1.3 var(--f-sans); }
.cvd-all .is-on .cvd-cap { font-weight: 700; }
@media (max-width: 520px) {
  .cvd-all { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cvd-all li, .cvd-all li:nth-child(-n+2) { grid-column: span 1; }
  .cvd-all li:first-child { grid-column: 1 / -1; }
}

/* ================= Drop zone ================= */
.cvd-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 300px; padding: 28px 20px;
  border: 1.5px dashed var(--ink-3); border-radius: var(--r-lg);
  background: var(--ground); text-align: center;
}
.cvd-drop .i { width: 34px; height: 34px; color: var(--ink-2); }
.cvd-drop-h { margin: 0; font: 600 17px/1.3 var(--f-sans); }
.cvd-drop-p { margin: 0; max-width: 42ch; font: 400 14px/1.6 var(--f-sans); color: var(--ink-2); }
.cvd-drop.is-over { border: 1.5px solid var(--ink-1); background: var(--hover); }

/* ================= Palette problems ================= */
.cvd-sum { margin: 0; font: 500 15px/1.45 var(--f-sans); }
.cvd-tally { margin: 0; font: 400 13px/1.5 var(--f-sans); color: var(--ink-2); }
.cvd-pairs { list-style: none; margin: 0; padding: 0; display: grid; }
.cvd-pairs:empty { display: none; }
.cvd-pair { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.cvd-pair:last-child { padding-bottom: 0; }
.cvd-2x2 { display: grid; grid-template-columns: 50px 1fr 1fr; align-content: start; }
.cvd-k { margin: 0; font: 400 12px/1.45 var(--f-sans); color: var(--ink-2); }
.cvd-2x2 .cvd-k { align-self: center; }
.cvd-cell {
  display: grid; place-items: center; min-height: 40px; min-width: 0;
  background: var(--sw); color: var(--ink);
  font: 500 12px/1 var(--f-mono); font-stretch: 75%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink-1) 12%, transparent);
}
.cvd-pair-t { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.cvd-verdict { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.cvd-d { font: 400 12px/1.4 var(--f-sans); color: var(--ink-2); }
.cvd-fixes { display: flex; flex-wrap: wrap; gap: 8px; }
.cvd-fixes .btn-o { flex: 0 1 auto; gap: 6px; padding: 0 10px; }
.cvd-fixes .mono { font-size: 12px; font-stretch: 75%; }
.cvd-dot { width: 16px; height: 16px; flex: none; border-radius: 4px; background: var(--c); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink-1) 24%, transparent); }
@container tpage (max-width: 689.98px) { .cvd-fixes .btn-o { min-height: 44px; } }
.cvd-more { border-top: 1px solid var(--line); }
.cvd-more summary { display: flex; align-items: center; gap: 6px; min-height: 44px; font: 500 14px/1.3 var(--f-sans); cursor: pointer; list-style: none; }
.cvd-more summary::-webkit-details-marker { display: none; }
.cvd-more[open] summary .i { transform: rotate(180deg); }
.cvd-ok { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(224px, 100%), 1fr)); gap: 8px 16px; }
.cvd-ok li { display: grid; grid-template-columns: 62px 62px 1fr; align-items: center; }
.cvd-ok .cvd-cell { min-height: 36px; }
.cvd-ok-t { display: flex; flex-direction: column; padding-left: 10px; font: 500 12px/1.3 var(--f-sans); }

@media (max-width: 520px) {
  .cvd-pair { grid-template-columns: minmax(0, 1fr); }
  .cvd-fixes .btn-o { flex: 1 1 0; }
  .cvd-drop { min-height: 220px; }
}
/* Landscape phones: the stage gives the handle and the panel head room */
@media (orientation: landscape) and (max-height: 500px) { .cvd-cmp { width: min(100%, max(240px, 70vh * var(--ar))); } }
