/* Pivozavr. Цвета — переменными (свет/тьма), вёрстка — от 320 px (скилл web-ui, «Мобильная вёрстка»).
   Ступени: 640 (телефон → планшет), 768 (меню шторкой → полосой), 960 (две колонки карточки). */

:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  /* #b45309 на белом и белый на нём — 5:1 (AA); #d97706 давал 3,2:1. */
  --accent: #b45309;
  --accent-strong: #92400e;
  --accent-text: #ffffff;
  --accent-soft: #fef3c7;
  --hero: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  --star: #f59e0b;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.04);
  --shadow-hover: 0 8px 28px rgb(0 0 0 / 0.1);
  --radius: 14px;
  --header-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111827;
    --surface: #1f2937;
    --surface-2: #273244;
    --text: #f9fafb;
    --muted: #9ca3af;
    --border: #374151;
    --accent: #f59e0b;
    --accent-strong: #fbbf24;
    --accent-text: #111827;
    --accent-soft: rgb(245 158 11 / 0.14);
    --hero: linear-gradient(135deg, #1f2937 0%, #2a2414 100%);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-hover: 0 8px 28px rgb(0 0 0 / 0.45);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111827;
  --surface: #1f2937;
  --surface-2: #273244;
  --text: #f9fafb;
  --muted: #9ca3af;
  --border: #374151;
  --accent: #f59e0b;
  --accent-strong: #fbbf24;
  --accent-text: #111827;
  --accent-soft: rgb(245 158 11 / 0.14);
  --hero: linear-gradient(135deg, #1f2937 0%, #2a2414 100%);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow-hover: 0 8px 28px rgb(0 0 0 / 0.45);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

main {
  flex: 1;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.5em;
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.6rem);
}

h2 {
  font-size: 1.35rem;
}

.h3 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 0.75em;
}

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

.wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.narrow {
  max-width: 860px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.accent {
  color: var(--accent);
}

.accent-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.accent-link:hover {
  text-decoration: underline;
}

.plain {
  list-style: none;
  margin: 0;
  padding: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 8px;
}

.skip:focus {
  top: 8px;
}

/* Спрайт иконок: не display:none — иначе градиент полузвезды не рисуется. */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 44px;
  padding: 0.55em 1.1em;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon-btn .icon {
  width: 22px;
  height: 22px;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  /* Без backdrop-filter и transform: внутри шторка меню с position: fixed. */
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-in {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: 1.3rem;
  font-weight: 800;
  text-decoration: none;
  color: var(--text);
}

.logo .icon {
  color: var(--accent);
  width: 1.4em;
  height: 1.4em;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}

.nav a,
.burger-menu a {
  padding: 8px 14px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  color: var(--muted);
}

.nav a:hover,
.burger-menu a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav a.active,
.burger-menu a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-toggle .icon {
  display: none;
}

:root:not([data-theme]) .theme-toggle .theme-auto,
:root[data-theme="light"] .theme-toggle .theme-light,
:root[data-theme="dark"] .theme-toggle .theme-dark {
  display: block;
}

.burger summary {
  list-style: none;
}

.burger summary::-webkit-details-marker {
  display: none;
}

.burger .when-open,
.burger[open] .when-closed {
  display: none;
}

.burger[open] .when-open {
  display: block;
}

/* Шторка меню — под шапкой во всю ширину. */
.burger-menu {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
}

.burger-menu a {
  padding: 12px 14px;
  font-size: 1.05rem;
}

.narrow-only {
  display: block;
}

.wide-only {
  display: none;
}

@media (min-width: 768px) {
  .narrow-only {
    display: none;
  }

  .wide-only {
    display: flex;
  }
}

/* ---------- главная и пивоварни ---------- */

.hero {
  background: var(--hero);
  border-bottom: 1px solid var(--border);
  padding: 40px 0 32px;
}

.hero-in {
  text-align: center;
}

.hero-lead {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 40em;
  margin: 0 auto 24px;
}

.search {
  display: flex;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-field .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px 10px 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search .btn {
  min-height: 48px;
}

.results {
  padding: 32px 0 48px;
  transition: opacity 0.15s;
}

.results.compact {
  padding-top: 8px;
}

.load-error {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  margin-bottom: 20px;
}

.results.htmx-request {
  opacity: 0.55;
}

.results-head {
  margin-bottom: 20px;
}

.results-head p {
  margin: 0;
}

.hint {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--accent-soft);
  margin-bottom: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
  gap: 20px;
}

/* ---------- карточки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.card.pad {
  padding: 20px;
}

.entity-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.entity-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-image {
  display: block;
  aspect-ratio: 4 / 3;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  flex: 1;
}

.card-body p {
  margin: 0;
}

.card-title {
  font-size: 1.1rem;
  margin: 0;
  overflow-wrap: anywhere;
}

.card-title a {
  text-decoration: none;
}

.card-title a:hover {
  color: var(--accent);
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 0;
}

.info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0;
}

.chars div {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
}

.chars dt {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chars dd {
  margin: 0;
  font-weight: 700;
}

.chars.big dd {
  font-size: 1.6rem;
  color: var(--accent);
}

.card-btn {
  margin-top: auto;
  width: 100%;
}

.card-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ---------- рейтинг ---------- */

.rating-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.rating-value {
  font-weight: 700;
}

.stars {
  display: inline-flex;
  gap: 1px;
  color: var(--star);
}

.star {
  width: 16px;
  height: 16px;
  stroke: var(--star);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.star-full {
  fill: currentColor;
}

.star-half {
  fill: url(#half-star);
}

.star-empty {
  fill: none;
  stroke: var(--border);
}

/* ---------- страницы пива и пивоварни ---------- */

.detail {
  padding: 20px 16px 48px;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.crumbs a {
  text-decoration: none;
  display: inline-block;
  padding: 10px 0;
}

.crumbs a:hover {
  color: var(--accent);
}

.crumbs [aria-current] {
  color: var(--text);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.detail-main {
  display: grid;
  gap: 24px;
  padding: 20px;
  margin-bottom: 24px;
}

.detail-image {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  max-height: 420px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.detail-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 16px;
}

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.detail-info h1 {
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-info .btn {
  align-self: flex-start;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}

.info-value {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.info-value a {
  color: var(--accent);
}

.prose {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.detail-more {
  display: grid;
  gap: 24px;
  align-items: start;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.facts {
  margin: 0;
}

.facts div {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.facts div:last-child {
  border-bottom: 0;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.facts dd a {
  color: var(--accent);
}

.rating-side {
  text-align: center;
}

.big-rating {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.big-rating .muted {
  font-size: 1.1rem;
  font-weight: 600;
}

.rating-side .stars .star {
  width: 22px;
  height: 22px;
}

.rating-side p {
  margin: 8px 0 0;
}

.icon-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.icon-list .icon {
  color: var(--accent);
}

.tip {
  display: flex;
  gap: 12px;
  padding: 10px 0;
}

.tip .icon {
  color: var(--accent);
  margin-top: 3px;
}

.tip p {
  margin: 2px 0 0;
}

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

  .detail-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: 32px;
    gap: 32px;
  }

  .detail-more {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  }
}

/* ---------- о проекте, ошибки, пусто ---------- */

.about {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 32px;
  padding-bottom: 48px;
}

.about-head {
  text-align: center;
}

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 16px;
}

.tech {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-2);
}

.tech p {
  margin: 4px 0 0;
}

.empty,
.error-page {
  text-align: center;
  padding: 48px 16px;
}

.empty > .icon {
  width: 48px;
  height: 48px;
  color: var(--muted);
}

.error-code {
  font-size: 4rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

/* ---------- страницы списка ---------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
}

.page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-decoration: none;
  font-weight: 600;
}

a.page:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page.current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.page.disabled {
  color: var(--muted);
  opacity: 0.6;
}

.page.gap {
  border: 0;
  background: none;
  min-width: 24px;
}

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

.footer {
  margin-top: 32px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 24px;
  padding-top: 40px;
  padding-bottom: 24px;
}

.footer-h {
  font-size: 1rem;
  margin-bottom: 12px;
}

.footer .plain li {
  margin-bottom: 2px;
}

.footer .plain a {
  color: var(--muted);
  text-decoration: none;
  display: inline-block;
  padding: 8px 0;
}

.footer .plain a:hover {
  color: var(--accent);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  padding-bottom: 24px;
  font-size: 0.9rem;
}

/* ---------- телефон ---------- */

@media (max-width: 640px) {
  .hero {
    padding: 28px 0 24px;
  }

  .search {
    flex-direction: column;
  }

  .results {
    padding-top: 24px;
  }

  .page.step {
    flex-basis: calc(50% - 3px);
    order: 1;
  }

  .detail-main,
  .card.pad {
    padding: 16px;
  }
}

@media (max-width: 360px) {
  .logo span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
