/* ============================================================
   Emigracja - design system
   Koncepcja: "Paszport i stempel" - gleboka zielen paszportu,
   zlote embossing, kremowy papier dokumentow.
   Light + dark, WCAG AA (kontrast >= 4.5:1), body 17px
   ============================================================ */

:root {
  /* Light theme - kremowy papier */
  --bg: #f6f1e6;
  --bg-soft: #efe8d8;
  --panel: #ffffff;
  --panel-2: #fbf8f0;
  --text: #2b2a25;
  --text-soft: #55524a;
  --muted: #6f6a5e;
  --border: #e2d9c3;
  --accent: #a87b1e;          /* zloto ciemne - tekst/akcenty na jasnym */
  --accent-strong: #8a6415;
  --accent-light: #d9a441;    /* zloto jasne - dekoracje */
  --accent-soft: #f0e2c0;
  --green: #1d5c3f;           /* zielen paszportu - naglowki, linki */
  --green-deep: #14402c;
  --header-bg: rgba(246, 241, 230, 0.92);
  --shadow: 0 1px 3px rgba(20, 30, 22, 0.08), 0 8px 24px rgba(20, 30, 22, 0.06);
  --shadow-hover: 0 4px 12px rgba(20, 30, 22, 0.12), 0 16px 40px rgba(20, 30, 22, 0.1);
  --radius: 14px;
  --radius-sm: 9px;
  --transition: all 0.2s ease-out;
  --font-display: "Unbounded", sans-serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
  --header-height: 64px;
  --sidebar-width: 300px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e2a1d;
    --bg-soft: #123524;
    --panel: #143524;
    --panel-2: #173d29;
    --text: #f2ead9;
    --text-soft: #cfc4ac;
    --muted: #a89c82;
    --border: #244d36;
    --accent: #d9a441;
    --accent-strong: #e0b25a;
    --accent-light: #f0c96a;
    --accent-soft: #2c3d1f;
    --green: #7fbf9a;
    --green-deep: #a3d4b8;
    --header-bg: rgba(14, 42, 29, 0.92);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.35);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { overflow-x: clip; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 800px 500px at -10% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(ellipse 700px 450px at 110% 110%, var(--accent-soft), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; text-wrap: balance; }

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent-strong); color: #fff; padding: 10px 18px;
  border-radius: 0 0 var(--radius-sm) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 150;
  height: var(--header-height);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-light), transparent);
  opacity: 0.3;
}
.header-inner {
  max-width: 1400px; margin: 0 auto; padding: 0 20px;
  height: 100%; display: flex; align-items: center; gap: 18px;
}
.menu-btn {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: 0; cursor: pointer; padding: 8px;
}
.menu-btn span {
  width: 22px; height: 2px; background: var(--text); border-radius: 2px;
  transition: var(--transition);
}
.menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.brand {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  color: var(--text); text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 26px; line-height: 1; }
.brand-name {
  font-family: var(--font-display); font-weight: 600; font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.brand-name em {
  font-style: normal; color: var(--accent-strong);
}

.search-wrap { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search-input {
  width: 100%; padding: 10px 16px; font-size: 0.95rem;
  font-family: var(--font-body); color: var(--text);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; outline: none; transition: var(--transition);
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-results {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover); overflow: hidden; z-index: 200;
}
.search-results.open { display: block; animation: fadeUp 0.2s ease-out; }
.search-item {
  display: block; padding: 10px 16px; border-bottom: 1px solid var(--border);
  text-decoration: none; transition: var(--transition);
}
.search-item:last-child { border-bottom: 0; }
.search-item:hover { background: var(--bg-soft); text-decoration: none; }
.si-title { font-weight: 600; color: var(--text); font-size: 0.95rem; }
.si-section { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.search-empty { padding: 12px 16px; color: var(--muted); font-size: 0.9rem; }

.header-tagline {
  font-size: 0.8rem; color: var(--muted); white-space: nowrap;
  font-family: var(--font-mono); letter-spacing: 0.04em;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1400px; margin: 0 auto; padding: calc(var(--header-height) + 20px) 20px 40px;
  display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); gap: 32px;
}

.sidebar {
  position: sticky; top: calc(var(--header-height) + 20px);
  max-height: calc(100vh - var(--header-height) - 40px);
  overflow-y: auto; padding: 6px 16px 16px 0;
  scrollbar-width: thin;
}
.side-group { margin-bottom: 4px; }
.side-group-title {
  cursor: pointer; list-style: none;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); padding: 10px 8px 6px;
  display: flex; align-items: center; gap: 8px; user-select: none;
}
.side-group-title::-webkit-details-marker { display: none; }
.side-group-title::before {
  content: ''; width: 14px; height: 1px; background: var(--accent); flex-shrink: 0;
}
.side-group[open] .side-group-title::before { background: var(--green); }
.side-group-items { display: flex; flex-direction: column; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.9rem; font-weight: 500; color: var(--text-soft);
  padding: 6px 10px; border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: var(--transition); text-decoration: none;
}
.sidebar-link:hover {
  color: var(--text); background: var(--bg-soft); text-decoration: none;
  transform: translateX(2px);
}
.sidebar-link.active {
  color: var(--accent-strong); background: var(--accent-soft);
  border-left-color: var(--accent);
}
.sidebar-link .s-icon { font-size: 0.95rem; flex-shrink: 0; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  z-index: 140;
}

.main-content { min-width: 0; }

/* ---------- Home hero ---------- */
.home-hero {
  position: relative;
  border-radius: var(--radius);
  padding: 48px 44px;
  background: var(--green-deep);
  background-image:
    radial-gradient(ellipse 500px 300px at 85% 15%, rgba(217, 164, 65, 0.18), transparent 60%),
    radial-gradient(ellipse 400px 300px at 10% 90%, rgba(127, 191, 154, 0.14), transparent 60%);
  color: var(--text-dark, #f2ead9);
  overflow: hidden;
  display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 32px; align-items: center;
  box-shadow: var(--shadow);
}
.hero-eyebrow {
  display: inline-block; font-family: var(--font-mono); font-size: 0.75rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-light);
  background: rgba(217, 164, 65, 0.12); border: 1px solid rgba(217, 164, 65, 0.35);
  padding: 5px 12px; border-radius: 999px; margin-bottom: 18px;
}
.home-hero h1 {
  font-size: clamp(1.6rem, 3.6vw, 2.6rem); font-weight: 600; color: #fff;
  margin-bottom: 14px;
}
.home-hero h1 .accent-word { color: var(--accent-light); }
.hero-sub { font-size: 1.02rem; color: #d8e4d8; margin-bottom: 24px; max-width: 56ch; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-block; padding: 12px 22px; border-radius: 999px;
  font-weight: 600; font-size: 0.95rem; text-decoration: none;
  transition: var(--transition); border: 1px solid transparent;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn-primary { background: var(--accent); color: #2b2108; }
.btn-primary:hover { background: var(--accent-light); box-shadow: 0 6px 18px rgba(217, 164, 65, 0.35); }
.btn-ghost { border-color: rgba(242, 234, 217, 0.4); color: #f2ead9; }
.btn-ghost:hover { background: rgba(242, 234, 217, 0.1); }

.hero-visual { display: flex; justify-content: center; align-items: center; }
.hero-stamp { text-align: center; }
.hero-stamp svg { width: 100%; max-width: 260px; height: auto; }
.stamp-ring {
  fill: none; stroke: var(--accent-light); stroke-width: 2.5;
  stroke-dasharray: 4 5; opacity: 0.85;
  animation: stampSpin 40s linear infinite;
  transform-origin: 100px 100px;
}
.stamp-ring-2 { fill: none; stroke: rgba(242, 234, 217, 0.5); stroke-width: 1.5; }
.stamp-text {
  font-family: var(--font-mono); font-size: 11.5px; fill: var(--accent-light);
  letter-spacing: 0.18em;
}
.stamp-text-2 { font-family: var(--font-mono); font-size: 9.5px; fill: rgba(242, 234, 217, 0.75); letter-spacing: 0.14em; }
.stamp-plane { fill: var(--accent-light); }
.stamp-center { fill: rgba(242, 234, 217, 0.12); }
.stamp-line { stroke: rgba(242, 234, 217, 0.35); stroke-width: 1; stroke-dasharray: 3 4; }
.hero-stamp-caption {
  font-family: var(--font-mono); font-size: 0.72rem; color: #b9cfc0;
  letter-spacing: 0.1em; margin-top: 10px;
}
@keyframes stampSpin { to { transform: rotate(360deg); } }

.hero-stats {
  grid-column: 1 / -1;
  display: flex; gap: 32px; flex-wrap: wrap; margin-top: 8px;
  padding-top: 22px; border-top: 1px solid rgba(242, 234, 217, 0.18);
}
.hero-stat { display: flex; flex-direction: column; }
.hero-stat b {
  font-family: var(--font-display); font-size: 1.5rem; color: var(--accent-light);
}
.hero-stat span { font-size: 0.82rem; color: #b9cfc0; }

/* ---------- Home sections ---------- */
.home-section { margin-top: 44px; }
.home-section h2 {
  font-size: 1.35rem; font-weight: 600; color: var(--text);
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px;
}
.sec-count {
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px; padding: 2px 8px;
}
.sec-desc { color: var(--muted); margin-bottom: 20px; max-width: 70ch; }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.home-card {
  position: relative; display: block;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  text-decoration: none; color: var(--text);
  transition: var(--transition); overflow: hidden;
}
.home-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--green));
  opacity: 0; transition: var(--transition);
}
.home-card:hover {
  transform: translateY(-3px); box-shadow: var(--shadow-hover);
  text-decoration: none; border-color: var(--accent-light);
}
.home-card:hover::before { opacity: 1; }
.hc-icon { font-size: 1.7rem; display: block; margin-bottom: 10px; }
.home-card h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; line-height: 1.4; }
.home-card p { font-size: 0.85rem; color: var(--muted); line-height: 1.55; }
.hc-more {
  display: inline-block; margin-top: 12px; font-size: 0.82rem; font-weight: 600;
  color: var(--accent-strong);
}
.hc-more .arrow { display: inline-block; transition: var(--transition); }
.home-card:hover .hc-more .arrow { transform: translateX(4px); }

/* ---------- Article ---------- */
.article-header { margin-bottom: 28px; }
.breadcrumbs {
  font-size: 0.82rem; color: var(--muted); margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.breadcrumbs a { color: var(--green); }
.breadcrumbs .sep { color: var(--muted); }
.article-header h1 {
  font-size: clamp(1.5rem, 3.2vw, 2.2rem); font-weight: 600; color: var(--text);
  margin-bottom: 12px;
}
.article-excerpt { font-size: 1.05rem; color: var(--text-soft); max-width: 70ch; }
.article-meta {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px;
  font-size: 0.8rem; color: var(--muted);
}
.tag {
  background: var(--accent-soft); color: var(--accent-strong);
  padding: 3px 10px; border-radius: 999px; font-weight: 600; font-size: 0.75rem;
}

.article-body { max-width: 820px; }
.article-body h2 {
  font-size: 1.3rem; font-weight: 600; color: var(--text);
  margin: 36px 0 12px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.article-body h3 { font-size: 1.05rem; font-weight: 600; color: var(--text); margin: 24px 0 8px; }
.article-body p { margin-bottom: 14px; color: var(--text); }
.article-body ul, .article-body ol { margin: 0 0 16px 22px; color: var(--text); }
.article-body li { margin-bottom: 6px; }
.article-body strong { color: var(--text); }
.article-body a { color: var(--green); text-decoration: underline; text-underline-offset: 2px; }

.article-toc {
  background: var(--panel-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 14px 18px; margin-bottom: 26px;
}
.article-toc summary {
  cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--text);
}
.article-toc ol { margin: 10px 0 0 20px; font-size: 0.88rem; }
.article-toc a { color: var(--text-soft); }
.article-toc a:hover { color: var(--accent-strong); }

.info-box {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 18px; margin: 18px 0;
  font-size: 0.95rem;
}
.info-box::before { content: '✱ '; color: var(--accent); font-weight: 700; }

.error-table, .compare-table {
  width: 100%; border-collapse: collapse; margin: 18px 0;
  font-size: 0.92rem;
}
.error-table th, .compare-table th {
  text-align: left; background: var(--green-deep); color: #f2ead9;
  padding: 10px 14px; font-weight: 600; font-size: 0.85rem;
}
.error-table td, .compare-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text);
}
.error-table tr:nth-child(even) td, .compare-table tr:nth-child(even) td { background: var(--panel-2); }
.table-responsive { overflow-x: auto; }

.faq-item {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 18px; margin-bottom: 12px;
}
.faq-item h3 { font-size: 1rem; margin: 0 0 8px; color: var(--green-deep); }
.faq-item p { margin: 0; font-size: 0.95rem; }

.glossary-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.glossary-term {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.glossary-term dt {
  font-weight: 700; color: var(--green-deep); font-size: 0.95rem;
}
.glossary-term dd { margin: 4px 0 0; font-size: 0.88rem; color: var(--text-soft); }

.article-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border);
}
.article-nav a {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 18px; text-decoration: none; transition: var(--transition);
}
.article-nav a:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.article-nav .an-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.article-nav .an-title { font-weight: 600; color: var(--text); margin-top: 4px; font-size: 0.92rem; }
.article-nav .next { text-align: right; }
.article-nav span { display: none; }

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  margin-top: 60px;
}
.footer-inner {
  max-width: 1400px; margin: 0 auto; padding: 32px 20px;
  font-size: 0.9rem; color: var(--text-soft);
}
.footer-note { font-size: 0.8rem; color: var(--muted); margin-top: 10px; }
.footer-copy { font-size: 0.8rem; color: var(--muted); margin-top: 14px; }

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.app-content > * { animation: fadeUp 0.25s ease-out; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding-top: calc(var(--header-height) + 16px); }
  .menu-btn { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 145;
    width: min(320px, 86vw); background: var(--bg);
    border-right: 1px solid var(--border);
    padding: calc(var(--header-height) + 12px) 18px 24px;
    transform: translateX(-102%); transition: transform 0.25s ease-out;
    max-height: 100vh; box-shadow: var(--shadow-hover);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .header-tagline { display: none; }
  .home-hero { grid-template-columns: 1fr; padding: 32px 24px; }
  .hero-visual { display: none; }
  .search-wrap { max-width: none; }
}

@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 18px; }
  .article-nav { grid-template-columns: 1fr; }
  .brand-name { font-size: 0.92rem; }
  .header-inner { gap: 10px; padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
