/* Sentence parts (PV-001, js/sentence-parts.js): the violet word you change, the number you drag, the bold answer and the
   word picker (a gentle menu on a laptop, a bottom sheet on a phone). Link it after pocket.css: it uses its Money · Ledger
   tokens (--accent, --surface*, --text*, --shadow-*). Three kinds of word, never alike: violet with a solid underline
   (you change it), bold (the answer); dotted (opens the detail) comes with SQ-005.
   Brief: docs/briefs/planning-v2.md, docs/briefs/sentence-query.md */

.sp { text-wrap: pretty; }
.sp-nw { white-space: nowrap; }   /* "$600," never breaks before its comma */

/* the words you change: violet, solid underline; numbers drag sideways */
.sp-word, .sp-num {
  all: unset; display: inline-block; box-sizing: border-box; cursor: pointer; white-space: nowrap;
  color: var(--accent); font-variant-numeric: tabular-nums;
  text-decoration: underline solid color-mix(in srgb, var(--accent) 45%, transparent);
  text-decoration-thickness: max(2px, .09em); text-underline-offset: .2em;
  padding: 0 2px; margin: 0 -2px; border-radius: 6px;
  transition: background-color .15s, text-decoration-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.sp-word[aria-expanded="true"], .sp-num.sp-open { background: color-mix(in srgb, var(--accent) 12%, transparent); text-decoration-color: var(--accent); }
@media (hover: hover) {
  .sp-word:hover, .sp-num:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); text-decoration-color: var(--accent); }
}
.sp-word:focus-visible, .sp-num:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sp-num { cursor: ew-resize; text-align: right; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.sp-num.sp-dragging { background: color-mix(in srgb, var(--accent) 18%, transparent); text-decoration-color: var(--accent); }
.sp-drag-cursor, .sp-drag-cursor * { cursor: ew-resize !important; user-select: none !important; -webkit-user-select: none !important; }

/* the engine's own kinds: your saved word wears a small star; a word it doesn't know stays grey with a "?" */
.sp-word.sp-mine::before { content: "★" / ""; display: inline-block; margin-right: 3px; font-size: .62em; vertical-align: .32em; text-decoration: none; }
.sp-word.sp-empty { color: var(--text-dim); font-weight: 600; }   /* a placeholder to tap, not an error: the violet underline stays */
.sp-word.sp-unknown { color: var(--text-dim); text-decoration-style: dotted; text-decoration-color: var(--yellow); }
.sp-word.sp-unknown::after { content: "?" / ""; display: inline-block; margin-left: 2px; font-size: .6em; vertical-align: .4em; color: var(--yellow); text-decoration: none; }

/* a picked word flashes once (a tint, no movement) */
.sp-word.sp-just { animation: sp-just 700ms cubic-bezier(.2, 0, 0, 1); }
@keyframes sp-just { from { background: color-mix(in srgb, var(--accent) 30%, transparent); } }

/* the answer: bold, tabular, updated in place (never animated) */
.sp-ans { display: inline-block; white-space: nowrap; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* the one-line hint, until the first drag */
.sp-hint { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font: 500 12.5px/1.4 var(--font-sans); color: var(--text-dim); }
.sp-hint[hidden] { display: none; }
.sp-hint-ico { width: 16px; height: 16px; flex: none; color: var(--accent); }

/* the picker: in the top layer, opaque, one soft shadow (omxqua menu: radius 14, items 8) */
.sp-picker {
  position: fixed; inset: auto; margin: 0; z-index: 1000; box-sizing: border-box;
  min-width: 220px; max-width: min(340px, calc(100vw - 24px)); max-height: min(380px, calc(100dvh - 24px));
  overflow: auto; overscroll-behavior: contain; padding: 6px; border: 0; border-radius: 14px;
  background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-md);
  font: 500 14px/1.35 var(--font-sans); letter-spacing: 0; text-align: left;
}
[data-theme="light"] .sp-picker { background: var(--surface); }
.sp-picker[hidden] { display: none; }
.sp-picker::backdrop { background: transparent; }
.sp-pk-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px 4px; }
.sp-pk-head[hidden] { display: none; }
.sp-pk-title { font: 600 12.5px/1.3 var(--font-sans); color: var(--text-dim); }

/* a word that can be typed: the field above its options */
.sp-type { padding: 4px 6px 6px; }
.sp-type-in { box-sizing: border-box; width: 100%; min-height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: rgb(from var(--text) r g b / .07); color: var(--text); font: 500 14px var(--font-sans); outline: none; }
.sp-type-in::placeholder { color: var(--text-dim); }
.sp-type-in:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sp-sheet .sp-type { padding: 4px 14px 8px; }
.sp-sheet .sp-type-in { min-height: 48px; font-size: 16px; }   /* 16px: a phone does not zoom the page into the field */
.sp-opt {
  all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--text); font: 500 14px/1.3 var(--font-sans);
}
.sp-opt:focus { background: rgb(from var(--text) r g b / .08); }
.sp-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }   /* drawn inside, never clipped */
@media (hover: hover) { .sp-opt:hover { background: rgb(from var(--text) r g b / .08); } }
.sp-opt[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.sp-hued::before { content: ""; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--sp-hue); }
.sp-opt-t { flex: 1 1 auto; min-width: 0; }
.sp-opt-n { flex: none; white-space: nowrap; font: 500 12px var(--font-sans); color: var(--text-dim); }
.sp-ck { flex: none; width: 16px; height: 16px; opacity: 0; }
.sp-opt[aria-checked="true"] .sp-ck { opacity: 1; }
.sp-act { color: var(--text-mid); }
.sp-sep { height: 1px; margin: 6px 4px; background: var(--border); }

/* a tap on a number: its value, a slider and its range */
.sp-picker.sp-slider { min-width: 280px; }
.sp-sl-val { padding: 2px 10px 0; font: 600 26px/1.2 var(--font-sans); letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--text); }
.sp-range { -webkit-appearance: none; appearance: none; display: block; box-sizing: border-box; width: calc(100% - 20px); height: 28px; margin: 12px 10px 8px; background: transparent; cursor: pointer; }
.sp-range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--accent-fill) var(--sp-fill, 50%), rgb(from var(--text) r g b / .14) var(--sp-fill, 50%)); }
.sp-range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border: 0; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 2px var(--accent-fill); }
.sp-range::-moz-range-track { height: 6px; border-radius: 999px; background: rgb(from var(--text) r g b / .14); }
.sp-range::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent-fill); }
.sp-range::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 2px var(--accent-fill); }
.sp-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 999px; }
.sp-sl-hint { padding: 0 10px 6px; font: 500 12.5px/1.4 var(--font-sans); color: var(--text-dim); }

/* phone: the same picker as a sheet along the bottom, under the thumb (48 px rows, a grabber, a close button) */
.sp-picker.sp-sheet {
  left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: auto;
  min-width: 0; max-width: none; max-height: min(72dvh, 560px); padding: 0 8px 10px; border-radius: 22px;
  box-shadow: var(--shadow-lg); font-size: 16px; transition: transform .22s cubic-bezier(.2, 0, 0, 1);
}
.sp-picker.sp-sheet::backdrop { background: rgb(13 12 18 / .45); }   /* a literal: custom properties don't reach ::backdrop in older browsers, and a missing dim would be worse */
.sp-sheet .sp-pk-head { position: relative; justify-content: center; min-height: 56px; padding: 18px 56px 6px; touch-action: none; }   /* the grab strip takes the finger: drag down to close (js/pocket-gestures.js) */
.sp-grab { position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 999px; background: rgb(from var(--text) r g b / .22); }
.sp-sheet .sp-pk-title { font: 600 15px/1.3 var(--font-sans); color: var(--text); text-align: center; }
.sp-pk-close { all: unset; box-sizing: border-box; position: absolute; top: 6px; right: 2px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; color: var(--text-mid); }
.sp-pk-close::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: rgb(from var(--text) r g b / .08); }
.sp-pk-close:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sp-x { position: relative; width: 16px; height: 16px; }
.sp-sheet .sp-opt { min-height: 48px; padding: 0 14px; border-radius: 12px; font-size: 16px; }
.sp-sheet .sp-opt-n { font-size: 13px; }
.sp-sheet .sp-sl-val { font-size: 30px; text-align: center; }
.sp-sheet .sp-sl-hint { text-align: center; }
.sp-sheet .sp-range { height: 48px; }
.sp-sheet .sp-range::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -11px; }

@media (prefers-reduced-motion: reduce) {
  .sp-picker.sp-sheet { transition: none; }
  .sp-word.sp-just { animation: none; }
}
