/* ============================================================
   НАТАЛЬНАЯ КНИГА — «атлас»: бумага, индиго, киноварь.
   Дизайн-система служебных страниц (вход + личный кабинет)
   в стиле лендинга /astro2/index2.php. Классы совпадают со
   старой темой (cta, quiz-input, nk-modal, cab-*) — JS не трогаем.
   Шрифты системные: Palatino/Georgia + моноширинный, без внешних.
   ============================================================ */

:root {
  --paper:      #f5efe3;
  --paper-2:    #ede4d0;
  --paper-deep: #e4d9c2;
  --ink:        #1d2542;
  --ink-soft:   #49506f;
  --ink-faint:  rgba(29, 37, 66, 0.45);
  --rule:       rgba(29, 37, 66, 0.25);
  --rule-soft:  rgba(29, 37, 66, 0.12);
  --verm:       #b0421f;
  --verm-deep:  #8c3014;
  --night:      #0d1330;
  --star:       #ece7f6;

  --f-serif: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --f-mono:  ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  --wrap: min(1140px, 92vw);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  /* clip — в отличие от hidden гасит горизонтальный пан и на iOS */
  overflow-x: hidden;
  overflow-x: clip;
}
body {
  background:
    radial-gradient(1100px 500px at 85% -5%, rgba(176, 66, 31, 0.05), transparent 60%),
    radial-gradient(900px 600px at 0% 30%, rgba(29, 37, 66, 0.05), transparent 55%),
    var(--paper);
  color: var(--ink);
  font-family: var(--f-serif);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: inherit; }
button { font-family: inherit; }

::selection { background: var(--verm); color: var(--paper); }
:focus-visible {
  outline: 2px dashed var(--verm);
  outline-offset: 3px;
  border-radius: 2px;
}

/* бумажное зерно — маркап страниц уже содержит .grain/.vignette */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  opacity: 0.20; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.5 0 0 0 0 0.42 0 0 0 0.28 0'/></filter><rect width='180' height='180' filter='url(%23p)'/></svg>");
  background-size: 180px 180px;
}
.vignette { display: none; }

.wrap { width: var(--wrap); margin: 0 auto; position: relative; }

/* ───────── типографика ───────── */
h1.display, h2.display, h3.display {
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.005em;
  line-height: 1.1;
  text-wrap: balance;
}
h1.display { font-size: clamp(32px, 4.4vw, 52px); }
h3.display { font-size: clamp(22px, 2.4vw, 28px); }
.display em {
  font-style: italic; font-weight: 400;
  color: var(--verm);
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--f-mono);
  font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 18px;
}
.eyebrow::before { content: "✶"; color: var(--verm); }

.lede { color: var(--ink-soft); font-size: 17px; text-wrap: pretty; }

/* ───────── шапка ───────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule-soft);
  padding: 14px 0;
}
.nav-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 19px; font-weight: 600; letter-spacing: 0.02em;
  text-decoration: none;
}
.brand::before { content: "✶"; color: var(--verm); font-size: 15px; }
.nav-links {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 22px;
  font-family: var(--f-mono);
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-soft);
}
.nav-links a {
  text-decoration: none; padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.25s ease, border-color 0.25s ease;
}
.nav-links a:hover { color: var(--verm); border-color: var(--verm); }
.cab-email {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.06em;
  color: var(--ink-faint); text-transform: none;
  max-width: min(46vw, 260px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ───────── кнопки (.cta = атлас-кнопка) ───────── */
.cta {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 15px 30px;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink);
  font-family: var(--f-mono); font-size: 13px;
  letter-spacing: 0.18em; text-transform: uppercase;
  text-decoration: none; cursor: pointer;
  box-shadow: 4px 4px 0 var(--verm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.cta:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--verm); }
.cta:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--verm); }
.cta .arrow { transition: transform 0.25s ease; }
.cta:hover .arrow { transform: translateX(4px); }
.cta.small { padding: 10px 18px; font-size: 11px; }
.cta.ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--ink); box-shadow: none;
}
.cta.ghost:hover { background: var(--ink); color: var(--paper); transform: none; }
.cta:disabled, .cta[disabled], .cta.is-loading {
  opacity: 0.45; pointer-events: none;
  box-shadow: 4px 4px 0 var(--rule);
}

/* ───────── поля ввода ───────── */
.quiz-input {
  width: 100%; padding: 13px 14px;
  background: color-mix(in srgb, var(--paper-2) 55%, transparent);
  border: 1px solid var(--rule);
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  font-family: var(--f-serif); font-size: 19px;
  color: var(--ink); outline: none;
  transition: border-color 0.3s ease, background 0.3s ease;
  color-scheme: light;
}
.quiz-input:focus { border-color: var(--verm); background: rgba(176, 66, 31, 0.05); }
.quiz-input::placeholder { color: var(--ink-faint); font-style: italic; }

/* ───────── вход / установка пароля ───────── */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 110px 20px 70px;
  position: relative; z-index: 2;
}
.auth-card {
  width: 100%; max-width: 440px;
  background:
    radial-gradient(600px 280px at 80% -10%, rgba(176, 66, 31, 0.05), transparent 60%),
    var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 8px 8px 0 var(--verm), 0 40px 80px -40px rgba(13, 19, 48, 0.5);
  padding: 44px 38px 38px;
  position: relative;
}
.auth-card::before, .auth-card::after,
.auth-card .corner-tl, .auth-card .corner-br {
  content: ""; position: absolute; width: 16px; height: 16px;
  border: 1px solid var(--verm); pointer-events: none;
}
.auth-card::before { top: 8px; left: 8px;   border-right: none; border-bottom: none; }
.auth-card::after  { top: 8px; right: 8px;  border-left: none;  border-bottom: none; }
.auth-card .corner-tl { bottom: 8px; left: 8px;  border-right: none; border-top: none; }
.auth-card .corner-br { bottom: 8px; right: 8px; border-left: none;  border-top: none; }

.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--verm);
  margin-bottom: 10px;
}
.auth-card h1.display { font-size: 28px; text-align: center; margin: 0 0 26px; }

.auth-field { margin-bottom: 16px; }
.auth-field label {
  display: block;
  font-family: var(--f-mono);
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.auth-card .quiz-input { width: 100%; }
.auth-card .cta { width: 100%; justify-content: center; margin-top: 10px; }

.auth-msg { padding: 12px 14px; font-size: 14.5px; line-height: 1.45; margin-bottom: 18px; }
.auth-msg.err {
  border: 1px solid var(--verm);
  background: rgba(176, 66, 31, 0.07);
  color: var(--verm-deep);
}
.auth-msg.ok {
  border: 1px solid var(--ink);
  background: color-mix(in srgb, var(--paper-2) 60%, transparent);
  color: var(--ink);
}

.auth-links {
  text-align: center; margin-top: 24px;
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
}
.auth-links a {
  color: var(--ink-soft); text-decoration: none;
  border-bottom: 1px dashed var(--rule);
  padding-bottom: 2px;
  transition: color 0.25s ease, border-color 0.25s ease;
}
.auth-links a:hover { color: var(--verm); border-color: var(--verm); }
.auth-sep { color: var(--verm); margin: 0 8px; }

/* ───────── личный кабинет ───────── */
.cab-main { padding: 130px 0 100px; position: relative; z-index: 2; min-height: 70vh; }

.cab-empty { margin-top: 36px; display: flex; flex-direction: column; align-items: flex-start; gap: 22px; }

.cab-grid {
  margin-top: 44px;
  display: grid;
  /* min(320px,100%) — на узких экранах карточка не шире контейнера */
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 32px;
}

.cab-card {
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 6px 6px 0 var(--verm), 0 30px 60px -40px rgba(13, 19, 48, 0.5);
  transition: transform 0.3s ease;
}
.cab-card:hover { transform: translateY(-4px); }

.cab-cover {
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(420px 320px at 50% 30%, rgba(176, 66, 31, 0.06), transparent 70%),
    var(--paper-2);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.cab-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cab-cover-ph { font-family: serif; font-size: 56px; color: var(--verm); opacity: 0.45; }

.cab-body { padding: 22px 24px 26px; }
.cab-body h3 { font-size: 24px; margin: 0 0 8px; }
.cab-meta {
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint);
}
.cab-plan {
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--verm);
  margin-top: 10px;
}

.cab-status {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px;
  font-size: 14.5px; font-style: italic; color: var(--ink-soft);
}
.cab-status.ready { color: var(--ink); font-style: normal; }
.cab-spin {
  font-family: serif; font-size: 17px; color: var(--verm);
  display: inline-block;
  animation: atlas-spin 1.6s linear infinite;
}
@keyframes atlas-spin { to { transform: rotate(360deg); } }

.cab-actions { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 12px; }

.cab-delivery { margin-top: 18px; font-size: 14px; color: var(--ink-soft); line-height: 1.5; }
.cab-delivery.done { color: var(--ink); }
.cab-delivery.done::before { content: "✶ "; color: var(--verm); }
.cab-track { font-family: var(--f-mono); font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

/* ───────── модалки (доставка / печать / ПВЗ) ───────── */
.nk-modal-overlay {
  position: fixed; inset: 0; z-index: 1000; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(13, 19, 48, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.nk-modal-overlay.open { display: flex; }
.nk-modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 8px 8px 0 var(--verm), 0 40px 90px rgba(7, 10, 28, 0.55);
  padding: 36px 34px; position: relative;
}
.nk-modal h3 { font-size: 26px; margin: 0 0 8px; }
.nk-modal .lede { font-size: 15px; margin: 0 0 22px; }
.nk-modal .auth-field { margin-bottom: 14px; }
.nk-modal label {
  display: block;
  font-family: var(--f-mono);
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.nk-modal .quiz-input { width: 100%; }
.nk-modal-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none;
  color: var(--ink); font-size: 19px; cursor: pointer;
  width: 34px; height: 34px; display: grid; place-items: center;
  transition: transform 0.3s ease, color 0.3s ease;
}
.nk-modal-close:hover { transform: rotate(90deg); color: var(--verm); }

.nk-point-box {
  border: 1px dashed var(--verm);
  background: rgba(176, 66, 31, 0.04);
  padding: 14px;
  margin-bottom: 16px;
  font-size: 14px; color: var(--ink-soft); line-height: 1.5;
}
.nk-point-box.chosen { border-style: solid; color: var(--ink); }
.nk-point-box strong { color: var(--verm-deep); }

/* ───────── тост ───────── */
.nk-toast {
  position: fixed; left: 50%; bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  max-width: 90vw; z-index: 9999; opacity: 0; pointer-events: none;
  background: var(--night); color: var(--star);
  border: 1px solid var(--verm);
  padding: 13px 20px; font-size: 14.5px; line-height: 1.45;
  box-shadow: 0 10px 40px rgba(7, 10, 28, 0.5);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.nk-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ───────── адаптив / движение ───────── */
@media (max-width: 560px) {
  /* шапка переносится на 2–3 строки — статичная не перекрывает контент */
  .nav { position: static; }
  .auth-wrap { min-height: 0; padding: 36px 20px 56px; }
  .auth-card { padding: 36px 24px 32px; }
  .cab-main { padding: 36px 0 70px; }
  .nav-links { gap: 4px 14px; }
  .nk-modal { padding: 30px 20px; }
  /* карта ПВЗ: на телефоне 560px не влезает (inline-высота → !important) */
  #nkEcomWidget { height: 62vh !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
