/* ============================================================================
   base.css — замороженный «водопровод» белых сайтов. Проверен на боевых
   сборках; сюда стекаются только те правила, на которых я уже обжигался.
   Тему НЕ задаёт: все цвета/шрифты идут из токенов, которые перекрывает
   <prefix>.css. Подключать первым:
       <link rel="stylesheet" href="assets/base.css?v=1">
       <link rel="stylesheet" href="assets/<prefix>.css?v=1">
   Правила-«почему» помечены (!). Их не трогать без причины.
   ========================================================================== */

:root{
  /* контракт токенов — тема переопределяет все до одного */
  --bg:#fff; --bg-2:#f6f5f3; --ink:#1c1a17; --ink-2:#000;
  --muted:#6f6a64; --line:#e3ded6; --accent:#8a6a3a; --accent-2:#b89a68;
  --r:4px; --r-g:20px; --w:1180px; --w-s:720px; --gap:56px;
  --f-display:Georgia,serif; --f-text:system-ui,-apple-system,"Segoe UI",sans-serif;
  --f-mono:ui-monospace,Menlo,monospace;
}

*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
/* (!) smooth-scroll ломает переходы по якорям в headless-скриншотах */
@media (prefers-reduced-motion:no-preference){html:not(.shooting){scroll-behavior:smooth}}
body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--f-text);
  font-size:17px;line-height:1.7;-webkit-font-smoothing:antialiased}
img,video,svg{max-width:100%;height:auto;display:block}
a{color:inherit}
button{font:inherit}
h1,h2,h3,h4{font-family:var(--f-display);line-height:1.12;margin:0 0 .5em;
  font-weight:400;text-wrap:balance}
p{margin:0 0 1.1em;text-wrap:pretty}

/* (!) ГЛАВНОЕ ПРАВИЛО. UA-шный [hidden]{display:none} имеет ту же
   специфичность, что любой класс, и проигрывает ему по порядку: любой
   .foo{display:flex} — особенно из медиазапроса — показывает скрытый блок.
   Так вылезали таймеры, подтверждения форм и cookie-баннер. */
[hidden]{display:none!important}

/* ---------- каркас ---------------------------------------------------- */
.wrap{width:min(100% - 40px,var(--w));margin-inline:auto}
.wrap--s{width:min(100% - 40px,var(--w-s))}
.sez{padding:clamp(56px,8vw,120px) 0}
.sez--t{padding-top:0}

/* (!) сетки должны ОБЪЯВЛЯТЬ display:grid сами. Раньше display жил только
   на .griglia, а .g-32/.g-23 ставились как модификаторы — и секции молча
   схлопывались в столбик. check_build.py теперь ловит это отдельно. */
.g-11,.g-21,.g-12,.g-32,.g-23,.g-3,.g-4,.grid{display:grid;gap:var(--gap);align-items:center}
.g-11{grid-template-columns:1fr 1fr}
/* (!) Дети грида имеют min-width:auto и растут под содержимое: широкая
   таблица или длинное слово распирают всю страницу. Без этой строки
   горизонтальный скролл вылезает на телефоне и его долго ищешь. */
.g-11>*,.g-21>*,.g-12>*,.g-32>*,.g-23>*,.g-3>*,.g-4>*,.grid>*{min-width:0}
.g-21{grid-template-columns:2fr 1fr}
.g-12{grid-template-columns:1fr 2fr}
.g-32{grid-template-columns:3fr 2fr}
.g-23{grid-template-columns:2fr 3fr}
.g-3{grid-template-columns:repeat(3,1fr);align-items:start}
.g-4{grid-template-columns:repeat(4,1fr);align-items:start}
.grid{grid-template-columns:repeat(var(--cols,3),1fr);align-items:start}

/* ---------- медиа ------------------------------------------------------ */
/* (!) aspect-ratio + cover: без них карточки прыгают при загрузке, а вырез
   товара на белом фоне исчезает на кремовой подложке. */
.carta{display:block;overflow:hidden;text-decoration:none}
.carta>img{width:100%;aspect-ratio:4/3;object-fit:cover;background:var(--bg-2);
  border-radius:var(--r);transition:transform .8s cubic-bezier(.22,.61,.36,1)}
.carta:hover>img{transform:scale(1.04)}
.fig{margin:0}
.fig img{width:100%;border-radius:var(--r)}
.fig figcaption{font-size:.84rem;color:var(--muted);margin-top:10px}
.fascia{width:100%;max-height:72vh;object-fit:cover}
.strip{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}
.strip img{width:100%;aspect-ratio:1/1;object-fit:cover;border-radius:var(--r)}

/* ---------- galeria: rowna siatka, bez dziur ----------------------------- */
/* (!) Dwa bledy, kazdy kosztowal rundę poprawek:
   1) brak aspect-ratio -> poszarpane kolumny przy mieszanych orientacjach;
   2) liczba zdjec niepodzielna przez liczbe kolumn -> dziura w ostatnim rzedzie.
   12 kolumn (dzieli sie przez 4, 3 i 2), a „ogon" rozciaga sie na caly rzad.
   Reguly ogona MUSZA siedziec w osobnych media queries: wersja desktopowa ma
   wyzsza specyficznosc niz mobilna i inaczej ja bije. */
.gal{display:grid;grid-template-columns:repeat(12,1fr);gap:18px}
.gal .fig{margin:0}
.gal .fig img{width:100%;object-fit:cover;border-radius:var(--r);
  background:var(--bg-2);display:block}
@media (min-width:901px){
  .gal--4 .fig{grid-column:span 3}
  .gal--3 .fig{grid-column:span 4}
  .gal .fig img{aspect-ratio:4/5}
  .gal--4 .fig:nth-child(4n+1):last-child{grid-column:span 12}
  .gal--4 .fig:nth-child(4n+1):last-child img{aspect-ratio:21/9}
  .gal--4 .fig:nth-child(4n+1):nth-last-child(2),
  .gal--4 .fig:nth-child(4n+1):nth-last-child(2) ~ .fig{grid-column:span 6}
  .gal--4 .fig:nth-child(4n+1):nth-last-child(3),
  .gal--4 .fig:nth-child(4n+1):nth-last-child(3) ~ .fig{grid-column:span 4}
  .gal--3 .fig:nth-child(3n+1):last-child{grid-column:span 12}
  .gal--3 .fig:nth-child(3n+1):last-child img{aspect-ratio:21/9}
  .gal--3 .fig:nth-child(3n+1):nth-last-child(2),
  .gal--3 .fig:nth-child(3n+1):nth-last-child(2) ~ .fig{grid-column:span 6}
}
@media (max-width:900px){
  .gal{gap:12px}
  .gal .fig{grid-column:span 6}
  .gal .fig img{aspect-ratio:1/1}
  .gal .fig:nth-child(2n+1):last-child{grid-column:span 12}
  .gal .fig:nth-child(2n+1):last-child img{aspect-ratio:16/9}
}

/* ---------- reveal ----------------------------------------------------- */
/* (!) НИКАКОГО clip-path на .riv — он выключает IntersectionObserver.
   Только opacity+transform. Без JS всё видно сразу. */
.riv,[data-r]{opacity:0;transform:translateY(18px);
  transition:opacity .7s ease,transform .7s cubic-bezier(.22,.61,.36,1)}
.riv.vis,[data-r].in{opacity:1;transform:none}
html:not(.js) .riv,html:not(.js) [data-r]{opacity:1;transform:none}
@media (prefers-reduced-motion:reduce){
  .riv,[data-r]{opacity:1!important;transform:none!important;transition:none}
  *{animation-duration:.01ms!important;transition-duration:.01ms!important}
}

/* ---------- кнопки и ссылки-кнопки ------------------------------------- */
.bottone{display:inline-flex;align-items:center;gap:.5em;vertical-align:top;
  padding:14px 26px;border:1px solid var(--ink);border-radius:var(--r);
  background:var(--ink);color:var(--bg);text-decoration:none;cursor:pointer;
  margin-bottom:10px;transition:background .25s,color .25s,border-color .25s}
.bottone--vuoto{background:transparent;color:var(--ink);border-color:var(--line)}
/* (!) кнопка, которая выглядит как ссылка — вместо href="#" в подвале
   (41 предупреждение линтера на прошлом сайте) */
.collega{background:none;border:0;padding:0;font:inherit;color:inherit;
  cursor:pointer;text-decoration:underline;text-underline-offset:3px;
  text-decoration-color:var(--accent)}

/* ---------- подтверждение без бэкенда ---------------------------------- */
/* (!) каждое действие без сервера обязано показать анимированное «готово» */
.fatto-msg{display:flex;align-items:center;gap:10px;padding:14px 18px;
  border:1px solid var(--accent);border-radius:var(--r);color:var(--accent);
  opacity:0;transform:translateY(8px);transition:opacity .4s,transform .4s}
.fatto-msg.is-on{opacity:1;transform:none}
.fatto-msg::before{content:"";width:9px;height:9px;border-radius:50%;
  background:var(--accent);animation:puls 1.6s ease-in-out infinite}
@keyframes puls{0%,100%{transform:scale(1);opacity:1}50%{transform:scale(1.5);opacity:.4}}

/* ---------- комплаенс: плашка и дисклеймер ----------------------------- */
.adbar{background:var(--ink);color:var(--bg);font-size:.68rem;letter-spacing:.09em;
  text-transform:uppercase;padding:9px 18px;text-align:center;line-height:1.6}
.adbar span{font-weight:600}
.disc{border-top:1px solid var(--line);padding:34px 0;font-size:.82rem;
  color:var(--muted);line-height:1.65}
.disc h2,.disc h3{font-size:.86rem;letter-spacing:.08em;text-transform:uppercase;
  font-family:var(--f-text);color:var(--ink)}

/* ---------- cookie ------------------------------------------------------ */
.ck{position:fixed;left:16px;right:16px;bottom:16px;z-index:60;max-width:560px;
  background:var(--bg);border:1px solid var(--line);border-radius:var(--r-g);
  padding:22px 24px;box-shadow:0 18px 50px rgba(0,0,0,.14);font-size:.9rem}
.ck__btns{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px}

/* ---------- таблицы, цифры, оглавление ---------------------------------- */
.tabella{width:100%;border-collapse:collapse;font-size:.92rem}
.tabella th,.tabella td{text-align:left;padding:12px 14px;border-bottom:1px solid var(--line)}
.cnt,[data-n],[data-to]{font-variant-numeric:tabular-nums}
.toc,.indice{position:sticky;top:90px;align-self:start}
.toc a.is-on,.indice a.is-on{color:var(--accent)}

/* ---------- буквица ----------------------------------------------------- */
/* (!) только .testo.cap — иначе буквица лезет в каждый абзацный блок */
.testo.cap>p:first-of-type::first-letter{float:left;font-family:var(--f-display);
  font-size:3.4em;line-height:.82;padding:.06em .1em 0 0;color:var(--accent)}

/* ---------- мобильные ---------------------------------------------------- */
@media (max-width:900px){
  .g-11,.g-21,.g-12,.g-32,.g-23,.g-3,.g-4,.grid{grid-template-columns:1fr;gap:34px}
}
@media (max-width:760px){
  body{font-size:16px}
  .wrap,.wrap--s{width:calc(100% - 32px)}
  /* (!) плашка на 375px иначе наезжает сама на себя */
  .adbar{font-size:.56rem;letter-spacing:.07em;padding:8px 14px;line-height:1.5}
  .adbar span{font-size:.64rem}
  /* (!) кнопки в hero перекрывались; !important бьёт инлайновые отступы темы.
     [hidden] выше остаётся сильнее — он с !important. */
  .bottone{display:flex;width:100%;justify-content:center;margin-left:0!important}
  /* (!) широкая таблица распирала вьюпорт и давала горизонтальный скролл */
  /* (!) класс таблицы зовут по-разному в каждой сборке — перечисляем все,
     иначе на телефоне колонки сжимаются до нечитаемых 100 px */
  .tabella,.tab,.tabela,.tabelle,.tablica{display:block;overflow-x:auto;
    -webkit-overflow-scrolling:touch}
  .toc,.indice{position:static}
}
