/* ==========================================================================
   Dom — baza wiedzy o budowie domu
   Jasny motyw, układ dokumentacyjny. Bez zależności zewnętrznych.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f6f7f9;
  --text: #1f2328;
  --text-muted: #5b6570;
  --border: #dde1e6;
  --border-strong: #c5ccd3;
  --accent: #2f6690;
  --accent-hover: #24506f;
  --accent-soft: #eaf1f7;

  --ok: #1f7a4d;
  --ok-soft: #e6f4ec;
  --warn: #9a6200;
  --warn-soft: #fdf3e1;
  --neutral-soft: #eef0f3;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --content-width: 960px;
  --header-h: 57px; /* nadpisywane przez skrypt rzeczywistą wysokością paska */
  --radius: 6px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

/* Cel kotwicy nie chowa się pod przyklejonym paskiem. */
[id] {
  scroll-margin-top: var(--header-h);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--neutral-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

/* --- Pasek górny ---------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: var(--text);
}

.brand svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.nav {
  position: relative; /* punkt odniesienia dla offsetLeft linków */
  display: flex;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav a {
  flex: none;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.nav a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Próg dobrany do szerokości wszystkich linków w jednym wierszu (~1190 px).
   Po dodaniu linku w nawigacji sprawdź, czy nadal wystarcza. */
@media (max-width: 1200px) {
  .topbar__inner {
    flex-wrap: wrap;
    gap: 2px 16px;
    padding: 8px 16px 6px;
  }

  .nav {
    flex-basis: 100%;
    padding-bottom: 2px;
  }

  .nav a:first-child {
    margin-left: -10px; /* wyrównanie tekstu pierwszego linku z logo */
  }
}

/* --- Treść ---------------------------------------------------------------- */

.content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 24px 64px;
}

.intro {
  padding: 48px 0 8px;
}

.intro h1 {
  margin: 0 0 12px;
  font-size: 2.25rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.lead {
  max-width: 65ch;
  margin: 0 0 12px;
  font-size: 1.15rem;
  color: var(--text-muted);
}

.meta,
.updated {
  font-size: 0.85rem;
  color: var(--text-muted);
}

section {
  padding-top: 40px;
}

h2 {
  margin: 0 0 6px;
  padding-bottom: 8px;
  font-size: 1.6rem;
  line-height: 1.25;
  border-bottom: 1px solid var(--border);
}

h3 {
  margin: 32px 0 10px;
  font-size: 1.15rem;
  line-height: 1.3;
}

p,
ul,
ol,
dl,
figure {
  margin: 0 0 16px;
}

li > ul,
li > ol {
  margin: 4px 0 0;
}

.updated {
  margin: 0 0 20px;
}

/* Tekst-zaślepka do uzupełnienia. */
.todo {
  color: var(--text-muted);
  font-style: italic;
}

@media (max-width: 640px) {
  .content {
    padding: 0 16px 48px;
  }

  .intro {
    padding-top: 32px;
  }

  .intro h1 {
    font-size: 1.85rem;
  }

  h2 {
    font-size: 1.4rem;
  }
}

/* --- Kafelki z kluczowymi danymi ----------------------------------------- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.facts > div {
  padding: 12px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.facts dt {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.facts dd {
  margin: 2px 0 0;
  font-size: 1.1rem;
  font-weight: 600;
}

@media (max-width: 640px) {
  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .facts > div {
    padding: 10px 12px;
  }
}

/* --- Lista parametrów (etykieta: wartość) -------------------------------- */

.spec {
  display: grid;
  grid-template-columns: minmax(160px, 30%) 1fr;
  gap: 6px 16px;
}

.spec dt {
  color: var(--text-muted);
}

.spec dd {
  margin: 0;
}

.spec dd > ul {
  margin: 4px 0 0;
}

@media (max-width: 640px) {
  .spec {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .spec dd {
    margin-bottom: 8px;
  }
}

/* --- Tabele --------------------------------------------------------------- */

.table-wrap {
  margin: 0 0 16px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

th,
td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

thead th {
  background: var(--bg-subtle);
  font-weight: 600;
  white-space: nowrap;
}

tbody:last-child > tr:last-child > * {
  border-bottom: none;
}

/* Wiersz-nagłówek grupy (np. strefy) na początku <tbody>. */
tbody .group > th {
  background: var(--bg-subtle);
  font-size: 0.85rem;
  font-weight: 600;
}

tfoot th,
tfoot td {
  font-weight: 600;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-strong);
  border-bottom: none;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Tabela klucz–wartość: nagłówki wierszy po lewej. */
.kv tbody th {
  width: 35%;
  font-weight: 500;
  color: var(--text-muted);
}

/* --- Schemat stref (funkcjonalny, nie rzut) ------------------------------ */

/* Strefy parteru w rzędzie, pod nimi wspólny korytarz (.zones__hall),
   piętro nad głównym domem połączone schodami. */
.zones {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 24px;
  grid-template-areas:
    "note note z4"
    "note note stairs"
    "z3   z2   z1"
    "l3   l2   l1"
    "hall hall hall";
  margin: 0 0 16px;
}

.zones__note {
  grid-area: note;
  margin: 0;
  padding-right: 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.zones__z1 { grid-area: z1; }
.zones__z2 { grid-area: z2; }
.zones__z3 { grid-area: z3; }
.zones__z4 { grid-area: z4; }
.zones__l1 { grid-area: l1; }
.zones__l2 { grid-area: l2; }
.zones__l3 { grid-area: l3; }
.zones__stairs { grid-area: stairs; }

.zone {
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
}

.zone__title {
  margin-bottom: 6px;
  font-weight: 600;
  line-height: 1.3;
}

.zone__title span {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.zone ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.85rem;
}

/* Łącznik między elementami schematu: pionowa linia z etykietą. */
.zones__link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.zones__link::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--border-strong);
}

.zones__link span {
  position: relative;
  padding: 2px 4px;
  background: var(--bg);
}

.zones__hall {
  grid-area: hall;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.9rem;
  text-align: center;
}

.zones__hall span {
  color: var(--text-muted);
}

/* Telefon: korytarz jako pionowy pasek po lewej, strefy odchodzą od niego w prawo. */
@media (max-width: 640px) {
  .zones {
    grid-template-columns: 40px 16px minmax(0, 1fr);
    column-gap: 0;
    grid-template-areas:
      "note note note"
      "hall l3   z3"
      "hall l2   z2"
      "hall l1   z1"
      ".    .    stairs"
      ".    .    z4";
  }

  .zones__note {
    margin-bottom: 12px;
    padding-right: 0;
  }

  .zones__z3,
  .zones__z2 {
    margin-bottom: 12px;
  }

  .zones__hall {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 6px;
    writing-mode: vertical-rl;
  }

  .zones__hall span,
  .zones__l1 span,
  .zones__l2 span,
  .zones__l3 span {
    display: none;
  }

  .zones__l1,
  .zones__l2,
  .zones__l3 {
    min-height: 0;
  }

  .zones__l1::before,
  .zones__l2::before,
  .zones__l3::before {
    top: 50%;
    bottom: auto;
    left: 0;
    width: 100%;
    height: 2px;
    margin: -1px 0 0;
  }
}

/* --- Obrazy --------------------------------------------------------------- */

.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px 24px;
}

/* Galeria: miniatury przycięte do wspólnych proporcji, kliknięcie otwiera oryginał. */
.gallery {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 16px;
}

.gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

@media (max-width: 640px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 12px;
  }
}

figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

figcaption {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Miejsce na obraz, który jeszcze nie został dodany. */
.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%; /* bez tego max-height zwęża blok przez aspect-ratio */
  aspect-ratio: 4 / 3;
  max-height: 320px;
  padding: 16px;
  background: var(--bg-subtle);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.placeholder code {
  font-size: 0.8rem;
}

/* --- Wyróżnienia ---------------------------------------------------------- */

.note {
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.note > :last-child {
  margin-bottom: 0;
}

/* Status: .badge (zaplanowane), .badge--progress (w toku), .badge--done (zakończone). */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge--progress {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--done {
  background: var(--ok-soft);
  color: var(--ok);
}

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

.footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer__inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 24px;
}

.footer p {
  margin: 0;
}

/* --- Wydruk --------------------------------------------------------------- */

@media print {
  .topbar {
    position: static;
  }

  .nav {
    display: none;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  figure,
  tr,
  .facts > div {
    break-inside: avoid;
  }
}
