/* Apple's look: true black, a colored glow behind everything, Liquid Glass controls on top.
   The glow takes the color of whatever app is on the TV (app.js sets --a and --b). */
:root {
  --a: #3f6dff;
  --b: #8a3ffc;
  --dim: rgba(235, 235, 245, 0.62);
  --spring: cubic-bezier(0.2, 1.3, 0.35, 1);
  --btn: clamp(56px, 17.5vw, 72px);
  --glass-rim: inset 0 0.5px 0 rgba(255, 255, 255, 0.62), inset 0 -0.5px 0 rgba(255, 255, 255, 0.16),
    inset 0.5px 0 0 rgba(255, 255, 255, 0.14), inset -0.5px 0 0 rgba(255, 255, 255, 0.14);
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; background: #000; overflow: hidden; overscroll-behavior: none; }
body {
  position: fixed;
  inset: 0;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; display: block; }
svg .solid { fill: currentColor; stroke: currentColor; stroke-width: 1; }

/* ---- the glow ---- */
.aura { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aura i { position: absolute; width: 95vmax; height: 95vmax; border-radius: 50%; filter: blur(90px); opacity: 0.38; transition: background-color 1.2s ease; }
.aura i:nth-child(1) { left: -55vmax; top: -48vmax; background-color: var(--a); }
.aura i:nth-child(2) { right: -55vmax; bottom: -45vmax; background-color: var(--b); }

/* ---- Liquid Glass ---- */
.glass {
  position: relative;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.17), rgba(255, 255, 255, 0.05) 42%, rgba(255, 255, 255, 0.09));
  -webkit-backdrop-filter: blur(26px) saturate(185%);
  backdrop-filter: blur(26px) saturate(185%);
  box-shadow: var(--glass-rim), 0 10px 34px rgba(0, 0, 0, 0.34);
}
.glass.round {
  width: var(--btn);
  height: var(--btn);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.28s var(--spring), background-color 0.2s ease;
}
.glass.round svg { width: 42%; height: 42%; }
.glass.round.small { --btn: 44px; }
.glass.round.small svg { width: 52%; height: 52%; }
.down { transform: scale(0.88) !important; background-color: rgba(255, 255, 255, 0.22); transition-duration: 0.06s !important; }

/* ---- the page ---- */
#remote {
  height: 100%;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: max(env(safe-area-inset-top), 16px) 16px 0;
}
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now p { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 14px; color: var(--dim); }
#dot { width: 7px; height: 7px; border-radius: 50%; background: #8e8e93; transition: background-color 0.3s; }
#dot.on { background: #30d158; box-shadow: 0 0 8px rgba(48, 209, 88, 0.8); }
#dot.wait { background: #ff9f0a; }

/* ---- the touch surface ---- */
#pad {
  flex: 1 1 0;
  min-height: 190px;
  border-radius: 38px;
  overflow: hidden;
  touch-action: none;
  transform-origin: 50% 50%;
  transition: transform 0.5s var(--spring);
}
#pad.touching { transition: none; }
#pad::before {   /* the sheen along the top edge */
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 42%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent);
  pointer-events: none;
}
#light {
  position: absolute;
  left: -130px;
  top: -130px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.08) 45%, transparent 70%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
#pad.touching #light { opacity: 1; transition-duration: 0.08s; }
#ring {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  opacity: 0;
  pointer-events: none;
}
.chev { position: absolute; width: 24px; height: 24px; opacity: 0.16; pointer-events: none; }
.chev[data-dir="UP"] { top: 16px; left: calc(50% - 12px); }
.chev[data-dir="DOWN"] { bottom: 16px; left: calc(50% - 12px); }
.chev[data-dir="LEFT"] { left: 16px; top: calc(50% - 12px); }
.chev[data-dir="RIGHT"] { right: 16px; top: calc(50% - 12px); }
#hint {
  position: absolute;
  inset: auto 0 50px;
  text-align: center;
  font-size: 13px;
  color: var(--dim);
  transition: opacity 0.5s ease;
  pointer-events: none;
}
#hint.gone { opacity: 0; }
#notice {
  position: absolute;
  inset: 50px 22px auto;
  padding: 12px 16px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.5);
  box-shadow: var(--glass-rim);
  text-align: center;
  font-size: 15px;
  line-height: 1.3;
  pointer-events: none;
}

/* ---- buttons + volume ---- */
.controls { display: flex; justify-content: space-between; align-items: stretch; gap: 12px; }
.keys { display: grid; grid-template-columns: repeat(3, var(--btn)); gap: 12px; flex: 1; justify-content: space-between; }
.volume {
  width: calc(var(--btn) + 6px);
  border-radius: calc(var(--btn) / 2 + 3px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.volume button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background-color 0.2s;
}
.volume button.down { transform: none !important; background-color: rgba(255, 255, 255, 0.16); }
.volume svg { width: 22px; height: 22px; }
#vol-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.1));
  transform: scaleY(0);
  transform-origin: 50% 100%;
  transition: transform 0.25s ease;
  pointer-events: none;
}
#vol-num { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 1px; min-height: 16px; }
#speaker .slash { display: none; }
#speaker.muted .slash { display: inline; }
#speaker.muted .waves { display: none; }

/* ---- apps ---- */
.dock {
  display: flex;
  gap: 10px;
  margin: 0 -16px;
  padding: 2px 16px max(env(safe-area-inset-bottom), 16px);
  overflow-x: auto;
  touch-action: pan-x;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.dock::-webkit-scrollbar { display: none; }
.tile {
  flex: 0 0 auto;
  position: relative;
  width: 104px;
  height: 60px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
  box-shadow: var(--glass-rim), 0 6px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.28s var(--spring), box-shadow 0.25s ease;
  touch-action: pan-x;
}
.tile img { max-width: 72%; max-height: 46%; display: block; pointer-events: none; }
.tile.on { box-shadow: 0 0 0 2px #fff, 0 6px 22px rgba(255, 255, 255, 0.28); }
.netflix { background: #000; }
.youtube, .ytv { background: #fff; color: #0f0f0f; }
.ytv img { max-width: 58%; }
.ytv b { font-size: 12px; font-weight: 800; letter-spacing: -0.02em; }
.disney { background: linear-gradient(180deg, #11306e, #081c44 55%, #0a2f4d); }
.hulu { background: #1ce783; }
.spotify { background: #000; }
.prime { background: linear-gradient(180deg, #1a8cff, #0057d8); }

/* ---- typing ---- */
#sheet {
  position: fixed;
  z-index: 5;
  left: 12px;
  right: 12px;
  top: max(env(safe-area-inset-top), 12px);
  max-width: 436px;
  margin: 0 auto;
  border-radius: 26px;
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(40, 40, 46, 0.72);
}
#typed {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 18px;
  outline: 0;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  font: inherit;
  font-size: 17px;   /* under 16px and iPhones zoom the whole page in */
  -webkit-user-select: text;
  user-select: text;
}
#typed::placeholder { color: var(--dim); }
#sheet-done { padding: 0 10px; height: 44px; font-weight: 600; color: #0a84ff; }

/* ---- pairing ---- */
#pair { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card {
  width: 100%;
  max-width: 380px;
  border-radius: 34px;
  padding: 30px 24px 26px;
  text-align: center;
}
.big { width: 54px; height: 54px; margin: 0 auto 14px; stroke-width: 1.3; }
h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
#pair-text { margin-top: 8px; font-size: 15px; line-height: 1.35; color: var(--dim); }
#pair-error { min-height: 20px; margin-top: 12px; font-size: 14px; color: #ff6961; }
#code-box { position: relative; margin-top: 20px; }
#cells { display: flex; justify-content: center; gap: 7px; }
#cells span {
  width: 42px;
  height: 54px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: var(--glass-rim);
}
#cells span.next { box-shadow: inset 0 0 0 1.5px #fff; }
#code { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 17px; }
.primary {
  width: 100%;
  height: 52px;
  margin-top: 8px;
  border-radius: 26px;
  background: #fff;
  color: #000;
  font-size: 17px;
  font-weight: 600;
  transition: transform 0.28s var(--spring), opacity 0.2s;
}
.primary:active { transform: scale(0.97); }
.primary:disabled { opacity: 0.5; }
