/* ==========================================================================
   Majonez UI — jeden plik, wszystkie komponenty.
   Neobrutalizm: grube czarne obrysy, twarde cienie bez rozmycia, mało zaokrągleń.
   ========================================================================== */

/* Tokeny (kolory, obrysy, cienie, typografia): styles/tokens.css — ładowany przed tym plikiem. */

/* ---------- Reset / baza ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  font: 400 var(--fs-base)/1.6 var(--font-body);
  color: var(--c-ink);
  background-color: var(--c-cream);
  background-image: radial-gradient(rgb(17 17 17 / 0.09) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
img, svg { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--c-ketchup); }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px dashed var(--c-ink);
  outline-offset: 4px;
}

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

.skip-link {
  position: absolute; left: var(--s4); top: -100px; z-index: 1000;
  background: var(--c-yellow); border: var(--border); box-shadow: var(--shadow-sm);
  padding: var(--s2) var(--s4); font-weight: 800; text-decoration: none;
}
.skip-link:focus { top: var(--s4); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: var(--s4); }
.stack > * + * { margin-top: var(--s4); }
.stack-lg > * + * { margin-top: var(--s6); }
.row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.mt-4 { margin-top: var(--s4); }
.mt-6 { margin-top: var(--s6); }
.grid { display: grid; gap: var(--s5); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid--form { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ---------- Typografia ---------- */
.display, h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
.tilt { display: inline-block; transform: rotate(var(--tilt)); }
.tilt--r { display: inline-block; transform: rotate(1.5deg); }
.lead { font-size: var(--fs-lg); font-weight: 600; }
.muted { color: var(--c-muted); }
.small { font-size: var(--fs-sm); }
.text-error { color: var(--c-ketchup-ink); font-weight: 700; }
.highlight {
  background: var(--c-yellow);
  padding: 0 0.2em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ---------- Karta ---------- */
.card {
  background: var(--c-paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s5);
}
.card--cream { background: var(--c-cream); }
.card--yellow { background: var(--c-yellow); }
.card--flush { padding: 0; overflow: hidden; }
.card__title { margin-bottom: var(--s4); }

/* ---------- Przycisk ---------- */
.btn {
  --btn-bg: var(--c-yellow);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px;
  padding: 0.6em 1.15em;
  font: 800 var(--fs-base)/1.1 var(--font-body);
  color: var(--c-ink);
  text-decoration: none;
  background: var(--btn-bg);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  user-select: none;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast);
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--c-ink); }
.btn:active,
.btn[aria-pressed="true"] {
  transform: translate(var(--press), var(--press));
  box-shadow: 0 0 0 var(--c-ink);
}
.btn--ghost { --btn-bg: var(--c-paper); }
.btn--cream { --btn-bg: var(--c-cream); }
.btn--danger { --btn-bg: var(--c-ketchup); }
.btn--success { --btn-bg: var(--c-green); }
.btn--sm { min-height: 36px; padding: 0.35em 0.8em; font-size: var(--fs-sm); }
.btn--lg { min-height: 56px; padding: 0.8em 1.5em; font-size: var(--fs-lg); box-shadow: var(--shadow); }
.btn--block { width: 100%; }
.btn--icon { padding: 0.35em; min-width: 44px; }
.btn[disabled], .btn[aria-disabled="true"] {
  cursor: not-allowed; opacity: 0.55; transform: none; box-shadow: var(--shadow-sm);
}
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::after {
  content: ""; width: 0.9em; height: 0.9em;
  border: 2.5px solid var(--c-ink); border-right-color: transparent; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn .icon { width: 1.4em; height: 1.4em; flex-shrink: 0; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--s1);
  padding: 0.1em 0.55em;
  font: 800 0.75rem/1.6 var(--font-body);
  text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--c-paper);
  border: 2px solid var(--c-ink);
  border-radius: var(--radius);
  box-shadow: 2px 2px 0 var(--c-ink);
  white-space: nowrap;
}
.badge--yellow { background: var(--c-yellow); }
.badge--danger { background: var(--c-ketchup); }
.badge--success { background: var(--c-green); }
.badge--sky { background: var(--c-sky); }
.badge--plain { text-transform: none; letter-spacing: 0; }

/* ---------- Formularze ---------- */
.field { display: grid; gap: var(--s1); align-content: start; }
/* Pole tekstowe obok przycisku w jednym rzędzie */
.row > .input { width: auto; min-width: 0; flex: 1 1 10rem; }
.row > .btn { flex: 0 0 auto; }
.label { font-weight: 800; }
.hint { font-size: var(--fs-sm); color: var(--c-muted); }
.input {
  width: 100%;
  min-height: 46px;
  padding: 0.55em 0.8em;
  background: var(--c-paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: inset 3px 3px 0 rgb(17 17 17 / 0.08);
}
.input::placeholder { color: #77725f; }
.input:focus-visible { outline: none; box-shadow: var(--shadow-sm); background: #fffdf3; }
.input[aria-invalid="true"] { border-color: var(--c-ketchup-ink); }
.input--mono { font-family: var(--font-mono); }

/* Przełącznik */
.switch {
  appearance: none; -webkit-appearance: none;
  position: relative; flex-shrink: 0;
  width: 58px; height: 32px;
  background: var(--c-paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background-color var(--t-fast);
}
.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: var(--c-ink);
  border-radius: 2px;
  transition: transform var(--t-fast);
}
.switch:checked { background: var(--c-green); }
.switch:checked::before { transform: translateX(26px); }
.switch-field { display: flex; align-items: center; gap: var(--s3); cursor: pointer; font-weight: 700; }

/* ---------- Dropdown (js/components/listbox.js) ---------- */
.mj-listbox { position: relative; }
.mj-listbox__button {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  width: 100%; min-height: 46px;
  padding: 0.55em 0.8em;
  text-align: left; font-weight: 700;
  background: var(--c-paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.mj-listbox__button::after {
  content: ""; flex-shrink: 0;
  width: 0; height: 0;
  border-inline: 6px solid transparent;
  border-top: 8px solid var(--c-ink);
  transition: transform var(--t-fast);
}
.mj-listbox__button:hover { background: #fffdf3; }
.mj-listbox__button[aria-expanded="true"] {
  transform: translate(var(--press), var(--press));
  box-shadow: 0 0 0 var(--c-ink);
  background: var(--c-yellow);
}
.mj-listbox__button[aria-expanded="true"]::after { transform: rotate(180deg); }
.mj-listbox__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mj-listbox__list {
  position: absolute; z-index: 100;
  top: calc(100% + 8px); left: 0; right: 0;
  max-height: min(50vh, 320px);
  overflow-y: auto;
  margin: 0; padding: var(--s1);
  list-style: none;
  background: var(--c-paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}
.mj-listbox--up .mj-listbox__list { top: auto; bottom: calc(100% + 8px); }
.mj-listbox__list:focus-visible { outline: 3px dashed var(--c-ink); outline-offset: 3px; }
.mj-listbox__option {
  display: flex; align-items: center; gap: var(--s2);
  min-height: 44px;
  padding: var(--s2) var(--s3);
  border: 2px solid transparent;
  border-radius: 2px;
  cursor: pointer;
}
.mj-listbox__option::before { content: ""; width: 1.1em; flex-shrink: 0; font-weight: 900; }
.mj-listbox__option[aria-selected="true"] { font-weight: 800; }
.mj-listbox__option[aria-selected="true"]::before { content: "✓"; }
.mj-listbox__option.is-active { background: var(--c-yellow); border-color: var(--c-ink); }
.mj-listbox__option[aria-disabled="true"] { color: var(--c-muted); cursor: not-allowed; }

/* ---------- Tabela ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--c-paper); }
.table th, .table td {
  padding: var(--s3) var(--s3);
  text-align: left; vertical-align: middle;
  border-bottom: var(--border);
}
.table th {
  background: var(--c-yellow);
  font: 900 0.8rem/1.2 var(--font-body);
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.table th + th, .table td + td { border-left: 2px solid var(--c-ink); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fffbea; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .empty { text-align: center; padding: var(--s6) var(--s4); color: var(--c-muted); font-weight: 600; }
.cell-clip { display: block; max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Na telefonie wiersze jako karty z etykietami */
@media (max-width: 680px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { border-bottom: var(--border); padding: var(--s2) 0; }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td {
    display: flex; justify-content: space-between; gap: var(--s3); align-items: center;
    border: 0 !important; padding: var(--s1) var(--s3);
    text-align: right;
  }
  .table--stack td::before {
    content: attr(data-label);
    font: 800 0.75rem/1.2 var(--font-body); text-transform: uppercase;
    text-align: left; flex-shrink: 0;
  }
  .table--stack td.empty, .table--stack td.actions { justify-content: flex-end; }
  .table--stack td.empty::before, .table--stack td.actions::before { content: none; }
  .table--stack td.empty { justify-content: center; }
  .cell-clip { max-width: 55vw; }
}

/* ---------- Zakładki ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: var(--s3); }
.tabs [role="tab"] {
  --btn-bg: var(--c-paper);
}
.tabs [role="tab"][aria-selected="true"] {
  --btn-bg: var(--c-yellow);
  transform: translate(var(--press), var(--press));
  box-shadow: 0 0 0 var(--c-ink);
}

/* ---------- Kafelek statystyki ---------- */
.stat { display: grid; gap: var(--s1); }
.stat__label { font: 800 0.75rem/1.2 var(--font-body); text-transform: uppercase; letter-spacing: 0.05em; }
.stat__value { font: 900 clamp(1.8rem, 1.4rem + 1.5vw, 2.6rem)/1 var(--font-display); font-variant-numeric: tabular-nums; }

/* Pasek udziału */
.bar { height: 14px; background: var(--c-cream); border: 2px solid var(--c-ink); border-radius: 2px; min-width: 80px; }
.bar__fill { height: 100%; background: var(--c-yellow-deep); }

/* ---------- Kropka statusu ---------- */
.dot {
  display: inline-block; flex-shrink: 0;
  width: 16px; height: 16px;
  border: 2.5px solid var(--c-ink); border-radius: 50%;
  background: var(--c-paper);
}
.dot--ok { background: var(--c-green); }
.dot--bad { background: var(--c-ketchup); }
.dot--wait { background: var(--c-yellow); animation: blink 0.9s steps(2, start) infinite; }

/* ---------- Modal (<dialog>) ---------- */
.modal {
  margin: auto; /* reset `* { margin: 0 }` psuje centrowanie <dialog> */
  width: min(92vw, 540px);
  max-height: 85vh;
  padding: 0;
  color: var(--c-ink);
  background: var(--c-paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.modal--wide { width: min(94vw, 760px); }
.modal::backdrop { background: rgb(17 17 17 / 0.55); }
.modal[open] { animation: pop 140ms ease-out; }
.modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--c-yellow);
  border-bottom: var(--border);
}
.modal__title { font-size: var(--fs-lg); }
.modal__body { padding: var(--s5) var(--s4); overflow: auto; max-height: calc(85vh - 140px); }
.modal__foot {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-top: var(--border);
  background: var(--c-cream);
}

/* ---------- Toasty ---------- */
.toasts {
  position: fixed; z-index: 2000;
  right: var(--s4); bottom: var(--s4); left: var(--s4);
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--s3);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--s3);
  width: min(100%, 420px);
  padding: var(--s3) var(--s4);
  font-weight: 700;
  background: var(--c-paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease-out;
}
.toast--success { background: var(--c-green); }
.toast--error { background: var(--c-ketchup); }
.toast--info { background: var(--c-sky); }
.toast__close { margin-left: auto; background: none; border: 0; cursor: pointer; font-weight: 900; font-size: 1.1rem; line-height: 1; padding: 2px 4px; }
.toast.is-leaving { animation: toast-out 160ms ease-in forwards; }

/* ---------- Pasek z żartami ---------- */
.ticker {
  overflow: hidden;
  background: var(--c-ink);
  color: var(--c-yellow);
  border-block: var(--border);
  font: 900 0.95rem/1 var(--font-display);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.ticker__track { display: flex; width: max-content; animation: ticker 28s linear infinite; }
.ticker__track span { padding: var(--s3) var(--s5); white-space: nowrap; }

/* ---------- Animacje ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { to { opacity: 0.35; } }
@keyframes pop { from { transform: scale(0.96) rotate(-1deg); opacity: 0; } }
@keyframes toast-in { from { transform: translateY(12px) rotate(1deg); opacity: 0; } }
@keyframes toast-out { to { transform: translateX(24px); opacity: 0; } }
@keyframes ticker { to { transform: translateX(-50%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ticker__track { animation: none; }
}

/* ==========================================================================
   Strona główna
   ========================================================================== */
.site-header { padding-block: var(--s4); }
.brand { display: inline-flex; align-items: center; gap: var(--s3); text-decoration: none; }
.brand__logo {
  width: 52px; height: 52px; object-fit: contain;
  background: var(--c-paper); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 2px;
}
.brand__name { font: 900 1.35rem/1 var(--font-display); }

.hero { padding-block: var(--s6) var(--s7); }
.hero__grid > * { max-width: 760px; }
.hero__title { margin-block: var(--s4) var(--s4); }
.hero__title .tilt { background: var(--c-yellow); border: var(--border); box-shadow: var(--shadow); padding: 0.05em 0.25em; }
.hero__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); margin-top: var(--s5); }
.hero__action { display: grid; gap: var(--s1); }
.hero__action .btn { width: 100%; }
.hero__action .hint { text-align: center; }

.status-card { display: grid; gap: var(--s3); }
.status-card__row { display: flex; align-items: center; gap: var(--s3); font-weight: 800; font-size: var(--fs-lg); }
.status-card__url { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--c-muted); word-break: break-all; }

.section { padding-block: var(--s7); }

.news__list { display: grid; gap: var(--s2); padding-left: 1.2em; }
.news__list li::marker { content: "✦  "; font-weight: 900; }

.site-footer { padding-block: var(--s6); border-top: var(--border); background: var(--c-paper); }

.meme { display: grid; gap: var(--s4); justify-items: center; text-align: center; }
.meme img { width: 220px; border: var(--border); box-shadow: var(--shadow-sm); }
.meme__caption { font: 900 var(--fs-xl)/1.1 var(--font-display); }

@media (max-width: 480px) {
  .hero__actions { grid-template-columns: 1fr; }
  .hero { padding-top: var(--s4); }
}

/* ==========================================================================
   Panel admina
   ========================================================================== */
.admin-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--c-paper);
  border-bottom: var(--border);
}
.admin-header__inner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding-block: var(--s3); }
.admin-main { padding-block: var(--s5) var(--s8); }
.login { max-width: 460px; margin: var(--s7) auto; }
.login .card { transform: rotate(-0.6deg); }
.env-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s4);
  font-weight: 800; font-size: var(--fs-sm);
  border-bottom: var(--border);
}
.env-banner--prod { background: var(--c-ketchup); }
.env-banner--other { background: var(--c-sky); }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; }
.card-pad { padding: var(--s4); border-bottom: var(--border); }
.toolbar > .row { flex: 1 1 360px; justify-content: flex-end; }
.toolbar .input[type="search"] { flex: 0 1 220px; }
@media (max-width: 680px) {
  .toolbar .input[type="search"] { flex: 1 1 100%; }
}
.panel-title { margin-bottom: var(--s4); }
.key-cell { display: inline-flex; align-items: center; gap: var(--s2); }
.answer-list { display: grid; gap: var(--s3); padding: 0; list-style: none; }
.answer-list li { border: 2px solid var(--c-ink); border-radius: var(--radius); padding: var(--s3); background: var(--c-cream); }
.answer-list .q { font-weight: 700; }
