/* Górne słowa snu (layers/hud.js): stale widoczne, przygaszone, bez pudełek.
   Sam pasek nie łapie myszy; łapią ją tylko tytuł po lewej i dwa znaki po prawej (cofnij, oko). */

.dream-ui > .hud {
  --hud-sleep: 0; /* 0..1, głęboki sen: słowa przygasają razem z całym snem */
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 64px;
  pointer-events: none;
  opacity: calc(1 - 0.6 * var(--hud-sleep));
  transition: opacity 1.2s var(--ease-out);
}

/* Przyciemnienie u góry, bez krawędzi: górna linia wchodzi na kafelki i bez niego znika na jasnych obrazach. */
.dream-ui > .hud::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 96px;
  background: linear-gradient(180deg, rgba(13, 11, 9, 0.8) 0%, rgba(13, 11, 9, 0.62) 38%, rgba(13, 11, 9, 0) 100%);
}

.hud .word-key {
  position: absolute;
  right: 100%;
  top: 13px;
}

.hud-left,
.hud-right {
  position: absolute;
  top: 20px;
  display: flex;
  align-items: center;
  height: 24px;
  gap: 22px;
}

.hud-left {
  left: 28px;
}

.hud-right {
  right: 28px;
  gap: 20px;
}

.hud .word {
  pointer-events: auto;
  font-weight: 500;
  color: var(--ink-dim);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}

.hud .word:hover,
.hud .word:focus-visible {
  color: var(--ink);
}

.hud .hud-title {
  color: var(--gold-dim);
  letter-spacing: 0.2em;
}

.hud .hud-title:hover {
  color: var(--gold);
}

.hud-note {
  color: var(--ink-dim);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}

/* Kreska ołówka lecąca od kafelka do oka (po pierwszym wyborze). */
.hud-flight {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.hud-flight path {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.3;
  stroke-linecap: round;
  opacity: 0.85;
}

.hud .word:disabled {
  color: var(--ink-faint);
  opacity: 0.55;
}

.hud .word[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- znak „cofnij” */

.hud-undo {
  flex: none;
  width: 38px;
  height: 32px;
  margin: -4px -4px;
  padding: 4px;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  color: var(--pencil);
  opacity: 0.78;
  transition: opacity 0.4s var(--ease-out);
}

.hud-undo[hidden] {
  display: none;
}

.hud-undo:hover,
.hud-undo:focus-visible {
  opacity: 1;
  outline: 0;
}

/* Nie ma czego cofać: znak zostaje na miejscu (nic nie skacze), tylko gaśnie. */
.hud-undo:disabled {
  opacity: 0.26;
  cursor: default;
}

.undo-sign {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.9));
}

.undo-sign path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- oko senności */

.hud-eye {
  flex: none;
  width: 44px;
  height: 30px;
  margin: -3px -4px;
  padding: 2px;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  color: var(--pencil);
  opacity: 0.78;
  transition:
    color 0.8s var(--ease-out),
    opacity 0.4s var(--ease-out);
}

.hud-eye:hover,
.hud-eye:focus-visible {
  opacity: 1;
  outline: 0;
}

.sleep-eye {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.9));
}

.sleep-lid,
.sleep-lashes path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* Powieka opada płynnie tam, gdzie przeglądarka umie animować kształt ścieżki. */
.sleep-lid,
.sleep-eye clipPath path {
  transition: d 1.4s var(--ease-out);
}

.sleep-iris {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
}

.sleep-pupil {
  fill: currentColor;
}

/* Rzęsy widać dopiero na zamkniętym oku. */
.sleep-lashes {
  opacity: 0;
  transition: opacity 0.9s var(--ease-out);
}

.hud-eye.is-full {
  color: var(--gold);
  opacity: 1;
  animation: sleep-pulse 3.6s ease-in-out infinite;
}

.hud-eye.is-full .sleep-lashes {
  opacity: 1;
}

/* Krótki złoty błysk: do oka wpadł okruch z mroku albo pierwszy wybór. */
.hud-eye.is-glint {
  animation: eye-glint 0.9s var(--ease-out);
}

@keyframes eye-glint {
  0% {
    color: var(--gold);
    filter: drop-shadow(0 0 0 rgba(232, 200, 154, 0));
  }
  22% {
    color: var(--gold);
    filter: drop-shadow(0 0 9px rgba(232, 200, 154, 0.95));
    opacity: 1;
  }
  100% {
    filter: drop-shadow(0 0 0 rgba(232, 200, 154, 0));
  }
}

@keyframes sleep-pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(232, 200, 154, 0));
    opacity: 0.72;
  }
  50% {
    filter: drop-shadow(0 0 7px rgba(232, 200, 154, 0.7));
    opacity: 1;
  }
}

[data-motion='quiet'] .hud-eye.is-full {
  animation: none;
}

/* ---------------------------------------------------------------- „cofnięto: …” */

/* Linijka zjeżdża spod prawych słów; ciemne podłoże bez krawędzi, żeby dało się ją czytać na obrazach. */
.hud-toast {
  position: absolute;
  right: 28px;
  top: 58px;
  z-index: 0;
  max-width: 46vw;
  font: 400 var(--size-small) / 1.4 var(--font-read);
  color: var(--ink);
  white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.95);
}

.hud-toast::before {
  content: '';
  position: absolute;
  inset: -12px -26px -14px;
  z-index: -1;
  border-radius: 24px;
  background: rgba(13, 11, 9, 0.86);
  filter: blur(10px);
}

/* ---------------------------------------------------------------- linijka „co to robi” (layers/hint.js) */

/* Lewy margines ten sam co w kolumnie tekstu skupienia (.focus-col): tytuł, pytanie i ta linijka stoją w pionie. */
.dream-ui > .hint-line {
  position: absolute;
  left: max(40px, 4.1vw);
  bottom: 18px;
  width: min(46vw, 620px);
  height: 3em;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
  font: 400 var(--size-small) / 1.5 var(--font-read);
}

.hint-text {
  position: relative;
  z-index: 0;
  margin: 0;
  color: var(--ink-dim);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.95);
}

.hint-text:not(:empty)::before {
  content: '';
  position: absolute;
  inset: -12px -24px -14px;
  z-index: -1;
  border-radius: 24px;
  background: rgba(13, 11, 9, 0.8);
  filter: blur(10px);
}

/* ---------------------------------------------------------------- pasek nocy (layers/night-bar.js) */

/* Prawy dolny róg mapy: słowo „wyśnij noc” (albo postęp nocy) nad cienką osią senności. */
.dream-ui > .night-dock {
  position: absolute;
  right: max(40px, 4.1vw);
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  pointer-events: auto;
  opacity: calc(0.9 - 0.5 * var(--hud-sleep, 0));
  transition: opacity 0.6s var(--ease-out);
}

.night-dock-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  min-height: 30px;
  font: 400 var(--size-small) / 1.5 var(--font-read);
}

.night-dock .word {
  color: var(--ink-dim);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.95);
}

.night-dock[data-state='ready'] .word {
  color: var(--ink);
}

.night-dock .word.is-confirm {
  color: var(--gold);
}

.night-dock[data-state='idle'] .word {
  opacity: 0.42;
  cursor: default;
}

.night-dock-status {
  color: var(--gold);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.95);
  animation: night-dock-breathe 3.4s ease-in-out infinite;
}

.night-dock-status[hidden],
.night-dock .word[hidden] {
  display: none;
}

.night-dock-axis {
  display: block;
  overflow: visible;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.9));
}

.night-dock-axis path {
  fill: none;
  stroke-linecap: round;
}

.night-dock.is-dreaming .night-bar-fill {
  animation: night-dock-breathe 3.4s ease-in-out infinite;
}

@keyframes night-dock-breathe {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* W skupieniu na kafelku, w kamerze i w nasłuchu róg należy do tamtych ekranów. */
.dream[data-focus] .night-dock,
.dream.is-somnura .night-dock,
.dream[data-focus] .ready-stack {
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- powiadomienia „gotowe” (layers/ready.js) */

.dream-ui > .ready-stack {
  position: absolute;
  right: max(40px, 4.1vw);
  bottom: 76px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  pointer-events: none;
  font: 400 var(--size-small) / 1.5 var(--font-read);
  transition: opacity 0.6s var(--ease-out);
}

.ready-list {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.ready-note {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(6px);
  filter: blur(6px);
  transition:
    opacity 0.7s var(--ease-out),
    transform 0.7s var(--ease-out),
    filter 0.7s var(--ease-out);
}

.ready-note.is-on {
  opacity: 1;
  transform: none;
  filter: none;
}

.ready-note .word {
  color: var(--gold);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.95);
}

.ready-note.is-quiet .word {
  color: var(--ink-dim);
}

.ready-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(232, 200, 154, 0.7);
  animation: ready-pulse 2.6s ease-in-out infinite;
}

.ready-note.is-quiet .ready-dot {
  background: var(--ink-faint);
  box-shadow: none;
  animation: none;
}

@keyframes ready-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

.ready-pending {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  color: var(--pencil);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.95);
}

.ready-pending[hidden] {
  display: none;
}

.ready-eye {
  width: 26px;
  height: 17px;
  overflow: visible;
  animation: ready-eye-blink 4.6s ease-in-out infinite;
  transform-origin: 50% 52%;
}

@keyframes ready-eye-blink {
  0%, 82%, 100% { transform: scaleY(1); }
  90% { transform: scaleY(0.12); }
}

@media (prefers-reduced-motion: reduce) {
  .ready-dot,
  .ready-eye,
  .night-dock-status,
  .night-dock.is-dreaming .night-bar-fill {
    animation: none;
  }
}
