/* ==========================================================================
   Akvárium – šetrič obrazovky
   Celoobrazovkový canvas + nenápadný HUD, ktorý sa zjaví len pri pohybe.
   ========================================================================== */

:root {
  --deep: #06141c;
  --glass: rgba(8, 24, 31, 0.58);
  --glass-strong: rgba(8, 24, 31, 0.78);
  --line: rgba(214, 240, 236, 0.14);
  --text: #e4f2ef;
  --text-dim: rgba(228, 242, 239, 0.62);
  --accent: #7fe3d2;
  --accent-ink: #05211d;

  --radius: 16px;
  --tap: 44px;
  --gap: 6px;
  --edge: max(14px, env(safe-area-inset-bottom));
  --edge-x: max(14px, env(safe-area-inset-right));

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --fade: 420ms;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--deep);
  color: var(--text);
  font: 14px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* --- Scéna ---------------------------------------------------------------- */

#tank {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default;

  &.is-feed-zone {
    cursor: pointer;
  }
}

body.is-idle #tank {
  cursor: none;
}

/* --- Hodiny --------------------------------------------------------------- */

.clock {
  position: fixed;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  font-weight: 200;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: rgba(236, 248, 246, 0.34);
  text-shadow: 0 2px 22px rgba(0, 20, 30, 0.5);
  pointer-events: none;
  user-select: none;
}

/* --- Úvodná nápoveda ------------------------------------------------------ */

.hint {
  position: fixed;
  left: 50%;
  top: 19vh;
  max-width: min(92vw, 760px);
  margin: 0;
  padding: 9px 16px;
  translate: -50% 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  text-wrap: balance;
  pointer-events: none;
  opacity: 0;
  transition: opacity 900ms var(--ease), translate 900ms var(--ease);

  &.is-visible {
    opacity: 0.92;
  }

  &:not(.is-visible) {
    translate: -50% -8px;
  }
}

/* --- HUD (auto-hide) ------------------------------------------------------ */

.hud {
  position: fixed;
  right: var(--edge-x);
  bottom: var(--edge);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  opacity: 0;
  visibility: hidden;
  translate: 0 10px;
  transition:
    opacity var(--fade) var(--ease),
    translate var(--fade) var(--ease),
    visibility 0s linear var(--fade);
}

/* Zámerne plochý selektor: bez neho by sa HUD v prehliadači bez CSS nestingu nikdy nezobrazil. */
.hud.is-visible {
  opacity: 1;
  visibility: visible;
  translate: 0 0;
  transition-delay: 0s;
}

.bar,
.panel {
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  box-shadow: 0 10px 34px rgba(0, 10, 16, 0.38);
}

.bar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 5px;
  border-radius: 999px;
}

.sep {
  width: 1px;
  height: 22px;
  margin-inline: 2px;
  background: var(--line);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: var(--tap);
  height: var(--tap);
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);

  &:hover {
    background: rgba(214, 240, 236, 0.12);
  }

  &:active {
    background: rgba(214, 240, 236, 0.2);
  }

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  &[aria-pressed="true"],
  &[aria-expanded="true"] {
    background: var(--accent);
    color: var(--accent-ink);
  }

  &.has-label {
    padding-inline: 12px 15px;
  }

  & svg {
    width: 22px;
    height: 22px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

.icon {
  display: inline-flex;
}

.btn-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* --- Panel nastavení ------------------------------------------------------ */

.panel {
  width: min(330px, calc(100vw - 2 * var(--edge-x)));
  /* panel je vyšší než malé okno – roluje sa vo vlastnom rámci nad lištou */
  max-height: calc(100vh - var(--tap) - 2 * var(--edge) - 34px);
  max-height: calc(100dvh - var(--tap) - 2 * var(--edge) - 34px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(214, 240, 236, 0.3) transparent;
  padding: 16px 18px 14px;
  border-radius: var(--radius);
  background: rgba(8, 24, 31, 0.88); /* veľa textu – panel musí byť čitateľný aj nad pestrou scénou */

  &[hidden] {
    display: none;
  }
}

.panel-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;

  & output {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    font-size: 12px;
  }
}

input[type="range"] {
  --track: rgba(214, 240, 236, 0.2);
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;

  &::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: var(--track);
  }

  &::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: var(--track);
  }

  &::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    margin-top: -7px;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
    appearance: none;
    -webkit-appearance: none;
  }

  &::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  }

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
  }
}

.group {
  min-width: 0;
  margin: 14px 0 6px;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);

  & legend {
    padding: 0 8px 0 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
  }
}

/* prepínače druhov: skutočný checkbox je neviditeľne roztiahnutý cez celý štítok */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 14px;
}

.chip {
  position: relative;
  display: inline-flex;
  cursor: pointer;

  & input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
  }

  & span {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text-dim);
    font-size: 13px;
    transition: background-color 160ms var(--ease), color 160ms var(--ease);
  }

  & input:checked + span {
    border-color: transparent;
    background: var(--accent);
    color: var(--accent-ink);
  }

  & input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

.select,
.time input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(214, 240, 236, 0.08);
  color: var(--text);
  font: inherit;
  cursor: pointer;

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

.select {
  width: 100%;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 14px;
}

.pill {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;

  &.is-quiet {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    font-weight: 400;
  }

  &:disabled {
    opacity: 0.4;
    cursor: default;
  }

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

.times {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.time {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-dim);

  & input {
    flex: 1;
    min-width: 0;
  }
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  cursor: pointer;

  & input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
  }

  & input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

.keys {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.9;

  & kbd {
    padding: 1px 5px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: rgba(214, 240, 236, 0.08);
    color: var(--text);
    font: inherit;
  }
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--text);
}

/* --- Úzke obrazovky ------------------------------------------------------- */

@media (max-width: 520px) {
  .hud {
    left: var(--edge-x);
    align-items: center;
  }

  .btn-label {
    display: none;
  }

  .btn.has-label {
    padding-inline: 11px;
  }

  .hint {
    font-size: 12px;
  }

  /* lišta je na úzkych displejoch vycentrovaná dole – hodiny sa posunú nad ňu */
  .clock {
    bottom: calc(var(--edge) + var(--tap) + 26px);
  }
}

@media (hover: none) {
  .keys {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hud,
  .hint {
    transition-duration: 1ms;
  }
}

/* ---- doplnky panela -------------------------------------------------------- */

.panel-title + .actions {
  margin: 0 0 6px;
}

.sub {
  margin: 0 0 8px;
  color: var(--text-dim);
  font-size: 13px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;

  & .check {
    flex: none;
  }

  & .select {
    flex: 1;
    min-width: 0;
  }
}

/* ---- karta ryby -------------------------------------------------------------- */

.fishcard {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 3;
  width: max-content;
  max-width: min(78vw, 250px);
  padding: 10px 14px 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--glass-strong);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  color: var(--text);
  pointer-events: none;
  user-select: none;
  will-change: transform;
  animation: fishcard-in 220ms var(--ease);

  & p {
    margin: 0;
  }
}

.fishcard-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.fishcard-kind {
  color: var(--text-dim);
  font-size: 12.5px;
}

.fishcard-facts {
  display: grid;
  gap: 3px;
  margin: 8px 0 0;
  font-size: 13px;

  & div {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 8px;
  }

  & dt {
    color: var(--text-dim);
  }

  & dd {
    margin: 0;
  }
}

@keyframes fishcard-in {
  from {
    opacity: 0;
  }
}

/* krátke bliknutie pri fotení */
.flash {
  position: fixed;
  inset: 0;
  z-index: 4;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  animation: flash 420ms ease-out;
}

@keyframes flash {
  from {
    opacity: 0.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fishcard,
  .flash {
    animation-duration: 1ms;
  }
}
