/* =========================================================================
   Ożywianie zdjęć — arkusz stylów
   Ciepła, retro-fotograficzna paleta: kość słoniowa, sepia, bursztyn.
   Mobile-first, bez frameworków i bez zewnętrznych fontów.
   ========================================================================= */

:root {
  --ivory: #fbf5e9;
  --ivory-deep: #f4ead7;
  --paper: #fffdf8;
  --ink: #2e2721;
  --ink-soft: #5c5147;
  --ink-mute: #7a6b5d;
  --sepia: #8a6a4f;
  --amber: #95540b;          /* akcent — kontrast 5.45:1 na kości słoniowej, 5.68:1 dla tekstu na tym tle */
  --amber-deep: #7a4406;
  --amber-soft: #f2ddb8;
  --line: #e2d3ba;
  --danger: #9a2c1c;
  --danger-soft: #fbe7e2;
  --ok: #4b6b3a;
  --shadow-sm: 0 1px 2px rgba(70, 50, 30, .08), 0 2px 8px rgba(70, 50, 30, .06);
  --shadow-md: 0 8px 28px rgba(70, 50, 30, .12);
  --radius: 14px;
  --radius-lg: 22px;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--ivory);
  background-image:
    radial-gradient(1200px 500px at 50% -180px, #fff8e8 0%, rgba(255, 248, 232, 0) 70%),
    radial-gradient(900px 600px at 90% 110%, #f0e2c9 0%, rgba(240, 226, 201, 0) 65%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; display: block; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 .5em;
  letter-spacing: -.01em;
}

h1 { font-size: clamp(1.9rem, 7vw, 3rem); }
h2 { font-size: clamp(1.35rem, 4.6vw, 1.75rem); }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1em; }

a { color: var(--amber-deep); }

.wrap {
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  padding-inline: 18px;
}

/* ---------- Dostępność ---------- */

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  background: var(--ink);
  color: var(--ivory);
  padding: .7rem 1rem;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Atrybut hidden musi wygrywać z display:flex/grid używanym w komponentach. */
[hidden] { display: none !important; }

/* Input file jest wizualnie ukryty, ale focusowany — obwódka idzie na dropzone. */
.dropzone:focus-within {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

/* ---------- Nagłówek ---------- */

.hero {
  padding: clamp(2.2rem, 8vw, 4rem) 0 clamp(1.4rem, 4vw, 2.2rem);
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 1.1rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--sepia);
}

.brand-mark { color: var(--amber); font-size: 1rem; letter-spacing: 0; }

.hero h1 { margin-bottom: .55em; }

.lede {
  max-width: 34rem;
  margin-inline: auto;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* ---------- Karta ---------- */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1.15rem, 5vw, 2rem);
  box-shadow: var(--shadow-md);
  margin-bottom: 2.4rem;
}

.card > h2 { margin-bottom: 1rem; }

/* ---------- Dropzone ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  text-align: center;
  padding: clamp(1.6rem, 8vw, 2.6rem) 1.1rem;
  border: 2px dashed #d3bd97;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 252, 244, .9), rgba(246, 236, 216, .7));
  cursor: pointer;
  transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}

.dropzone:hover { border-color: var(--amber); background-color: #fffaf0; }
.dropzone.is-dragover {
  border-color: var(--amber);
  border-style: solid;
  background-color: #fdf1d8;
  transform: scale(1.008);
}

.dropzone-icon {
  font-size: 1.9rem;
  line-height: 1;
  margin-bottom: .35rem;
  filter: sepia(.4);
}

.dropzone-title { font-weight: 600; font-size: 1.02rem; }
.dropzone-hint { color: var(--ink-mute); font-size: .86rem; max-width: 26rem; }

/* ---------- Podgląd pliku ---------- */

.preview {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin-top: 1rem;
  padding: .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdfa;
}

.preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--ivory-deep);
  filter: sepia(.12);
}

.preview-meta { min-width: 0; flex: 1 1 auto; }
.preview-name {
  margin: 0;
  font-weight: 600;
  font-size: .92rem;
  overflow-wrap: anywhere;
}
.preview-size { margin: 0; color: var(--ink-mute); font-size: .82rem; }

/* ---------- Pola ---------- */

.field { margin-top: 1.15rem; }

.field label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .35rem;
}

.field input[type="email"],
.admin-token {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cdb995;
  border-radius: 10px;
  padding: .8rem .9rem;
  min-height: 48px;
  appearance: none;
}

.field input::placeholder { color: #a2937f; }
.field input:focus-visible { outline-offset: 2px; }

.hint {
  margin: .4rem 0 0;
  color: var(--ink-mute);
  font-size: .82rem;
}

/* ---------- Przyciski ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  min-height: 52px;
  padding: .85rem 1.2rem;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .16s ease, box-shadow .16s ease, transform .06s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  margin-top: 1.25rem;
  color: #fffaf0;
  background: linear-gradient(180deg, var(--amber), var(--amber-deep));
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .22);
}

.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #8a4b06, #6b3904); }
.btn-primary:disabled {
  cursor: not-allowed;
  opacity: .55;
  box-shadow: none;
}

.btn-ghost {
  color: var(--ink);
  background: transparent;
  border-color: #cdb995;
}
.btn-ghost:hover { background: var(--ivory-deep); }

.link-btn {
  display: inline-block;
  margin-top: .9rem;
  padding: .35rem .1rem;
  min-height: 44px;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--amber-deep);
  background: none;
  border: 0;
  border-bottom: 1px solid currentColor;
  cursor: pointer;
}
.link-btn:hover { color: var(--amber); }

/* ---------- Błędy ---------- */

.error {
  margin-top: 1.1rem;
  padding: .85rem 1rem;
  border: 1px solid #e7b9ae;
  border-left: 4px solid var(--danger);
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: .92rem;
}
.error strong { display: block; }

/* ---------- Postęp ---------- */

.progress-head {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: .8rem;
}

.progress-label {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.spinner {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid var(--amber-soft);
  border-top-color: var(--amber);
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progressbar {
  position: relative;
  height: 14px;
  border-radius: 99px;
  background: var(--ivory-deep);
  border: 1px solid var(--line);
  overflow: hidden;
}

.progressbar-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #d79a3c, var(--amber));
  transition: width .5s ease;
}

.progressbar.indeterminate .progressbar-fill {
  width: 38%;
  animation: slide 1.6s ease-in-out infinite;
}

@keyframes slide {
  0%   { transform: translateX(-105%); }
  100% { transform: translateX(285%); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .progressbar.indeterminate .progressbar-fill { animation: pulse 2s ease-in-out infinite; transform: none; width: 100%; opacity: .5; }
  .btn, .dropzone { transition: none; }
}

@keyframes pulse {
  0%, 100% { opacity: .35; }
  50% { opacity: .7; }
}

.progress-note {
  margin: .85rem 0 0;
  color: var(--ink-mute);
  font-size: .85rem;
}

#progress-step .btn-ghost { margin-top: 1.2rem; }

/* ---------- Wynik ---------- */

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin: 0 0 .4rem;
  padding: .25rem .7rem;
  border-radius: 99px;
  background: #e8efdf;
  color: var(--ok);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.result-title { margin-bottom: .8rem; }

.video-frame {
  border-radius: var(--radius);
  overflow: hidden;
  background: #241f1a;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.video-frame video {
  width: 100%;
  max-height: 70vh;
  background: #241f1a;
}

.result-note {
  margin: .75rem 0 1.1rem;
  color: var(--ink-mute);
  font-size: .85rem;
}

.actions { display: grid; gap: .6rem; }
.actions .btn { margin-top: 0; }

@media (min-width: 520px) {
  .actions { grid-template-columns: 1fr 1fr; }
}

.copy-feedback {
  min-height: 1.4em;
  margin: .55rem 0 0;
  color: var(--ok);
  font-size: .85rem;
}

/* Pole z linkiem, gdy przeglądarka odmówi dostępu do schowka. */
.copy-manual {
  width: 100%;
  margin-top: .5rem;
  padding: .7rem .85rem;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: .95rem;
}

/* Komunikat dla przeglądarek bez JavaScriptu. */
.noscript {
  margin: 1rem 0;
  padding: .9rem 1.1rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- Jak to działa ---------- */

.how { margin-bottom: 2.6rem; }
.how h2 { text-align: center; margin-bottom: 1.2rem; }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .85rem;
}

.step {
  position: relative;
  padding: 1.1rem 1.1rem 1.1rem 3.4rem;
  background: rgba(255, 253, 248, .72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.step h3 { margin: 0 0 .3rem; }

.step p {
  margin: 0;
  color: var(--ink-soft);
  font-size: .93rem;
}

.step-num {
  position: absolute;
  left: 1rem;
  top: 1rem;
  width: 1.85rem;
  height: 1.85rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--amber-soft);
  color: var(--amber-deep);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .95rem;
}

@media (min-width: 700px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
  .step { padding: 3.2rem 1.1rem 1.2rem; }
}

/* ---------- Stopka ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(244, 234, 215, .6);
  padding: 1.6rem 0 2.2rem;
  color: var(--ink-soft);
  font-size: .88rem;
}

.site-footer p { margin: 0 0 .6rem; }
.site-footer strong { color: var(--ink); }
.footer-small { color: var(--ink-mute); font-size: .82rem; }

/* =========================================================================
   ADMIN
   ========================================================================= */

.admin-body { min-height: 100vh; }

.admin-header {
  padding: 2rem 0 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, .7);
  margin-bottom: 1.6rem;
}

.admin-header h1 { font-size: clamp(1.5rem, 5vw, 2rem); margin-bottom: .25rem; }
.admin-header p { margin: 0; color: var(--ink-mute); font-size: .9rem; }
.admin-header .wrap { max-width: 1080px; }

.admin-main { max-width: 1080px; padding-bottom: 3rem; }

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.admin-toolbar .field { flex: 1 1 260px; margin: 0; }
.admin-toolbar .btn { width: auto; min-width: 132px; margin: 0; }

.admin-status {
  font-size: .85rem;
  color: var(--ink-mute);
  margin: 0 0 1rem;
  min-height: 1.3em;
}
.admin-status.is-error { color: var(--danger); }

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table { width: 100%; border-collapse: collapse; font-size: .9rem; }

thead th {
  text-align: left;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sepia);
  background: var(--ivory-deep);
  padding: .7rem .8rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: .75rem .8rem;
  border-bottom: 1px solid #efe4d1;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fffaf0; }

.cell-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-queued  { background: #efe3cd; color: #6d5a3c; }
.badge-running { background: #fbe8c6; color: #8a4f08; }
.badge-done    { background: #e5eedb; color: #3f5c2f; }
.badge-error   { background: var(--danger-soft); color: var(--danger); }
.badge-unknown { background: #e9e3d8; color: #5c5147; }

.btn-small {
  width: auto;
  min-height: 44px;
  padding: .45rem .95rem;
  font-size: .85rem;
  border-radius: 8px;
}

.btn-small[disabled] { opacity: .5; cursor: not-allowed; }

.empty-row td {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-mute);
}

.admin-table-link { font-size: .82rem; }

/* Karty zamiast tabeli na wąskim ekranie */
@media (max-width: 720px) {
  .table-wrap { border: 0; background: none; box-shadow: none; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    margin-bottom: .7rem;
    padding: .3rem .2rem;
    box-shadow: var(--shadow-sm);
  }
  tbody td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px dashed #efe4d1;
    padding: .5rem .85rem;
    text-align: right;
  }
  tbody tr td:last-child { border-bottom: 0; }
  tbody td::before {
    content: attr(data-label);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--sepia);
    text-align: left;
    flex: 0 0 auto;
  }
  .empty-row td { display: block; text-align: center; }
  .empty-row td::before { content: none; }
}
