/* הטווח שלי - Daniel's vocal range tool. Songbook palette (navy night + violet, gold for the one thing that matters),
   Daniel Letters. A tool: fast and quiet, one focal point per screen. Motion tokens from design-interaction-dna. */
@font-face { font-family: "Daniel Letters"; font-weight: 400; font-display: swap; src: url("fonts/DanielLetters-Regular.woff2") format("woff2"); }
@font-face { font-family: "Daniel Letters"; font-weight: 500; font-display: swap; src: url("fonts/DanielLetters-Medium.woff2") format("woff2"); }
@font-face { font-family: "Daniel Letters"; font-weight: 700; font-display: swap; src: url("fonts/DanielLetters-Bold.woff2") format("woff2"); }
@font-face { font-family: "Daniel Letters"; font-weight: 900; font-display: swap; src: url("fonts/DanielLetters-Black.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --bg: #0b1340;
  --bg-2: #1a1560;
  --surface: #141d55;
  --line: rgba(255, 255, 255, .12);
  --text: #ffffff;
  --muted: #b9c8ee;
  --quiet: #7d8bbd;
  --gold: #ffde59;
  --gold-2: #f2b53b;
  --violet: #8c30fe;
  --blue: #2a66e0;
  --easy: #ffde59;          /* the comfortable range: the one band the eye should find */
  --ok: #8fb3ff;            /* possible */
  --edge: #5b4fa8;          /* reachable with effort */
  --head: #c78cff;          /* falsetto */
  --good: #7ee0a0;
  --warn: #ff9b7a;
  --radius: 14px;
  --gutter: 16px;

  --dur-instant: 90ms; --dur-fast: 160ms; --dur-base: 240ms; --dur-medium: 360ms;
  --ease-out: cubic-bezier(.16, 1, .3, 1); --ease-in: cubic-bezier(.55, 0, 1, .45); --ease-pop: cubic-bezier(.34, 1.36, .64, 1);
  --rise-sm: 8px; --rise: 14px; --press: .97; --dir: -1;
}
@media (prefers-reduced-motion: reduce) { :root { --rise-sm: 0px; --rise: 0px; --press: 1; --dur-medium: 160ms; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }
body {
  margin: 0; min-height: 100dvh; color: var(--text);
  font-family: "Daniel Letters", "Rubik", system-ui, sans-serif; font-size: 17px; line-height: 1.5;
  background: radial-gradient(120% 70% at 85% -10%, #2b1a7a 0%, transparent 60%), var(--bg);
  background-attachment: scroll;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button { font: inherit; color: inherit; }
:where(a, button, [tabindex]):focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--gold); border-radius: 10px; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(var(--gutter), env(safe-area-inset-right, 0px)) 8px max(var(--gutter), env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.back { width: 44px; height: 44px; margin-inline-start: -10px; display: grid; place-items: center; border: 0; background: none; border-radius: 12px; cursor: pointer; }
.back svg { width: 24px; height: 24px; }
.back:active { transform: scale(var(--press)); }
.bar-title { font-size: 19px; font-weight: 700; margin: 0; flex: 1; }
.mic-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px rgba(126, 224, 160, .18); }

main { display: block; max-width: 560px; margin: 0 auto; padding: 20px max(var(--gutter), env(safe-area-inset-right, 0px)) 120px max(var(--gutter), env(safe-area-inset-left, 0px)); outline: none; }
/* The screen fades in; only its text rises. The section itself never gets a transform: that would trap the fixed
   action bar inside it (a transformed ancestor becomes the containing block of position: fixed). */
main > * { animation: fade var(--dur-medium) var(--ease-out) backwards; }
main > * > :is(h2, .lead, .step-no) { animation: enter var(--dur-medium) var(--ease-out) backwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes enter { from { opacity: 0; transform: translateY(var(--rise-sm)); } }

h2 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; font-weight: 900; text-wrap: balance; }
h3 { font-size: 18px; margin: 28px 0 10px; font-weight: 700; color: var(--muted); }
p { margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 17px; max-width: 34em; }
.small { font-size: 14px; color: var(--quiet); }
.step-no { font-size: 14px; color: var(--quiet); letter-spacing: .02em; margin-bottom: 4px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-size: 17px; font-weight: 700; text-decoration: none; transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast);
}
.btn:active:not(:disabled) { transform: scale(var(--press)); transition-duration: var(--dur-instant); }
.btn.primary { background: var(--gold); color: #1b1240; border-color: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; }
.btn.link { background: none; border-color: transparent; color: var(--muted); padding: 0 8px; min-height: 44px; font-weight: 500; }
.btn svg { width: 20px; height: 20px; flex: none; }

/* sticky action area at the bottom: the next step is always in reach of the thumb */
.actions {
  position: fixed; inset: auto 0 0 0; z-index: 4; display: flex; gap: 10px; justify-content: center;
  padding: 12px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.actions .btn { flex: 1; max-width: 300px; }
.actions .why { position: absolute; inset: -14px 0 auto; text-align: center; font-size: 14px; color: var(--quiet); pointer-events: none; }

/* home menu: plain rows, not cards */
.rows { margin-top: 26px; border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 10px 2px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: start; cursor: pointer; }
.row:active { background: rgba(255, 255, 255, .04); }
.row .t { font-size: 18px; font-weight: 700; display: block; }
.row .d { font-size: 14px; color: var(--quiet); display: block; }
.row .go { margin-inline-start: auto; color: var(--quiet); }
.row .go svg { width: 18px; height: 18px; transform: scaleX(-1); }

/* the big readout */
.big-range { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 18px 0 2px; direction: ltr; justify-content: flex-end; }
.big-range .n { font-size: 52px; line-height: 1; font-weight: 900; }
.big-range .dash { font-size: 32px; color: var(--quiet); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin: 18px 0 6px; }
.fact .k { font-size: 14px; color: var(--quiet); display: block; }
.fact .v { font-size: 22px; font-weight: 700; }
.fact .v .s { font-size: 15px; color: var(--muted); font-weight: 500; margin-inline-start: 6px; }
.fact.key .v { color: var(--easy); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* keyboard strip: one fixed frame C2..C6 so ranges are compared by eye, never rescaled */
.kbd-wrap { margin: 16px 0 6px; }
.kbd { display: block; width: 100%; height: auto; direction: ltr; }
.kbd-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.kbd-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }

/* live note */
.live { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 6px 16px; margin: 18px 0 10px; min-height: 96px; }
.live .note { font-size: 64px; line-height: .95; font-weight: 900; direction: ltr; min-width: 2.6ch; }
.live .note.idle { color: var(--quiet); }
.live .sol { font-size: 20px; color: var(--muted); }
.live .hz { font-size: 13px; color: var(--quiet); direction: ltr; text-align: end; }
.found { display: flex; align-items: baseline; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 10px 0 14px; min-height: 58px; }
.found .k { color: var(--quiet); font-size: 15px; }
.found .v { font-size: 30px; font-weight: 900; color: var(--easy); direction: ltr; }
.found .v.none { color: var(--quiet); font-size: 18px; font-weight: 500; }
.found .s { color: var(--muted); }
.found.bump .v { animation: bump var(--dur-base) var(--ease-pop); }
@keyframes bump { from { transform: scale(1.12); } }

canvas.trace { display: block; width: 100%; height: 230px; border-radius: 12px; background: rgba(0, 0, 0, .18); touch-action: pan-y; }

/* tuning needle against a target */
.tune { position: relative; height: 54px; margin: 16px 0 6px; direction: ltr; }
.tune .track { position: absolute; inset: 24px 0 auto; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--warn) 0 25%, var(--line) 25% 40%, var(--good) 40% 60%, var(--line) 60% 75%, var(--warn) 75%); opacity: .7; }
.tune .mid { position: absolute; left: 50%; top: 12px; width: 2px; height: 30px; background: var(--text); opacity: .5; transform: translateX(-1px); }
.tune .needle { position: absolute; top: 8px; left: 50%; width: 14px; height: 38px; margin-left: -7px; border-radius: 7px; background: var(--gold); transition: left 90ms linear, opacity var(--dur-fast); }
.tune .needle.off { opacity: .2; }
.tune-label { text-align: center; min-height: 26px; color: var(--muted); }
.hold { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 10px 0 4px; }
.hold > i { display: block; height: 100%; width: 0; background: var(--good); transition: width 90ms linear; }

.target { text-align: center; margin: 8px 0 0; }
.target .n { font-size: 64px; font-weight: 900; line-height: 1; direction: ltr; }
.target .sol { font-size: 20px; color: var(--muted); }

.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.rate .btn { flex-direction: column; gap: 0; min-height: 70px; padding: 6px; }
.rate .btn small { font-weight: 400; font-size: 13px; color: var(--quiet); }
.rate .btn[data-r="easy"] { border-color: var(--easy); }
.ladder { display: flex; flex-wrap: wrap; gap: 6px; direction: ltr; justify-content: center; margin: 14px 0 0; }
.ladder span { min-width: 40px; padding: 3px 6px; border-radius: 8px; text-align: center; font-size: 13px; border: 1px solid var(--line); color: var(--quiet); }
.ladder .easy { background: var(--easy); color: #1b1240; border-color: transparent; }
.ladder .ok { background: var(--ok); color: #101a40; border-color: transparent; }
.ladder .hard { border-color: var(--warn); color: var(--warn); }
.ladder .miss { text-decoration: line-through; }
.ladder .now { border-color: var(--text); color: var(--text); }

.tip { border-inline-start: 3px solid var(--gold); padding: 4px 12px; color: var(--muted); font-size: 15px; margin: 14px 0; }

/* history */
.hist { list-style: none; padding: 0; margin: 16px 0 0; border-top: 1px solid var(--line); }
.hist li { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.hist .open { flex: 1; display: block; text-align: start; padding: 12px 2px; border: 0; background: none; cursor: pointer; min-height: 64px; }
.hist .when { color: var(--quiet); font-size: 14px; }
.hist .what { font-size: 18px; font-weight: 700; }
.hist .del { width: 44px; height: 44px; border: 0; background: none; color: var(--quiet); cursor: pointer; border-radius: 10px; }

.picker { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0; direction: ltr; }   /* minus on the left, plus on the right: the way the keyboard above goes */
.picker .btn { width: 56px; padding: 0; font-size: 24px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 6px 0 4px; }
.seg button { min-height: 44px; border: 0; background: none; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--gold); font-weight: 700; }

.empty { color: var(--muted); padding: 30px 0; }
.mic-ask { text-align: start; padding-top: 10px; }

.toast {
  position: fixed; z-index: 9; inset-inline: 16px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); max-width: 420px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 12px; background: #f4f1ff; color: #1b1240;
  animation: toast var(--dur-medium) var(--ease-out);
}
.toast button { margin-inline-start: auto; border: 0; background: none; color: #4b2bd0; font-weight: 700; min-height: 40px; padding: 0 10px; cursor: pointer; }
@keyframes toast { from { opacity: 0; transform: translateY(var(--rise)); } }

@media (min-width: 900px) {
  main { padding-top: 36px; }
  canvas.trace { height: 280px; }
  .actions { position: static; background: none; padding: 18px 0 0; justify-content: flex-start; }
  .actions .why { position: static; order: 9; align-self: center; text-align: start; }
}
.hist div.open { cursor: default; }
