/*!
 * Wędrujące Gwiazdy — style. Paleta wspólna z kalkulatorami BaZi, Gua i Tong Shu.
 */

.fsx {
  --fsx-cream: #FAF6F0;
  --fsx-ink: #262626;
  --fsx-muted: #6F6A64;
  --fsx-accent: #C0392B;
  --fsx-line: #E7DFD4;
  --fsx-radius: 6px;
  --fsx-head: Georgia, "Times New Roman", serif;

  /* Kolory dziewięciu gwiazd wprost z ich tradycyjnych nazw.
     Białe gwiazdy dostają obrys, inaczej zniknęłyby na jasnym tle. */
  --fsx-1: #FFFFFF;   /* biała jedynka */
  --fsx-2: #1A1A1A;   /* czarna dwójka */
  --fsx-3: #1F8A70;   /* szmaragdowa trójka */
  --fsx-4: #4E7C46;   /* zielona czwórka */
  --fsx-5: #C8960C;   /* żółta piątka */
  --fsx-6: #FFFFFF;   /* biała szóstka */
  --fsx-7: #C0392B;   /* czerwona siódemka */
  --fsx-8: #FFFFFF;   /* biała ósemka */
  --fsx-9: #7B2D8E;   /* fioletowa dziewiątka */
  --fsx-outline: #6F6A64;

  box-sizing: border-box;
  max-width: 980px;
  margin: 2em auto;
  padding: clamp(20px, 4vw, 36px);
  background: #fff;
  border: 1px solid var(--fsx-line);
  border-radius: var(--fsx-radius);
  color: var(--fsx-ink);
  font-size: 16px;
  line-height: 1.65;
}

.fsx *, .fsx *::before, .fsx *::after { box-sizing: border-box; }
.fsx p, .fsx h2, .fsx h3 { margin: 0; padding: 0; }
.fsx :focus-visible { outline: 2px solid var(--fsx-accent); outline-offset: 2px; }

.fsx-kicker {
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  font-weight: 700; color: var(--fsx-accent);
}

.fsx-title {
  font-family: var(--fsx-head);
  font-size: clamp(26px, 4.4vw, 33px);
  line-height: 1.2; font-weight: 700; margin-top: 8px !important;
}

.fsx-lede { margin-top: 10px !important; color: var(--fsx-muted); }

.fsx-eyebrow {
  font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase;
  font-weight: 700; color: var(--fsx-accent);
}

/* ------------------------------------------------------------------ *
 * Formularz
 * ------------------------------------------------------------------ */

/* ------------------------------------------------------------------ *
 * Przełącznik języka
 * ------------------------------------------------------------------ */

.fsx-lang {
  display: inline-flex;
  margin-top: 16px;
  background: #fff;
  border: 1px solid var(--fsx-line);
  border-radius: var(--fsx-radius);
  overflow: hidden;
}

.fsx-lang-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 8px 15px;
  background: #fff;
  color: var(--fsx-muted);
  border: 0;
  border-right: 1px solid var(--fsx-line);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.fsx-lang-btn:last-child { border-right: 0; }
.fsx-lang-btn:hover { color: var(--fsx-accent); }
.fsx-lang-btn.is-on { background: var(--fsx-accent); color: #fff; }

.fsx-form {
  margin-top: 24px;
  padding: 18px 20px;
  background: var(--fsx-cream);
  border: 1px solid var(--fsx-line);
  border-radius: var(--fsx-radius);
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: flex-end;
}

.fsx-field { display: flex; flex-direction: column; gap: 7px; flex: 1 1 240px; min-width: 0; max-width: 100%; }

/* Etykiety muszą móc się złamać — najdłuższa z nich rozpychała kolumnę
   poza krawędź ekranu. Zakaz łamania zostaje tylko w pasku daty, gdzie
   etykieta stoi w jednej linii z polem. */
.fsx-lab {
  font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase;
  font-weight: 700; color: var(--fsx-muted);
  line-height: 1.35; overflow-wrap: break-word;
}

.fsx-datebar .fsx-lab { white-space: nowrap; }

/* Pole daty w formularzu ma wyglądać jak listy wyboru obok — Safari nadaje
   kontrolkom daty własny wygląd i szerokość, więc je zerujemy. */
.fsx select,
.fsx-form input[type="date"] {
  font: inherit; font-size: 16px; color: var(--fsx-ink);
  padding: 10px 12px; background: #fff;
  border: 1px solid var(--fsx-line); border-radius: var(--fsx-radius);
  width: 100%; max-width: 100%; min-width: 0;
  -webkit-appearance: none; appearance: none;
  text-align: left; line-height: 1.3;
}

.fsx-form input[type="date"]::-webkit-date-and-time-value { text-align: left; }

/* ------------------------------------------------------------------ *
 * Dwie kolumny: nieruchomość i czas
 * ------------------------------------------------------------------ */

.fsx-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 22px;
  margin-top: 24px;
  align-items: start;
}

.fsx-panel {
  padding: 20px 22px;
  background: var(--fsx-cream);
  border: 1px solid var(--fsx-line);
  border-left: 4px solid var(--fsx-accent);
  border-radius: var(--fsx-radius);
}

/* --- podsumowanie wykresu --- */

.fsx-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.fsx-sum {
  display: flex; flex-direction: column; gap: 1px;
  padding: 9px 11px; background: #fff;
  border: 1px solid var(--fsx-line); border-radius: var(--fsx-radius);
}

.fsx-sum-label {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  font-weight: 700; color: var(--fsx-muted);
}

.fsx-sum-value { font-weight: 700; font-size: 15px; line-height: 1.25; }
.fsx-sum-sub { font-size: 11.5px; color: var(--fsx-muted); line-height: 1.3; }

/* ------------------------------------------------------------------ *
 * Siatka dziewięciu pałaców — północ zawsze na dole
 * ------------------------------------------------------------------ */

/* Siatka nieruchomości ma boczne marginesy, w których mieszczą się znaczniki
   skierowania i osadzenia razem z podpisami. Marginesy nie zmieniają układu
   odniesienia, więc procenty w znacznikach nadal liczą się względem siatki. */
.fsx-prop-wrap { position: relative; margin: 52px 64px 26px; }
.fsx-time-wrap { position: relative; margin: 18px 0 0; }

.fsx-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  background: var(--fsx-line);
  border: 2px solid var(--fsx-ink);
  border-radius: var(--fsx-radius);
  overflow: hidden;
}

.fsx-cell {
  position: relative;
  background: #fff;
  min-height: 124px;
  padding: 20px 8px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}

.fsx-cell-c { background: var(--fsx-cream); }
.fsx-cell-plain { min-height: 78px; padding: 20px 6px 8px; }

.fsx-dir {
  position: absolute;
  top: 5px; left: 0; right: 0;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  font-weight: 700; color: var(--fsx-muted);
}

.fsx-top { display: flex; justify-content: space-between; width: 100%; padding: 0 4px; }
.fsx-small { font-size: 20px; font-weight: 700; line-height: 1; }
.fsx-big { font-family: var(--fsx-head); font-size: 30px; font-weight: 700; line-height: 1.1; }
.fsx-star-name { font-size: 10.5px; color: var(--fsx-muted); line-height: 1.25; }

/* dół komórki: gwiazdy roku, miesiąca i dnia */
.fsx-time-row {
  display: flex; justify-content: center; gap: 9px;
  margin-top: 4px; padding-top: 5px;
  border-top: 1px dashed var(--fsx-line);
  width: 88%;
}

.fsx-time-slot { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.fsx-time-lab { font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; color: var(--fsx-muted); }
.fsx-time-num { font-size: 16px; font-weight: 700; }

/* --- znaczniki skierowania i osadzenia --- */

.fsx-marker {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--fsx-accent);
  pointer-events: none;
  white-space: nowrap;
}

/* Przy górnej krawędzi podpis idzie nad symbolem, żeby sam symbol przylegał
   do siatki. Przy dolnej kolejność jest już właściwa. */
.fsx-at-S, .fsx-at-SE, .fsx-at-SW { flex-direction: column-reverse; }

.fsx-arrow { display: block; position: relative; width: 24px; height: 24px; }

.fsx-arrow-head {
  position: absolute; top: 0; left: 50%;
  margin-left: -9px;
  width: 0; height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 11px solid currentColor;
}

.fsx-arrow-stem {
  position: absolute; top: 9px; left: 50%;
  margin-left: -2.5px;
  width: 5px; height: 15px;
  background: currentColor;
  border-radius: 1px;
}

.fsx-marker-label { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; }

.fsx-at-E .fsx-marker-label,
.fsx-at-W .fsx-marker-label,
.fsx-at-SE .fsx-marker-label,
.fsx-at-SW .fsx-marker-label,
.fsx-at-NE .fsx-marker-label,
.fsx-at-NW .fsx-marker-label { font-size: 9px; letter-spacing: 0.03em; }

/* znak osadzenia w kształcie litery T */
.fsx-tee { display: block; width: 26px; height: 22px; position: relative; }
.fsx-tee-bar { position: absolute; top: 0; left: 0; width: 26px; height: 6px; background: currentColor; border-radius: 2px; }
.fsx-tee-stem { position: absolute; top: 0; left: 50%; margin-left: -3px; width: 6px; height: 20px; background: currentColor; border-radius: 2px; }

/* Położenie: południe u góry, północ na dole, wschód po lewej.
   Kierunki pośrednie siadają w narożnikach, dzięki czemu skierowanie
   i osadzenie leżą dokładnie na jednej przekątnej. */
.fsx-at-S  { top: -50px; left: 50%; transform: translateX(-50%); }
.fsx-at-N  { bottom: -50px; left: 50%; transform: translateX(-50%); }
.fsx-at-E  { left: -62px; top: 50%; transform: translateY(-50%); }
.fsx-at-W  { right: -62px; top: 50%; transform: translateY(-50%); }

.fsx-at-SE { top: -46px; left: -44px; }
.fsx-at-NW { bottom: -46px; right: -44px; }
.fsx-at-SW { top: -46px; right: -44px; }
.fsx-at-NE { bottom: -46px; left: -44px; }

/* obraca się sam symbol, podpis zostaje poziomy */
.fsx-rot-S  { transform: rotate(0deg); }
.fsx-rot-SE { transform: rotate(-45deg); }
.fsx-rot-SW { transform: rotate(45deg); }
.fsx-rot-N  { transform: rotate(180deg); }
.fsx-rot-NE { transform: rotate(-135deg); }
.fsx-rot-NW { transform: rotate(135deg); }
.fsx-rot-E  { transform: rotate(-90deg); }
.fsx-rot-W  { transform: rotate(90deg); }

/* ------------------------------------------------------------------ *
 * Przełącznik warstw czasu
 * ------------------------------------------------------------------ */

.fsx-tabs {
  display: flex;
  margin-top: 14px;
  background: #fff;
  border: 1px solid var(--fsx-line);
  border-radius: var(--fsx-radius);
  overflow: hidden;
}

.fsx-tab {
  flex: 1 1 0;
  font: inherit; font-size: 12.5px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 10px 6px;
  background: #fff; color: var(--fsx-ink);
  border: 0; border-right: 1px solid var(--fsx-line);
  cursor: pointer; -webkit-appearance: none; appearance: none;
}

.fsx-tab:last-child { border-right: 0; }
.fsx-tab.is-on { background: var(--fsx-accent); color: #fff; }

.fsx-panel-title {
  font-family: var(--fsx-head);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 6px !important;
}

/* --- rozszerzona legenda dziewięciu gwiazd --- */

.fsx-starkey {
  margin-top: 24px;
  padding: 20px 22px;
  background: var(--fsx-cream);
  border: 1px solid var(--fsx-line);
  border-left: 4px solid var(--fsx-accent);
  border-radius: var(--fsx-radius);
}

.fsx-starkey-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px 20px;
  margin-top: 14px;
}

.fsx-starkey-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 8px 0;
  border-top: 1px solid var(--fsx-line);
}

.fsx-starkey-num {
  font-family: var(--fsx-head);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

.fsx-starkey-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fsx-starkey-name { font-weight: 700; font-size: 14.5px; line-height: 1.3; }
.fsx-starkey-el { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; color: var(--fsx-muted); }
.fsx-starkey-desc { font-size: 13.5px; color: var(--fsx-muted); line-height: 1.45; }

.fsx-combo-legend {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  font-size: 12.5px; color: var(--fsx-muted); line-height: 1.4;
}

.fsx-combo-legend[hidden] { display: none; }
.fsx-combo-legend b { font-weight: 700; }

.fsx-legend {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--fsx-line);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px 16px;
  font-size: 12.5px;
  color: var(--fsx-muted);
}

.fsx-legend b { font-weight: 700; }

.fsx-note {
  margin-top: 18px !important;
  padding-top: 14px;
  border-top: 1px solid var(--fsx-line);
  font-size: 13px; color: var(--fsx-muted);
}

/* ------------------------------------------------------------------ *
 * Kolory gwiazd
 * ------------------------------------------------------------------ */

.fsx-s1, .fsx-s6, .fsx-s8 {
  -webkit-text-stroke: 1.6px var(--fsx-outline);
  paint-order: stroke fill;
  text-shadow: 0 0 1px rgba(38, 38, 38, 0.45);
}

.fsx-s1 { color: var(--fsx-1); }
.fsx-s2 { color: var(--fsx-2); }
.fsx-s3 { color: var(--fsx-3); }
.fsx-s4 { color: var(--fsx-4); }
.fsx-s5 { color: var(--fsx-5); }
.fsx-s6 { color: var(--fsx-6); }
.fsx-s7 { color: var(--fsx-7); }
.fsx-s8 { color: var(--fsx-8); }
.fsx-s9 { color: var(--fsx-9); }

/* ------------------------------------------------------------------ *
 * Mniejsze ekrany
 * ------------------------------------------------------------------ */

@media (max-width: 780px) {
  .fsx-cols { grid-template-columns: 1fr; }
  .fsx-prop-wrap { margin-left: 52px; margin-right: 52px; }
  .fsx-at-E { left: -50px; }
  .fsx-at-W { right: -50px; }
  .fsx-at-SE, .fsx-at-NE { left: -36px; }
  .fsx-at-SW, .fsx-at-NW { right: -36px; }
}

@media (max-width: 560px) {
  /* Podpisy znaczników powtarzają to, co stoi w podsumowaniu nad siatką,
     więc na wąskim ekranie zostają same symbole, a siatka odzyskuje szerokość. */
  .fsx-marker-label { display: none; }

  .fsx-prop-wrap { margin: 38px 28px 22px; }
  .fsx-at-S { top: -32px; }
  .fsx-at-N { bottom: -32px; }
  .fsx-at-E { left: -28px; }
  .fsx-at-W { right: -28px; }
  .fsx-at-SE, .fsx-at-SW { top: -30px; }
  .fsx-at-NE, .fsx-at-NW { bottom: -30px; }
  .fsx-at-SE, .fsx-at-NE { left: -26px; }
  .fsx-at-SW, .fsx-at-NW { right: -26px; }

  .fsx-arrow { width: 18px; height: 18px; }
  .fsx-arrow-head { margin-left: -7px; border-left-width: 7px; border-right-width: 7px; border-bottom-width: 9px; }
  .fsx-arrow-stem { top: 7px; margin-left: -2px; width: 4px; height: 11px; }
  .fsx-tee { width: 20px; height: 17px; }
  .fsx-tee-bar { width: 20px; height: 5px; }
  .fsx-tee-stem { margin-left: -2.5px; width: 5px; height: 15px; }

  .fsx-cell { min-height: 98px; padding: 15px 2px 6px; }
  .fsx-dir { font-size: 8.5px; letter-spacing: 0.03em; }
  .fsx-big { font-size: 22px; }
  .fsx-small { font-size: 15px; }
  .fsx-top { padding: 0 2px; }
  .fsx-time-row { gap: 4px; width: 96%; }
  .fsx-time-lab { font-size: 7.5px; letter-spacing: 0; }
  .fsx-time-num { font-size: 13px; }
  .fsx-panel { padding: 18px 14px; }
  .fsx-starkey { padding: 18px 14px; }
}

@media print {
  .fsx-form, .fsx-tabs { display: none !important; }
  .fsx { border: 0; padding: 0; max-width: none; }
}

/* ------------------------------------------------------------------ *
 * Wariant kompaktowy — sam panel gwiazd na dziś
 * ------------------------------------------------------------------ */

.fsx-compact { max-width: 480px; }

.fsx-datebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--fsx-cream);
  border: 1px solid var(--fsx-line);
  border-radius: var(--fsx-radius);
}

.fsx-datebar .fsx-lab { margin: 0; }

.fsx-datebar input[type="date"] {
  font: inherit; font-size: 16px; color: var(--fsx-ink);
  padding: 9px 11px; background: #fff;
  border: 1px solid var(--fsx-line); border-radius: var(--fsx-radius);
  flex: 1 1 150px; min-width: 0;
  -webkit-appearance: none; appearance: none; text-align: left;
}

.fsx-back-today {
  font: inherit; font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  padding: 10px 14px; background: #fff; color: var(--fsx-ink);
  border: 1px solid var(--fsx-line); border-radius: var(--fsx-radius);
  cursor: pointer; -webkit-appearance: none; appearance: none;
}

.fsx-back-today:hover { border-color: var(--fsx-accent); color: var(--fsx-accent); }
.fsx-back-today[hidden] { display: none; }
.fsx-compact .fsx-time-wrap { margin: 16px 0 0; }
.fsx-compact .fsx-cell { min-height: 92px; }

.fsx-more {
  display: inline-block;
  margin-top: 18px;
  padding: 12px 22px;
  background: var(--fsx-accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--fsx-radius);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.fsx-more:hover { filter: brightness(0.9); color: #fff; }
