/* ==========================================================================
   filmowo.tv — „atrament + bursztyn”. Tokeny, reset, typografia, przyciski.
   ========================================================================== */
:root {
  color-scheme: dark;
  --bg: #07080d;
  --bg-elev: #0e1018;
  --surface: #151826;
  --surface-2: #1c2033;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #f2efe9;
  --text-muted: #9a9fb2;
  --text-dim: #858a9e; /* 5.8:1 na --bg, 5.2:1 na --surface (AA dla drobnego tekstu) */
  --accent: #f5a524;
  --accent-hi: #ffcf70;
  --accent-ink: #1a1200;
  --accent-glow: rgba(245, 165, 36, .35);
  --danger: #ff6b5b;
  --ok: #5fd39a;
  --glass: rgba(20, 22, 34, .55);
  --font-display: "Bricolage Grotesque", "Geist", ui-sans-serif, system-ui, sans-serif;
  --font-ui: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-md: 1rem;
  --fs-lg: clamp(1.0625rem, .98rem + .3vw, 1.25rem);
  --fs-xl: clamp(1.25rem, 1.05rem + .8vw, 1.75rem);
  --fs-2xl: clamp(1.75rem, 1.2rem + 2.2vw, 3rem);
  --fs-hero: clamp(2.25rem, 1.1rem + 4.6vw, 5.25rem);
  --gutter: clamp(16px, 4vw, 64px);
  --nav-h: 64px;
  --tabbar-h: 0px;
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --maxw: 100%;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-1: 150ms;
  --dur-2: 200ms;
  --dur-3: 250ms;
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7), 0 8px 20px -8px rgba(0, 0, 0, .6);
}
/* Kolor */
/* Typografia */
/* Układ */
/* Ruch — własne krzywe (nigdy ease-in dla UI) */
@media (max-width: 767px) {
  :root { --nav-h: 56px; --tabbar-h: calc(60px + env(safe-area-inset-bottom)); }
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; background: var(--bg); }
body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(245, 165, 36, .07), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(80, 100, 220, .06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, video, iframe { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:where(input[type="submit"].btn) { cursor: pointer; border: 0; -webkit-appearance: none; appearance: none; }
a { color: inherit; text-decoration: none; }
:where(ul, ol)[role="list"] { list-style: none; padding: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; }
p { text-wrap: pretty; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* --- Dostępność --- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-sm); }
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform var(--dur-2) var(--ease-out);
}
.skip-link:focus-visible { transform: none; }
.main:focus { outline: none; }
.muted { color: var(--text-muted); }
.num, .meta, .card__meta, .tile__count { font-variant-numeric: tabular-nums; }
.fineprint { font-size: var(--fs-xs); color: var(--text-dim); }
.fineprint a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px; }
.section-label {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* --- Ikony --- */
.icon { width: 1.25em; height: 1.25em; flex: none; }
[aria-pressed="true"] .when-off, [aria-pressed="false"] .when-on { display: none; }

/* --- Przyciski --- */
.btn {
  --btn-h: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 20px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--fs-md);
  max-width: 100%;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-1) var(--ease-out),
    background-color var(--dur-2) var(--ease-out),
    border-color var(--dur-2) var(--ease-out),
    color var(--dur-2) var(--ease-out),
    box-shadow var(--dur-3) var(--ease-out);
}
.btn > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.btn:active { transform: scale(0.97); }
.btn .icon { width: 20px; height: 20px; }
.btn--lg { --btn-h: 52px; padding: 0 26px; font-size: var(--fs-lg); }
.btn--lg .icon { width: 22px; height: 22px; }
.btn--sm { --btn-h: 36px; padding: 0 14px; font-size: var(--fs-sm); }
.btn--sm .icon { width: 16px; height: 16px; }
.btn--wide { width: 100%; }
.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 28px -10px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn--glass {
  background: rgba(255, 255, 255, .14);
  color: var(--text);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.btn--ghost { background: rgba(255, 255, 255, .04); border: 1px solid var(--line-strong); color: var(--text); }
.btn--ghost[aria-pressed="true"] { border-color: rgba(245, 165, 36, .55); color: var(--accent-hi); background: rgba(245, 165, 36, .1); }
.btn--icon { width: var(--btn-h); padding: 0; }
.btn--icon .btn__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.btn__count:empty { display: none; }
.btn__count { font-variant-numeric: tabular-nums; color: var(--text-muted); font-weight: 500; }
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { background: var(--accent-hi); box-shadow: 0 10px 36px -8px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .4); }
  .btn--glass:hover { background: rgba(255, 255, 255, .22); }
  .btn--ghost:hover { border-color: rgba(255, 255, 255, .32); background: rgba(255, 255, 255, .08); }
}
/* Okrągłe przyciski (panel podglądu) */
.round-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .35);
  background: rgba(10, 12, 20, .5);
  color: var(--text);
  transition: transform var(--dur-1) var(--ease-out), border-color var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.round-btn:active { transform: scale(0.94); }
.round-btn .icon { width: 20px; height: 20px; }
.round-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-hi); }
.round-btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.round-btn--accent .icon { width: 18px; height: 18px; margin-left: 2px; }
@media (hover: hover) and (pointer: fine) {
  .round-btn:hover { border-color: #fff; background: rgba(255, 255, 255, .1); }
  .round-btn--accent:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
}
/* Serduszko — wypełnienie po polubieniu */
[data-controller~="like"][aria-pressed="true"] .icon { fill: currentColor; }
[data-controller~="like"][aria-pressed="true"] { color: var(--accent-hi); }
[data-controller~="like"].is-popping .icon { animation: heart-pop 300ms var(--ease-out); }
@keyframes heart-pop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }

/* --- Odznaki, meta --- */
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; }
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1;
  white-space: nowrap;
}
.badge--audio { color: var(--accent-hi); background: rgba(245, 165, 36, .12); box-shadow: inset 0 0 0 1px rgba(245, 165, 36, .35); }
.badge--age { color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); font-variant-numeric: tabular-nums; }
.rating { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-variant-numeric: tabular-nums; }
.rating .rating__star { width: 14px; height: 14px; color: var(--accent); }
.rating .rating__score { font-weight: 650; }
.rating .rating__max, .rating .rating__votes { color: var(--text-muted); font-weight: 500; }
.rating .rating__src {
  margin-left: 2px;
  font-size: .625rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-dim);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 1px 4px;
}

/* --- Chipy --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.chip:active { transform: scale(0.97); }
.chip__count { margin-left: 8px; color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: var(--fs-xs); }
@media (hover: hover) and (pointer: fine) {
  .chip:hover { background: rgba(245, 165, 36, .12); border-color: rgba(245, 165, 36, .4); }
  .chip--tint:hover { background: rgba(var(--tint), .14); border-color: rgba(var(--tint), .5); }
}

/* --- Obrazki: łagodne pojawianie się po załadowaniu --- */
/* Ukryte do załadowania tylko gdy działają moduły JS (img_controller); z pamięci podręcznej — od razu. */
.js:not(.legacy-js) .thumb { opacity: 0; transition: opacity 250ms var(--ease-out); }
.js:not(.legacy-js) .thumb.is-loaded { opacity: 1; }
.thumb.is-instant { transition: none; }

/* --- Toasty --- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 20px);
  z-index: 300;
  display: grid;
  gap: 8px;
  justify-items: center;
  translate: -50% 0;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  background: rgba(28, 32, 51, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out);
}
@starting-style {
  .toast { opacity: 0; transform: translateY(8px) scale(0.97); }
}
.toast.is-leaving { opacity: 0; transform: translateY(4px) scale(0.98); transition-duration: 150ms; }
.toast--alert { border-color: rgba(255, 107, 91, .5); }

/* --- View Transitions (Turbo Drive + MPA) --- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-fade-out 160ms var(--ease-out) both; }
::view-transition-new(root) { animation: vt-fade-in 240ms var(--ease-out) both; }
::view-transition-group(art) { animation-duration: 420ms; animation-timing-function: var(--ease-drawer); }
::view-transition-old(art), ::view-transition-new(art) { height: 100%; object-fit: cover; overflow: clip; }
::view-transition-group(nav), ::view-transition-group(tabbar) { animation: none; }
::view-transition-old(nav), ::view-transition-old(tabbar) { display: none; }
::view-transition-new(nav), ::view-transition-new(tabbar) { animation: none; }
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }
html[data-instant]::view-transition-group(*), html[data-instant]::view-transition-old(*), html[data-instant]::view-transition-new(*) {
  animation: none !important;
}

/* --- Przeglądarki bez import maps (Safari < 16.4): przycisk „Filtruj” zamiast autosubmitu --- */
.legacy-only { display: none !important; }
.legacy-js .legacy-only { display: inline-flex !important; }

/* --- Snop projektora: motyw marki (hero, 404, ładowanie) --- */
.beam {
  position: absolute;
  pointer-events: none;
  background: conic-gradient(from 118deg at 0% 0%, transparent 0deg, rgba(255, 207, 112, .09) 10deg, rgba(255, 207, 112, .03) 26deg, transparent 40deg);
}

/* --- Ograniczony ruch: zostają przenikania, znika przesuwanie i skalowanie --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  ::view-transition-group(art) { animation-duration: 0s; }
  .btn:active, .round-btn:active, .chip:active { transform: none; }
  [data-controller~="like"].is-popping .icon { animation: none; }
  .toast, .toast.is-leaving { transform: none; }
  @starting-style { .toast { transform: none; } }
}
