/* GM — minimal industrial/lab reagent storefront (mobile-first) */

/* Simple grotesque (local) — same on every device, Cyrillic included */
@font-face {
  font-family: "GM Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/manrope-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "GM Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/manrope-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "GM Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/manrope-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "GM Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ink: #111111;
  --muted: #a8a8a8;
  --hairline: #ececec;
  --bg: #ffffff;
  --gap: clamp(28px, 5vw, 72px);
  --page-pad-x: clamp(22px, 6vw, 72px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "GM Grotesk", Arial, Helvetica, sans-serif;
  --tracking: 0.14em;
}

[data-theme="dark"] {
  --ink: #ffffff;
  --muted: #6e6e6e;
  --hairline: #2a2a2a;
  --bg: #111111;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: var(--tracking);
}

body {
  font-family: var(--font);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background-color .25s ease, color .25s ease;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: inherit;
}

button {
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: var(--tracking);
  background: none;
  border: none;
  margin: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

img {
  max-width: 100%;
  height: auto;
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px var(--page-pad-x) 0;
}

@media (min-width: 721px) {
  .topbar { padding-top: 24px; }
}

.wordmark {
  font-size: 15px;
  letter-spacing: var(--tracking);
  font-weight: 500;
  text-align: center;
  text-transform: uppercase;
}

@media (min-width: 721px) {
  .wordmark { font-size: 16px; }
}

.wordmark a {
  display: inline-block;
  padding: 8px 10px 8px 14px;
  border: 2px solid var(--ink);
  box-sizing: border-box;
}

/* ---------- Product / category grid ---------- */

main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
}

main:not(.product) {
  justify-content: center;
}

.grid {
  --grid-cols: 2;
  --grid-gap-x: 20px;
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(
      min(
        100%,
        calc((100% - (var(--grid-cols) - 1) * var(--grid-gap-x)) / var(--grid-cols))
      ),
      1fr
    )
  );
  gap: 36px var(--grid-gap-x);
  padding: 20px var(--page-pad-x) 36px;
  width: 100%;
  align-items: start;
}

@media (min-width: 721px) {
  .grid {
    --grid-cols: 4;
    --grid-gap-x: 28px;
    gap: var(--gap) var(--grid-gap-x);
    padding: 32px var(--page-pad-x) 48px;
  }
}

@media (min-width: 1101px) {
  .grid { --grid-cols: 6; }
}

/* Catalog with few items: readable on phone, not huge on desktop */
.grid--sparse {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 36px 20px;
}

.grid--sparse .tile {
  flex: 0 0 auto;
  width: min(42vw, 168px);
  max-width: 100%;
}

@media (min-width: 721px) {
  .grid--sparse {
    gap: var(--gap) var(--grid-gap-x);
  }

  .grid--sparse .tile {
    width: calc(
      (100% - (var(--n) - 1) * var(--grid-gap-x)) / var(--n) * 0.5
    );
    max-width: min(280px, 42vw);
  }
}

.tile { display: block; }

.tile.is-out,
.product.is-out {
  opacity: 0.38;
  filter: grayscale(0.55) brightness(0.85);
}

.tile.is-out .tile-code::after,
.product.is-out .product-code::after {
  content: " · нет в наличии";
  font-size: 0.85em;
  opacity: 0.85;
}

.tile-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--hairline);
  cursor: pointer;
  touch-action: manipulation;
}

.tile-media svg,
.tile-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  display: block;
}

.tile-code {
  margin-top: 14px;
  text-align: center;
  font-size: 11px;
  letter-spacing: var(--tracking);
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1.35;
}

@media (min-width: 721px) {
  .tile-code {
    margin-top: 16px;
    font-size: 12px;
  }
}

/* ---------- Footer actions (Telegram + theme) ---------- */

.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 16px calc(28px + var(--safe-b));
  margin-top: auto;
  width: 100%;
}

@media (min-width: 721px) {
  .site-footer {
    padding: 28px 16px 48px;
  }
}

.footer-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 8vw, 72px);
}

.footer-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  transition: opacity .2s ease, transform .2s ease;
  color: var(--ink);
  touch-action: manipulation;
}

@media (min-width: 721px) {
  .footer-icon {
    width: clamp(34px, 6vw, 44px);
    height: clamp(34px, 6vw, 44px);
  }
}

@media (hover: hover) and (pointer: fine) {
  .footer-icon:hover {
    opacity: 0.75;
    transform: scale(1.06);
  }
}

.footer-icon:active {
  opacity: 0.7;
}

.footer-icon img,
.footer-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.footer-icon.history-link {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
}

@media (min-width: 721px) {
  .footer-icon.history-link {
    width: calc(clamp(34px, 6vw, 44px) + 4px);
    height: calc(clamp(34px, 6vw, 44px) + 4px);
    min-width: calc(clamp(34px, 6vw, 44px) + 4px);
    min-height: calc(clamp(34px, 6vw, 44px) + 4px);
  }
}

.theme-toggle .icon-moon {
  transform: scale(1.20);
  transform-origin: center;
  shape-rendering: geometricPrecision;
}

.theme-toggle .icon-sun {
  transform: scale(1.08);
  transform-origin: center;
}

.tg-link img {
  filter: invert(0);
  transition: filter .25s ease;
}

[data-theme="dark"] .tg-link img {
  filter: invert(1);
}

.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* click-flash feedback */

.flash-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: 1;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.flash-overlay.fade { opacity: 0; }

/* ---------- Product card ---------- */

.product {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  width: 100%;
  text-align: left;
}

/* Full-bleed square under the store name (phone-first) */
.product-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  margin: 0;
  overflow: hidden;
  background: var(--hairline);
  flex-shrink: 0;
}

.product-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.product-body {
  padding: 18px var(--page-pad-x) 8px;
  width: 100%;
}

.product-code,
.product-desc,
.product-desc a {
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: var(--tracking);
  font-weight: 500;
  line-height: 1.5;
  text-transform: uppercase;
}

.product-code {
  margin: 0;
  text-align: left;
  color: var(--ink);
}

/* Editable description block — grows with your text, wraps safely */
.product-desc {
  margin-top: 14px;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.product-desc p {
  margin: 0 0 0.85em;
}

.product-desc p:last-child {
  margin-bottom: 0;
}

.product-desc a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  display: inline;
  padding: 0;
}

.product-desc a:hover {
  opacity: 0.7;
}

.product-pay {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
}

.product-pay[hidden] {
  display: none !important;
}

.product-pay .product-price {
  margin-top: 0;
}

.product-pay-status {
  margin: 14px 0 0;
  font-size: 14px;
  letter-spacing: var(--tracking);
  line-height: 1.4;
  max-width: 28em;
}

.product-pay-status[hidden] {
  display: none !important;
}

/* ---------- Payment wait page ---------- */

.pay-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px var(--page-pad-x) 40px;
  width: 100%;
}

.pay-card {
  width: min(100%, 420px);
  text-align: left;
}

.pay-title {
  margin: 0;
  font-size: 16px;
  letter-spacing: var(--tracking);
  font-weight: 500;
  line-height: 1.3;
}

.pay-amount {
  margin: 14px 0 0;
  font-size: 15px;
  letter-spacing: var(--tracking);
}

.pay-status {
  margin: 18px 0 0;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: var(--tracking);
  max-width: 28em;
}

.pay-status a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pay-link {
  margin-top: 22px;
}

/* ---------- History ---------- */

.history-page {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px var(--page-pad-x) 32px;
}

.history-heading {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: var(--tracking);
  text-align: center;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-empty {
  margin: 24px 0;
  text-align: center;
  opacity: 0.6;
  font-size: 14px;
}

.history-item {
  display: block;
  padding: 14px 0;
  border-top: 1px solid var(--hairline);
  color: inherit;
}

.history-item:last-child {
  border-bottom: 1px solid var(--hairline);
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.history-item-name,
.history-item-amount {
  font-size: 15px;
  letter-spacing: var(--tracking);
}

.history-item-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 12px;
  opacity: 0.65;
  letter-spacing: var(--tracking);
}

.product-price {
  display: inline-block;
  margin-top: 18px;
  padding: 12px 22px;
  background: #ffffff;
  color: #111111;
  border: 1px solid #111111;
  border-radius: 0;
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: var(--tracking);
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: opacity .2s ease;
  appearance: none;
  -webkit-appearance: none;
}

.product-price:disabled,
.product-price.is-disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.product-price[hidden] {
  display: none !important;
}

@media (hover: hover) and (pointer: fine) {
  .product-price:hover {
    opacity: 0.85;
  }
}

/* Desktop / high-res: large square left, title + description to the right */
@media (min-width: 900px) {
  .product {
    flex-direction: row;
    align-items: flex-start;
    gap: clamp(28px, 3.5vw, 56px);
    padding: 8px 0 24px;
    padding-left: clamp(12px, 2vw, 28px);
    padding-right: var(--page-pad-x);
  }

  .product-media {
    --square: min(26vw, 520px);
    width: var(--square);
    max-width: calc(100% - 280px);
    margin-left: 200px;
    margin-top: 100px;
  }

  .product-body {
    --square: min(26vw, 520px);
    flex: 1 1 auto;
    min-width: 220px;
    max-width: none;
    width: auto;
    padding: 0;
    margin-top: 100px;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* same height as the square → price sits on its bottom edge */
    min-height: var(--square);
  }

  .product-code,
  .product-desc,
  .product-desc a {
    font-size: 16px;
  }

  .product-desc {
    margin-top: 18px;
    max-width: none;
  }

  .product-pay {
    margin-top: auto;
  }

  .product-price {
    font-size: 16px;
  }
}
