/* =========================================================
   Auth · карта — это форма входа
   Подключается после app.css; дополняет существующую секцию Auth.
   Размер карты — ISO 1.586, все внутренние отступы в cqw,
   поэтому карта масштабируется целиком без медиазапросов.
   ========================================================= */

.cc {
  --rx: 0deg;
  --ry: 0deg;
  --flip: 0deg;
  --mx: 50%;
  --my: 38%;
  --cc-a: #1b2013;
  --cc-b: #0a0c09;
  --cc-c: #12160e;
  --cc-glow: rgba(184, 244, 92, 0.2);
  container-type: inline-size;
  margin: 12px 0 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* обратная сторона по желанию: клик по карте или кнопка под ней */
.cc.is-flipped { --flip: 180deg; }

.cc__scene { perspective: 1200px; perspective-origin: 50% 40%; }

.cc__tilt {
  position: relative;
  width: 100%;
  aspect-ratio: 1.586;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx)) rotateY(calc(var(--ry) + var(--flip)));
  transition: transform 0.7s var(--ease);
}

/* пока курсор над картой — следуем за ним без «плывущего» лага */
.cc.is-pointer .cc__tilt { transition: transform 0.05s linear; }

/* ---------- грани ---------- */

.cc__face {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(130% 160% at 12% -10%, var(--cc-glow), transparent 52%),
    radial-gradient(90% 120% at 100% 110%, rgba(0, 0, 0, 0.5), transparent 60%),
    linear-gradient(148deg, var(--cc-a) 0%, var(--cc-c) 46%, var(--cc-b) 100%);
  box-shadow:
    0 34px 70px rgba(0, 0, 0, 0.55),
    0 10px 48px -4px var(--cc-glow),
    0 6px 16px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}

/* brushed metal */
.cc__face::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(102deg, rgba(255, 255, 255, 0.032) 0 1px, transparent 1px 5px);
  mix-blend-mode: overlay;
}

/* иридисцентный отблеск + полоса полированного металла */
.cc__face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 18%, rgba(255, 255, 255, 0.085) 33%, rgba(255, 255, 255, 0.015) 41%, transparent 49%),
    linear-gradient(118deg, rgba(255, 255, 255, 0.1), transparent 30%, transparent 70%, rgba(255, 255, 255, 0.05));
}

.cc__face--back {
  transform: rotateY(180deg);
  background: linear-gradient(148deg, #151515 0%, #0e0e0e 60%, #0a0a0a 100%);
}

/* блик за курсором */
.cc__glare {
  position: absolute;
  inset: -20%;
  z-index: 6;
  pointer-events: none;
  background: radial-gradient(320px 260px at var(--mx) var(--my), rgba(255, 255, 255, 0.2), transparent 62%);
  mix-blend-mode: soft-light;
  opacity: 0;
  transition: opacity 0.45s var(--ease);
}
.cc.is-pointer .cc__glare { opacity: 1; }

/* ---------- поля прямо на карте ---------- */

.cc__input {
  min-width: 0;
  border: 0;
  border-radius: 3px;
  padding: 0;
  font: inherit;
  color: #f4f4ef;
  background: none;
  outline: none;
  caret-color: var(--accent);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  user-select: text;
  transition: box-shadow 0.2s var(--ease);
}
.cc__input::placeholder { color: rgba(255, 255, 255, 0.38); opacity: 1; }
.cc__input:focus-visible { outline: none; box-shadow: 0 1px 0 rgba(184, 244, 92, 0.85); }

/* ---------- лицевая ---------- */

.cc__head {
  position: absolute;
  left: max(14px, 5.4cqw);
  right: max(14px, 5.4cqw);
  top: max(12px, 4.9cqw);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: clamp(9px, 3.2cqw, 13px);
}

.cc__chip {
  position: relative;
  flex: none;
  width: clamp(34px, 10.3cqw, 43px);
  height: clamp(24px, 7.6cqw, 32px);
  border-radius: 7px;
  overflow: hidden;
  background: linear-gradient(135deg, #e8dda4 0%, #b9a259 26%, #e2d493 48%, #8d783c 72%, #cdbc7c 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.4),
    inset 0 -5px 9px rgba(0, 0, 0, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.5);
}
.cc__chip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(130% 100% at 18% 0%, rgba(255, 255, 255, 0.55), transparent 46%);
}
.cc__chip i { position: absolute; background: rgba(74, 59, 18, 0.5); }
.cc__chip i:nth-child(1) { left: 50%; top: 5px; bottom: 5px; width: 1px; }
.cc__chip i:nth-child(2) { top: 50%; left: 6px; right: 6px; height: 1px; }

.cc__wave {
  flex: none;
  width: clamp(16px, 5.2cqw, 22px);
  height: clamp(16px, 5.2cqw, 22px);
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.72);
}

.cc__brand {
  margin-left: auto;
  font-size: clamp(9px, 2.7cqw, 11px);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.cc__input--number {
  position: absolute;
  left: max(14px, 5.4cqw);
  right: max(14px, 5.4cqw);
  top: 52%;
  z-index: 3;
  height: clamp(34px, 10cqw, 40px);
  transform: translateY(-50%);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  font-size: clamp(13px, 4.5cqw, 18.5px);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  white-space: nowrap;
}

.cc__foot {
  position: absolute;
  left: max(14px, 5.4cqw);
  right: max(14px, 5.4cqw);
  bottom: max(12px, 4.4cqw);
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(12px, 4cqw, 18px);
}
.cc__field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cc__field--holder { flex: 1; }
.cc__field--exp { flex: none; width: clamp(50px, 16cqw, 64px); }
.cc__field .cc__input { width: 100%; }
.cc__label {
  font-size: clamp(7.5px, 2.1cqw, 8.5px);
  font-weight: 650;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.46);
  line-height: 1;
  white-space: nowrap;
}
.cc__field--holder .cc__input,
.cc__field--exp .cc__input {
  height: clamp(20px, 6.4cqw, 26px);
  font-size: clamp(10px, 2.8cqw, 11.5px);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- обратная ---------- */

.cc__magnet {
  position: absolute;
  left: 0;
  right: 0;
  top: 13%;
  height: clamp(34px, 11.2cqw, 47px);
  background: #040404;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}
.cc__magnet::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(94deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 7px);
  opacity: 0.6;
}

.cc__backrow {
  position: absolute;
  left: max(14px, 5.4cqw);
  right: max(14px, 5.4cqw);
  top: 46%;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cc__signature {
  flex: 1;
  height: clamp(30px, 9.4cqw, 39px);
  border-radius: 4px;
  background: repeating-linear-gradient(0deg, #e8e5da 0 3px, #f4f2ea 3px 6px);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.cc__cvv {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(64px, 20cqw, 84px);
  height: clamp(30px, 9.4cqw, 39px);
  padding: 0 8px;
  border-radius: 4px;
  background: #f4f2ea;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  transition: box-shadow 0.2s var(--ease);
}
.cc__cvv:focus-within { box-shadow: 0 0 0 2px rgba(184, 244, 92, 0.8); }
.cc__input--cvv {
  width: 100%;
  color: #1b1b1b;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: clamp(11px, 3.3cqw, 14px);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-indent: 0.1em;
  text-align: center;
  text-shadow: none;
}
.cc__input--cvv::placeholder { color: rgba(27, 27, 27, 0.42); }
.cc__input--cvv:focus-visible { box-shadow: none; }

.cc__backfoot {
  position: absolute;
  left: max(14px, 5.4cqw);
  right: max(14px, 5.4cqw);
  bottom: max(12px, 4.2cqw);
  font-size: clamp(8px, 2.2cqw, 9px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
}

/* ---------- бренд по началу номера (тёмная премиум-гамма) ---------- */

.cc[data-brand="visa"] { --cc-a: #10182b; --cc-b: #080d16; --cc-c: #0d1420; --cc-glow: rgba(38, 116, 255, 0.16); }
.cc[data-brand="mastercard"] { --cc-a: #211310; --cc-b: #100a09; --cc-c: #18100d; --cc-glow: rgba(255, 92, 54, 0.14); }
.cc[data-brand="mir"] { --cc-a: #0f2017; --cc-b: #08120c; --cc-c: #0c1911; --cc-glow: rgba(0, 196, 130, 0.15); }
.cc[data-brand="amex"] { --cc-a: #0f1a26; --cc-b: #080f16; --cc-c: #0c141d; --cc-glow: rgba(84, 168, 255, 0.15); }
.cc[data-brand="unionpay"] { --cc-a: #201114; --cc-b: #100a0b; --cc-c: #170d0f; --cc-glow: rgba(226, 72, 82, 0.12); }

/* ---------- кнопка переворота под картой ---------- */

.cc-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.cc-flip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 27px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.cc-flip::before { content: "⇄"; font-size: 12px; line-height: 1; }
.cc-flip:hover { color: var(--accent); border-color: rgba(184, 244, 92, 0.45); background: rgba(184, 244, 92, 0.06); }
.cc-flip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- форма вокруг карты ---------- */

.auth-form--card { margin-top: 16px; gap: 8px; }
.auth-form--card .btn { height: 46px; border-radius: 12px; }
.auth-form--email { margin-top: 14px; }
.auth__link {
  color: var(--text-2);
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.25);
  text-underline-offset: 2px;
  transition: color 0.2s;
}
.auth__link:hover { color: var(--accent); }
.auth__link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.auth__card .auth__subtitle { margin-top: 6px; }
.auth__divider { margin: 18px 0 12px; }
.auth__hint { margin-top: 8px; }
.auth__hint--demo { margin-top: 10px; }
.auth__terms { margin-top: 20px; }

/* iOS не зумит страницу, только если поле не меньше 16px */
@media (pointer: coarse) {
  .cc__input--number { font-size: max(16px, 4.5cqw); }
  .cc__field--holder .cc__input,
  .cc__field--exp .cc__input { font-size: 16px; letter-spacing: 0; }
  .cc__input--cvv { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .cc__tilt,
  .cc.is-pointer .cc__tilt { transition: none; }
  .cc__glare { display: none; }
}
