/*
 * global.css — общие компоненты: layout, модалки, кнопки, корзина.
 * Подключать после tokens.css.
 * Здесь НЕТ :root — все переменные живут в tokens.css.
 */

/* ── Base reset ──────────────────────────────────────────────────────── */

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

body {
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--body);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* ── Layout containers ───────────────────────────────────────────────── */

.container {
  width: 100%;
  max-width: var(--max-w-content);
  margin: 0 auto;
  padding: 0 1rem;
}

.container--wide {
  width: 100%;
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ── Typography helpers (без !important) ─────────────────────────────── */

.heading-xl  { font-size: var(--text-4xl); font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.heading-lg  { font-size: var(--text-3xl); font-weight: 700; line-height: 1.2; }
.heading-md  { font-size: var(--text-2xl); font-weight: 700; line-height: 1.3; }
.heading-sm  { font-size: var(--text-xl);  font-weight: 600; line-height: 1.4; }
.heading-xs  { font-size: var(--text-lg);  font-weight: 600; line-height: 1.4; }
.text-sm     { font-size: var(--text-sm);  color: var(--gray); }
.text-muted  { color: var(--gray); }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), color var(--transition), opacity var(--transition);
  text-decoration: none;
}

/* Primary (red) — CTA на лендинге, модалках */
.btn--primary {
  background: var(--red);
  color: #fff;
}
.btn--primary:hover {
  background: var(--red-hover);
  color: #fff;
}

/* Green — добавить в корзину, завершить заказ */
.btn--green {
  background: var(--green);
  color: #fff;
}
.btn--green:hover {
  background: var(--green-hover);
  color: #fff;
}

/* Outline — вторичное действие */
.btn--outline {
  background: transparent;
  color: var(--dark);
  border: 1.5px solid var(--border);
}
.btn--outline:hover {
  border-color: var(--gray-light);
  background: var(--bg-muted);
}

/* Ghost — «назад к покупкам» и т.п. */
.btn--ghost {
  background: var(--bg-subtle);
  color: var(--dark);
}
.btn--ghost:hover {
  background: var(--border-light);
}

/* ── add-to-cart-button (React + SSR) ───────────────────────────────── */

.add-to-cart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 10px 20px;
  width: 100%;
  font-size: var(--text-md);
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 1rem;
  color: #fff;
  background: var(--green);
  transition: background var(--transition);
  text-decoration: none;
  text-align: center;
}

.add-to-cart-button:hover {
  background: var(--green-hover);
  color: #fff;
}

/* close-button: нейтральная (было orange — это антипаттерн) */
.close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 10px 20px;
  width: 100%;
  font-size: var(--text-md);
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 1rem;
  color: var(--dark);
  background: var(--bg-subtle);
  transition: background var(--transition);
}

.close-button:hover {
  background: var(--border-light);
}

/* ── Modal: полноэкранная (React, корзина и т.п.) ────────────────────── */

.global-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.global-modal-container {
  height: 90%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 500px;
  width: 100%;
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.global-modal-footer {
  display: flex;
  max-width: 500px;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: sticky;
  bottom: 0;
  background: var(--white);
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, .06);
}

.modal-buttons {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

/* ── Modal overlay (промо на лендинге) ───────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.is-open {
  display: flex;
}

/* ── Cart / Order buttons ─────────────────────────────────────────────── */

.cart-button-shopping,
.cart-button-finish {
  border: none;
  padding: 11px 16px;
  width: 100%;
  font-size: var(--text-md);
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  color: #fff;
  transition: background var(--transition);
}

.cart-button-shopping {
  background: var(--bg-subtle);
  color: var(--dark);
}

.cart-button-shopping:hover {
  background: var(--border-light);
}

.cart-button-finish {
  background: var(--green);
}

.cart-button-finish:hover {
  background: var(--green-hover);
}

/* ── Login button ─────────────────────────────────────────────────────── */

.login-button {
  border: none;
  border-radius: var(--radius);
  background: var(--green);
  padding: 10px 20px;
  font-size: var(--text-md);
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  width: 100%;
  transition: background var(--transition);
}

.login-button:hover {
  background: var(--green-hover);
}

/* ── Misc helpers ─────────────────────────────────────────────────────── */

.total-price {
  font-size: var(--text-3xl);
  font-weight: 700;
  margin-bottom: 8px;
}

.global-title {
  text-align: left;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 12px 16px 4px;
}

.global-description {
  padding: 0 16px 10px;
  font-size: var(--text-sm);
  color: var(--gray);
  line-height: 1.5;
}

/* ── Modal login popup ─────────────────────────────────────────────────── */

.modal-login-container {
  position: absolute;
  top: 5rem;
  right: 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1000;
}

.modal-login-content {
  background: var(--white);
  padding: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.modal-login-content a {
  text-decoration: none;
  color: var(--dark);
  display: block;
  font-size: var(--text-lg);
}

@media (min-width: 768px) {
  .modal-login-container {
    top: 5.5rem;
    right: 1rem;
  }
}
