/*
 * styles.css — umiar i światło.
 * Granatowa noc, srebrny chłód, złoto tylko jako akcent. Nic zbędnego.
 */

:root {
  --ink: #05060b;
  --silver: #aebbd2;
  --silver-dim: #6c7790;
  --gold: #e8c07a;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: ui-sans-serif, -apple-system, 'Segoe UI', Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--silver);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#field {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ----- warstwa interfejsu ----- */

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: clamp(20px, 5vh, 54px) 20px;
  z-index: 5;
}

#top { text-align: center; }

#top .line {
  font-family: var(--serif);
  font-size: clamp(13px, 1.6vw, 17px);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--silver-dim);
  margin-bottom: 0.9em;
  padding-left: 0.42em;
}

.count {
  font-family: var(--sans);
  font-weight: 200;
  font-size: clamp(26px, 5vw, 52px);
  letter-spacing: 0.16em;
  color: #e9eef9;
  font-variant-numeric: tabular-nums;
}

#meter {
  width: clamp(120px, 22vw, 240px);
  height: 1px;
  margin: 1.3em auto 0.7em;
  background: rgba(174, 187, 210, 0.16);
  overflow: hidden;
}
#meter-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(174,187,210,0.5), var(--gold));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.5s ease;
}

.count .ms {
  font-size: 0.5em;
  color: var(--silver-dim);
  letter-spacing: 0.08em;
  vertical-align: baseline;
  margin-left: 0.15em;
}

.gate-formal {
  font-size: clamp(9px, 1.1vw, 11px);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--silver-dim);
  margin-bottom: 0.9em;
  opacity: 0.65;
}

.sub {
  font-size: 10px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--silver-dim);
}

/* poziom korelacji w czasie rzeczywistym (−100…0…+100; 0 = splot, ∞ w oknie ±1 min) */
.corr {
  margin-top: 0.8em;
  font-family: var(--sans);
  font-weight: 200;
  font-size: clamp(15px, 2vw, 22px);
  letter-spacing: 0.14em;
  color: var(--silver);
  font-variant-numeric: tabular-nums;
  min-height: 1.1em;
  transition: color 0.6s ease, font-size 0.6s ease;
}
.corr.inf { color: var(--gold); font-size: clamp(22px, 3.4vw, 34px); letter-spacing: 0.05em; }

/* ----- sterowanie skalą czasu (zoom) ----- */
#zoomhud {
  position: fixed;
  right: clamp(14px, 3vw, 30px);
  bottom: clamp(14px, 3vw, 30px);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.scale-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(12px, 1.6vw, 16px);
  letter-spacing: 0.08em;
  color: var(--silver);
  opacity: 0.78;
  text-shadow: 0 0 20px rgba(10, 16, 34, 0.9);
}
.zoom-btns { display: flex; gap: 8px; pointer-events: auto; }
.zoom-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: rgba(10, 14, 26, 0.5);
  border: 1px solid rgba(174, 187, 210, 0.2);
  color: var(--silver);
  font-size: 17px; line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 0.4s ease, color 0.4s ease, background 0.4s ease;
}
.zoom-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(232, 192, 122, 0.08); }
.zoom-btn:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(232, 192, 122, 0.4); }
/* automatyczna perspektywa aktywna — delikatna złota poświata na ⌂ */
.zoom-btn.auto-on { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 12px rgba(232, 192, 122, 0.25); }

/* poezja */
.poem {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(16px, 2.4vw, 25px);
  line-height: 1.5;
  text-align: center;
  max-width: 22em;
  color: #cfd8ea;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 2.4s ease, transform 2.4s ease;
  text-shadow: 0 0 30px rgba(20, 30, 60, 0.8);
  padding: 0 18px;
}
.poem.show { opacity: 0.92; transform: translateY(0); }

/* numer dołączenia sygnatury — dymek przy kursorze (najechanie/klik na falę) */
.hover-num {
  position: fixed;
  transform: translate(14px, -50%);
  padding: 3px 9px;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--gold);
  background: rgba(8, 10, 18, 0.74);
  border: 1px solid rgba(232, 192, 122, 0.4);
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 8;
  white-space: nowrap;
}
.hover-num.show { opacity: 0.95; }
.hover-num .hn-sub { display: block; font-size: 11px; letter-spacing: 0.05em; color: var(--silver); opacity: 0.78; margin-top: 2px; }

/* ekran sygnowania — numer, udostępnij */
.you-num { font-size: 12px; letter-spacing: 0.18em; color: var(--gold); opacity: 0.85; margin: 6px 0 8px; min-height: 1em; }
.enter-actions { margin-top: 14px; display: flex; gap: 10px; justify-content: center; }
.enter-link {
  background: transparent; border: 1px solid rgba(232, 192, 122, 0.45); color: var(--gold);
  font-family: var(--sans); font-size: 12px; letter-spacing: 0.14em; padding: 7px 16px;
  border-radius: 999px; cursor: pointer; transition: background 0.3s ease;
}
.enter-link:hover { background: rgba(232, 192, 122, 0.1); }
.intro em { font-style: italic; color: var(--silver); }
.intro strong { font-weight: 400; color: var(--gold); }
/* komunikat „tylko z zaproszenia" + zablokowany przycisk */
.enter-gate {
  max-width: 24em; margin: 12px auto 0; font-size: 12.5px; line-height: 1.6;
  letter-spacing: 0.04em; color: var(--silver-dim);
}
.enter-gate strong { color: var(--gold); font-weight: 400; }
#enter-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* chwilowy podpis skali czasu podczas zoomu — poniżej haseł i linijki czasu
   (nie nachodzi na podpisy jednostek osi, które siedzą ~62% wysokości) */
.scale-flash {
  position: absolute;
  top: 72%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--serif);
  font-size: clamp(15px, 2.2vw, 24px);
  letter-spacing: 0.2em;
  color: var(--gold);
  text-shadow: 0 0 26px rgba(232, 192, 122, 0.4);
  opacity: 0;
  transition: opacity 0.55s ease;
  pointer-events: none;
  white-space: nowrap;
}
.scale-flash.show { opacity: 0.9; }

/* stopka */
#bottom {
  display: flex;
  align-items: center;
  gap: 0.9em;
  font-size: clamp(11px, 1.4vw, 13px);
  letter-spacing: 0.16em;
  color: var(--silver-dim);
  text-transform: lowercase;
}
#bottom .stat span { color: var(--silver); font-weight: 400; }
.dot-sep { opacity: 0.5; }

/* ----- brama wejścia ----- */

#enter {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(7, 9, 17, 0.62), rgba(5, 6, 11, 0.92));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  transition: opacity 2.6s ease, visibility 2.6s ease;
  padding: 24px;
}
#enter.gone { opacity: 0; visibility: hidden; pointer-events: none; }

.enter-inner { text-align: center; max-width: 30em; }

.mark {
  font-size: 40px;
  color: var(--gold);
  opacity: 0.85;
  margin-bottom: 0.5em;
  animation: breathe 7s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.95; transform: scale(1.06); }
}

#enter h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(40px, 9vw, 86px);
  letter-spacing: 0.34em;
  padding-left: 0.34em;
  color: #f2f4fa;
  margin-bottom: 0.32em;
}

.motto {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(15px, 2.2vw, 21px);
  color: var(--gold);
  opacity: 0.92;
  margin-bottom: 1.8em;
}

.intro {
  font-size: clamp(13px, 1.7vw, 15px);
  line-height: 1.9;
  color: var(--silver-dim);
  letter-spacing: 0.04em;
  margin-bottom: 2.4em;
}

#enter-btn {
  pointer-events: auto;
  background: transparent;
  border: 1px solid rgba(232, 192, 122, 0.5);
  color: var(--gold);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  padding: 1.1em 2.6em;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.6s ease, border-color 0.6s ease, color 0.6s ease, letter-spacing 0.6s ease;
}
#enter-btn:hover {
  background: rgba(232, 192, 122, 0.08);
  border-color: var(--gold);
  color: #f6e6c4;
  letter-spacing: 0.4em;
}

.whisper {
  margin-top: 1.8em;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(108, 119, 144, 0.7);
}

/* ----- oś czasu (sekretny tryb czuwania) ----- */

.scrub {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 15;
  /* panel sterowania trzymany SOLIDNIE ciemny (nie odwracany przy bramie) — czytelny
     i jako ciemny pasek na rozjaśnionym/odwróconym polu, i na zwykłej nocy */
  background: linear-gradient(180deg, rgba(8, 10, 18, 0.96), rgba(8, 10, 18, 0.92) 68%, rgba(8, 10, 18, 0.76));
  border-bottom: 1px solid rgba(174, 187, 210, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 12px 18px 20px;
}
.scrub-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
  flex-wrap: wrap;
}
.scrub-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--gold);
  opacity: 0.8;
}

.scrub-btn {
  background: transparent;
  border: 1px solid rgba(174, 187, 210, 0.22);
  color: var(--silver);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1;
  padding: 7px 11px;
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.4s ease, color 0.4s ease, background 0.4s ease;
}
.scrub-btn.wide { letter-spacing: 0.18em; text-transform: uppercase; font-size: 11px; }
.scrub-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(232, 192, 122, 0.06); }

.scrub-range {
  flex: 1 1 220px;
  min-width: 160px;
  height: 2px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(174, 187, 210, 0.2);
  outline: none;
  border-radius: 2px;
  cursor: pointer;
}
.scrub-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(232, 192, 122, 0.7);
  cursor: grab;
}
.scrub-range::-moz-range-thumb {
  width: 13px; height: 13px; border: none;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px rgba(232, 192, 122, 0.7);
  cursor: grab;
}

.scrub-readout {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 230px;
  text-align: right;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--silver-dim);
}
.scrub-date { color: var(--silver); font-variant-numeric: tabular-nums; }
.scrub-meta .g { color: var(--gold); }

.scrub-dt {
  background: rgba(174, 187, 210, 0.06);
  border: 1px solid rgba(174, 187, 210, 0.18);
  color: var(--silver);
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 3px;
  color-scheme: dark;
}

.scrub-test { display: inline-flex; align-items: center; gap: 6px; }
.scrub-num {
  width: 60px;
  background: rgba(174, 187, 210, 0.06);
  border: 1px solid rgba(174, 187, 210, 0.18);
  color: var(--silver);
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px;
  border-radius: 3px;
  color-scheme: dark;
}

/* widoczny fokus klawiatury (a11y) */
.scrub-range:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.scrub-btn:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(232, 192, 122, 0.4); }

/* gdy oś czasu odsłonięta, zepchnij interfejs niżej o realną wysokość paska */
body.scrubbing #ui { padding-top: calc(var(--scrub-h, 96px) + 14px); }

@media (max-width: 720px) {
  .scrub-readout { text-align: left; min-width: 0; }
  .scrub-title { width: 100%; }
}

@media (max-width: 520px) {
  .scrub-title { display: none; }
  .scrub-dt { display: none; }            /* precyzyjny wybór ukryty na wąskim — suwak wystarcza */
  .scrub-readout { flex-basis: 100%; order: 9; }
  .scrub-inner { gap: 8px; }
}

@media (max-width: 520px) {
  #top .line { letter-spacing: 0.3em; }
  .count { letter-spacing: 0.1em; }
  /* zostaw miejsce na HUD zoomu, by nie nachodził na stopkę */
  #ui { padding-bottom: 74px; }
  #zoomhud { gap: 6px; }
  .scale-label { font-size: 12px; }
}

/* ----- czytelność na KAŻDYM tle (także w „punkcie szarości") ----- */
/* Mocny cień-obwódka daje kontrast niezależnie od jasności tła: gdy pole mdleje
   do szarości w połowie inwersji, ciemna obwódka utrzymuje napisy widoczne (a po
   inwersji UI sama obwódka się odwraca i nadal kontrastuje). */
#top, #bottom, .poem, .corr, .scale-flash, #zoomhud, #scrub, .scale-label {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 0 9px rgba(0, 0, 0, 0.55);
}
.poem { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 0 30px rgba(20, 30, 60, 0.8); }
/* przyciski/obwódki — wyraźniejsze, by nie znikały na szarości */
.zoom-btn, .scrub-btn { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }

/* ----- inwersja interfejsu zsynchronizowana z inwersją pola ----- */
/* Gdy pole odwraca luminescencję przy bramie, odwracamy interfejs NAD polem
   (centralne napisy, HUD zoomu), by napisy pozostały czytelne. Panel czuwania
   (#scrub) NIE jest odwracany — to solidny ciemny pasek, czytelny na każdym
   stanie pola; odwracanie zamieniało go w blady pas zlewający się z jasnym polem. */
#ui, #zoomhud { transition: filter 0.45s ease; }
body.inverted #ui,
body.inverted #zoomhud { filter: invert(1) hue-rotate(180deg); }

/* ----- przełącznik języka (dyskretny, lewy dolny róg) ----- */
/* Poza #ui/#zoomhud, więc inwersja bramy go nie dotyka — zawsze czytelny. */
#lang {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 30;
  opacity: 0.42;
  transition: opacity 0.3s ease;
}
#lang:hover, #lang:focus-within { opacity: 1; }
#lang-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(8, 10, 18, 0.72);
  color: #cdd6ee;
  border: 1px solid rgba(160, 178, 220, 0.28);
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.02em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
#lang-select:hover { border-color: rgba(232, 192, 122, 0.5); color: #e8e8f2; }
#lang-select option { background: #0a0c14; color: #cdd6ee; }
@media (max-width: 560px) { #lang { opacity: 0.55; } #lang-select { font-size: 11px; padding: 4px 9px; } }
