/* Signature Correction: what is particular to this page, over /shared/base.css (tokens, frame,
   controls, file button, problems, out-of-date results, dialog and the narrow layout). */

.small { font-size: 0.88rem; }
.card > p.small { margin: 0.4rem 0; }

/* The signing pad: drawing must not scroll or zoom the page. */
.pad-frame, .result-frame, .morph-frame { position: relative; }
.pad {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  touch-action: none;
  cursor: crosshair;
}
.pad:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pad-empty {
  position: absolute;
  left: 6%;
  top: 74%;
  margin: 0;
  pointer-events: none;
  font-size: 0.95rem;
}

.result, .morph {
  display: block;
  width: 100%;
  aspect-ratio: 2.4 / 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.result.brushing { cursor: cell; touch-action: none; }
.result-empty[hidden], .legend[hidden] { display: none; }
.result-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: #5a5a5a; /* on the light checkerboard in both themes */
}
.morph-frame .result-empty { color: var(--muted); }

/* Radio groups drawn as pills: the chosen one is filled and ticked. */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  border: 0;
  padding: 0;
  margin: 0 0 0.6rem;
}
.segmented label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--surface);
  cursor: pointer;
}
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:has(input:checked) { background: var(--primary); border-color: var(--primary); color: var(--surface); }
.segmented label:has(input:checked)::before { content: "✓"; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; align-items: center; }
/* Legend keys on a scrap of the view's white paper, so the ink shows in either theme. */
.key {
  display: inline-block;
  width: 1.8rem;
  height: 0.9rem;
  vertical-align: middle;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.key-after { background: linear-gradient(var(--ink), var(--ink)) center / 75% 0.32rem no-repeat, #fff; }
.key-before { background: linear-gradient(#d0312d, #d0312d) center / 75% 1px no-repeat, #fff; }

.settings output { color: var(--text); font-variant-numeric: tabular-nums; margin-left: 0.3rem; }
.settings input[type="range"] { padding: 0; }
.settings input[type="color"] { min-height: 2.2rem; padding: 0.15rem; width: 4rem; }
.settings label.check { flex-direction: row; align-items: flex-start; gap: 0.5rem; grid-column: 1 / -1; }
.settings label.check input { margin-top: 0.3rem; }
.input-row select { flex: none; }

details.more { margin-top: 0.75rem; }
details.more summary { cursor: pointer; color: var(--primary); font-weight: 600; }

.scrub { display: flex; align-items: center; gap: 0.5rem; flex: 1 1 12rem; color: var(--muted); font-size: 0.92rem; }
.scrub input { flex: 1; min-width: 6rem; }
.scrub output { min-width: 3ch; color: var(--text); font-variant-numeric: tabular-nums; }

.filmstrip {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 7rem), 1fr));
}
.filmstrip li { display: flex; flex-direction: column; gap: 0.2rem; align-items: center; }
.filmstrip canvas {
  width: 100%;
  aspect-ratio: 2.4 / 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.toolbar .spacer { flex: 1; }
dialog .pad-frame { margin-top: 1rem; }

/* Wide screens: the settings beside the corrected view, then the morph across the page, its
   view beside its controls. */
@media (min-width: 1000px) {
  .layout { grid-template-rows: auto auto 1fr; }
  .layout > .morph-card { grid-column: 1 / -1; }
  .morph-body { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 0 1.5rem; align-items: start; }
  .morph-view { grid-column: 1; grid-row: 1; }
  .morph-controls { grid-column: 2; grid-row: 1; }
  .morph-controls .settings { grid-template-columns: minmax(0, 1fr); }
}

/* Ink-length editing: one shared ruler and a compact stack of explicit spans. */
.stroke-timeline { position: relative; height: 24px; margin: .5rem 0; border-bottom: 1px solid var(--border); }
.timeline-stroke { position: absolute; top: 8px; height: 5px; border-radius: 2px; }
.effect-row { border-top: 1px solid var(--border); padding: .5rem 0; }
.effect-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .88rem; }
.effect-top button { padding: .15rem .45rem; font-size: .8rem; }
.effect-track { position: relative; height: 38px; margin: .3rem 0; background: var(--surface-2); }
.effect-bar { position: absolute; top: 0; height: 100%; min-width: 2px; background: color-mix(in srgb, var(--primary) 18%, var(--surface)); display: flex; }
.effect-bar button { position: absolute; height: 100%; padding: 0; border-radius: 0; touch-action: none; }
.span-from, .span-to { width: 24px; z-index: 2; background: var(--surface); }
.span-from { left: 0; transform: translateX(-50%); }
.span-to { right: 0; transform: translateX(50%); }
.span-body { left: 12px; right: 12px; min-width: 0; overflow: hidden; background: transparent; }
.effect-track { margin-left: 12px; margin-right: 12px; }
.effect-controls { display: grid; grid-template-columns: repeat(auto-fit,minmax(74px,1fr)); gap: .35rem; }
.effect-controls label { display: flex; flex-direction: column; font-size: .75rem; gap: .2rem; min-width: 0; }
.effect-controls input, .effect-controls select { width: 100%; min-width: 0; padding: .2rem; font-variant-numeric: tabular-nums; }
.effect-controls input[type=range] { padding: 0; }
.effect-row:focus-within { outline: 2px solid var(--primary); outline-offset: 3px; }
.warp-controls { margin: .7rem 0; }
.result.warping { touch-action: none; cursor: move; }
.revealing .effect-row { animation: reveal-effect .4s both; animation-delay: calc(2.3s + var(--row) * .15s); }
@keyframes reveal-effect { from {opacity:0;transform:translateY(-12px);} to {opacity:1;transform:translateY(0);} }
@media (max-width:600px) {
  .effect-controls { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .effect-controls input,.effect-controls select { font-size:16px; }
  .effect-track,.effect-bar button { height:44px; }
  .span-from,.span-to { width:32px; }
}
@media (prefers-reduced-motion:reduce) { .revealing .effect-row { animation:none; } }
/* Keep the affected ink in view while adjusting a lower bar or the brush. */
.results-card > .result-frame { position: sticky; top: .5rem; z-index: 3; background: var(--surface); }
#effect-editor input, #effect-editor button, #effect-editor select { scroll-margin-top: 19rem; }
@media (max-width:600px) { #effect-editor input, #effect-editor button, #effect-editor select { scroll-margin-top: 11rem; } }
.creation-overlay { position: fixed; pointer-events: none; z-index: 6; }
.effect-top strong { margin-right: auto; }
.span-move { touch-action: none; }
@media (max-height: 500px) {
  .result { height: 140px; aspect-ratio: auto; }
  #effect-editor input, #effect-editor button, #effect-editor select { scroll-margin-top: 10rem; }
}
