/* Live ASCII frog portrait (home page). */
.hero-art {
  width: min(100%, 25rem);
  margin: 0;
  justify-self: end;
  container-type: inline-size;
}
.portrait-print, .portrait-terminal {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--line);
}
.hero-art [hidden] { display: none; }
.portrait-terminal { cursor: crosshair; touch-action: none; }
.portrait-controls {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font: 0.74rem/1.45 var(--mono);
}
.portrait-title { color: var(--accent); font-size: 0.85rem; }
.portrait-controls p { margin: 0.3rem 0; }
.portrait-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.8rem; }
.portrait-actions button {
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  background: var(--well);
  color: var(--phosphor);
  font: inherit;
  cursor: pointer;
}
.portrait-actions button:hover { border-color: var(--phosphor); }
.portrait-actions label { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.portrait-actions input { accent-color: var(--phosphor); }
.portrait-actions + .portrait-actions { margin-top: 0.35rem; }
/* Eleven experiments flow as one wrapping row of chips (Edit, then Simulate). */
.portrait-modes { display: flex; flex-wrap: wrap; margin-bottom: 0.65rem; gap: 0.35rem; }
.portrait-mode-row { display: contents; }
.portrait-modes button { padding-inline: clamp(0.25rem, 1.8cqi, 0.5rem); }
.portrait-modes button[aria-pressed="true"] {
  background: var(--phosphor);
  border-color: var(--phosphor);
  color: var(--bg);
}
.portrait-actions button:disabled { opacity: 0.55; cursor: default; }
#trace-tolerance, #flow-threshold { width: 5rem; }
#portrait-status { min-height: 2.9em; color: var(--ink); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Color by mood */
.palette-form input {
  flex: 1 1 9rem; min-width: 0; min-height: 2rem; padding: 0.3rem 0.5rem;
  border: 1px solid var(--line); background: var(--well); color: var(--ink); font: inherit;
}
.palette-form input:focus-visible { outline: 1px solid var(--phosphor); border-color: var(--phosphor); }
.palette-swatches { display: flex; gap: 0.5rem; margin-top: 0.45rem; }
.palette-swatches[hidden] { display: none; }
.palette-swatch {
  display: flex; padding: 3px; border: 1px solid var(--line); background: none; cursor: pointer;
}
.palette-swatch span { width: 0.9rem; height: 1.25rem; }
.palette-swatch[aria-pressed="true"], .palette-swatch:hover { border-color: var(--phosphor); }
.palette-swatch:focus-visible, .portrait-actions button:focus-visible { outline: 2px solid var(--phosphor); outline-offset: 2px; }
/* Peel and Restore */
.portrait-stage {
  position: relative;
  aspect-ratio: 1;
  background: #031803;
  /* Inset edge so the reserved square has a border while the photo is hidden
     (visibility:hidden also hides the <img> border). Does not affect layout. */
  box-shadow: inset 0 0 0 1px var(--line);
}
.portrait-ascii-seed {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--line);
}
/* Hide the source photo until the ASCII canvas has been painted over it.
   Visibility (not display) keeps the reserved square so the layout does not shift.
   .is-ready is added in CSS-class form after first paint; peel can then reveal the photo. */
.portrait-print { visibility: hidden; }
.portrait-stage.is-ready .portrait-print { visibility: visible; }
.portrait-stage .portrait-terminal { position: absolute; inset: 0; }
.peel-seam {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; overflow: visible;
  filter: drop-shadow(0 0 1.5px rgb(0 0 0 / 0.85));
}
.peel-seam line { stroke: var(--phosphor); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
/* Generous hit area around the seam handle. left/top are set in JS to the
   geometry handle (96% at rest). The ::after dot is visual only. */
.peel-handle {
  position: absolute; left: 96%; top: 96%; width: 2.75rem; height: 2.75rem;
  transform: translate(-50%, -50%);
  border-radius: 50%; touch-action: none; cursor: grab; z-index: 2;
}
.peel-handle::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 0.6rem; height: 0.6rem;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--phosphor); box-shadow: 0 0 0 2px rgb(3 24 3 / 0.85), 0 0 4px rgb(0 0 0 / 0.6);
  pointer-events: none;
  transition: transform 0.15s;
}
.peel-handle:hover::after, .is-dragging .peel-handle::after { transform: translate(-50%, -50%) scale(1.3); }
.is-dragging, .is-dragging * { cursor: grabbing; }
.peel-handle:focus-visible { outline: 2px solid var(--phosphor); outline-offset: -0.85rem; }
.restore-default {
  display: block; position: absolute; top: 0.45rem; right: 0.45rem; z-index: 5;
  padding: 0.2rem 0.45rem; border: 1px solid var(--line);
  background: rgb(3 24 3 / 0.92); color: var(--phosphor);
  font: 0.72rem/1.4 var(--mono); cursor: pointer; pointer-events: auto;
  opacity: 1; transition: border-color 0.15s;
}
.restore-default:hover, .restore-default:focus-visible { border-color: var(--phosphor); }
.restore-default:focus-visible { outline: 2px solid var(--phosphor); outline-offset: 2px; }
.restore-default:disabled { opacity: 0.5; cursor: default; }
.peel-handle[hidden], .peel-seam[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .peel-handle::after, .restore-default { transition: none; }
}
