/* ============================================
   RESET & ZMIENNE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Atrybut hidden ma priorytet nad własnymi display w klasach */
[hidden] {
  display: none !important;
}

:root {
  /* Paleta */
  --bg-0: #0a0708;
  --bg-1: #13101a;
  --bg-2: #1a1525;
  --surface: rgba(26, 21, 37, 0.88);
  --surface-raised: rgba(36, 30, 52, 0.92);
  --border: rgba(245, 197, 24, 0.12);
  --border-strong: rgba(245, 197, 24, 0.3);

  --text: #f4ecdd;
  --text-dim: #a39aaa;
  --text-faint: #635a6e;

  --gold: #f5c518;
  --gold-soft: #e9b923;
  --gold-deep: #b8910e;
  --purple: #a855f7;
  --purple-soft: #c084fc;
  --purple-deep: #7c3aed;

  --success: #4ade80;

  /* Typografia */
  --font-display: 'Instrument Serif', 'Georgia', serif;
  --font-body: 'Geist', 'Helvetica Neue', system-ui, sans-serif;

  /* Przejścia */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(168, 85, 247, 0.15), transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(245, 197, 24, 0.08), transparent 70%),
    var(--bg-0);
}

/* ============================================
   TŁA DEKORACYJNE
   ============================================ */
.bg-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.35;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

.bg-glow {
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 600px;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse, rgba(168, 85, 247, 0.18), transparent 60%);
  filter: blur(40px);
  animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.1); }
}

/* ============================================
   LAYOUT
   ============================================ */
.app {
  position: relative;
  z-index: 10;
  max-width: 560px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

@media (max-width: 520px) {
  .app { padding: 32px 20px 48px; gap: 24px; }
}

/* ============================================
   HEADER
   ============================================ */
.header {
  text-align: center;
  animation: fadeInDown 0.8s var(--ease) both;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 28px;
  background: rgba(245, 197, 24, 0.04);
}

.brand-mark {
  color: var(--gold);
  font-size: 10px;
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(44px, 10vw, 72px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.title em {
  font-style: italic;
  font-weight: 400;
  background: linear-gradient(135deg, var(--gold) 0%, var(--purple-soft) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
}

.subtitle {
  color: var(--text-dim);
  font-size: 15px;
  max-width: 400px;
  margin: 0 auto;
}

/* ============================================
   CARD (kalkulator)
   ============================================ */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 48px -12px rgba(0, 0, 0, 0.5);
  animation: fadeInUp 0.8s var(--ease) 0.1s both;
}

/* Rozmycie tła bez tworzenia stacking context na .card */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: -1;
  pointer-events: none;
}

@media (max-width: 520px) {
  .card { padding: 24px 20px; border-radius: 20px; }
}

.step {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeInUp 0.5s var(--ease) both;
}

.step[data-step="1"] {
  z-index: 500;
}

.step-hidden {
  display: none;
}

.step.visible {
  display: flex;
}

.label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.label-num {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 0.15em;
  padding: 3px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: rgba(245, 197, 24, 0.06);
}

/* ============================================
   INPUT + DROPDOWN
   ============================================ */
.search-wrap {
  position: relative;
  z-index: 500;
}

.input, .select {
  width: 100%;
  background: rgba(10, 7, 8, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  transition: all 0.3s var(--ease);
  outline: none;
}

.input::placeholder {
  color: var(--text-faint);
}

.input:focus, .select:focus {
  border-color: var(--gold);
  background: rgba(10, 7, 8, 0.7);
  box-shadow: 0 0 0 4px rgba(245, 197, 24, 0.08);
}

.search-loader {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid rgba(245, 197, 24, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.search-loader.active {
  opacity: 1;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #1f1a2e;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  list-style: none;
  max-height: 340px;
  overflow-y: auto;
  z-index: 200;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 20px 50px -8px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(0, 0, 0, 0.4);
  animation: fadeInUp 0.25s var(--ease);
}

.dropdown-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 10px;
  margin: 4px;
  transition: background 0.15s;
  align-items: center;
}

.dropdown-item:hover,
.dropdown-item.active {
  background: rgba(245, 197, 24, 0.08);
}

.dropdown-item img, .dropdown-item .poster-fallback {
  width: 40px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-1);
  flex-shrink: 0;
}

.poster-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 20px;
}

.dropdown-item-text {
  flex: 1;
  min-width: 0;
}

.dropdown-item-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-item-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ============================================
   WYBRANY SERIAL (karta mini)
   ============================================ */
.chosen-show {
  display: flex;
  gap: 14px;
  padding: 12px;
  background: rgba(168, 85, 247, 0.06);
  border: 1px solid rgba(168, 85, 247, 0.15);
  border-radius: 14px;
  align-items: center;
  animation: fadeInUp 0.4s var(--ease);
}

.chosen-show img, .chosen-show .poster-fallback {
  width: 46px;
  height: 68px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.chosen-show-info {
  flex: 1;
  min-width: 0;
}

.chosen-show-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chosen-show-meta {
  font-size: 13px;
  color: var(--text-dim);
}

/* ============================================
   SELECTY
   ============================================ */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23a39aaa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* ============================================
   SLIDER
   ============================================ */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: rgba(10, 7, 8, 0.4);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 100px;
  background: linear-gradient(to right, var(--gold) 0%, var(--gold) var(--val, 22%), rgba(255,255,255,0.08) var(--val, 22%), rgba(255,255,255,0.08) 100%);
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  cursor: grab;
  border: 3px solid var(--bg-1);
  box-shadow: 0 0 0 1px var(--gold), 0 4px 12px rgba(245, 197, 24, 0.4);
  transition: transform 0.2s var(--ease-spring);
}

.slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.2);
}

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  cursor: grab;
  border: 3px solid var(--bg-1);
  box-shadow: 0 0 0 1px var(--gold);
}

.slider-value {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 32px;
  letter-spacing: -0.03em;
  min-width: 60px;
  text-align: right;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.slider-unit {
  font-size: 16px;
  color: var(--text-dim);
  margin-left: 2px;
}

/* ============================================
   HINT
   ============================================ */
.hint {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}

.hint.warn {
  color: var(--gold-soft);
}

.hint.error {
  color: #ff6b6b;
}

/* ============================================
   MANUAL RUNTIME (gdy brak danych z TMDB)
   ============================================ */
.manual-runtime {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(245, 197, 24, 0.06);
  border: 1px solid rgba(245, 197, 24, 0.2);
  border-radius: 12px;
  margin-top: 4px;
  animation: fadeInUp 0.4s var(--ease);
}

.manual-runtime[hidden] {
  display: none !important;
}

.manual-runtime-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.manual-runtime-text {
  flex: 1;
  font-size: 13px;
  color: var(--gold-soft);
  line-height: 1.3;
}

.manual-runtime-input {
  width: 72px;
  background: rgba(10, 7, 8, 0.6);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  outline: none;
  transition: all 0.2s var(--ease);
  -moz-appearance: textfield;
}

.manual-runtime-input::-webkit-outer-spin-button,
.manual-runtime-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.manual-runtime-input:focus {
  border-color: var(--gold);
  background: rgba(10, 7, 8, 0.8);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.1);
}

.manual-runtime-unit {
  font-size: 13px;
  color: var(--text-dim);
  margin-left: -4px;
}

/* ============================================
   CTA
   ============================================ */
.cta {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 18px 24px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--bg-0);
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-soft) 100%);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.3s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 24px -8px rgba(245, 197, 24, 0.5);
}

.cta::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.2) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform 0.6s var(--ease);
}

.cta:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px -8px rgba(245, 197, 24, 0.6);
}

.cta:not(:disabled):hover::before {
  transform: translateX(100%);
}

.cta:not(:disabled):active {
  transform: translateY(0);
}

.cta:disabled {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-faint);
  cursor: not-allowed;
  box-shadow: none;
}

/* ============================================
   WYNIK
   ============================================ */
.result {
  animation: fadeInUp 0.6s var(--ease-spring);
}

.result-inner {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 48px -12px rgba(0, 0, 0, 0.5);
}

.result-poster {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.25;
  filter: blur(2px);
}

.result-poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(10, 7, 8, 0.5) 0%,
    rgba(10, 7, 8, 0.85) 50%,
    rgba(10, 7, 8, 0.95) 100%);
}

.result-content {
  position: relative;
  z-index: 1;
  padding: 40px 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (max-width: 520px) {
  .result-content { padding: 32px 20px 24px; }
}

.result-badge {
  font-size: 48px;
  line-height: 1;
  animation: bounce 0.8s var(--ease-spring) 0.2s both;
}

@keyframes bounce {
  0% { transform: scale(0) rotate(-15deg); opacity: 0; }
  50% { transform: scale(1.1) rotate(5deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.result-title {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(30px, 6vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.result-blocks {
  display: grid;
  gap: 12px;
}

.result-block {
  background: rgba(26, 21, 37, 0.6);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-block-accent {
  border-color: rgba(245, 197, 24, 0.25);
  background: linear-gradient(135deg, rgba(245, 197, 24, 0.08) 0%, rgba(168, 85, 247, 0.05) 100%);
}

.result-block-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 500;
}

.result-block-accent .result-block-head {
  color: var(--gold);
}

.result-block-main {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.result-block-meta {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dot {
  width: 3px;
  height: 3px;
  background: var(--text-faint);
  border-radius: 50%;
}

/* ============================================
   AKCJE
   ============================================ */
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-share, .btn-ghost {
  flex: 1;
  min-width: 140px;
  padding: 14px 20px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-share {
  background: var(--text);
  color: var(--bg-0);
  border: none;
}

.btn-share:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px rgba(244, 236, 221, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(245, 197, 24, 0.04);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.05em;
  display: flex;
  justify-content: center;
  gap: 10px;
  align-items: center;
}

.footer .sep { color: var(--text-faint); }

/* ============================================
   TOAST
   ============================================ */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(140%);
  background: var(--text);
  color: var(--bg-0);
  padding: 14px 22px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  transition: transform 0.4s var(--ease-spring), opacity 0.3s var(--ease), visibility 0s linear 0.4s;
  pointer-events: none;
  max-width: calc(100vw - 40px);
  text-align: center;
  opacity: 0;
  visibility: hidden;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
  transition: transform 0.4s var(--ease-spring), opacity 0.3s var(--ease), visibility 0s linear 0s;
}

/* ============================================
   BUY ME A COFFEE (floating)
   ============================================ */
.bmc {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #FFDD00 0%, #FFC83D 100%);
  color: #1a1205;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 100px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 8px 24px -4px rgba(255, 221, 0, 0.35),
    0 2px 8px -2px rgba(0, 0, 0, 0.5);
  transition: all 0.3s var(--ease-spring);
  animation: bmcPop 0.6s var(--ease-spring) 1.2s both;
  will-change: transform;
}

.bmc:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 14px 32px -6px rgba(255, 221, 0, 0.5),
    0 4px 12px -2px rgba(0, 0, 0, 0.5);
}

.bmc:active {
  transform: translateY(-1px) scale(1);
}

.bmc-icon {
  font-size: 18px;
  display: inline-block;
  transition: transform 0.4s var(--ease-spring);
}

.bmc:hover .bmc-icon {
  transform: rotate(-12deg) scale(1.15);
}

.bmc-text {
  letter-spacing: -0.005em;
}

@keyframes bmcPop {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 520px) {
  .bmc {
    bottom: 16px;
    right: 16px;
    padding: 10px 14px;
    font-size: 13px;
  }
  .bmc-icon { font-size: 16px; }
}

/* Na mobile przy pokazanym wyniku zmniejsz do samej ikony, żeby nie zasłaniał treści */
@media (max-width: 420px) {
  .bmc-text {
    display: none;
  }
  .bmc {
    padding: 12px;
    width: 44px;
    height: 44px;
    justify-content: center;
  }
}

/* ============================================
   ANIMACJE KLUCZOWE
   ============================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   SCROLLBAR (dropdown)
   ============================================ */
.dropdown::-webkit-scrollbar {
  width: 8px;
}
.dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.dropdown::-webkit-scrollbar-thumb {
  background: rgba(245, 197, 24, 0.2);
  border-radius: 10px;
}
.dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(245, 197, 24, 0.4);
}
