/* ============================================================================
   SORIMOTO - store layer: cart drawer, order status and legal pages.
   Uses the tokens from styles.css (same palette, radius scale and type).
   Everything under .shop-on only applies once the server turned the store on.
   Layers: nav 50, grain 60, cart 70.
============================================================================ */

/* ----------------------------- Nav cart button ---------------------------- */
.nav__cart {
  position: relative; flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: var(--r-pill);
  display: grid; place-items: center; font-size: 1.3rem; color: var(--text);
  background: rgba(8,8,10,0.42); border: 1px solid var(--line-2);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: border-color 0.3s, background 0.3s, transform 0.4s var(--ease);
}
.nav__cart:hover { border-color: rgba(255,255,255,0.32); background: rgba(255,255,255,0.08); }
.nav__cart:active { transform: scale(0.96); }
.nav__cart-n {
  position: absolute; top: -4px; right: -4px;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  background: var(--red); color: #fff;
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500; line-height: 1;
}
.nav__cart-n[hidden] { display: none; }

.btn[disabled], .btn[aria-busy="true"] { opacity: 0.62; pointer-events: none; }

/* ----------------------------- Cart drawer -------------------------------- */
/* Lock the page behind the drawer without the layout jumping by a scrollbar. */
html.cart-open { overflow: hidden; scrollbar-gutter: stable; }

.cart { position: fixed; inset: 0; z-index: 70; }
.cart[hidden] { display: none; }
.cart__backdrop {
  position: absolute; inset: 0; background: rgba(5,5,6,0.66);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.35s var(--ease); touch-action: none;
}
.cart__panel {
  position: absolute; top: 0; right: 0; height: 100dvh; width: min(460px, 100vw);
  display: flex; flex-direction: column;
  background: var(--bg-2); border-left: 1px solid var(--line-2);
  box-shadow: -40px 0 90px -40px rgba(0,0,0,0.95);
  transform: translateX(100%); transition: transform 0.45s var(--ease);
}
.cart__panel:focus { outline: none; }
.cart.is-open .cart__backdrop { opacity: 1; }
.cart.is-open .cart__panel { transform: none; }

.cart__head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.3rem 1.4rem; border-bottom: 1px solid var(--line);
}
.cart__title { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; letter-spacing: -0.02em; line-height: 1; }
.cart__close {
  width: 44px; height: 44px; border-radius: var(--r-pill); display: grid; place-items: center;
  font-size: 1.2rem; color: var(--dim); border: 1px solid var(--line-2);
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.cart__close:hover { color: #fff; border-color: rgba(255,255,255,0.32); background: rgba(255,255,255,0.06); }

.cart__test, .testbar {
  font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.04em; text-align: center;
  color: #fff; background: rgba(232,32,42,0.18); border-bottom: 1px solid var(--red-deep);
  padding: 0.6rem 1rem;
}
.cart__test[hidden] { display: none; }

.cart__body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0.4rem 1.4rem;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.22) transparent;
}
.cart__list { list-style: none; }

.citem {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 0.2rem 1rem;
  padding: 1.1rem 0; align-items: center;
}
.citem + .citem { border-top: 1px solid var(--line); }
.citem__media {
  grid-row: span 2; width: 76px; height: 76px; border-radius: var(--r-chip); overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(60% 52% at 50% 46%, rgba(232,32,42,0.2), transparent 74%),
    linear-gradient(180deg, #101014, #0b0b0e);
}
.citem__media img { width: 100%; height: 100%; object-fit: contain; padding: 9%; }
.citem__info { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.1rem 0.8rem; align-items: baseline; }
.citem__name { font-weight: 700; font-size: 1rem; line-height: 1.25; }
.citem__price { font-family: var(--font-mono); font-weight: 500; font-size: 1rem; color: #fff; white-space: nowrap; grid-row: 1; grid-column: 2; }
.citem__type { grid-column: 1 / -1; color: var(--mute); font-size: 0.84rem; }
.citem__ctl { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-top: 0.5rem; }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--r-pill); }
.qty__btn {
  width: 40px; height: 38px; display: grid; place-items: center; font-size: 0.95rem; color: var(--text);
  border-radius: var(--r-pill); transition: background 0.2s, color 0.2s;
}
.qty__btn:hover:not([disabled]) { background: rgba(255,255,255,0.08); }
.qty__btn[disabled] { color: rgba(255,255,255,0.26); cursor: default; }
.qty__n { min-width: 2ch; text-align: center; font-family: var(--font-mono); font-size: 0.95rem; }
.citem__del {
  width: 40px; height: 40px; border-radius: var(--r-pill); display: grid; place-items: center;
  font-size: 1.1rem; color: var(--mute); transition: color 0.2s, background 0.2s;
}
.citem__del:hover { color: var(--red-soft); background: rgba(232,32,42,0.1); }

.cart__empty { display: none; flex-direction: column; align-items: flex-start; gap: 0.5rem; padding: 2.6rem 0 2rem; }
.cart__empty > i { font-size: 2.4rem; color: var(--red-soft); margin-bottom: 0.6rem; }
.cart__empty-t { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
.cart__empty-d { color: var(--dim); font-size: 0.95rem; margin-bottom: 1.1rem; }
.cart--empty .cart__empty { display: flex; }
.cart--empty .cart__list, .cart--empty .cart__foot { display: none; }

.cart__foot {
  padding: 1.2rem 1.4rem calc(1.3rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; gap: 0.9rem;
}
.cart__sum { display: grid; gap: 0.55rem; }
.cart__sum > div { display: flex; align-items: baseline; justify-content: space-between; gap: 1.2rem; }
.cart__sum dt { color: var(--dim); font-size: 0.92rem; }
.cart__sum dd { color: var(--text); font-size: 0.92rem; text-align: right; }
.cart__total dt { color: var(--text); font-weight: 700; font-size: 1.05rem; }
.cart__total dd { font-family: var(--font-mono); font-weight: 500; font-size: 1.5rem; color: #fff; white-space: nowrap; }
.cart__pay { width: 100%; }
.cart__error, .ostate__error {
  color: #fff; font-size: 0.9rem; line-height: 1.45;
  background: rgba(232,32,42,0.16); border: 1px solid var(--red-deep); border-radius: var(--r-chip);
  padding: 0.7rem 0.85rem;
}
.cart__error[hidden], .ostate__error[hidden] { display: none; }
.cart__legal { color: var(--mute); font-size: 0.8rem; line-height: 1.5; }
.cart__legal a { color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }
.cart__legal a:hover { color: var(--text); }

/* ----------------------------- Landing additions -------------------------- */
.has-legal .footer__grid { grid-template-columns: 1.5fr 1fr 1fr 1fr; }
.footer__req { margin-top: 1rem; color: var(--mute); font-size: 0.82rem; display: grid; gap: 0.2rem; }
.footer__req a { color: var(--dim); transition: color 0.25s; }
.footer__req a:hover { color: var(--red-soft); }
.footer__req p:empty { display: none; }

/* ----------------------------- Store pages (order, legal) ----------------- */
.page { display: flex; flex-direction: column; min-height: 100dvh; }
.page > main { flex: 1; padding-block: clamp(2.4rem, 6vw, 4.5rem) clamp(3.5rem, 8vw, 6rem); }
.testbar { display: none; }
.is-test .testbar { display: block; }

.pagehead { border-bottom: 1px solid var(--line); background: var(--bg-2); }
.pagehead__in { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.pagehead__back { padding: 0.7rem 1.3rem; font-size: 0.9rem; }

.doc { max-width: 76ch; color: var(--dim); font-size: 1rem; line-height: 1.7; }
.doc h1 {
  font-family: var(--font-display); font-weight: 800; color: var(--text);
  font-size: clamp(1.9rem, 4.4vw, 3rem); line-height: 1.05; letter-spacing: -0.02em;
}
.doc__meta { color: var(--mute); font-family: var(--font-mono); font-size: 0.8rem; margin-top: 1rem; }
.doc__meta:empty { display: none; }
.doc h2 {
  font-family: var(--font-display); font-weight: 600; color: var(--text);
  font-size: 1.25rem; line-height: 1.2; margin: 2.6rem 0 0.9rem; scroll-margin-top: 1.5rem;
}
.doc p + p { margin-top: 0.75rem; }
.doc ul { list-style: none; display: grid; gap: 0.75rem; }
.doc li { position: relative; padding-left: 1.4rem; }
.doc li::before { content: ""; position: absolute; left: 0; top: 0.78em; width: 10px; height: 1px; background: var(--red); }
.doc ul + p, .doc p + ul { margin-top: 0.9rem; }
.doc b { color: var(--text); font-weight: 600; }
.doc a { color: var(--text); text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 3px; }
.doc a:hover { color: var(--red-soft); }
.doc__req { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; background: var(--surface); }
.doc__req > div { display: grid; grid-template-columns: minmax(9rem, 14rem) minmax(0, 1fr); gap: 1rem; padding: 0.85rem 1.2rem; }
.doc__req > div + div { border-top: 1px solid var(--line); }
.doc__req dt { color: var(--mute); font-size: 0.9rem; }
.doc__req dd { color: var(--text); overflow-wrap: anywhere; }

.pagefoot { border-top: 1px solid var(--line); background: var(--bg-2); padding-block: 1.8rem; }
.pagefoot__in { display: flex; align-items: center; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; }
.pagefoot__links { display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem; }
.pagefoot__links a { color: var(--dim); font-size: 0.92rem; transition: color 0.25s; }
.pagefoot__links a:hover { color: var(--red-soft); }
.pagefoot__legal { color: var(--mute); font-size: 0.82rem; }
.pagefoot__legal a { color: var(--dim); }
.pagefoot__legal a:hover { color: var(--red-soft); }

/* order status card */
.ostate {
  max-width: 600px; margin-inline: auto;
  border: 1px solid var(--line); border-radius: var(--r-card);
  background: linear-gradient(170deg, var(--surface-2), var(--surface));
  padding: clamp(1.6rem, 4vw, 2.6rem);
  display: flex; flex-direction: column; gap: 1rem;
}
.ostate__icon {
  width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 1.8rem;
  border: 1px solid var(--line-2); color: var(--dim); background: rgba(255,255,255,0.04);
}
.ostate__icon--ok { color: #fff; background: var(--red); border-color: transparent; box-shadow: 0 14px 34px -14px var(--red-glow); }
.ostate__icon--bad { color: var(--red-soft); background: rgba(232,32,42,0.12); border-color: var(--red-deep); }
.ostate__title { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.08; letter-spacing: -0.02em; margin-top: 0.4rem; }
.ostate__text { color: var(--dim); max-width: 46ch; }
.ostate__sum { display: grid; margin-top: 0.6rem; border-top: 1px solid var(--line); }
.ostate__sum > div { display: flex; align-items: baseline; justify-content: space-between; gap: 1.2rem; padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.ostate__sum dt { color: var(--dim); font-size: 0.95rem; }
.ostate__sum dd { font-family: var(--font-mono); font-size: 0.95rem; color: var(--text); white-space: nowrap; }
.ostate__total dt { color: var(--text); font-weight: 700; }
.ostate__total dd { font-size: 1.3rem; color: #fff; }
.ostate__actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 0.8rem; }

/* skeleton shown until the order loads; same shape as the final card */
.ostate__skel { display: flex; flex-direction: column; gap: 1rem; }
.skel { display: block; border-radius: var(--r-chip); background: linear-gradient(100deg, rgba(255,255,255,0.05) 30%, rgba(255,255,255,0.11) 50%, rgba(255,255,255,0.05) 70%); background-size: 220% 100%; }
.skel { animation: skel 1.4s linear infinite; }
.skel--icon { width: 56px; height: 56px; border-radius: 14px; }
.skel--title { width: 70%; height: 2rem; }
.skel--line { width: 92%; height: 1rem; }
.skel--box { width: 100%; height: 7rem; margin-top: 0.6rem; }
@keyframes skel { to { background-position: -220% 0; } }

/* ----------------------------- Responsive --------------------------------- */
@media (max-width: 1024px) {
  .has-legal .footer__grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  /* the cart icon takes the place of the "Где купить" pill; the link stays in the menu */
  .shop-on .nav__cta > .btn { display: none; }
}
@media (max-width: 520px) {
  .has-legal .footer__grid { grid-template-columns: 1fr; }
  .cart__panel { width: 100vw; border-left: none; }
  .doc__req > div { grid-template-columns: 1fr; gap: 0.15rem; }
  .ostate__actions .btn { width: 100%; }
  .pagehead__back { display: none; }
}

/* Short screens (phones held sideways): the pinned summary would leave no room
   for the items, so the whole drawer scrolls as one column instead. */
@media (max-height: 620px) {
  .cart__panel { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.22) transparent; }
  .cart__body { flex: none; overflow: visible; }
}

/* ----------------------------- Reduced motion ----------------------------- */
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none !important; }
}
