@font-face { font-family: Rubik; font-weight: 400; font-display: swap; src: url(fonts/rubik-latin-400.woff2) format('woff2'); }
@font-face { font-family: Rubik; font-weight: 500; font-display: swap; src: url(fonts/rubik-latin-500.woff2) format('woff2'); }
@font-face { font-family: Rubik; font-weight: 700; font-display: swap; src: url(fonts/rubik-latin-700.woff2) format('woff2'); }
@font-face { font-family: Rubik; font-weight: 400; font-display: swap; src: url(fonts/rubik-hebrew-400.woff2) format('woff2'); unicode-range: U+0590-05FF, U+FB1D-FB4F; }
@font-face { font-family: Rubik; font-weight: 500; font-display: swap; src: url(fonts/rubik-hebrew-500.woff2) format('woff2'); unicode-range: U+0590-05FF, U+FB1D-FB4F; }
@font-face { font-family: Rubik; font-weight: 700; font-display: swap; src: url(fonts/rubik-hebrew-700.woff2) format('woff2'); unicode-range: U+0590-05FF, U+FB1D-FB4F; }

:root {
  --body: #0f3d3e;
  --body-deep: #0a2c2d;
  --body-lift: #17504f;
  --rubber: #f1e6d2;
  --rubber-edge: #bfae93;
  --mustard: #e9b44c;
  --mustard-edge: #a97c25;
  --ink: #12282a;
  --paper: #f4ecdc;
  --soft: #a8c4bf;
  --mascot: #d97757;
  --out: cubic-bezier(.16, 1, .3, 1);
  --dr-bg: #0f3d3e;
  --dr-scrim: rgba(5, 22, 23, .6);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--body);
  color: var(--paper);
  font: 400 17px/1.4 Rubik, system-ui, sans-serif;
  overscroll-behavior: none;
}
.sprite { position: absolute; width: 0; height: 0; }
.hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }

.pixel { display: block; shape-rendering: crispEdges; fill: var(--mascot); overflow: visible; }

/* Rubber keys sit on a hard edge and sink into it when pressed. */
.key {
  min-height: 60px;
  border: 0;
  border-radius: 16px;
  background: var(--rubber);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 6px 0 var(--rubber-edge);
  transition: transform .09s ease-out, box-shadow .09s ease-out;
}
.key:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--rubber-edge); }
.key svg { width: 26px; height: 26px; fill: currentColor; display: block; margin: auto; }
.key-mustard { background: var(--mustard); box-shadow: 0 6px 0 var(--mustard-edge); }
.key-mustard:active { box-shadow: 0 1px 0 var(--mustard-edge); }
.plain { min-height: 44px; padding: 0 6px; background: none; border: 0; color: var(--soft); text-decoration: underline; text-underline-offset: 4px; }
.send { min-height: 48px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--body-lift); color: var(--paper); font-weight: 500; }
input:not([type=range]) {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--body-deep);
  color: var(--paper);
  font: inherit;
  font-size: 16px;
}
input::placeholder { color: var(--soft); }

#login { min-height: 100%; max-width: 360px; margin: 0 auto; padding: 24px 20px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
#login h1 { margin: 0; font-size: 34px; font-weight: 700; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login label { color: var(--soft); }
#login-error { min-height: 24px; margin: 0; color: var(--mustard); }
.login-mascot { width: 112px; height: 80px; animation: bob 1.2s steps(2) infinite; }

#app { height: 100dvh; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.top { display: flex; align-items: center; justify-content: space-between; padding: 4px 18px 0; }
#status { margin: 0; color: var(--soft); font-size: 14px; }
.tab { flex: 1; min-height: 0; width: 100%; max-width: 480px; margin: 0 auto; padding: 8px 18px 14px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }

.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0 12px env(safe-area-inset-bottom); background: var(--body-deep); }
.tabs button { min-height: 62px; background: none; border: 0; color: var(--soft); font-weight: 500; }
.tabs button[aria-current] { color: var(--mustard); }

/* Talk */
#tab-talk { align-items: center; overflow: hidden; }
#log { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding-top: 4px; }
#log:empty::before { content: 'Hold the key below and talk to him, in Hebrew or English.'; margin: auto; max-width: 28ch; text-align: center; color: var(--soft); }
#log p { margin: 0; padding: 9px 14px; max-width: 86%; border-radius: 16px; unicode-bidi: plaintext; animation: pop .34s var(--out) both; }
#log .me { align-self: flex-end; background: var(--body-lift); border-end-end-radius: 4px; }
#log .him { align-self: flex-start; background: var(--paper); color: var(--ink); border-end-start-radius: 4px; }
#stage { flex: none; height: 86px; display: flex; align-items: flex-end; justify-content: center; }
.stage-mascot { width: 112px; height: 80px; }
#stage[data-state=idle] .stage-mascot { animation: bob 1.3s steps(2) infinite; }
#stage[data-state=think] .stage-mascot { animation: think .7s ease-in-out infinite; }
#stage[data-state=talk] .stage-mascot { animation: chatter .34s steps(2) infinite; }
#stage[data-state=listen] .stage-mascot { transform: scale(calc(1 + var(--level, 0) * .16)); transform-origin: 50% 100%; }

.hold-wrap { position: relative; flex: none; width: 148px; height: 148px; display: grid; place-items: center; }
.ring { position: absolute; inset: 0; border-radius: 50%; background: var(--mustard); opacity: 0; pointer-events: none; }
.listening .ring-a { opacity: .24; transform: scale(calc(1.04 + var(--level, 0) * .34)); }
.listening .ring-b { opacity: .14; transform: scale(calc(1.12 + var(--level, 0) * .62)); }
#hold {
  position: relative;
  width: 132px;
  height: 132px;
  border: 0;
  border-radius: 50%;
  background: var(--mustard);
  color: var(--ink);
  box-shadow: 0 9px 0 var(--mustard-edge);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform .09s ease-out, box-shadow .09s ease-out;
}
#hold svg { width: 52px; height: 52px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; pointer-events: none; }
#hold svg rect { fill: currentColor; stroke: none; }
.listening #hold { transform: translateY(7px); box-shadow: 0 2px 0 var(--mustard-edge); }
#hold-hint { margin: -4px 0 0; color: var(--soft); user-select: none; -webkit-user-select: none; }
#chat-form, #text-form { display: flex; gap: 8px; width: 100%; }

/* Remote: a real cross, like the rubber D-pad on a hardware remote. */
.pad { display: grid; grid-template-columns: repeat(3, 84px); grid-template-rows: repeat(3, 76px); gap: 8px; justify-content: center; }
.pad-up { grid-area: 1 / 2; } .pad-left { grid-area: 2 / 1; } .pad-ok { grid-area: 2 / 2; } .pad-right { grid-area: 2 / 3; } .pad-down { grid-area: 3 / 2; }
.row { display: grid; gap: 10px; }
.row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.rocker { display: grid; grid-template-columns: 96px 1fr 96px; align-items: center; text-align: center; color: var(--soft); }
.rocker .key { font-size: 26px; }
.chip { min-height: 44px; padding: 0 15px; border: 0; border-radius: 22px; background: var(--body-lift); color: var(--paper); }
.chip:active { background: var(--mustard); color: var(--ink); }
.chip-alt { background: none; box-shadow: inset 0 0 0 1.5px var(--body-lift); }

/* Music */
#tab-music { justify-content: center; gap: 20px; }
#music { display: flex; flex-direction: column; gap: 14px; }
#music-empty { display: flex; flex-direction: column; gap: 14px; text-align: center; color: var(--soft); }
#song { margin: 0; font-size: 38px; line-height: 1.12; font-weight: 700; unicode-bidi: plaintext; overflow-wrap: anywhere; }
#artist { margin: 0; color: var(--soft); font-size: 20px; unicode-bidi: plaintext; }
#seek { width: 100%; height: 44px; margin: 6px 0 0; accent-color: var(--mustard); background: none; }
.transport { display: grid; grid-template-columns: 1fr 1.5fr 1fr; gap: 12px; margin-top: 8px; }
.transport .key { min-height: 76px; font-size: 19px; }

/* More drawer */
#more [data-drawer-panel] { color: var(--paper); padding: calc(env(safe-area-inset-top) + 12px) 18px 18px; gap: 12px; }
#more header, #more footer { display: flex; justify-content: space-between; align-items: center; }
#more h2 { margin: 0; font-size: 24px; }
#more h3 { margin: 0 0 8px; font-size: 16px; font-weight: 500; color: var(--soft); }
#more [data-drawer-body] { flex: 1; min-height: 0; overflow-y: auto; }
#face-setup, #spotify-setup { margin-bottom: 26px; }
#face-setup p, #spotify-setup p { margin: 0 0 14px; }
#face-enable { width: 100%; padding: 0 16px; }
#spotify-connect { display: grid; place-items: center; text-decoration: none; }
#crashes { margin: 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.5 Rubik, sans-serif; color: var(--paper); }

@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes think { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
@keyframes chatter { 50% { transform: translateY(-5px) scaleY(1.05); } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.96); } }
