/*
Theme Name: Trzy Fale BIP 2026
Theme URI: https://bip.trzyfale.slupsk.pl/
Author: OSF / SIG9
Description: Nowoczesna, dostępna skórka WordPress dla Biuletynu Informacji Publicznej Trzy Fale Sp. z o.o.
Version: 0.1.1
Requires at least: 6.4
Tested up to: 6.8
Requires PHP: 8.0
Text Domain: trzyfale-bip-2026
Tags: accessibility-ready, custom-menu, two-columns, editor-style
*/

:root {
  --tf-bg: #f5f7fa;
  --tf-surface: #ffffff;
  --tf-surface-soft: #eef4f8;
  --tf-border: #d9e4ec;
  --tf-text: #172331;
  --tf-muted: #596879;
  --tf-primary: #005d96;
  --tf-primary-dark: #003d63;
  --tf-accent: #0a8fbf;
  --tf-focus: #f6c343;
  --tf-success: #237a45;
  --tf-radius: 8px;
  --tf-shadow: 0 10px 28px rgba(14, 35, 55, 0.08);
  --tf-content: 1180px;
  --tf-shell: 1460px;
  color-scheme: light;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--tf-bg);
  color: var(--tf-text);
  font-family: Arial, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

body.tfbip-contrast {
  --tf-bg: #000000;
  --tf-surface: #000000;
  --tf-surface-soft: #111111;
  --tf-border: #ffff00;
  --tf-text: #ffffff;
  --tf-muted: #f5f5f5;
  --tf-primary: #ffff00;
  --tf-primary-dark: #ffff00;
  --tf-accent: #ffff00;
  --tf-focus: #00ffff;
  --tf-shadow: none;
}

body.tfbip-contrast a,
body.tfbip-contrast .site-title,
body.tfbip-contrast .section-label {
  color: #ffff00;
}

body.tfbip-large-text {
  font-size: 18px;
}

a {
  color: var(--tf-primary);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--tf-primary-dark);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--tf-focus);
  outline-offset: 3px;
}

img {
  max-width: 100%;
  height: auto;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 999;
  padding: 0.75rem 1rem;
  background: var(--tf-focus);
  color: #111;
  font-weight: 700;
}

.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.screen-reader-text:focus {
  width: auto;
  height: auto;
  clip: auto;
  white-space: normal;
}

.skip-link:focus {
  top: 1rem;
}

.top-bar {
  background: var(--tf-primary-dark);
  color: #fff;
}

.top-bar__inner,
.site-header__inner,
.site-footer__inner {
  width: min(calc(100% - 2rem), var(--tf-content));
  margin-inline: auto;
}

.site-shell {
  width: min(calc(100% - 2rem), var(--tf-shell));
  margin-inline: auto;
}

.top-bar__inner {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  font-size: 0.9rem;
}

.top-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.top-bar a {
  color: #fff;
}

.site-header {
  background: linear-gradient(135deg, var(--tf-surface) 0%, var(--tf-surface-soft) 100%);
  border-bottom: 1px solid var(--tf-border);
}

.site-header__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: center;
  padding: 1.5rem 0;
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.brand__content {
  display: grid;
  gap: 0.25rem;
}

.bip-logo {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 89px;
  min-height: 101px;
}

.bip-logo img {
  display: block;
  width: 89px;
  height: auto;
}

.brand__eyebrow,
.section-label {
  color: var(--tf-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-title {
  margin: 0;
  color: var(--tf-primary-dark);
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.12;
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.custom-logo-link {
  display: inline-flex;
  width: fit-content;
}

.custom-logo {
  max-height: 86px;
  width: auto;
}

.site-description {
  max-width: 56rem;
  margin: 0;
  color: var(--tf-muted);
}

.header-tools {
  display: grid;
  gap: 0.75rem;
  justify-items: end;
}

.search-form {
  display: flex;
  width: min(100%, 360px);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  overflow: hidden;
  background: var(--tf-surface);
}

.search-form label {
  flex: 1;
}

.search-field {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  border: 0;
  padding: 0 0.9rem;
  background: transparent;
  color: var(--tf-text);
  font: inherit;
}

.search-submit,
.tool-button {
  min-height: 44px;
  border: 0;
  background: var(--tf-primary);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.search-submit {
  padding: 0 1rem;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.tool-button {
  border: 1px solid var(--tf-primary);
  border-radius: var(--tf-radius);
  padding: 0 0.75rem;
}

.tool-button[data-mode="contrast"] {
  background: #111;
  border-color: #111;
  color: #ffff00;
}

.primary-nav {
  background: var(--tf-surface);
  border-bottom: 1px solid var(--tf-border);
}

.primary-nav ul,
.sidebar-nav ul,
.footer-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.primary-nav .menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  width: min(calc(100% - 2rem), var(--tf-content));
  margin-inline: auto;
}

.primary-nav a {
  display: block;
  padding: 0.9rem 1rem;
  color: var(--tf-text);
  font-weight: 700;
  text-decoration: none;
}

.primary-nav a:hover,
.primary-nav .current-menu-item > a,
.primary-nav .current_page_item > a {
  background: var(--tf-primary);
  color: #fff;
}

.site-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.5rem 0 2rem;
}

.site-sidebar,
.site-main,
.content-card,
.document-meta,
.site-footer {
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  box-shadow: var(--tf-shadow);
}

.site-sidebar {
  align-self: start;
  padding: 1rem;
  position: sticky;
  top: 1rem;
}

.sidebar-title {
  margin: 0 0 0.75rem;
  color: var(--tf-primary-dark);
  font-size: 1.15rem;
}

.site-sidebar .section-label {
  margin-top: 0;
}

.sidebar-nav a {
  display: block;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--tf-border);
  color: var(--tf-text);
  text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav .current-menu-item > a,
.sidebar-nav .current_page_item > a {
  background: var(--tf-surface-soft);
  color: var(--tf-primary-dark);
}

.sidebar-nav .sub-menu a,
.sidebar-nav .children a {
  padding-left: 1.5rem;
  font-size: 0.94rem;
}

.sidebar-actions {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

.sidebar-actions a {
  display: block;
  padding: 0.7rem 0.8rem;
  border-radius: var(--tf-radius);
  background: var(--tf-surface-soft);
  font-weight: 700;
  text-decoration: none;
}

.site-main {
  font-size: 0.94rem;
  min-width: 0;
  padding: clamp(1rem, 2.5vw, 2rem);
}

.breadcrumbs {
  margin-bottom: 1rem;
  color: var(--tf-muted);
  font-size: 0.92rem;
}

.entry-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--tf-border);
}

.entry-title {
  margin: 0.2rem 0 0;
  color: var(--tf-primary-dark);
  font-size: clamp(1.45rem, 3vw, 2.05rem);
  line-height: 1.18;
}

.entry-meta {
  margin-top: 0.5rem;
  color: var(--tf-muted);
  font-size: 0.92rem;
}

.entry-content {
  font-size: 0.96rem;
  overflow-wrap: anywhere;
}

.entry-content h2,
.entry-content h3 {
  color: var(--tf-primary-dark);
  line-height: 1.25;
}

.entry-content table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.entry-content th,
.entry-content td {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--tf-border);
}

.entry-content th {
  background: var(--tf-surface-soft);
  text-align: left;
}

.document-meta {
  font-size: 0.9rem;
  margin-top: 2rem;
  padding: 1rem;
  box-shadow: none;
}

.document-meta__title {
  margin: 0 0 0.75rem;
  color: var(--tf-primary-dark);
  font-size: 1rem;
}

.document-meta dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.4rem 1rem;
  margin: 0;
}

.document-meta dt {
  color: var(--tf-muted);
  font-weight: 700;
}

.document-meta dd {
  margin: 0;
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tf-border);
}

.document-actions a,
.document-actions button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  background: var(--tf-surface-soft);
  color: var(--tf-primary-dark);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.document-actions a:hover,
.document-actions button:hover {
  border-color: var(--tf-primary);
  background: var(--tf-primary);
  color: #fff;
}

.document-history {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tf-border);
}

.document-history h3 {
  margin: 0 0 0.75rem;
  color: var(--tf-primary-dark);
  font-size: 1rem;
}

.document-history__toggle {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  background: var(--tf-primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.document-history__toggle:hover {
  background: var(--tf-primary-dark);
}

.document-history__panel {
  margin-top: 0.85rem;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.table-scroll table {
  width: 100%;
  border-collapse: collapse;
}

.table-scroll th,
.table-scroll td {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--tf-border);
  text-align: left;
  vertical-align: top;
}

.table-scroll th {
  background: var(--tf-surface-soft);
  color: var(--tf-primary-dark);
}

.changelog-table {
  font-size: 0.94rem;
}

.post-list {
  display: grid;
  gap: 1rem;
}

.content-card {
  padding: 1rem;
  box-shadow: none;
}

.content-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}

.pagination {
  margin-top: 1.5rem;
}

.pagination .nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-numbers {
  display: inline-flex;
  min-width: 2.5rem;
  min-height: 2.5rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  background: var(--tf-surface);
  text-decoration: none;
}

.page-numbers.current {
  background: var(--tf-primary);
  color: #fff;
}

.site-footer {
  border-radius: 0;
  border-inline: 0;
  border-bottom: 0;
  box-shadow: none;
}

.site-footer__inner {
  display: grid;
  gap: 1rem;
  padding: 1.5rem 0;
}

.footer-nav .menu,
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.footer-links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sitemap__list,
.sitemap__list ul {
  margin: 0.35rem 0 0.35rem 1.25rem;
  padding: 0;
}

.sitemap__list {
  margin-left: 0;
  list-style-position: inside;
}

.sitemap__list li {
  margin: 0.35rem 0;
}

.sitemap__list a {
  font-weight: 700;
}

.site-footer p {
  margin: 0;
  color: var(--tf-muted);
}

.wp-block-file a,
.entry-content a[href$=".pdf"],
.entry-content a[href$=".doc"],
.entry-content a[href$=".docx"],
.entry-content a[href$=".xls"],
.entry-content a[href$=".xlsx"] {
  font-weight: 700;
}

@media (max-width: 860px) {
  .top-bar__inner,
  .site-header__inner,
  .site-shell {
    width: min(calc(100% - 1rem), var(--tf-shell));
  }

  .top-bar__inner,
  .site-header__inner {
    grid-template-columns: 1fr;
  }

  .top-bar__inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 0.6rem 0;
  }

  .site-header__inner {
    display: grid;
  }

  .brand {
    align-items: flex-start;
  }

  .header-tools {
    justify-items: stretch;
  }

  .search-form {
    width: 100%;
  }

  .tool-row {
    justify-content: flex-start;
  }

  .site-shell {
    grid-template-columns: 1fr;
  }

  .site-sidebar {
    position: static;
  }

  .primary-nav .menu {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .primary-nav a {
    white-space: nowrap;
  }

  .document-meta dl {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    margin: 16mm;
  }

  * {
    background: transparent !important;
    box-shadow: none !important;
  }

  html,
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
    line-height: 1.45;
  }

  .top-bar,
  .site-header,
  .header-tools,
  .primary-nav,
  .site-sidebar,
  .site-footer,
  .breadcrumbs,
  .document-actions,
  .document-history,
  .skip-link {
    display: none !important;
  }

  .site-shell,
  .site-main {
    display: block;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .entry-header {
    margin-bottom: 0.8rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #999;
  }

  .entry-title {
    color: #000 !important;
    font-size: 18pt;
  }

  .entry-content,
  .document-meta {
    font-size: 10.5pt;
  }

  .entry-content a {
    color: #000 !important;
    text-decoration: underline;
  }

  .entry-content table {
    display: table;
    overflow: visible;
    width: 100%;
    page-break-inside: auto;
  }

  .entry-content tr,
  .document-meta {
    page-break-inside: avoid;
  }

  .document-meta {
    margin-top: 1rem;
    padding: 0.75rem;
    border: 1px solid #999;
    border-radius: 0;
  }

  .document-meta__title {
    color: #000 !important;
  }
}
