/* Typephoria: вид первой версии сайта (ADR 0014) — светлая бумага, чернила, красный акцент,
   заголовки Playfair Display, текст и кнопки DM Sans. Цветными остаются плитки с надписями.
   Шрифты интерфейса свои, внешних ресурсов нет. */

@font-face {
  font-family: "DM Sans";
  src: url("/fonts/dmsans/dmsans.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "Playfair Display";
  src: url("/fonts/playfairdisplay/playfairdisplay.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Playfair Display";
  src: url("/fonts/playfairdisplay-italic/playfairdisplay-italic.woff2") format("woff2");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #f1f1ef;
  --card: #ffffff;
  --ink: #060512;
  --muted: #5f5e63;
  --line: #cacac8;
  --accent: #ff3150;
  --accent-dark: #e01e3e;
  --focus: #2b4acb;
  --display: "Playfair Display", Georgia, serif;
  --text: "DM Sans", Arial, sans-serif;
  --shadow: 0 18px 48px rgba(6, 5, 18, 0.11);
  --wrap: 1360px;
  --gutter: clamp(16px, 4vw, 40px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 24px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.55 var(--text); overflow-x: hidden; }
h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
canvas { display: block; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

h1, h2, h3, .logo { font-family: var(--display); }
h1 { font-weight: 700; font-size: clamp(2.6rem, 6vw, 5.6rem); line-height: 1; letter-spacing: -0.04em; text-wrap: balance; }
h2 { font-weight: 700; font-size: clamp(1.8rem, 3vw, 2.7rem); line-height: 1.05; letter-spacing: -0.03em; text-wrap: balance; }
h3 { font-weight: 700; font-size: 1.22rem; line-height: 1.2; letter-spacing: -0.012em; }
.lede { font-size: clamp(1.08rem, 1.5vw, 1.28rem); line-height: 1.5; color: #3a342c; max-width: 34em; }
.kicker { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); }
.kicker::before { content: ""; display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--accent); margin-right: 0.7em; }

/* ---------- шапка ---------- */

.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.logo { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.logo-mark { font: 600 2.1rem/1 var(--display); letter-spacing: -0.13em; padding-bottom: 3px; border-bottom: 2px solid var(--accent); }
.logo-mark i { font-style: italic; }
.logo-name { font: 800 0.95rem/1 var(--text); letter-spacing: 0.075em; text-transform: uppercase; padding-left: 14px; border-left: 2px solid var(--accent); }

/* ---------- кнопки ---------- */

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 18px; border: 1.5px solid var(--ink); border-radius: 999px; font-weight: 800; font-size: 0.8rem; letter-spacing: 0.02em; text-transform: uppercase; text-decoration: none; background: transparent; transition: background 0.15s, color 0.15s, transform 0.15s; }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* ---------- главная: лента образцов, вид первой версии (ADR 0014) ---------- */

main > section.design-section { margin-bottom: clamp(40px, 6vw, 80px); }
/* лента как в Pinterest: плитки идут по рядам слева направо, высота у каждой своя (по пропорциям надписи), и каждая
   встаёт под самую короткую колонку. Сетка с рядами по 4px: home.js даёт плитке столько рядов, сколько её высота */
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(285px, calc((100% - 54px) / 4)), 1fr)); grid-auto-rows: 4px; column-gap: 18px; margin-top: clamp(20px, 3vw, 36px); }
.design { align-self: start; margin-bottom: 18px; display: grid; background: var(--card); border: 1px solid #e2e2df; border-radius: 14px; padding: 10px; box-shadow: 0 8px 25px rgba(20, 18, 12, 0.07); transition: transform 0.25s, box-shadow 0.25s; }
.design:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.design[hidden] { display: none; }
.specimen { position: relative; }
.specimen img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: #e9e8e5; opacity: 0; transition: opacity 0.2s; }
.design.is-ready img { opacity: 1; }
.icon-btn { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--ink); box-shadow: 0 4px 14px rgba(6, 5, 18, 0.18); text-decoration: none; }
.icon-btn:hover { background: var(--accent); color: #fff; }
.design-body { display: grid; gap: 6px; padding: 16px 8px 8px; }
.design-body h3 { font-size: 1.65rem; line-height: 1; letter-spacing: -0.03em; }
.btn-dl { margin-top: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border: 1.5px solid var(--accent); border-radius: 999px; background: transparent; color: var(--accent); font: 800 0.8rem var(--text); letter-spacing: 0.02em; text-transform: uppercase; }
.btn-dl:hover { background: var(--accent); color: #fff; }
.btn-dl:disabled { opacity: 0.6; cursor: progress; }
.icon-btn svg, .btn-dl svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* ---------- 404 ---------- */

main > section, main > div.wrap { margin-bottom: clamp(56px, 8vw, 104px); }
.page-head { display: grid; gap: 18px; padding-block: clamp(28px, 5vw, 60px) 0; justify-items: start; }

/* ---------- подвал ---------- */

.site-footer { border-top: 1px solid var(--line); padding-block: 48px 36px; }
.foot-brand { display: grid; gap: 10px; align-content: start; max-width: 26em; color: var(--muted); font-size: 0.95rem; }

/* ---------- узкие экраны ---------- */

@media (max-width: 860px) {
  .design-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; }
  .design { padding: 6px; margin-bottom: 10px; }
  .design-body { padding: 10px 4px 4px; }
  .design-body h3 { font-size: 1.2rem; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  /* лента на телефоне — как у Pinterest (просьба владельца 18 ноября, его снимок): 4 px по краям и между плитками,
     место уходит самим плиткам. Сетка выходит за поля страницы; ряды по 2 px — вертикальный зазор ровнее */
  .design-grid { margin-inline: calc(4px - var(--gutter)); column-gap: 4px; grid-auto-rows: 2px; }
  .design { padding: 4px; margin-bottom: 4px; border-radius: 12px; box-shadow: none; }
  .specimen img { border-radius: 9px; }
  .design-body { padding: 8px 4px 4px; }
}

/* меню Download (ADR 0030): общее для ленты и редактора, строится в download.js */
.dl-menu { position: fixed; z-index: 50; display: grid; min-width: 220px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
.dl-menu[hidden] { display: none; }
.dl-menu button { display: flex; align-items: baseline; gap: 10px; padding: 10px 12px; border: 0; border-radius: 9px; background: transparent; text-align: left; font: 400 14px var(--text); }
.dl-menu button:hover:not(:disabled), .dl-menu button:focus-visible { background: var(--paper); }
.dl-menu button:disabled { opacity: 0.45; cursor: not-allowed; }
.dl-menu strong { min-width: 34px; font-weight: 700; }
.dl-menu span { color: var(--muted); font-size: 13px; }
/* файл готовится (download.js): крутилка справа и бегущая полоска снизу у пункта, остальные пункты гаснут */
.dl-menu button { position: relative; overflow: hidden; }
.dl-menu[aria-busy="true"] button:not([data-state]) { opacity: 0.45; pointer-events: none; }
.dl-menu button[data-state="busy"] { padding-right: 40px; background: var(--paper); cursor: progress; }
.dl-menu button[data-state="busy"] span { color: var(--ink); }
.dl-menu button[data-state="busy"]::after { content: ""; position: absolute; right: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border: 2px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: dl-spin 0.7s linear infinite; }
.dl-menu button[data-state="busy"]::before { content: ""; position: absolute; left: 0; bottom: 0; width: 40%; height: 3px; border-radius: 2px; background: var(--accent, #ff3355); animation: dl-run 1.1s ease-in-out infinite; }
.dl-menu button[data-state="done"] span { color: #2f9e44; font-weight: 600; }
.dl-menu button[data-state="error"] span { color: #e5484d; }
@keyframes dl-spin { to { transform: rotate(360deg); } }
@keyframes dl-run { from { translate: -100% 0; } to { translate: 250% 0; } }
@media (prefers-reduced-motion: reduce) { .dl-menu button[data-state="busy"]::after, .dl-menu button[data-state="busy"]::before { animation-duration: 3s; } }
