/* FJN System — E0 component styles, part 1: base, icons, spinner, buttons.
   Source: design/2026-09-25_E0_fundament-wspolny-wyglad/design/FJN System projektowy.dc.html (screenshot screens/00_System-projektowy.png).
   Colours only from fjn-tokens.css (v1.1, D35).
   The styles are split into fjn-*.css files loaded in base.html in a fixed order (the cascade depends on it). */

:root {
  --fjn-ctl: var(--fjn-ctl-md);     /* control height: desktop 40, tablet/phone 44, hall 56 */
}

@media (max-width: 1279px), (pointer: coarse) {
  :root { --fjn-ctl: var(--fjn-ctl-touch); }
}

/* ---------- Basics ---------- */

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

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

body {
  margin: 0;
  background: var(--fjn-bg);
  color: var(--fjn-text);
  font-family: var(--fjn-font);
  font-size: var(--fjn-fs-body);
  line-height: var(--fjn-lh-body);
}

h1, h2, h3 { margin: 0; }
h1 { font-size: var(--fjn-fs-h1); line-height: var(--fjn-lh-h1); }
h2 { font-size: var(--fjn-fs-h2); line-height: var(--fjn-lh-h2); }
p { margin: 0; }
a { color: var(--fjn-brand-600); font-weight: var(--fjn-fw-bold); text-decoration: none; }
a:hover { color: var(--fjn-brand-700); text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .fjn-mono { font-family: var(--fjn-font-mono); }

:focus-visible { outline: none; box-shadow: var(--fjn-focus-btn); }

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

.fjn-eyebrow {
  font: var(--fjn-fw-bold) 11px/1 var(--fjn-font-mono);
  letter-spacing: .06em; text-transform: uppercase; color: var(--fjn-text-3);
}

/* Field heading in cards (e.g. "Nazwa urządzenia") — base typeface, uppercase */
.fjn-overline {
  font-size: var(--fjn-fs-label); line-height: var(--fjn-lh-label); font-weight: var(--fjn-fw-bold);
  letter-spacing: .04em; text-transform: uppercase; color: var(--fjn-text-2);
}

.fjn-muted { color: var(--fjn-text-2); }
.fjn-small { font-size: var(--fjn-fs-small); line-height: var(--fjn-lh-small); }

/* Width-dependent visibility (table on K/T, cards on M) */
@media (max-width: 767px) {
  .fjn-hide-m { display: none !important; }
  /* The title is already in the phone header — page heading for screen readers only */
  .fjn-sr-only-m {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}
@media (min-width: 768px) { .fjn-only-m { display: none !important; } }

/* ---------- Icons ---------- */

.fjn-icon { flex: none; display: inline-block; vertical-align: middle; }
.fjn-icon--14 { width: 14px; height: 14px; }
.fjn-icon--16 { width: 16px; height: 16px; }
.fjn-icon--18 { width: 18px; height: 18px; }
.fjn-icon--20 { width: 20px; height: 20px; }
.fjn-icon--22 { width: 22px; height: 22px; }
.fjn-icon--24 { width: 24px; height: 24px; }
.fjn-icon--28 { width: 28px; height: 28px; }
.fjn-icon--32 { width: 32px; height: 32px; }

/* ---------- Spinner (fjn-spin animation, ANIMACJE.md) ---------- */

.fjn-spinner {
  flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: fjn-spin 800ms linear infinite;
}

/* ---------- Buttons ---------- */

.fjn-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--fjn-sp-2);
  height: var(--fjn-ctl); padding: 0 var(--fjn-sp-4);
  border: 1px solid transparent; border-radius: var(--fjn-r-md);
  font-size: var(--fjn-fs-body); font-weight: var(--fjn-fw-bold); line-height: 1;
  white-space: nowrap; text-decoration: none; cursor: pointer;
  background: none;
}
.fjn-btn:hover { text-decoration: none; }
.fjn-btn .fjn-spinner { display: none; }

/* Primary */
.fjn-btn--primary { background: var(--fjn-brand-600); color: var(--fjn-text-inverse); }
.fjn-btn--primary:hover { background: var(--fjn-brand-700); color: var(--fjn-text-inverse); }
.fjn-btn--primary:active { background: var(--fjn-brand-800); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .25); }

/* Secondary */
.fjn-btn--secondary { background: var(--fjn-surface); color: var(--fjn-text); border-color: var(--fjn-border-strong); }
.fjn-btn--secondary:hover { background: var(--fjn-surface-2); color: var(--fjn-text); }
.fjn-btn--secondary:active { background: var(--fjn-btn-secondary-active); border-color: var(--fjn-text-disabled); }

/* Danger */
.fjn-btn--danger { background: var(--fjn-danger-700); color: var(--fjn-text-inverse); }
.fjn-btn--danger:hover { background: var(--fjn-danger-800); color: var(--fjn-text-inverse); }
.fjn-btn--danger:active { background: var(--fjn-danger-900); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .25); }

/* Danger outline (e.g. "Zablokuj konto" in the account panel, E0-51) */
.fjn-btn--danger-outline { background: var(--fjn-surface); color: var(--fjn-danger-700); border-color: var(--fjn-danger-700); }
.fjn-btn--danger-outline:hover { background: var(--fjn-danger-100); color: var(--fjn-danger-700); }

/* Success (action in the success bar: "Dodaj pojazd") */
.fjn-btn--success { background: var(--fjn-success-700); color: var(--fjn-text-inverse); }
.fjn-btn--success:hover { color: var(--fjn-text-inverse); filter: brightness(.9); }

/* Text */
.fjn-btn--text { padding: 0 var(--fjn-sp-2); color: var(--fjn-brand-600); }
.fjn-btn--text:hover { background: var(--fjn-brand-50); color: var(--fjn-brand-700); text-decoration: underline; }
.fjn-btn--text:active { background: var(--fjn-brand-100); color: var(--fjn-brand-800); text-decoration: underline; }
.fjn-btn--text:focus-visible { box-shadow: 0 0 0 2px var(--fjn-focus-ring); }

/* Icon — always with aria-label and title */
.fjn-btn--icon { width: var(--fjn-ctl); padding: 0; color: var(--fjn-text-2); }
.fjn-btn--icon:hover { background: var(--fjn-surface-2); color: var(--fjn-text); }
.fjn-btn--icon:active { background: var(--fjn-btn-secondary-active); color: var(--fjn-text); }
.fjn-btn--icon:focus-visible { box-shadow: 0 0 0 2px var(--fjn-focus-ring); }

/* Smaller variant (e.g. actions in the success bar, 36 px) */
.fjn-btn--sm { height: 36px; padding: 0 var(--fjn-sp-3); font-size: 14px; }

/* Disabled */
.fjn-btn:disabled, .fjn-btn[aria-disabled="true"]:not([aria-busy="true"]) {
  background: var(--fjn-btn-disabled-bg); color: var(--fjn-text-disabled);
  border-color: transparent; box-shadow: none; cursor: not-allowed;
}
.fjn-btn--secondary:disabled, .fjn-btn--secondary[aria-disabled="true"]:not([aria-busy="true"]) {
  background: var(--fjn-bg); border-color: var(--fjn-border);
}
.fjn-btn--text:disabled, .fjn-btn--text[aria-disabled="true"],
.fjn-btn--icon:disabled, .fjn-btn--icon[aria-disabled="true"] { background: none; }
.fjn-btn--icon:disabled, .fjn-btn--icon[aria-disabled="true"] { color: var(--fjn-icon-disabled); }

/* Loading: "Zapisywanie…" — no double submit (SPEC par. 4) */
.fjn-btn[aria-busy="true"] { opacity: .8; cursor: not-allowed; }
.fjn-btn--secondary[aria-busy="true"] { opacity: 1; color: var(--fjn-text-2); }
.fjn-btn[aria-busy="true"] .fjn-spinner { display: inline-block; }
.fjn-btn[aria-busy="true"] > .fjn-icon { display: none; }

/* Hall — 56 px, 2 px border for poor lighting */
.fjn-btn--hall {
  height: var(--fjn-ctl-hall); min-width: 240px; padding: 0 var(--fjn-sp-6);
  border-radius: 8px; font-size: 18px; gap: var(--fjn-sp-3);
}
.fjn-btn--hall.fjn-btn--secondary { border: 2px solid var(--fjn-text); }
.fjn-btn--hall:focus-visible { box-shadow: 0 0 0 3px var(--fjn-surface), 0 0 0 6px var(--fjn-focus-ring); }
@media (max-width: 767px) { .fjn-btn--hall { width: 100%; min-width: 0; } }

.fjn-btn--block { width: 100%; }
.fjn-btn--square { width: var(--fjn-ctl); padding: 0; }

.fjn-actions { display: flex; flex-wrap: wrap; gap: var(--fjn-sp-3); align-items: center; }
.fjn-actions--end { justify-content: flex-end; }
@media (max-width: 767px) {
  .fjn-actions--stack-m { flex-direction: column-reverse; align-items: stretch; }
  /* Form footer on the phone: Cancel 1/3, primary action 2/3 */
  .fjn-actions--fill-m { flex-wrap: nowrap; }
  .fjn-actions--fill-m > .fjn-btn { flex: 1; height: 48px; }
  .fjn-actions--fill-m > .fjn-btn--primary, .fjn-actions--fill-m > .fjn-btn--danger { flex: 2; }
}
