/* =====================================================================
   Окно «Детали пакета» (#modal-)
   Разметка окна — esim365_country_card_template_modal.php,
   содержимое (.pd) — esim365_country_card_template_single_card_render.php,
   доработки — js/package-details.js.
   Подключается из render-файла на всех страницах с карточками тарифов,
   поэтому токены v3 берутся с запасными значениями.
   ===================================================================== */
html #modal-{
  --pd-brand:  var(--brand, #593196);
  --pd-ink:    var(--ink-hero, #232331);
  --pd-muted:  var(--ink-muted, #5c5770);
  --pd-subtle: var(--ink-subtle, #65607a);
  --pd-line:   var(--line, #ece9f6);
  --pd-wash:   var(--lav-wash, #ece7fb);
  --pd-radius: var(--radius, 8px);
  padding:24px 16px; background:rgba(28,18,48,.55);
}
html #modal- #modal--{
  display:flex; flex-direction:column;
  width:min(480px, 100%); max-width:none;
  max-height:min(760px, calc(100vh - 48px)); max-height:min(760px, calc(100dvh - 48px));
  padding:0; overflow:hidden;
  border-radius:16px; background:#fff; box-shadow:0 40px 90px -40px rgba(28,18,48,.6);
  color:var(--pd-ink); font-family:var(--font, inherit); text-align:left;
}
html #modal- #modal--:focus{ outline:none; }

/* Крестик — как в окне оплаты */
html #modal- #modal---{
  position:absolute; top:16px; right:16px; z-index:2;
  width:40px; height:40px; padding:0; border:0; border-radius:50%;
  background:#f4f1f9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235c5770' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / 18px no-repeat;
  color:transparent; font-size:0; line-height:0;
  transition:background-color .15s ease;
}
html #modal- #modal---:hover{ background-color:var(--pd-wash); }
html #modal- #modal---:focus-visible{ outline:2px solid var(--pd-brand); outline-offset:2px; }

/* Прокручивается только содержимое, кнопка всегда на виду */
html #modal- #modal-content-{
  flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain;
  padding:24px 24px 4px; font-size:15px; line-height:1.45; color:var(--pd-ink);
}
html #modal- #modal-----{
  flex:none; display:block; margin:0; padding:14px 24px 20px;
  border-top:1px solid var(--pd-line); background:#fff;
}
html #modal- #modal------{
  display:flex; align-items:center; justify-content:center;
  width:100% !important; min-height:52px; margin:0 !important; padding:12px 20px !important;
  border:0; border-radius:var(--pd-radius); background:var(--pd-brand); color:#fff;
  font-family:inherit; font-size:16px !important; font-weight:800; line-height:1.2; text-transform:none; letter-spacing:0;
  box-shadow:0 14px 28px -20px rgba(89,49,150,.8);
  transition:background-color .15s ease, transform .15s ease;
}
html #modal- #modal------:hover{ background:#6a40ad; transform:translateY(-1px); }
html #modal- #modal------:focus-visible{ outline:2px solid var(--pd-brand); outline-offset:3px; }
html #modal- .pd-buy-price{ margin-left:.35em; white-space:nowrap; }

/* ---------- Шапка: тип, объём и срок, цена, страна ---------- */
/* первая строка шапки уступает место крестику */
html #modal- .pd-head > :first-child{ margin-right:48px; }
html #modal- .pd-type{
  display:inline-block; padding:4px 10px; border-radius:999px;
  background:var(--pd-wash); color:var(--pd-brand);
  font-size:12px; font-weight:800; line-height:1.3; letter-spacing:.02em;
}
html #modal- .pd-head__row{ display:flex; align-items:baseline; justify-content:space-between; gap:8px 16px; flex-wrap:wrap; margin-top:10px; }
html #modal- .pd-title{ font-size:22px; font-weight:800; line-height:1.25; letter-spacing:-.01em; color:var(--pd-ink); }
html #modal- .pd-price{ display:flex; align-items:baseline; gap:8px; white-space:nowrap; font-size:22px; font-weight:800; line-height:1.25; color:var(--pd-ink); }
/* цена с промокодом приходит из карточки: .price-orig + .price-promo */
html #modal- .pd-price :is(.price-orig, .price-orig-){ order:-1; margin:0; font-size:14px; font-weight:600; color:var(--pd-subtle); text-decoration:line-through; }
html #modal- .pd-price .price-promo{ margin:0; font-size:inherit; font-weight:inherit; color:inherit; }
html #modal- .pd-price .price-promo span{ color:inherit; }
html #modal- .pd-where{ margin-top:4px; font-size:14px; font-weight:600; line-height:1.4; color:var(--pd-subtle); }

/* ---------- Группы «подпись — значение» ---------- */
html #modal- .pd-sec{ margin-top:22px; }
html #modal- .pd-sec__t{
  margin:0 0 2px; font-size:12px; font-weight:800; line-height:1.3;
  letter-spacing:.08em; text-transform:uppercase; color:var(--pd-subtle);
}
html #modal- .pd-list{ margin:0; padding:0; }
html #modal- .pd-row{
  display:grid; grid-template-columns:minmax(0, 44%) minmax(0, 1fr); gap:4px 16px; align-items:baseline;
  padding:10px 0; border-bottom:1px solid var(--pd-line);
}
html #modal- .pd-row:last-child{ border-bottom:0; }
html #modal- .pd-row dt{ margin:0; font-weight:500; color:var(--pd-muted); }
html #modal- .pd-row dd{ margin:0; font-weight:700; color:var(--pd-ink); text-align:right; overflow-wrap:anywhere; }
/* длинные значения (ограничение скорости, списки стран) — под подписью */
html #modal- .pd-row--stack{ grid-template-columns:1fr; }
html #modal- .pd-row--stack dd{ text-align:left; }
html #modal- .pd-long{ font-weight:600 !important; line-height:1.55; }
html #modal- .pd-row dd a{ color:var(--pd-brand); }
html #modal- .pd-note{ display:block; margin-top:2px; font-size:13px; font-weight:500; line-height:1.4; color:var(--pd-subtle); }

/* ---------- Возврат и совместимость (скрипт переносит их под кнопку) ---------- */
html #modal- .pd-foot{ display:flex; flex-direction:column; align-items:center; gap:4px; margin-top:20px; font-size:13px; line-height:1.45; color:var(--pd-subtle); text-align:center; }
html #modal- #modal----- .pd-foot{ margin-top:12px; }
html #modal- .pd-foot p{ margin:0; }
html #modal- .pd-foot a{ color:var(--pd-brand); font-weight:700; text-decoration:underline; text-underline-offset:2px; }
html #modal- .pd-foot a:hover{ text-decoration-thickness:2px; }

/* ---------- Телефон: окно выезжает снизу ---------- */
@media (max-width:600px){
  html #modal-{ align-items:flex-end; padding:0; }
  html #modal- #modal--{
    width:100%; max-height:92vh; max-height:92dvh;
    border-radius:16px 16px 0 0;
  }
  html #modal- #modal---{ top:12px; right:12px; }
  html #modal- #modal-content-{ padding:20px 18px 4px; }
  html #modal- #modal-----{ padding:12px 18px calc(14px + env(safe-area-inset-bottom)); }
  html #modal- .pd-title, html #modal- .pd-price{ font-size:20px; }
  html #modal- .pd-row:not(.pd-row--stack){ grid-template-columns:minmax(0, 46%) minmax(0, 1fr); }
  html #modal- .pd-row{ gap:2px 12px; }
}
