/* «Гербарій»: товари — як аркуші гербарію: білий аркуш на шавлієвому тлі,
   друкована етикетка з номером і латинською назвою. */
:root {
  --ground: #eef1ec;   /* шавлієве тло */
  --paper: #ffffff;    /* аркуш */
  --ink: #18231c;      /* текст */
  --green: #24432f;    /* гербарний зелений */
  --sage: #687a6c;     /* приглушений текст */
  --line: #d3dad1;     /* тонкі лінії */
  --accent: #a8405a;   /* півонія — лише для цін і акцентів */

  --font-display: 'Alegreya', Georgia, 'Times New Roman', serif;
  --font-body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-label: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', monospace;

  --radius: 2px;
  --gap: clamp(16px, 3vw, 32px);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.1; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
section[id] { scroll-margin-top: 84px; }

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.kicker, .label {
  font-family: var(--font-label);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sage);
}

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border: 1px solid var(--green); border-radius: var(--radius);
  font: 500 0.95rem/1 var(--font-body); text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.btn--solid { background: var(--green); color: var(--paper); }
.btn--solid:hover { background: var(--ink); }
.btn--outline { background: transparent; color: var(--green); }
.btn--outline:hover { background: var(--green); color: var(--paper); }
.btn--small { min-height: 38px; padding: 0 14px; font-size: 0.875rem; }
.link { color: var(--green); text-underline-offset: 3px; }

.demo-bar {
  background: var(--green); color: var(--paper);
  font: 0.75rem/1.4 var(--font-label); text-align: center;
  padding: 8px max(16px, env(safe-area-inset-left, 0px));
}

/* Шапка */
.header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--ground) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header__inner { display: flex; align-items: center; gap: var(--gap); min-height: 68px; }
.brand { display: flex; flex-direction: column; text-decoration: none; line-height: 1.1; }
.brand__name { font: 700 1.6rem/1 var(--font-display); color: var(--green); }
.brand__tag { font: 0.7rem/1.4 var(--font-label); color: var(--sage); letter-spacing: 0.04em; margin-top: 4px; }
.nav { display: flex; gap: 22px; margin-left: auto; }
.nav a { text-decoration: none; font-size: 0.95rem; color: var(--ink); }
.nav a:hover { color: var(--accent); }
.header__actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--green);
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.icon-btn .dot { fill: currentColor; stroke: none; }
.icon-btn:hover { border-color: var(--green); }

/* Перший екран */
.hero {
  display: grid; grid-template-columns: 1.1fr 0.9fr; align-items: center;
  gap: clamp(24px, 5vw, 72px);
  padding-block: clamp(32px, 7vw, 88px);
}
.hero__text { display: grid; gap: 20px; min-width: 0; }
.lead { font-size: 1.125rem; max-width: 34ch; color: #2f3b33; }
.hero__cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }

/* Аркуш гербарію */
.sheet {
  margin: 0; background: var(--paper); border: 1px solid var(--line);
  padding: clamp(12px, 2vw, 20px); box-shadow: 0 1px 0 var(--line), 0 18px 40px -28px rgba(24, 35, 28, .35);
}
.sheet__specimen, .card__specimen {
  aspect-ratio: 4 / 5; max-width: 100%;
  background: var(--ground) center / cover no-repeat;
  display: grid; place-items: center; position: relative; overflow: hidden;
}
.sheet__specimen::after, .card__specimen::after {
  content: ""; position: absolute; inset: 10px; border: 1px solid rgba(36, 67, 47, .14); pointer-events: none;
}
.hero-slide {
  position: absolute; inset: 0; background: center / cover no-repeat;
  opacity: 0; transform: scale(1.03);
  transition: opacity 1.4s ease, transform 6s ease-out;
}
.hero-slide.is-active { opacity: 1; transform: scale(1); }
.swap { transition: opacity .35s ease; }
.swap.is-changing { opacity: 0; }

/* Плавное появление при прокрутке (класс has-reveal ставит app.js, если анимация уместна) */
.has-reveal .reveal {
  opacity: 0; transform: translateY(28px);
  transition: opacity .8s ease, transform .8s cubic-bezier(.2, .7, .2, 1);
  transition-delay: var(--delay, 0ms);
}
.has-reveal .reveal.is-visible { opacity: 1; transform: none; }

.placeholder__latin { font: italic 400 1.15rem/1.3 var(--font-display); color: var(--sage); padding: 0 24px; text-align: center; }
.hero__sheet { transform: rotate(1.2deg); }
.hero__sheet .label {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px;
  margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line);
}
.label i { font-family: var(--font-display); font-size: 0.95rem; text-transform: none; letter-spacing: 0; color: var(--ink); }

/* Розділи */
.section { padding-block: clamp(48px, 8vw, 96px); }
.section--paper { background: var(--paper); border-block: 1px solid var(--line); }
.section__head { display: grid; gap: 10px; margin-bottom: clamp(24px, 4vw, 40px); }

/* Каталог */
.filters { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 24px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 16px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
  font: 500 0.9rem/1 var(--font-body); color: var(--ink);
}
.chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: var(--paper); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: var(--gap); }

.card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--paper); border: 1px solid var(--line); padding: 12px 12px 16px; min-width: 0;
}
.card__meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.card__name { font-size: 1.35rem; }
.card__open { all: unset; cursor: pointer; }
.card__open:hover { color: var(--accent); }
.card__open:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.card__specimen { cursor: pointer; }
.specimen-img { width: 100%; height: 100%; object-fit: cover; }
.card__latin { font: italic 400 0.95rem/1.3 var(--font-display); color: var(--sage); min-height: 1.3em; }
.card__desc { font-size: 0.9rem; color: #3a463e; flex: 1; }
.card__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.card__price { font: 500 1.05rem/1 var(--font-label); color: var(--accent); white-space: nowrap; }
.card__out { display: none; font: 0.8rem/1.2 var(--font-label); color: var(--sage); text-align: right; }
.card.is-out > * { opacity: .6; } /* не на самой карточке — иначе спорит с плавным появлением */
.card.is-out .card__add { display: none; }
.card.is-out .card__out { display: block; }

.notice {
  background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 20px; display: grid; gap: 16px; max-width: 640px;
}
.notice__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Про нас */
.about { display: grid; grid-template-columns: 1.3fr 1fr; gap: clamp(24px, 5vw, 64px); align-items: start; }
.about > div { display: grid; gap: 16px; max-width: 62ch; }
.label-card {
  margin: 0; border: 1px solid var(--line); background: var(--ground);
  font-family: var(--font-label); font-size: 0.875rem;
}
.label-card div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 12px 16px; border-bottom: 1px dashed var(--line); }
.label-card div:last-child { border-bottom: 0; }
.label-card dt { color: var(--sage); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.06em; padding-top: 2px; }
.label-card dd { margin: 0; }

/* Доставка */
.terms { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.terms div { border-top: 2px solid var(--green); padding-top: 14px; display: grid; gap: 8px; align-content: start; }
.terms dt { font: 500 1.35rem/1.2 var(--font-display); }
.terms dd { margin: 0; color: #3a463e; }

/* Відгуки */
.reviews { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.review { margin: 0; display: grid; gap: 12px; align-content: start; }
.review blockquote { margin: 0; font: italic 400 1.2rem/1.45 var(--font-display); }
.review figcaption { font: 0.8rem/1 var(--font-label); color: var(--sage); text-transform: uppercase; letter-spacing: 0.06em; }

/* Контакти */
.contacts { display: grid; grid-template-columns: 1fr auto; gap: var(--gap); align-items: end; }
.contacts > div:first-child { display: grid; gap: 10px; }
.contacts__line { font-size: 1.1rem; }
.contacts__actions { display: flex; flex-wrap: wrap; gap: 10px; }

.footer { border-top: 1px solid var(--line); padding-block: 24px; font: 0.8rem/1.4 var(--font-label); color: var(--sage); }
.footer__inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Кошик */
.cart-fab {
  position: fixed; z-index: 20;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 20px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--green); color: var(--paper); font: 500 0.95rem/1 var(--font-body);
  box-shadow: 0 12px 30px -12px rgba(24, 35, 28, .7);
}
.cart-fab:hover { background: var(--ink); }
.cart-fab__count {
  display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 999px; background: var(--paper); color: var(--green); font: 500 0.8rem/1 var(--font-label);
}
.cart-fab__total { font-family: var(--font-label); font-size: 0.85rem; opacity: .85; }
.footer { padding-bottom: 96px; }

.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0;
  width: min(440px, 100%); height: 100dvh; max-width: 100%; max-height: none;
  border: 0; border-left: 1px solid var(--line); padding: 0;
  background: var(--paper); color: var(--ink);
}
.drawer::backdrop { background: rgba(24, 35, 28, .4); }
.drawer__inner { height: 100%; display: flex; flex-direction: column; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.drawer__head h2 { font-size: 1.6rem; }
.drawer__head .icon-btn { background: none; cursor: pointer; }
.drawer__body { flex: 1; overflow-y: auto; padding: 8px 20px 20px; }
.drawer__foot { border-top: 1px solid var(--line); padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; }
.cart-empty { color: var(--sage); padding-top: 16px; }
.cart-total { font: 500 1.15rem/1 var(--font-display); display: flex; justify-content: space-between; }
.cart-total span { font-family: var(--font-label); color: var(--accent); }

.cart-lines { list-style: none; margin: 0; padding: 0; }
.line {
  display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 10px;
  padding: 14px 0; border-bottom: 1px dashed var(--line);
}
.line__info { display: grid; gap: 4px; min-width: 0; }
.line__name { font: 500 1.05rem/1.2 var(--font-display); }
.line__price { text-transform: none; }
.line__sum { font: 500 0.9rem/1 var(--font-label); min-width: 72px; text-align: right; }
.line__remove { border: 0; background: none; color: var(--sage); font-size: 1.3rem; width: 32px; height: 32px; cursor: pointer; }
.line__remove:hover { color: var(--accent); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); }
.qty button { width: 32px; height: 32px; border: 0; background: none; cursor: pointer; font-size: 1.05rem; color: var(--green); }
.qty button:hover { background: var(--ground); }
.qty__value { min-width: 26px; text-align: center; font: 500 0.9rem/1 var(--font-label); }
.card__add.is-added { background: var(--ink); }
.foot-note { font: 0.75rem/1.4 var(--font-label); color: var(--sage); }

/* Оформлення замовлення */
.checkout { display: grid; gap: 16px; padding-top: 12px; }
.back { justify-self: start; border: 0; background: none; padding: 4px 0; color: var(--green); font: 500 0.9rem/1 var(--font-body); cursor: pointer; }
.field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { font: 500 0.85rem/1.2 var(--font-body); padding: 0; }
.optional { color: var(--sage); font-weight: 400; }
.field input, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink);
  font: 400 16px/1.4 var(--font-body); /* 16px — иначе iPhone приближает поле */
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(36, 67, 47, .12); }
.field [aria-invalid="true"] { border-color: var(--accent); }
.field__error { color: var(--accent); font-size: 0.82rem; }
.field__error:empty { display: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.methods { gap: 8px; }
.methods legend { margin-bottom: 8px; }
.method { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); cursor: pointer; }
.method:has(input:checked) { border-color: var(--green); background: var(--ground); }
.method input { accent-color: var(--green); width: 18px; height: 18px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.send-error { border-left-color: var(--accent); padding: 14px; }
.done { display: grid; gap: 14px; padding-top: 24px; }
.done h3 { font-size: 2rem; }
#checkout-submit[disabled] { opacity: .7; cursor: progress; }

.toast {
  position: fixed; z-index: 30; inset: auto auto calc(84px + env(safe-area-inset-bottom, 0px)) 50%;
  transform: translateX(-50%); margin: 0;
  width: max-content; max-width: calc(100% - 32px);
  padding: 12px 16px; border: 0; background: var(--ink); color: var(--paper);
  font: 0.9rem/1.4 var(--font-body); box-shadow: 0 10px 30px -12px rgba(24, 35, 28, .6);
}

/* Картка товару */
body:has(dialog[open]) { overflow: hidden; } /* страница под окном не прокручивается */
.product {
  width: min(980px, calc(100% - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--line); background: var(--paper); color: var(--ink); overflow: auto;
}
.product::backdrop { background: rgba(24, 35, 28, .45); }
.product__close { position: absolute; top: 12px; right: 12px; z-index: 3; background: var(--paper); cursor: pointer; }
.product__layout { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(20px, 4vw, 40px); padding: 24px; }
.product__photo { cursor: default; }
.product__info { display: grid; gap: 14px; align-content: start; padding-top: 8px; min-width: 0; }
.product__info h2 { font-size: clamp(1.8rem, 3.2vw, 2.5rem); padding-right: 40px; }
.product__latin { font: italic 400 1.1rem/1.3 var(--font-display); color: var(--sage); }
.product__buy { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; padding-block: 6px; }
.product__price { font: 500 1.6rem/1 var(--font-label); color: var(--accent); }
.product__out { font: 0.9rem/1.2 var(--font-label); color: var(--sage); }
.product__facts { margin: 0; border-top: 1px solid var(--line); }
.product__facts div { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.product__facts dt { font: 0.72rem/1.7 var(--font-label); text-transform: uppercase; letter-spacing: 0.06em; color: var(--sage); }
.product__facts dd { margin: 0; font-size: 0.95rem; }

/* Телефон: каталог в две колонки, как в больших магазинах */
@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 8px 8px 10px; gap: 6px; }
  .card__specimen::after { inset: 6px; }
  .card__meta, .card__desc { display: none; }
  .card__name { font-size: 1.05rem; line-height: 1.15; }
  .card__latin { font-size: 0.8rem; }
  .card__foot { flex-direction: column; align-items: stretch; gap: 8px; margin-top: auto; }
  .card__add { width: 100%; }
  .card__out { text-align: left; }
}

/* Телефон: картка товару на весь екран, кнопка «До кошика» внизу */
@media (max-width: 700px) {
  .product { width: 100%; max-width: 100%; height: 100dvh; max-height: none; margin: 0; border: 0; }
  .product__layout { grid-template-columns: 1fr; gap: 16px; padding: 0; }
  .product__photo { aspect-ratio: 1 / 1; }
  .product__close { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); }
  .product__info { padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
  .product__info h2 { padding-right: 0; }
  .product__buy {
    order: 10; position: sticky; bottom: 0; z-index: 2; justify-content: space-between;
    margin-inline: -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--paper); border-top: 1px solid var(--line);
  }
}

/* Телефон */
@media (max-width: 860px) {
  .nav { display: none; }
  .header__actions { margin-left: auto; }
  .hero, .about, .contacts { grid-template-columns: 1fr; }
  .hero__sheet { transform: none; max-width: 420px; }
  .terms, .reviews { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .btn__label { display: none; }
  .line { grid-template-columns: 1fr auto auto; }
  .line__sum { display: none; }
  .header .btn--outline { width: 44px; padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
