/* =========================================================
   kalkulatormaterialow.pl — arkusz stylów
   ========================================================= */

:root {
  --ink: #23272b;
  --ink-soft: #4b5157;
  --muted: #737a80;
  --paper: #f5f4f1;
  --card: #ffffff;
  --line: #dddad3;
  --line-strong: #c6c2b8;
  --accent: #f2b705;
  --accent-dark: #9a6b00;
  --accent-soft: #fdf3d0;
  --link: #8a5d00;
  --green: #2f6b4f;
  --green-soft: #e4efe8;
  --warn: #8a5a00;
  --warn-soft: #fdf2d8;
  --error: #a3271b;
  --error-soft: #fbe4e1;

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

  --radius: 6px;
  --container: 1120px;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}

img, svg { max-width: 100%; }

a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--ink); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); margin-top: 1.8em; }
h3 { font-size: 1.15rem; margin-top: 1.5em; }
p { margin: 0 0 1em; }

code, .mono { font-family: var(--mono); font-size: .92em; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 8px 14px;
  z-index: 100;
}
.skip-link:focus { left: 10px; top: 10px; }

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

/* ---------- Header ---------- */

.site-header {
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 3px solid var(--accent);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-size: 1.05rem;
  white-space: nowrap;
}
.logo:hover { color: #fff; }
.logo-mark { width: 34px; height: 34px; color: #fff; flex-shrink: 0; }
.logo-text strong { font-weight: 700; color: var(--accent); }

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 2px;
}

.nav-list a {
  display: block;
  color: #e4e8e6;
  text-decoration: none;
  padding: 8px 11px;
  border-radius: var(--radius);
  font-size: .95rem;
}
.nav-list a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-list a[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; }

.nav-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  background: none;
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  border-radius: var(--radius);
  padding: 8px 12px;
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
}

.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
  position: relative;
  transition: transform .2s, background .2s;
}
.nav-toggle-bar::before,
.nav-toggle-bar::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bar::before { top: -6px; }
.nav-toggle-bar::after { top: 6px; }

.nav-toggle[aria-expanded="true"] .nav-toggle-bar { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 1020px) {
  .nav-toggle { display: inline-flex; }

  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--ink);
    border-bottom: 3px solid var(--accent);
    display: none;
  }
  .main-nav.is-open { display: block; }

  .nav-list {
    flex-direction: column;
    padding: 8px 20px 16px;
  }
  .nav-list a { padding: 12px 10px; font-size: 1rem; border-bottom: 1px solid rgba(255,255,255,.07); border-radius: 0; }
}

/* ---------- Breadcrumbs / intro ---------- */

.breadcrumbs {
  font-size: .88rem;
  color: var(--muted);
  padding: 16px 0 0;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs span[aria-hidden] { margin: 0 4px; }

.page-intro { padding: 18px 0 8px; max-width: 780px; }
.page-intro .lead { font-size: 1.15rem; color: var(--ink-soft); }

/* ---------- Home ---------- */

.hero {
  padding: 46px 0 34px;
  border-bottom: 1px solid var(--line);
  /* siatka jak na papierze milimetrowym */
  background:
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(31,43,45,.05) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(31,43,45,.05) 39px 40px),
    var(--paper);
}
.hero h1 { max-width: 760px; }
.hero .lead { font-size: 1.2rem; color: var(--ink-soft); max-width: 680px; }

.hero-facts {
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  color: var(--ink-soft);
  font-size: .95rem;
}
.hero-facts li::before { content: "■"; color: var(--accent); font-size: .8em; margin-right: 8px; vertical-align: 1px; }

.tool-grid {
  list-style: none;
  padding: 0;
  margin: 26px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.tool-grid-small { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.tool-card a {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s, transform .15s;
}
.tool-card a:hover { border-color: var(--line-strong); border-left-color: var(--ink); transform: translateY(-2px); }
.tool-card-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 6px; }
.tool-card-lead { color: var(--ink-soft); font-size: .95rem; }
.tool-card-more { margin-top: auto; padding-top: 12px; color: var(--link); font-weight: 600; font-size: .92rem; }

/* ---------- Tool panel ---------- */

.tool-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin: 18px 0 30px;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}

@media (max-width: 600px) {
  .tool-panel { padding: 16px; margin-left: -8px; margin-right: -8px; }
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: -4px 0 20px;
  overflow-x: auto;
}
.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 14px;
  font: inherit;
  font-size: .97rem;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.tab-panel[hidden] { display: none; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px 18px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }

label, .label { font-weight: 600; font-size: .92rem; }
.hint { font-size: .85rem; color: var(--muted); font-weight: 400; }

input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 11px;
  min-height: 44px;
}
input.mono, textarea.mono { font-family: var(--mono); font-size: .95rem; }
textarea { min-height: 170px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 2px solid rgba(242,183,5,.45); outline-offset: 0; }

.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: .98rem;
  font-weight: 600;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--accent); color: var(--ink); }
.btn-primary:hover { background: #dca500; color: var(--ink); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn-link { background: none; border: none; color: var(--link); padding: 10px 6px; text-decoration: underline; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.swap-btn { align-self: end; }

/* ---------- Results ---------- */

.result {
  margin-top: 22px;
  border-top: 1px dashed var(--line-strong);
  padding-top: 18px;
}
.result[hidden] { display: none; }
.result-title { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.result-item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  position: relative;
}
.result-label { display: block; font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.result-value { display: block; font-family: var(--mono); font-size: 1.22rem; font-weight: 600; word-break: break-all; }
.result-sub { display: block; font-size: .85rem; color: var(--ink-soft); font-family: var(--mono); }
.result-main .result-value { font-size: 1.6rem; color: var(--ink); }
.result-main { background: var(--accent-soft); border-color: #f0d98a; }

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: .75rem;
  padding: 3px 7px;
  cursor: pointer;
  color: var(--ink-soft);
}
.copy-btn:hover { border-color: var(--ink); color: var(--ink); }
.copy-btn.is-done { background: var(--green-soft); border-color: var(--green); color: var(--green); }

.table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; background: #fff; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--paper); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
td.num { font-family: var(--mono); text-align: right; }
tr:last-child td { border-bottom: none; }
tr.row-error td { background: var(--error-soft); }

.notice {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 14px 0;
  font-size: .95rem;
  border: 1px solid;
}
.notice[hidden] { display: none; }
.notice p:last-child { margin: 0; }
.notice-info { background: var(--green-soft); border-color: #b9d4c3; }
.notice-warn { background: var(--warn-soft); border-color: #ecd193; color: #5c3d00; }
.notice-error { background: var(--error-soft); border-color: #ecb8b1; color: var(--error); }

.preview-svg {
  width: 100%;
  height: 300px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: block;
  margin-top: 12px;
}

.map {
  height: 480px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 16px;
  z-index: 1;
}
@media (max-width: 600px) { .map { height: 360px; } }

/* ---------- Content (opis pod narzędziem) ---------- */

.layout-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 40px;
  align-items: start;
  padding-bottom: 30px;
}
@media (max-width: 900px) { .layout-content { grid-template-columns: 1fr; gap: 10px; } }

.content { max-width: 760px; }
.content ul, .content ol { padding-left: 1.3em; margin: 0 0 1em; }
.content li { margin-bottom: .35em; }
.content table { margin: 0; }

.example-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 16px 0;
}
.example-box p:last-child { margin: 0; }

.formula {
  font-family: var(--mono);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  overflow-x: auto;
  margin: 12px 0 16px;
  white-space: pre;
  font-size: .95rem;
}

.sidebar { position: sticky; top: 90px; }
@media (max-width: 900px) { .sidebar { position: static; } }

.side-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  font-size: .95rem;
}
.side-box h2 { font-size: 1rem; margin: 0 0 10px; }
.side-box ul { list-style: none; padding: 0; margin: 0; }
.side-box li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.side-box li:last-child { border-bottom: none; }

/* ---------- FAQ ---------- */

.faq { margin-top: 10px; }
.faq-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.faq-item summary {
  cursor: pointer;
  padding: 13px 44px 13px 16px;
  font-weight: 600;
  list-style: none;
  position: relative;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--accent);
}
.faq-item[open] summary::after { content: "−"; }
.faq-answer { padding: 0 16px 6px; color: var(--ink-soft); }

/* ---------- Related ---------- */

.related { border-top: 1px solid var(--line); padding: 10px 0 46px; background: #f1eee7; }

/* ---------- Footer ---------- */

.site-footer { background: var(--ink); color: #c9d0ce; font-size: .93rem; padding-top: 40px; }
.site-footer a { color: #e4e8e6; text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }

.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(4, 1fr);
  gap: 26px;
}
@media (max-width: 960px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .footer-grid { grid-template-columns: 1fr; } }

.footer-logo { color: #fff; font-size: 1.1rem; }
.footer-logo strong { color: var(--accent); }
.footer-heading { color: #fff; font-weight: 600; margin-bottom: 8px; }
.footer-links { list-style: none; margin: 0; padding: 0; }
.footer-links li { margin-bottom: 6px; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); margin-top: 26px; padding: 16px 20px 24px; font-size: .85rem; color: #98a3a1; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.footer-bottom p { margin: 0; }
.footer-credit a { color: var(--accent); }

/* ---------- Menu z podmenu (desktop) ---------- */

.nav-item { position: relative; }
.nav-sub { display: none; }

@media (min-width: 1021px) {
  .nav-sub {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 270px;
    list-style: none;
    margin: 0;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 10px 24px rgba(0,0,0,.12);
  }
  .nav-item:hover > .nav-sub,
  .nav-item:focus-within > .nav-sub { display: block; }
  .nav-sub a { color: var(--ink); padding: 8px 10px; font-size: .93rem; }
  .nav-sub a:hover { background: var(--paper); color: var(--ink); }
  .nav-sub a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }
}

@media (max-width: 1020px) {
  .nav-item.has-open > .nav-sub,
  .nav-item > a[aria-current="page"] + .nav-sub { display: block; }
  .nav-sub { list-style: none; padding: 0 0 6px 14px; margin: 0; }
  .nav-sub a { font-size: .93rem; color: #c8ced2; padding: 9px 10px; }
}

/* ---------- Pola z jednostką ---------- */

.input-unit { position: relative; display: flex; }
.input-unit input { padding-right: 52px; }
.unit {
  position: absolute;
  right: 1px; top: 1px; bottom: 1px;
  display: flex; align-items: center;
  padding: 0 12px;
  color: var(--muted);
  font-size: .9rem;
  background: var(--paper);
  border-left: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  pointer-events: none;
}

.form-section { margin: 22px 0 6px; padding-top: 16px; border-top: 1px dashed var(--line-strong); }
.form-section:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.form-section-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; font-weight: 700; }
.field[hidden], .form-grid[hidden], .form-section[hidden] { display: none; }

/* ---------- Lista zakupów ---------- */

.shopping-title { margin: 26px 0 4px; font-size: 1.1rem; }
.shopping td, .shopping th { white-space: normal; }
.shopping td:first-child { min-width: 160px; }
.shopping th.num, .shopping td.num { text-align: right; }
.shopping tfoot td { font-weight: 700; background: var(--paper); border-top: 2px solid var(--line-strong); }
.price-input { width: 96px !important; min-height: 36px !important; padding: 5px 8px !important; text-align: right; font-size: .95rem !important; }
.actions-small { margin-top: 10px; }
.result-note { font-size: .9rem; color: var(--ink-soft); margin: 14px 0 0; }
.result-note[hidden] { display: none; }

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

.steps { counter-reset: step; list-style: none; padding-left: 0 !important; }
.steps li { counter-increment: step; position: relative; padding-left: 44px; margin-bottom: 12px; min-height: 30px; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem;
}

.section-block { margin-top: 34px; }
.section-block h2 a { color: var(--ink); text-decoration: none; }
.section-block h2 a:hover { text-decoration: underline; }
.section-block .section-lead { color: var(--ink-soft); max-width: 720px; }
.related-sections { margin-top: 18px; color: var(--ink-soft); }

.tool-card a { border-left-color: var(--accent); }

/* ---------- Reklamy (włączane w includes/config.php) ---------- */

.ad-slot { display: none; }
.ad-slot.is-active { display: block; margin: 26px 0; min-height: 120px; text-align: center; }
.ad-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.sidebar .ad-slot.is-active { min-height: 250px; }

/* ---------- Utility ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Telefony (od 360 px, bez przewijania w poziomie) ---------- */

html, body { overflow-x: clip; }

@media (max-width: 600px) {
  body { font-size: 1rem; }
  .container { padding: 0 14px; }
  .logo { font-size: .95rem; gap: 8px; }
  .logo-mark { width: 28px; height: 28px; }
  .nav-toggle { padding: 7px 10px; }
  .page-intro .lead, .hero .lead { font-size: 1.05rem; }
  .tool-panel { padding: 14px; margin-left: 0; margin-right: 0; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .result-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .result-item { padding: 10px; }
  .result-value { font-size: 1.05rem; }
  .result-main .result-value { font-size: 1.25rem; }
  .actions .btn { flex: 1 1 auto; }
  .tool-grid, .tool-grid-small { grid-template-columns: 1fr; }

  .formula { white-space: pre-wrap; word-break: break-word; font-size: .85rem; padding: 10px 12px; }
  .table-wrap { overflow-x: visible; border: none; }
  table { font-size: .88rem; }
  th, td { white-space: normal; padding: 7px 8px; }

  /* Lista zakupów jako karty */
  .shopping thead { display: none; }
  .shopping, .shopping tbody, .shopping tfoot, .shopping tr, .shopping td { display: block; width: 100%; }
  .shopping tr { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; padding: 8px 12px; background: #fff; }
  .shopping td { border: none; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right !important; }
  .shopping td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; font-family: var(--font); }
  .shopping td.cell-name { font-weight: 700; text-align: left !important; display: block; padding-bottom: 6px; }
  .shopping td.cell-total-label { display: none; }
  .shopping tfoot tr { background: var(--paper); border-width: 2px; }
  .shopping tfoot td { border-top: none; }
  .price-input { width: 110px !important; }
}

@media (max-width: 380px) {
  .result-grid { grid-template-columns: 1fr; }
  .logo-text { font-size: .9rem; }
}

/* ---------- Druk: tylko wynik i lista zakupów ---------- */

@media print {
  .site-header, .site-footer, .related, .actions, .breadcrumbs, .layout-content, .ad-slot, #calc-form, .page-intro .lead { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .tool-panel { border: none; padding: 0; margin: 0; box-shadow: none; }
  .result { border: none; padding: 0; margin: 0; }
  .result-item { border: 1px solid #999; background: #fff !important; }
  .price-input { border: none !important; }
  .page-intro h1 { font-size: 18pt; }
}
