/*
  e-artlife // digital lab — design system
  Ciemny motyw, surowy produkt AI, minimalne animacje.
*/

:root {
  /* Kolory */
  --bg: #0B0F14;
  --surface: #0F1620;
  --surface-alt: #121B26;
  --text: #E6EDF3;
  --text-muted: #9FB0C0;
  --accent: #7CFFB2;
  --accent-hover: #5ee99a;
  --border: #223041;
  --error: #f87171;
  --success: #7CFFB2;
  /* Aliasy dla skryptów (blog.js, chatbot.js) */
  --accent-color: var(--accent);
  --accent-hover-color: var(--accent-hover);
  --border-color: var(--border);
  --text-primary: var(--text);
  --text-secondary: var(--text-muted);

  /* Typografia */
  --font-sans: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Rytm (spacing scale) */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  --radius: 12px;
  --max-text: 72ch;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
}

/* Typografia */
h1, h2, h3, h4 {
  margin: 0 0 var(--s4);
  font-weight: 600;
  line-height: 1.25;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
h3 { font-size: 1.15rem; }

p {
  margin: 0 0 var(--s4);
  max-width: var(--max-text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.font-mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* Layout */
.site-header {
  padding: var(--s5) var(--s4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header .wrap {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
}

.site-logo {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text);
}

.site-logo:hover { text-decoration: none; color: var(--accent); }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4);
}

.site-nav a {
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

main {
  flex: 1;
  padding: var(--s6) var(--s4) var(--s8);
}

.main-wrap {
  max-width: 960px;
  margin: 0 auto;
}

/* Panele / karty */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s6);
  margin-bottom: var(--s6);
}

.panel h2 {
  margin-top: 0;
  margin-bottom: var(--s5);
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Siatka 3 kafelków "Co tu jest" */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--s5);
}

.tile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s5);
  background: var(--surface-alt);
}

.tile:hover { border-color: var(--accent); }

.tile h3 {
  font-family: var(--font-mono);
  font-size: 1rem;
  margin-bottom: var(--s2);
  color: var(--accent);
}

.tile p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Schemat architektury (Input → Przetwarzanie → Output) */
.schema-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  max-width: 28rem;
  margin: 0 auto;
}

.schema-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: var(--s4) var(--s5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.schema-step + .schema-arrow + .schema-step { margin-top: 0; }

.schema-label {
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--s2);
}

.schema-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.schema-arrow {
  padding: var(--s2) 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--accent);
  line-height: 1;
}

/* Architektura — układ [tag] value (jak w konsoli) */
.schema-flow-system {
  max-width: 32rem;
}

.schema-flow-system .schema-row {
  display: flex;
  align-items: baseline;
  gap: var(--s4);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.schema-flow-system .schema-arrow { margin-left: var(--s4); }

.schema-flow-system .schema-tag {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--accent);
  min-width: 5.5rem;
}

.schema-flow-system .schema-row + .schema-arrow + .schema-row { margin-top: 0; }

/* Lista "Aktualnie" — logi */
.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.log-list li {
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.log-list li:last-child { border-bottom: 0; }

.log-list li::before {
  content: "› ";
  color: var(--accent);
  margin-right: var(--s2);
}

/* Zasady — lista inżynierska */
.rules-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rules-list li {
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text);
}

.rules-list li:last-child { border-bottom: 0; }

.rules-list li::before {
  content: "· ";
  color: var(--accent);
  font-weight: bold;
  margin-right: var(--s2);
}

/* Logi konsoli [BUILD], [TEST]… */
.log-console .log-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  margin-right: var(--s2);
}

.log-console li::before { content: none; }

/* Stopka */
.site-footer {
  padding: var(--s6) var(--s4);
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.site-footer .wrap {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
}

.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

.footer-block { flex-direction: column; align-items: flex-start; gap: var(--s4); }
.footer-tagline { margin: 0 0 var(--s2); font-size: 0.85rem; color: var(--accent); }
.footer-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s4); width: 100%; }

.stack-line { margin: 0; font-size: 0.9rem; color: var(--text-muted); }

/* Hero */
.hero {
  padding: var(--s8) 0;
  text-align: left;
}

.hero .title {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--text);
  margin-bottom: var(--s4);
}

.hero .subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: var(--max-text);
  margin-bottom: var(--s5);
  line-height: 1.6;
}

.hero .hero-context {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: var(--s5);
}

.hero .status-block {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--s4);
}

.hero .status-block span { color: var(--accent); }

/* Formularz — produktowy */
.form-group {
  margin-bottom: var(--s5);
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--s2);
}

.form-group .hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--s2);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: var(--s3) var(--s4);
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group input:invalid:not(:placeholder-shown),
.form-group textarea:invalid:not(:placeholder-shown) {
  border-color: var(--error);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.btn {
  display: inline-block;
  padding: var(--s3) var(--s5);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover { background: var(--accent-hover); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Komunikaty formularza */
.form-msg {
  padding: var(--s4);
  border-radius: var(--radius);
  margin-top: var(--s5);
  font-size: 0.9rem;
}

.form-msg.success {
  background: rgba(124, 255, 178, 0.1);
  border: 1px solid var(--success);
  color: var(--text);
}

.form-msg.error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
}

/* Chat — console-like (floating widget) */
.chat-widget {
  position: fixed;
  bottom: var(--s5);
  right: var(--s5);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.chat-console {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 520px;
  margin-bottom: var(--s4);
}

.chat-console .chat-header {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-console .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--s4);
  min-height: 200px;
}

/* Wiadomości dodawane przez chatbot.js — styl logów */
.chat-console .chat-messages > div {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.chat-console .chat-messages > div:last-child { border-bottom: none; }

.chat-console .chat-messages .typing-indicator {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chat-avatar {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: cover;
}

.chat-console .chat-bubble,
.chat-console .glass-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s3) var(--s4);
  flex: 1;
  min-width: 0;
}

.chat-console .chat-bubble .text-sm,
.chat-console .glass-card .text-sm {
  margin: 0;
  color: var(--text);
  white-space: pre-line;
}

.chat-console .chat-messages > div.justify-end .glass-card {
  background: rgba(124, 255, 178, 0.12);
  border-color: var(--accent);
}

.chat-console .chat-input-row {
  display: flex;
  padding: var(--s4);
  border-top: 1px solid var(--border);
  gap: var(--s2);
}

.chat-console .chat-input-row input {
  flex: 1;
  padding: var(--s3) var(--s4);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chat-console .chat-input-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-toggle {
  padding: var(--s3) var(--s5);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}

.chat-toggle:hover { background: var(--accent-hover); }
.chat-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chat-toggle .hidden { display: none !important; }
#chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--error);
  color: var(--bg);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Quick questions w chatcie */
#quick-questions {
  padding: 0 var(--s4) var(--s3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

#quick-questions button,
.quick-question-btn {
  padding: var(--s2) var(--s3);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

#quick-questions button:hover,
.quick-question-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-user-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Blog — changelog style */
.changelog-list { list-style: none; margin: 0; padding: 0; }

.changelog-list li {
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--border);
}

.changelog-list li:last-child { border-bottom: 0; }

.changelog-list a {
  color: var(--text);
  display: block;
}

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

.changelog-list .date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: var(--s1);
}

.changelog-list .title { font-weight: 600; margin-bottom: var(--s2); }
.changelog-list .excerpt { font-size: 0.9rem; color: var(--text-muted); }

/* Karty artykułów (blog.js) — metadane i treść */
#blog-list .article-card .article-meta,
#blog-list .article-card .article-category-badge { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); margin-bottom: var(--s2); }
#blog-list .article-card .article-card-image { display: none; }
#blog-list .article-card h3 { margin: 0 0 var(--s2); font-size: 1rem; }
#blog-list .article-card p { margin: 0; font-size: 0.9rem; color: var(--text-muted); }
#blog-list .article-card a { color: inherit; }
#blog-list .article-card a:hover { color: var(--accent); }

/* Strona blog: filtry kategorii i paginacja */
.category-filters-wrap,
#category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  min-height: 2.5rem;
  margin-bottom: var(--s5);
}

#category-filters button,
.category-filter-btn {
  padding: var(--s2) var(--s4);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
#category-filters button:hover,
.category-filter-btn:hover { border-color: var(--accent); color: var(--accent); }
#category-filters button.active,
.category-filter-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.blog-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  margin-top: var(--s6);
}
.blog-pagination button {
  padding: var(--s2) var(--s4);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.blog-pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.blog-pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.blog-pagination button:not(:disabled) { cursor: pointer; }

/* Blog — strona listy */
.blog-intro { margin-bottom: var(--s5); max-width: var(--max-text); }

.back-to-list { margin-top: var(--s5); margin-bottom: 0; }
.btn-close-modal { margin-bottom: var(--s4); }

/* Artykuł — typografia */
.article-body { max-width: var(--max-text); }

.article-body h1, .article-body h2, .article-body h3 {
  margin-top: var(--s6);
  margin-bottom: var(--s4);
}

.article-body pre,
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.article-body pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4);
  overflow-x: auto;
  margin: var(--s4) 0;
}

.article-body code { background: var(--surface-alt); padding: 2px 6px; border-radius: 4px; }
.article-body pre code { padding: 0; background: none; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--s4);
  margin: var(--s4) 0;
  color: var(--text-muted);
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 20, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--s4);
}

.modal-overlay[aria-hidden="true"] { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s6);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

/* Modal artykułu — prawie pełna szerokość ekranu */
#article-modal .modal-box {
  max-width: min(1200px, 95vw);
}

/* Animacje — minimalne, z szacunkiem do prefers-reduced-motion */
@media (prefers-reduced-motion: no-preference) {
  .fade-in {
    animation: fadeIn 0.4s ease-out;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.loading-state {
  text-align: center;
  padding: var(--s8) 0;
}
.loading-spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { margin-top: var(--s4); color: var(--text-muted); }
@media (prefers-reduced-motion: reduce) {
  .loading-spinner { animation: none; border-top-color: var(--accent); }
}

/* Mobile: hamburger bez zewnętrznych bibliotek */
.nav-toggle {
  display: none;
  padding: var(--s2) var(--s3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
}

@media (max-width: 640px) {
  .nav-toggle { display: block; }
  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
  }
  .site-nav.is-open { display: flex; }
  .site-header .wrap { flex-direction: column; align-items: flex-start; }
}

/* Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-red-400 { color: var(--error); }

/* Lista bloga — karty jako rzędy changelog */
#blog-list .article-card {
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  background: none;
  border-radius: 0;
}
#blog-list .article-card:hover { border-color: var(--accent); }
#blog-list .article-card:last-child { border-bottom: 0; }
