/* ============================================================
   color-scope.css  ·  vectorscope color filter (photo gallery)
   ------------------------------------------------------------
   Styles for the "Color" filter on photo-gallery.html: the
   sidebar toggle, the scope panel above the grid, and the
   hover palettes on photos. Behaviour lives in js/color-scope.js.
   The dish follows the theme: neutral pale white in light mode,
   deep navy in dark.
   ============================================================ */

:root {
  /* Neutral (untinted) greys in light mode: a colored backdrop would shift
     how the plotted photo colors read. */
  --scope-dish:   #F5F5F5;
  --scope-rim:    rgba(0, 0, 0, 0.04);
  --scope-grid:   rgba(0, 0, 0, 0.10);
  --scope-label:  var(--color-text-faint);
  --scope-skin:   rgba(0, 0, 0, 0.22);
  --scope-puck:   var(--color-text-primary);
  --scope-halo:   rgba(252, 252, 252, 0.9);
  --scope-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
  --pal-text-on-dark:  #fcfcfc;   /* hex text on a palette block, same in both themes */
  --pal-text-on-light: #232742;
}
[data-theme="dark"] {
  --scope-dish:   var(--color-bg-sidebar);
  --scope-rim:    var(--color-bg-toggle);
  --scope-grid:   var(--color-border-hairline);
  --scope-label:  var(--color-text-faint);
  --scope-skin:   rgba(252, 252, 252, 0.26);
  --scope-puck:   var(--color-text-primary);
  --scope-halo:   rgba(0, 0, 0, 0.35);
  --scope-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --pal-text-on-dark:  #fcfcfc;
  --pal-text-on-light: #232742;
}

/* ---- sidebar toggle ---- */
/* Last item in the category list; a hairline above sets it apart on desktop. */
.color-toggle { position: relative; margin-top: 19px; }
.color-toggle::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; border-top: 0.5px solid var(--color-border-hairline); }
.color-toggle .swatch {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  /* The site accent palette, arranged as a little hue wheel. */
  background: conic-gradient(from 90deg, var(--color-accent-pink), var(--color-accent-yellow), var(--color-accent-green),
    var(--color-accent-teal), var(--color-accent), var(--color-accent-purple), var(--color-accent-pink));
  box-shadow: inset 0 0 0 0.5px var(--color-border-hairline);
}
.color-toggle .label { display: inline-flex; align-items: center; gap: 9px; }

/* ---- panel ---- */
.color-panel {
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(220px, 1fr);
  gap: 40px;
  align-items: center;
  margin: 0 0 40px;
  padding-bottom: 36px;
  border-bottom: 0.5px solid var(--color-border-hairline);
}
.color-panel[hidden] { display: none; }

.scope {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--scope-dish);
  box-shadow: inset 0 0 0 0.5px var(--scope-grid), 0 0 0 7px var(--scope-rim), var(--scope-shadow);
  touch-action: none;
  cursor: crosshair;
  user-select: none;
}
.scope-trace, .scope-grat { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; }
.scope-grat { overflow: visible; pointer-events: none; }
.scope-grat .g { fill: none; stroke: var(--scope-grid); stroke-width: 0.004; }
.scope-grat .g-skin { stroke: var(--scope-skin); stroke-width: 0.004; stroke-dasharray: 0.02 0.015; }
.scope-grat .g-t {
  fill: var(--scope-label); font: 600 0.062px 'Instrument Sans', sans-serif; letter-spacing: 0.004px;
  text-anchor: middle; dominant-baseline: central;
}

.scope-puck, .scope-brand, .scope-hover {
  position: absolute; left: 50%; top: 50%; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none;
}
.scope-puck {
  width: 24px; height: 24px;
  border: 1.5px solid var(--scope-puck);
  box-shadow: 0 0 0 1px var(--scope-halo), 0 2px 10px rgba(0, 0, 0, 0.25);
  pointer-events: auto; cursor: grab; outline: none;
}
.scope-puck::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; border-radius: 50%;
  transform: translate(-50%, -50%); background: var(--puck, var(--scope-puck)); box-shadow: 0 0 0 1px var(--scope-puck);
}
.scope-puck:focus-visible { box-shadow: 0 0 0 1px var(--scope-halo), 0 0 0 4px var(--color-accent); }
.scope-puck.hint { animation: puck-hint 2.4s ease-in-out 0.6s 2; }
@keyframes puck-hint { 0%, 100% { scale: 1; } 50% { scale: 1.25; } }
.scope-brand { width: 12px; height: 12px; border: 1.5px solid var(--scope-puck); }
.scope-hover { width: 16px; height: 16px; border: 1px dashed var(--scope-puck); opacity: 0.8; }

/* ---- info column ---- */
.color-info { min-width: 0; }
.color-lede { font-size: 13.5px; line-height: 1.55; color: var(--color-text-secondary); max-width: 320px; margin-bottom: 18px; }
.color-readout {
  display: flex; gap: 22px; margin-bottom: 20px;
  font: 600 11px 'Instrument Sans', sans-serif; letter-spacing: 0.16em;   /* same as the eyebrow */
  color: var(--color-text-muted); text-transform: uppercase;
}
.color-readout b { color: var(--color-text-primary); font-size: 13px; font-weight: 600; letter-spacing: 0.02em; margin-left: 8px; font-variant-numeric: tabular-nums; }

.color-match {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; margin-bottom: 12px; max-width: 320px;
  border-bottom: 0.5px solid var(--color-border-hairline);
}
.color-match[data-bad] { border-bottom-color: var(--color-error); }
.color-chip { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 0.5px var(--color-border-hairline); }
.color-match input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  font: 500 14px 'Instrument Sans', sans-serif; font-variant-numeric: tabular-nums; color: var(--color-text-primary);
}
/* iPhones zoom the whole page in when you tap a text box under 16px (and stay
   zoomed, so the page can pan sideways). Touch screens get 16px. */
@media (pointer: coarse) { .color-match input { font-size: 16px; } }
.color-match input::placeholder { color: var(--color-text-muted); }
.color-note { font-size: 12.5px; line-height: 1.5; color: var(--color-text-muted); max-width: 320px; min-height: 19px; }

/* ---- gallery in color mode ---- */
.gallery .photo.color-out { display: none !important; }
.gallery.color-mode .photo { position: relative; }
.color-empty { font-size: 14px; color: var(--color-text-muted); text-align: center; padding: 40px 0; }
.color-empty[hidden] { display: none; }

/* 5-block palette over the bottom of the photo, only while hovering it (like the
   reference). Hover a block to see its hex, click it to copy. */
.photo-pal {
  display: none;
  position: absolute; left: 10px; right: 10px; bottom: 14px;   /* inside the polaroid frame */
  border-radius: 0 0 2px 2px; overflow: hidden;
}
.gallery.color-mode .photo-pal { display: flex; opacity: 0; transition: opacity 0.15s ease; }
.gallery.color-mode .photo:hover .photo-pal, .gallery.color-mode .photo:focus-within .photo-pal { opacity: 1; }
.pal-chip {
  flex: 1; min-width: 0; height: 30px; padding: 0; border: none; cursor: copy; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font: 500 10.5px/1 'Instrument Sans', sans-serif; font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
  color: var(--pal-text-on-dark); transition: flex-grow 0.18s ease;
}
.pal-chip.lt { color: var(--pal-text-on-light); }
.pal-chip span { opacity: 0; white-space: nowrap; transition: opacity 0.15s ease; }
/* The block you hover widens to make room for its hex code, which fades in. */
.pal-chip:hover, .pal-chip:focus-visible { flex-grow: 2.6; }
.pal-chip:hover span, .pal-chip:focus-visible span { opacity: 1; transition-delay: 0.06s; }
/* Touch has no hover: a thin always-on strip instead. */
@media (hover: none) {
  .gallery.color-mode .photo-pal { opacity: 1; }
  .photo-pal .pal-chip { height: 10px; }
  .pal-chip span { display: none; }
}

/* Same palette in the lightbox, inside the frame and joined to the bottom of the photo. */
.lightbox-pal {
  display: flex; height: 34px;
  width: 0; min-width: 100%;          /* match the photo, never widen the frame */
  border-radius: 0 0 2px 2px; overflow: hidden;
}
/* Photo + palette read as one piece: square where they meet, rounded outside. */
.lightbox-frame:has(.lightbox-pal) img { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.color-toast {
  position: fixed; left: 50%; top: 76px; transform: translate(-50%, -12px);   /* top, so it never covers a palette */
  /* A light card in light mode, a dark one in dark mode (same surface as the photo frames). */
  background: var(--color-bg-frame); color: var(--color-text-primary);
  border: 0.5px solid var(--color-border-hairline);
  font: 500 13.5px/1.45 'Instrument Sans', sans-serif; text-align: center;
  /* As wide as the message needs (not squeezed to half the screen), roomy padding. */
  width: max-content; max-width: calc(100vw - 32px); padding: 12px 22px; border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; z-index: 300;   /* above the lightbox */
}
.color-toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  /* Phones and tablets: just another pill in the same wrapping row. */
  .color-toggle { margin-top: 0; }
  .color-toggle::before { display: none; }
  .color-panel { grid-template-columns: 1fr; gap: 28px; justify-items: center; text-align: left; }
  .scope { max-width: 260px; }
  .color-info { width: 100%; max-width: 340px; }
}
@media (prefers-reduced-motion: reduce) { .scope-puck.hint { animation: none; } }

/* ---- how to leave color mode ---- */
.color-exit { font-size: 12.5px; line-height: 1.5; color: var(--color-text-muted); margin: -12px 0 16px; }
.color-exit[hidden] { display: none; }
.color-exit b { font-weight: 600; color: var(--color-text-secondary); }
/* Sidebar categories while the scope is on: counts are color matches; none = faded. */
.filter.color-none { opacity: 0.4; }

/* Screen-reader-only text (the "N photos match" announcement). */
.color-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
