/* =========================================================
   Базова система AiPhoto: шрифти, токени, типографіка, кнопки,
   форми, шапка й підвал. Підключається на всіх сторінках.

   Ідея: фотостудія й лабораторія. Сірий паперовий фон студії, чорна плівка,
   білі відбитки, червоний восковий олівець — лише для позначок і головної дії,
   помаранчеві номери кадрів на кромці плівки. Заголовки — Unbounded
   (широкий, як маркування на коробці з плівкою), текст — Geologica.
   ========================================================= */

/* ---------- Шрифти (локально, з @fontsource-variable) ---------- */
@font-face { font-family: "Unbounded"; font-style: normal; font-display: swap; font-weight: 200 900; src: url(/fonts/unbounded-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-style: normal; font-display: swap; font-weight: 200 900; src: url(/fonts/unbounded-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Geologica"; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/fonts/geologica-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Geologica"; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/fonts/geologica-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- Токени ---------- */
:root {
  /* Основні кольори */
  --studio: #c7cacd;      /* сірий паперовий фон студії — тло сторінок */
  --film: #000000;        /* плівка */
  --print: #ffffff;       /* папір відбитка */
  --wax: #e0312b;         /* восковий олівець: позначки й головна дія */
  --wax-deep: #b8221d;
  --edge: #f2a541;        /* номери кадрів на кромці плівки */
  --ink: #1a1c1f;         /* текст */

  /* Похідні сірі */
  --studio-2: #b9bdc1;    /* тінь фону, розділювачі на сірому */
  --studio-3: #dadcde;    /* світліший фон блоків */
  --ink-2: #33373c;       /* другорядний текст */
  --ink-3: #474c52;       /* підказки (≥ 4,5:1 на сірому) */
  --film-2: #1c1d1f;      /* дрібні поверхні на плівці */
  --film-ink: #e9eaeb;    /* текст на плівці */
  --film-ink-2: #a3a7ab;

  /* Назви, якими користуються спільні сторінки (баланс, адмінка, вхід) */
  --page: var(--studio);
  --paper: var(--print);
  --paper-2: var(--studio-3);
  --line: rgba(26, 28, 31, 0.14);
  --line-strong: rgba(26, 28, 31, 0.3);
  --blue: var(--ink);               /* вибране й фокус */
  --blue-deep: #000;
  --blue-tint: rgba(26, 28, 31, 0.07);
  --blue-line: rgba(26, 28, 31, 0.28);
  --on-blue: #fff;
  --on-ink: #fff;
  --marker: var(--wax);
  --mint: #2f7d5b;
  --k-image: var(--wax);
  --e-image: var(--wax-deep);
  --plate: var(--film);
  --screen: var(--film-2);
  --primary: var(--ink);
  --primary-hover: #000;
  --primary-text: var(--ink);
  --primary-soft: var(--blue-tint);
  --primary-soft-2: var(--blue-line);
  --text: var(--ink);
  --text-2: var(--ink-2);
  --text-3: var(--ink-3);
  --card: var(--print);

  --ok: #1d6b47;
  --ok-tint: rgba(29, 107, 71, 0.12);
  --warn: #8a4b00;
  --warn-tint: rgba(242, 165, 65, 0.26);
  --danger: #b8221d;
  --danger-tint: rgba(224, 49, 43, 0.1);

  --font-display: "Unbounded", "Arial Black", sans-serif;
  --font-body: "Geologica", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Радіуси: відбитки мають майже прямі кути, кнопки — трохи м’якші */
  --r-xs: 3px;
  --r-s: 6px;
  --r-btn: 8px;
  --r-m: 8px;
  --r-l: 12px;
  --r-pill: 999px;

  --wrap: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --section-y: clamp(64px, 9vw, 120px);
  --header-h: 66px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  /* Відбиток, що лежить на сірому столі */
  --shadow-print: 0 1px 1px rgba(26, 28, 31, 0.12), 0 12px 24px -16px rgba(26, 28, 31, 0.5);
  --shadow-float: 0 2px 6px rgba(26, 28, 31, 0.16), 0 28px 60px -24px rgba(26, 28, 31, 0.55);

  color-scheme: light;
  accent-color: var(--ink);
}

/* ---------- Скидання ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:where(h1, h2, h3, h4, p, figure, blockquote, dl, dd) { margin: 0; }
:where(ul, ol)[class] { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--ink); color: #fff; }

:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 3px; border-radius: var(--r-xs); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: fixed; left: 16px; top: -60px; z-index: 100;
  padding: 10px 16px; border-radius: var(--r-s);
  background: var(--ink); color: #fff; text-decoration: none; font-weight: 700;
}
.skip-link:focus { top: 12px; }

/* ---------- Типографіка ---------- */
.h1, .h2, .display {
  font-family: var(--font-display);
  font-weight: 600;
  text-wrap: balance;
}
.h1 { font-size: clamp(2.2rem, 1.3rem + 3.4vw, 4.3rem); line-height: 1.02; letter-spacing: -0.035em; }
.h2 { font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.7rem); line-height: 1.08; letter-spacing: -0.03em; }
.h3 { font-size: 1.12rem; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
.lead { font-size: clamp(1.05rem, 1rem + 0.3vw, 1.18rem); line-height: 1.6; color: var(--ink-2); max-width: 36em; }
.muted { color: var(--ink-2); }
.mono { font-variant-numeric: tabular-nums; }
p { text-wrap: pretty; }

.wrap { width: min(100% - var(--gutter) * 2, var(--wrap)); margin-inline: auto; }

/* ---------- Кнопки ---------- */
.btn {
  --btn-h: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: var(--btn-h);
  padding: 0 22px;
  border: 1.5px solid transparent;
  border-radius: var(--r-btn);
  font-weight: 650; font-size: 0.97rem; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active:not(:disabled, [aria-disabled="true"]) { transform: scale(0.97); }
.btn svg { width: 1.1em; height: 1.1em; flex: none; }
.btn--sm { --btn-h: 40px; padding: 0 16px; font-size: 0.92rem; }
.btn--lg { --btn-h: 56px; padding: 0 28px; font-size: 1.02rem; }
.btn--block { width: 100%; }
.btn--primary, .btn--dark { background: var(--ink); color: #fff; }
.btn--light { background: var(--print); color: var(--ink); border-color: var(--line-strong); }
.btn--soft { background: var(--blue-tint); color: var(--ink); }
.btn--ghost { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn--on-blue { background: var(--print); color: var(--ink); }
.btn--ghost-dark { background: transparent; border-color: rgba(255, 255, 255, 0.5); color: #fff; }
.btn--danger { background: var(--danger); color: #fff; }
/* Головна дія — восковий олівець */
.btn--marker, .btn--key { background: var(--wax); color: #fff; font-weight: 700; }
.btn--quiet { background: transparent; color: var(--ink-2); padding-inline: 12px; }
@media (hover: hover) {
  .btn--primary:hover, .btn--dark:hover { background: #000; }
  .btn--light:hover { border-color: var(--ink); }
  .btn--ghost:hover { background: var(--ink); color: #fff; }
  .btn--soft:hover { background: var(--blue-line); }
  .btn--on-blue:hover { background: var(--studio-3); }
  .btn--ghost-dark:hover { border-color: #fff; background: rgba(255, 255, 255, 0.08); }
  .btn--danger:hover, .btn--marker:hover, .btn--key:hover { background: var(--wax-deep); }
  .btn--quiet:hover { color: var(--ink); background: rgba(26, 28, 31, 0.07); }
}
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.btn .spinner { width: 18px; height: 18px; }

.link { color: var(--ink); font-weight: 650; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
@media (hover: hover) { .link:hover { text-decoration-color: var(--wax); } }

.spinner {
  width: 22px; height: 22px; flex: none;
  border: 2.5px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Форми ---------- */
.field { display: grid; gap: 7px; }
.field + .field { margin-top: 18px; }
.field__label { font-weight: 650; font-size: 0.92rem; }
.field__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field__hint { font-size: 0.85rem; color: var(--ink-3); }
.field__error { font-size: 0.86rem; color: var(--danger); font-weight: 600; }
.field__error:empty { display: none; }
.input {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-s);
  background: var(--print);
  font-size: 1rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
textarea.input { min-height: 92px; resize: vertical; line-height: 1.5; }
.input::placeholder { color: #767b81; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(26, 28, 31, 0.14); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-tint); }
@media (hover: hover) { .input:hover:not(:focus) { border-color: var(--ink-3); } }
@media (forced-colors: active) { .input:focus { outline: 2px solid Highlight; } }
.input--with-btn { padding-right: 52px; }
.input-wrap { position: relative; }
.input-wrap__btn {
  position: absolute; right: 4px; top: 50%; translate: 0 -50%;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-s); background: transparent; color: var(--ink-3);
}
@media (hover: hover) { .input-wrap__btn:hover { color: var(--ink); background: var(--studio-3); } }
.input-wrap__btn svg { width: 20px; height: 20px; }
.input-wrap__btn .icon-eye-off { display: none; }
.input-wrap__btn[aria-pressed="true"] .icon-eye { display: none; }
.input-wrap__btn[aria-pressed="true"] .icon-eye-off { display: block; }

.check { display: flex; gap: 12px; align-items: flex-start; font-size: 0.9rem; line-height: 1.5; color: var(--ink-2); cursor: pointer; }
.check input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; cursor: pointer; accent-color: var(--ink); }
.check a { color: var(--ink); }

.form-alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-s);
  font-size: 0.92rem; line-height: 1.45; font-weight: 600;
}
.form-alert:empty { display: none; }
.form-alert--error { background: var(--danger-tint); color: var(--danger); }
.form-alert--ok { background: var(--ok-tint); color: var(--ok); }
.form-alert--info { background: var(--blue-tint); color: var(--ink); }
.form-alert a { color: inherit; font-weight: 800; }

/* Сегментовані перемикачі (radio) */
.segmented { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-s);
  background: var(--print); font-weight: 600; font-size: 0.92rem; cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}
@media (hover: hover) { .segmented label:hover { border-color: var(--ink); } }
.segmented input:checked + label { background: var(--ink); border-color: var(--ink); color: #fff; }
.segmented input:focus-visible + label { outline: 2.5px solid var(--ink); outline-offset: 2px; }

/* ---------- Знак сервісу ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; color: inherit; border-radius: var(--r-xs); }
.brand__logo { display: block; width: 34px; height: 34px; flex: none; }
.brand__logo svg { width: 100%; height: 100%; }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: -0.02em; line-height: 1; white-space: nowrap; }

/* ---------- Шапка сайту ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--page) 90%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease;
}
.site-header[data-scrolled] { border-bottom-color: var(--line); }
.site-header__inner { height: var(--header-h); display: flex; align-items: center; gap: 28px; }
.site-nav { display: flex; gap: 2px; margin-left: auto; }
.site-nav a {
  padding: 8px 12px; border-radius: var(--r-s);
  text-decoration: none; font-weight: 550; font-size: 0.94rem; color: var(--ink-2);
  transition: color 150ms ease;
}
@media (hover: hover) { .site-nav a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--wax); text-underline-offset: 6px; text-decoration-thickness: 2px; } }
.site-header__actions { display: flex; align-items: center; gap: 6px; }
.site-header__actions .btn { --btn-h: 44px; }
.site-header__login { padding: 8px 12px; font-weight: 650; font-size: 0.94rem; text-decoration: none; border-radius: var(--r-s); }
@media (hover: hover) { .site-header__login:hover { text-decoration: underline; text-underline-offset: 5px; } }
.nav-toggle {
  display: none;
  width: 44px; height: 44px; margin-left: auto;
  place-items: center;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-s);
  background: var(--print);
}
.nav-toggle svg { width: 20px; height: 20px; }
.mobile-nav { display: none; }

@media (max-width: 960px) {
  .site-nav, .site-header__actions .site-header__login { display: none; }
  .site-header__actions { margin-left: auto; }
  .nav-toggle { display: grid; margin-left: 0; }
  .mobile-nav {
    display: block;
    position: fixed; inset: var(--header-h) 0 auto 0; z-index: 49;
    padding: 4px var(--gutter) 20px;
    background: var(--page);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 24px 40px -28px rgba(26, 28, 31, 0.6);
  }
  .mobile-nav[hidden] { display: none; }
  .mobile-nav a { display: block; padding: 14px 2px; border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 650; font-size: 1.05rem; }
  .mobile-nav a:last-child { border-bottom: 0; }
}
.site-header__cta-short { display: none; }
@media (max-width: 480px) {
  .site-header__inner { gap: 12px; }
  .site-header__actions .btn { padding-inline: 14px; }
  .site-header__cta-long { display: none; }
  .site-header__cta-short { display: inline; }
}

/* ---------- Підвал: світла приймальня фотоательє ----------
   Після темної кімнати фіналу — світлий папір студії; розділи підписані дрібно, посилання — чорним,
   унизу — пунктир відриву, як на квитанції, і реквізити. */
.site-footer { padding: clamp(48px, 6vw, 72px) 0 32px; background: var(--studio-3); color: var(--ink-2); font-size: 0.94rem; }
.site-footer .brand { color: var(--ink); }
.site-footer__grid { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: clamp(28px, 4vw, 48px); }
.site-footer__brand p { margin-top: 14px; max-width: 30ch; line-height: 1.5; }
.site-footer h2 { margin-bottom: 12px; font-family: var(--font-body); font-size: 0.84rem; font-weight: 650; color: var(--ink-3); }
.site-footer ul { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.site-footer a { text-decoration: none; color: var(--ink); font-weight: 550; }
@media (hover: hover) { .site-footer a:hover { text-decoration: underline; text-decoration-color: var(--wax); text-decoration-thickness: 2px; text-underline-offset: 5px; } }
.site-footer :focus-visible { outline-color: var(--ink); }
.site-footer__bottom { margin-top: clamp(36px, 4.5vw, 52px); padding-top: 18px; border-top: 1.5px dashed var(--line-strong); display: flex; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; font-size: 0.84rem; color: var(--ink-3); }
@media (max-width: 760px) {
  .site-footer__grid { grid-template-columns: 1fr 1fr; }
  .site-footer__brand { grid-column: 1 / -1; }
}
/* Під палець — посилання підвалу рядками по 44 px */
@media (max-width: 760px), (pointer: coarse) {
  .site-footer ul { gap: 0; }
  .site-footer ul a { display: flex; align-items: center; min-height: 44px; line-height: 1.3; }
  .site-footer h2 { margin-bottom: 2px; }
}

/* ---------- Сповіщення (toasts) ---------- */
.toasts {
  position: fixed; z-index: 200; left: 50%; bottom: 24px; translate: -50% 0;
  display: grid; gap: 8px; width: min(440px, calc(100% - 32px));
  pointer-events: none;
}
/* Контейнер — popover у верхньому шарі (api.js): прибираємо типові стилі popover */
.toasts[popover] { inset: auto auto 24px 50%; height: auto; margin: 0; padding: 0; border: 0; background: none; color: inherit; overflow: visible; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-radius: var(--r-m);
  background: var(--film); color: var(--film-ink);
  box-shadow: var(--shadow-float);
  font-weight: 550; font-size: 0.94rem; line-height: 1.4;
  animation: toast-in 300ms var(--ease-out);
}
.toast--error { background: #5a0f0c; }
.toast__icon { flex: none; width: 20px; height: 20px; }
.toast[data-leaving] { animation: toast-out 200ms ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; } }

/* ---------- Діалоги ---------- */
dialog.modal {
  width: min(500px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0; border-radius: var(--r-l);
  background: var(--print); color: var(--ink);
  box-shadow: var(--shadow-float);
}
dialog.modal::backdrop { background: rgba(10, 11, 12, 0.7); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: modal-in 220ms var(--ease-out); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal__body { padding: 28px; }
.modal__title { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; letter-spacing: -0.03em; line-height: 1.2; margin-bottom: 10px; }
.modal__close {
  position: absolute; top: 14px; right: 14px;
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-s); background: transparent; color: var(--ink-2);
}
@media (hover: hover) { .modal__close:hover { background: var(--studio-3); color: var(--ink); } }
.modal__close svg { width: 20px; height: 20px; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 24px; }

/* ---------- Швидкий вхід у режимі розробки (лише localhost) ---------- */
.dev-login {
  position: fixed; z-index: 250; top: 16px; right: 16px;
  width: min(340px, calc(100% - 32px));
  padding: 16px 18px;
  border-radius: 12px;
  background: #000; color: #f4f4f5;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  font: 500 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.dev-login__title { font-weight: 750; font-size: 14px; color: var(--edge); }
.dev-login__text { margin-top: 6px; color: rgba(255, 255, 255, 0.72); }
.dev-login__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dev-login .btn { font-family: inherit; box-shadow: none; border: 0; }
.dev-login .btn--primary { background: var(--wax); color: #fff; }
.dev-login .btn--light { background: #fff; color: #111; }
@media (max-width: 600px) { .dev-login { top: auto; bottom: 90px; right: 16px; } }

/* ---------- Значок балансу (public/js/token.js) ---------- */
.token { --t-bg: var(--ink); --t-fg: #fff; flex: none; overflow: visible; }
.token--s { width: 18px; height: 18px; }
.token--m { width: 28px; height: 28px; }
.token--l { width: 64px; height: 64px; }
.token__box { fill: var(--t-bg); }
.token__tick { fill: var(--t-fg); stroke: var(--t-fg); stroke-width: 1.2; stroke-linejoin: round; transform-origin: 12px 11.5px; }
.token__stand { stroke: var(--t-bg); stroke-width: 2.2; stroke-linecap: round; }
.token[data-level="out"] { --t-bg: #7a7f85; --t-fg: #fff; }
.token[data-level="low"] { --t-bg: var(--edge); --t-fg: var(--ink); }
.token[data-level="ok"] { --t-bg: #fff; --t-fg: var(--ink); }
.token[data-level="lots"] { --t-bg: #fff; --t-fg: var(--ink); }
.token[data-level="max"] { --t-bg: var(--wax); --t-fg: #fff; }
@media (prefers-reduced-motion: no-preference) {
  [data-burst="spend"] .token { animation: token-spend 0.7s var(--ease-out); }
  [data-burst="gain"] .token { animation: token-gain 0.8s var(--ease-out); }
  [data-burst="gain"] .token__tick { animation: token-tick 0.6s 0.1s var(--ease-out) backwards; }
}
@keyframes token-spend { 30% { transform: translateY(-3px) rotate(-8deg) scale(0.9); } }
@keyframes token-gain { 35% { transform: scale(1.35) rotate(6deg); } }
@keyframes token-tick { from { transform: scale(0.2); opacity: 0; } }

/* ---------- Плівка: спільний елемент головної, входу й кабінету ----------
   Чорна смуга з перфорацією згори й знизу та номерами кадрів на кромці. */
.film {
  position: relative;
  background: var(--film);
  padding: 32px 0;
}
.film::before, .film::after {
  content: ""; position: absolute; left: 0; right: 0; height: 12px;
  /* Перфорація: сірі віконця з кроком плівки — крізь них видно фон студії */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='12'%3E%3Crect x='9' width='12' height='12' rx='2.5' fill='%23c7cacd'/%3E%3C/svg%3E") repeat-x 0 0 / 30px 12px;
  pointer-events: none;
}
.film::before { top: 10px; }
.film::after { bottom: 10px; }
/* Номер кадру на кромці: помаранчевий, як на справжній плівці */
.frame-no { font-family: var(--font-display); font-weight: 600; font-size: 0.7rem; letter-spacing: 0.02em; color: var(--edge); font-variant-numeric: tabular-nums; }

/* ---------- Пакет кадрів — коробка плівки (головна й баланс у кабінеті) ----------
   Верх — етикетка коробки: велика кількість кадрів, як «36 exp» на плівці, назва й перфорація.
   Три кольори коробок: світла, чорна (популярна) і червона. Низ — на що вистачить, ціна й кнопка. */
.fbox-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(14px, 2vw, 22px); align-items: end; margin: 0; padding: 0; list-style: none; }
.fbox { position: relative; display: flex; flex-direction: column; min-width: 0; overflow: hidden; border-radius: 6px; background: var(--print); box-shadow: var(--shadow-print); }
.fbox__top {
  --perf: var(--print);
  position: relative; display: grid; gap: 2px;
  padding: 20px 22px 34px;
  background: var(--studio-3); color: var(--ink);
}
/* Перфорація по нижньому краю етикетки: віконця кольору паперу під нею */
.fbox__top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 8px; height: 10px;
  background: radial-gradient(circle at 50% 50%, var(--perf) 0 3.6px, transparent 4px) 0 0 / 22px 10px repeat-x;
  -webkit-mask: linear-gradient(#000, #000); mask: linear-gradient(#000, #000);
}
.fbox__badge { justify-self: start; margin-bottom: 8px; padding: 3px 9px; border-radius: 3px; background: var(--wax); color: #fff; font-size: 0.76rem; font-weight: 700; }
.fbox__exp { display: flex; align-items: baseline; gap: 8px; }
.fbox__exp b { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.8rem, 2rem + 2.4vw, 3.8rem); letter-spacing: -0.06em; line-height: 0.95; font-variant-numeric: tabular-nums; }
.fbox__exp span { font-family: var(--font-display); font-weight: 500; font-size: 0.9rem; letter-spacing: 0.01em; }
.fbox__name { margin-top: 6px; font-family: var(--font-body); font-weight: 700; font-size: 1.05rem; line-height: 1.25; }
.fbox--film .fbox__top { background: var(--film); color: #fff; }
.fbox--film .fbox__exp b, .fbox--film .fbox__exp span { color: var(--edge); }
.fbox--wax .fbox__top { background: var(--wax); color: #fff; }
.fbox--wax .fbox__badge { background: var(--film); color: var(--edge); }
.fbox__body { display: flex; flex-direction: column; flex: 1; gap: 10px; padding: 16px 22px 22px; }
.fbox__note { color: var(--ink-3); font-size: 0.9rem; line-height: 1.45; }
.fbox__uses { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 0.9rem; color: var(--ink-2); }
.fbox__uses li { display: flex; align-items: baseline; gap: 8px; }
.fbox__uses li::before { content: ""; flex: none; width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 1px; translate: 0 -1px; }
.fbox__uses b { color: var(--ink); }
.fbox__price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px; padding-top: 14px; border-top: 1px dashed var(--line-strong); font-weight: 650; }
.fbox__price b { font-family: var(--font-display); font-weight: 600; font-size: 2rem; letter-spacing: -0.05em; line-height: 1; }
.fbox__save { margin-left: auto; padding: 2px 8px; border-radius: 3px; background: var(--ok-tint); color: var(--ok); font-size: 0.8rem; font-weight: 750; }
.fbox__per { margin-top: -6px; font-size: 0.84rem; color: var(--ink-3); }
.fbox__body .btn { margin-top: auto; }
.fbox__body .fbox__per + .btn { margin-top: 8px; }
.fbox--popular { box-shadow: 0 0 0 2px var(--ink), var(--shadow-float); }
@media (min-width: 861px) { .fbox--popular { margin-top: -14px; } .fbox--popular .fbox__top { padding-top: 26px; } }
/* На телефоні коробки — стрічкою, яку гортають пальцем */
@media (max-width: 860px) {
  .fbox-row {
    display: flex; gap: 12px; overflow-x: auto; overscroll-behavior-x: contain;
    margin-inline: calc(var(--gutter) * -1); padding: 6px var(--gutter) 14px;
    scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); scrollbar-width: none;
  }
  .fbox-row::-webkit-scrollbar { display: none; }
  .fbox { flex: 0 0 min(80%, 320px); scroll-snap-align: center; }
}
/* Пейджер під стрічкою (public/js/fbox-pager.js): шматок плівки з віконцями, активне — помаранчеве */
.fbox-pager { display: none; }
@media (max-width: 860px) {
  .fbox-pager { display: flex; justify-content: center; margin-top: 6px; }
  .fbox-pager__film { display: flex; align-items: center; height: 26px; padding: 0 6px; border-radius: 4px; background: var(--film); }
  .fbox-pager button { display: grid; place-items: center; width: 44px; height: 44px; margin-block: -9px; padding: 0; border: 0; background: none; -webkit-tap-highlight-color: transparent; }
  .fbox-pager i { width: 14px; height: 11px; border-radius: 2.5px; background: #5a5d61; transition: background-color 160ms ease; }
  .fbox-pager button[aria-current="true"] i { background: var(--edge); }
  .fbox-pager button:focus-visible { outline: none; }
  .fbox-pager button:focus-visible i { box-shadow: 0 0 0 2px var(--film), 0 0 0 4.5px #fff; }
}

/* Обведення восковим олівцем (SVG-штрих) */
.wax-mark { position: absolute; z-index: 2; max-width: none; pointer-events: none; overflow: visible; }
.wax-mark path { fill: none; stroke: var(--wax); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }

/* Менше руху: прибираємо зсуви, лишаємо зміну прозорості */
@media (prefers-reduced-motion: reduce) {
  .toast, dialog.modal[open] { animation-name: fade-in; }
  .btn:active:not(:disabled, [aria-disabled="true"]) { transform: none; }
}
@keyframes fade-in { from { opacity: 0; } }
