/* Базовые стили: сброс, типографика, оболочка, общие компоненты. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--wall, var(--paper));
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-md);
  line-height: 1.5;
  font-kerning: normal;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.5s var(--ease);
}
img, svg { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }

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

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: var(--radius-ui);
}
.skip-link:focus { top: 10px; }

/* ---------- Шапка ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: clamp(12px, 3vw, 40px);
  padding: 0 var(--gutter);
  background: color-mix(in oklab, var(--wall, var(--paper)) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; white-space: nowrap;
  font-family: var(--serif); font-size: var(--t-xl); font-weight: 500; letter-spacing: -0.01em;
}
.brand svg { width: 22px; height: 22px; color: var(--accent); }

.main-nav { display: flex; gap: 4px; }
.main-nav a {
  text-decoration: none; color: var(--ink-2);
  padding: 7px 12px; border-radius: var(--radius-chip);
  font-size: var(--t-sm); font-weight: 500;
}
.main-nav a:hover { color: var(--ink); background: var(--rule); }
.main-nav a[aria-current="page"] { color: var(--ink); background: color-mix(in oklab, var(--ink) 9%, transparent); }
.main-nav svg { display: none; }

.header-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search-trigger {
  display: flex; align-items: center; gap: 10px;
  min-width: 260px; height: 38px; padding: 0 10px 0 12px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-ui);
  background: var(--paper-2); color: var(--ink-3);
  font-size: var(--t-sm); text-align: left;
}
.search-trigger:hover { border-color: var(--ink-3); color: var(--ink-2); }
.search-trigger svg { width: 16px; height: 16px; flex: none; }
.search-trigger span { flex: 1; }
kbd {
  font-family: var(--sans); font-size: 11px; line-height: 1;
  padding: 3px 6px; border: 1px solid var(--rule-strong); border-radius: 4px; color: var(--ink-3);
}
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid transparent; border-radius: var(--radius-ui); background: none; color: var(--ink-2);
}
.icon-btn:hover { background: var(--rule); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}

/* Мобильная навигация — нижняя панель */
@media (max-width: 760px) {
  :root { --header-h: 54px; }
  /* backdrop-filter у шапки сделал бы её контейнером для fixed-навигации — на мобильном фон сплошной */
  .site-header { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--wall, var(--paper)); }
  .search-trigger { min-width: 0; width: 38px; padding: 0; justify-content: center; border-color: transparent; background: none; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .main-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    justify-content: space-around; gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in oklab, var(--paper-2) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--rule);
  }
  .main-nav a { display: grid; justify-items: center; gap: 2px; padding: 6px 10px; font-size: 11px; border-radius: 10px; }
  .main-nav svg { display: block; width: 22px; height: 22px; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

/* ---------- Общие элементы ---------- */
.page { padding: clamp(28px, 5vw, 64px) var(--gutter) 96px; max-width: 1440px; margin: 0 auto; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border: 1px solid var(--ink); border-radius: var(--radius-ui);
  background: var(--ink); color: var(--paper);
  font-size: var(--t-sm); font-weight: 500; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: color-mix(in oklab, var(--ink) 86%, var(--accent)); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn.ghost:hover { border-color: var(--ink); background: transparent; }
.btn svg { width: 16px; height: 16px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-chip);
  background: transparent; color: var(--ink-2);
  font-size: var(--t-sm); text-decoration: none; white-space: nowrap;
}
a.chip:hover, button.chip:hover { border-color: var(--ink-2); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip .count { color: var(--ink-3); font-size: var(--t-xs); }
.chip[aria-pressed="true"] .count { color: color-mix(in oklab, var(--paper) 70%, transparent); }

.swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--ink-3)); flex: none; }
.era-tag { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: var(--t-sm); text-decoration: none; }
a.era-tag:hover { color: var(--ink); text-decoration: underline; }

.serif { font-family: var(--serif); }
.muted { color: var(--ink-3); }

.section-title {
  font-family: var(--serif); font-size: var(--t-3xl); font-weight: 500; letter-spacing: -0.01em;
  margin-bottom: 20px;
}

/* ---------- Изображение-работа ---------- */
.art { margin: 0; }
.art-frame {
  display: block; position: relative; overflow: hidden;
  background: var(--ph, var(--paper-3));
  aspect-ratio: var(--ar, 4 / 3);
}
.art-frame img {
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.6s var(--ease);
}
.art-frame img.is-loaded { opacity: 1; }
.art-frame.contain img { object-fit: contain; }
.art-frame .palette-card {
  position: absolute; inset: 0; display: grid; grid-template-rows: repeat(5, 1fr);
}
.art-frame .palette-card i { display: block; }
.art-frame .palette-card-note {
  position: absolute; left: 12px; bottom: 10px; right: 12px;
  font-size: var(--t-xs); color: rgb(255 255 255 / 0.9); text-shadow: 0 1px 2px rgb(0 0 0 / 0.5);
}
.art-frame .palette-card:empty + .palette-card-note {
  color: var(--ink-2); text-shadow: none;
}
.credit { margin-top: 8px; font-size: var(--t-xs); color: var(--ink-3); line-height: 1.45; }
.credit a { color: inherit; }
.badge-fair {
  display: inline-block; margin-right: 6px; padding: 1px 6px;
  border: 1px solid var(--rule-strong); border-radius: 4px; font-size: 10.5px; color: var(--ink-2);
  cursor: help;
}
.credit-note { display: block; margin-top: 2px; }

/* Статус проверки связи: текст + форма, а не только цвет. */
.st { white-space: nowrap; }
.st.st-verified::before { content: "✓ "; }
.st.st-unverified { color: var(--ink-3); }
.st.st-unverified::before { content: "? "; }

/* ---------- Поиск (диалог) ---------- */
dialog { color: var(--ink); }
.search-dialog {
  width: min(680px, calc(100vw - 24px)); max-height: min(640px, calc(100vh - 80px));
  margin: 10vh auto auto; padding: 0;
  border: 1px solid var(--rule); border-radius: 12px;
  background: var(--paper-2); box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.45);
  overflow: hidden;
}
.search-dialog::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.search-dialog[open] { display: flex; flex-direction: column; }
.search-box { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--rule); }
.search-box svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.search-box input {
  flex: 1; height: 62px; border: 0; outline: none; background: none;
  font-family: var(--serif); font-size: var(--t-2xl);
}
.search-box input::placeholder { color: var(--ink-3); }
.search-results { overflow-y: auto; padding: 8px; list-style: none; }
.search-results li a {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 14px;
  padding: 8px 10px; border-radius: 8px; text-decoration: none;
}
.search-results li a[aria-selected="true"], .search-results li a:hover { background: color-mix(in oklab, var(--ink) 7%, transparent); }
.search-results .thumb { width: 52px; height: 52px; background: var(--ph, var(--paper-3)); overflow: hidden; border-radius: 3px; }
.search-results .thumb img { width: 100%; height: 100%; object-fit: cover; }
.search-results .r-name { font-family: var(--serif); font-size: var(--t-lg); line-height: 1.25; }
.search-results .r-sub { font-size: var(--t-sm); color: var(--ink-3); }
.search-results .r-dates { font-size: var(--t-sm); color: var(--ink-3); text-align: right; }
.search-hint { padding: 14px 18px 18px; font-size: var(--t-sm); color: var(--ink-3); }
.search-hint button { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 0.2em; }
.search-group-title { padding: 10px 10px 4px; font-size: var(--t-xs); color: var(--ink-3); }

/* ---------- Лайтбокс ---------- */
.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgb(12 12 13 / 0.94); color: #eee;
}
.lightbox[open] { display: grid; grid-template-rows: 1fr auto; }
.lightbox img { max-width: calc(100vw - 48px); max-height: calc(100vh - 120px); margin: auto; object-fit: contain; }
.lightbox figcaption { padding: 12px 24px 20px; text-align: center; font-size: var(--t-sm); color: #bbb; }
.lightbox .icon-btn { position: absolute; top: 14px; right: 14px; color: #eee; }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 80; transform: translate(-50%, 12px);
  padding: 10px 16px; border-radius: 8px; background: var(--ink); color: var(--paper);
  font-size: var(--t-sm); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 760px) { .toast { bottom: 88px; } }

/* ---------- Подвал ---------- */
.site-footer {
  padding: 32px var(--gutter) 40px; border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; gap: 8px 28px; color: var(--ink-3); font-size: var(--t-sm);
}
.site-footer a { color: var(--ink-2); }

.loading, .error-state { padding: 20vh var(--gutter); text-align: center; color: var(--ink-3); font-family: var(--serif); font-size: var(--t-xl); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.28s; }
