/* Worek na monety — spokojny ciemny teal ze złotym akcentem */

:root {
  color-scheme: dark;
  --bg: #0a1f29;
  --surface: #10303f;
  --surface-2: #153a4b;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f2f6f8;
  --muted: #a9bdc7;
  --gold: #f2b632;
  --warn-bg: rgba(242, 182, 50, 0.12);
  --warn-line: rgba(242, 182, 50, 0.55);

  --btn-top: #ffe27a;
  --btn-bottom: #f5b82e;
  --btn-edge: #b97d0d;
  --btn-ink: #2f1f00;

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

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding: clamp(0.625rem, 2vw, 1.5rem) 1.25rem 1rem;
  color: var(--text);
  line-height: 1.5;
  background:
    radial-gradient(48rem 24rem at 50% -4rem, rgba(242, 182, 50, 0.1), transparent 70%),
    var(--bg);
}

.page {
  width: min(56rem, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

h1, h2, h3, p, ul, ol { margin: 0; }

/* ---------- Nagłówek ---------- */

.hero {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-bottom: 0.5rem;
}

.bag {
  flex: none;
  width: clamp(5.5rem, 16vw, 8.5rem);
  height: auto;
  filter: drop-shadow(0 0.7rem 0.8rem rgba(0, 0, 0, 0.4));
}

.hero h1 {
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.hero p {
  max-width: none;
  margin-top: 0.5rem;
  font-size: clamp(0.85rem, 2.4vw, 1.125rem);
  text-wrap: balance;
  color: var(--muted);
}

/* ---------- Panele ---------- */

.panel {
  position: relative;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--surface);
}

.panel h2 {
  margin-bottom: 1rem;
  font-size: 1.05rem;
  font-weight: 700;
}

/* Jedno okno: po lewej połączenie, po prawej lista kontrolna – a po sparowaniu komunikat */
.connect {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1.5rem;
}

.pane { min-width: 0; }

.pane-info {
  padding-left: 1.5rem;
  border-left: 1px solid var(--line);
}

.info-paired {
  display: none;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.info-paired h2 { margin-bottom: 0.4rem; color: #b6f2cf; }
.info-paired .pair-path { color: var(--text); font-size: 1.05rem; line-height: 1.4; }
.info-paired strong { font-weight: 700; }

.connect[data-state="success-pair"] .info-before { display: none; }
.connect[data-state="success-pair"] .info-paired {
  display: flex;
  animation: fade-in 320ms ease-out;
}

@keyframes fade-in { from { opacity: 0; transform: translateY(0.4rem); } }

/* ---------- Połączenie ---------- */

.action {
  margin-top: 1.75rem; /* obniża maskotkę i przycisk w oknie Połączenie */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

button {
  min-width: min(100%, 15rem);
  padding: 1rem 2rem 1.1rem;
  border: 0;
  border-radius: 0.8rem;
  background: linear-gradient(var(--btn-top), var(--btn-bottom));
  color: var(--btn-ink);
  box-shadow:
    inset 0 0.1rem 0 rgba(255, 255, 255, 0.5),
    0 0.3rem 0 var(--btn-edge),
    0 0.9rem 1.2rem rgba(0, 0, 0, 0.3);
  cursor: pointer;
  font: inherit;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 160ms ease;
}

#thing-state {
  display: block;
  font-size: clamp(1.15rem, 4vw, 1.4rem);
  font-weight: 750;
  line-height: 1.2;
  text-wrap: balance;
}

button:hover:not(:disabled) { filter: brightness(1.06); }

button:active:not(:disabled) {
  transform: translateY(0.25rem);
  box-shadow:
    inset 0 0.1rem 0 rgba(255, 255, 255, 0.5),
    0 0.05rem 0 var(--btn-edge),
    0 0.3rem 0.6rem rgba(0, 0, 0, 0.3);
}

button:focus-visible {
  outline: 0.2rem solid #fff;
  outline-offset: 0.3rem;
}

button:disabled { cursor: progress; }

button[data-state="success-pair"],
button[data-state="success-exchange"] {
  --btn-top: #b6f2cf;
  --btn-bottom: #4fd08a;
  --btn-edge: #25975c;
  --btn-ink: #06301b;
}

button[data-state="failure"] {
  --btn-top: #ffc2c2;
  --btn-bottom: #ff6b6b;
  --btn-edge: #c63c48;
  --btn-ink: #3d0a10;
}

button[data-state="unsupported"] {
  --btn-top: #6c7388;
  --btn-bottom: #4a5062;
  --btn-edge: #2e3340;
  --btn-ink: rgba(255, 255, 255, 0.85);
  cursor: not-allowed;
}

.detail {
  max-width: 22rem;
  font-size: 0.95rem;
  text-align: center;
  color: var(--muted);
  overflow-wrap: anywhere;
  white-space: pre-line; /* zachowuje podział na linie w komunikatach */
}

.detail:empty { display: none; } /* pusty komunikat nie zajmuje miejsca na dole okna */

button[data-state="failure"] + .detail { color: #ffb3b3; }

button[data-state="success-pair"] + .detail,
button[data-state="success-exchange"] + .detail { color: #b6f2cf; }

/* ---------- Maskotka ---------- */

.mascot {
  order: -1;
  position: relative;
  width: 100%;
  height: 9rem;
}

.mascot img {
  position: absolute;
  bottom: 0;
  left: 50%;
  height: auto;
  translate: -50% 0;
  filter: drop-shadow(0 0.5rem 0.5rem rgba(0, 0, 0, 0.35));
}

.m-idle { width: 8.5rem; }

/* Po sparowaniu / odebraniu pocztówki: grafika wyśrodkowana w polu maskotki (9rem).
   Selektor ".mascot .m-win" jest celowo mocniejszy niż ".mascot img" – inaczej
   "height: auto" i "bottom: 0" z tamtej reguły nadpisywałyby rozmiar i pozycję. */
.mascot .m-win {
  display: none;
  width: auto;
  height: 9.5rem;
  max-height: calc(100% + 1rem);
  top: 50%;
  bottom: auto;
  translate: -50% -50%;
  object-fit: contain;
}

button:is([data-state="success-pair"], [data-state="success-exchange"]) ~ .mascot .m-idle { display: none; }
button:is([data-state="success-pair"], [data-state="success-exchange"]) ~ .mascot .m-win {
  display: block;
  animation: pop-in 480ms cubic-bezier(0.3, 1.6, 0.5, 1);
}

button[data-state="unsupported"] ~ .mascot .m-idle,
button[data-state="failure"] ~ .mascot .m-idle {
  filter: grayscale(0.7) drop-shadow(0 0.5rem 0.5rem rgba(0, 0, 0, 0.35));
}

button:is([data-state="requesting-device"], [data-state="connecting"], [data-state="reading-device"], [data-state="pairing"], [data-state="exchanging"]) ~ .mascot .m-idle {
  animation: hop 700ms ease-in-out infinite;
}

@keyframes hop { 50% { transform: translateY(-0.7rem); } }

@keyframes pop-in { from { transform: scale(0.5) translateY(1rem); opacity: 0; } }

/* ---------- Lista kontrolna ---------- */

.checks {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0;
  list-style: none;
}

.checks li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.95rem;
  color: var(--muted);
}

.checks li strong { color: var(--text); font-weight: 700; }

.tick {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  margin-top: 0.05rem;
  border-radius: 50%;
  background: var(--surface-2);
  color: #7fe0ad;
  font-size: 0.8rem;
  font-weight: 800;
}

.tick-warn { background: var(--gold); color: #2f1f00; }

/* ---------- Instrukcje ---------- */

.steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 1rem 1.1rem 1.1rem 3.1rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--surface-2);
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: var(--gold);
  color: #2f1f00;
  font-size: 0.85rem;
  font-weight: 800;
}

.steps h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.4rem; }

.steps p { font-size: 0.93rem; color: var(--muted); }

.steps .then {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
}

/* ---------- Stopka ---------- */

.footer {
  width: min(56rem, 100%);
  margin: 1.25rem auto 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line); /* napis nad linią, strona kończy się pod nią */
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- Telefon ---------- */

@media (max-width: 42rem) {
  .connect, .steps { grid-template-columns: 1fr; }
  .pane-info {
    padding-left: 0;
    padding-top: 1.25rem;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .hero { gap: 1rem; }
  .panel { padding: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .mascot img, button, .info-paired { animation: none !important; transition: none; }
}
