/* === Wiki Links === */
.wiki-link {
  color: var(--teal);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* === Flavor Map Table === */
.matrix {
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px;
  overflow: auto;
}

.matrix table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.matrix th,
.matrix td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 14px;
  vertical-align: top;
}

.matrix th {
  background: #edf5ef;
  color: #183b33;
}

/* === Score Grid (Tasting Sheet) === */
.score-grid {
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.score-grid div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.score-grid strong {
  display: block;
  font-size: 20px;
}

.score-grid input {
  width: 100%;
  accent-color: var(--teal);
}

@media (max-width: 820px) {
  .score-grid {
    grid-template-columns: 1fr;
  }
}

/* === Brand Logo === */
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  flex: 0 0 auto;
}

.brand {
  min-width: 0;
  flex: 0 0 auto;
}

.brand span {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
  line-break: strict;
  display: inline-block;
  min-width: max-content;
  max-width: none;
}

/* === Hero Heading === */
h1,
h2,
h3,
.card strong,
.list-grid strong,
.mini-links strong {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

p,
li {
  overflow-wrap: break-word;
}

.hero h1 {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  text-wrap: balance;
  max-width: 880px;
}

.article-hero h1 {
  font-size: clamp(42px, 4vw, 72px);
  line-height: 1.06;
  text-wrap: balance;
  max-width: 14.5ch;
}

.article-hero .lead,
.article-hero .meta {
  max-width: 34rem;
}

.keep-word {
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  hyphens: none;
}

/* === Topbar Shadow === */
.topbar {
  box-shadow: 0 8px 28px rgba(23, 32, 27, .06);
}

/* === Nav Wrap === */
.nav {
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* === Legal Strip === */
.legal-strip {
  background: #17201b;
  color: #fff8df;
  font-size: 13px;
  line-height: 1.35;
  padding: 8px max(20px, calc((100vw - var(--max)) / 2));
  text-align: center;
}

/* === Hero Animation === */
.hero-copy {
  animation: heroRise .7s ease-out both;
}

@keyframes heroRise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Card Hover Glow === */
.card,
.category-grid a,
.list-grid a,
.tool,
.score-grid div,
.idea-grid > div {
  position: relative;
  isolation: isolate;
  will-change: transform;
  transition: transform .22s ease, box-shadow .22s ease;
}

.card::after,
.category-grid a::after,
.list-grid a::after,
.tool::after,
.score-grid div::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(244, 182, 63, .18), rgba(47, 111, 94, .12));
  opacity: 0;
  transition: opacity .22s ease;
  z-index: -1;
}

.card:hover,
.category-grid a:hover,
.list-grid a:hover,
.tool:hover,
.score-grid div:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 42px rgba(23, 32, 27, .13);
}

.card:hover::after,
.category-grid a:hover::after,
.list-grid a:hover::after,
.tool:hover::after,
.score-grid div:hover::after {
  opacity: 1;
}

/* === Scroll-driven Section Fade === */
@supports (animation-timeline: view()) {
  .section {
    animation: sectionFade .55s ease both;
    animation-timeline: view();
    animation-range: entry 0% cover 22%;
  }
}

@keyframes sectionFade {
  from {
    opacity: .25;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Feature Grid Icons === */
.feature-grid img {
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
}

/* === Icon Cards (Market Reviews) === */
.icon-card > img {
  width: 92px;
  height: 92px;
  object-fit: contain;
  margin: 22px auto 6px;
  aspect-ratio: 1;
}

.icon-card {
  background:
    linear-gradient(180deg, rgba(237, 245, 239, .75), rgba(255, 253, 246, 0) 42%),
    #fff;
}

/* === Section Head Accent Bar === */
.section-head h2::after {
  content: "";
  display: block;
  width: 58px;
  height: 4px;
  margin-top: 10px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), var(--green));
}

/* === Page Head Decorative Element === */
.page-head {
  position: relative;
}

.page-head::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: 10px;
  width: 120px;
  height: 120px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(244, 182, 63, .24), rgba(47, 111, 94, .18));
  transform: rotate(8deg);
  z-index: -1;
}

.visual-head > img {
  width: 76px;
  height: 76px;
  margin-bottom: 18px;
  filter: drop-shadow(0 10px 22px rgba(23, 32, 27, .12));
}

.photo-head > img {
  width: min(100%, 560px);
  height: clamp(180px, 28vw, 280px);
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 22px 60px rgba(23, 32, 27, .16);
}

/* === Article Index Clusters === */
.article-cluster {
  margin-bottom: 42px;
}

.cluster-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.cluster-title img {
  width: 104px;
  height: 68px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 26px rgba(23, 32, 27, .12);
}

.article-index .list-grid a {
  display: grid;
  grid-template-columns: 148px 1fr;
  column-gap: 16px;
  align-items: start;
}

/* === Article Thumbnail Art === */
.article-thumb {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #f6ead0;
  border: 1px solid var(--line);
  isolation: isolate;
}

.article-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--thumb-x, 50%) var(--thumb-y, 50%);
  filter: saturate(var(--thumb-sat, 105%)) hue-rotate(var(--thumb-hue, 0deg)) contrast(1.04);
  transform: scale(1.05);
  transition: transform .35s ease;
}

.card:hover .article-thumb img {
  transform: scale(1.1);
}

.article-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, .42), transparent 18%),
    linear-gradient(135deg, transparent 35%, color-mix(in srgb, var(--thumb-glow, var(--gold)) 44%, transparent));
  mix-blend-mode: screen;
  pointer-events: none;
}

.article-thumb i {
  position: absolute;
  left: 12px;
  bottom: 10px;
  width: 42px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .68);
  box-shadow: 0 -13px 0 rgba(255, 255, 255, .28), 30px -7px 0 rgba(255, 255, 255, .22);
}

.article-thumb b {
  position: absolute;
  right: 10px;
  bottom: 9px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(23, 32, 27, .86);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

.market-thumb em {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 253, 246, .86);
  border: 1px solid rgba(255, 255, 255, .55);
  box-shadow: 0 8px 22px rgba(23, 32, 27, .16);
}

.market-thumb em img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: none;
  transform: none;
}

.card:hover .market-thumb em img {
  transform: none;
}

.card > .article-thumb {
  aspect-ratio: 16 / 10;
  border-width: 0 0 1px;
  border-radius: 0;
}

.article-index .list-grid a > .article-thumb {
  grid-row: span 3;
  width: 148px;
  height: 104px;
  box-shadow: 0 10px 24px rgba(23, 32, 27, .1);
}

/* === Cookie Banner === */
.cookie-banner {
  position: fixed;
  left: 20px;
  right: 20px;
  bottom: 18px;
  z-index: 50;
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: rgba(255, 253, 246, .96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(23, 32, 27, .18);
  backdrop-filter: blur(14px);
  animation: slideUp .4s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-banner img {
  width: 48px;
  height: 48px;
}

.cookie-banner p,
.footer-legal {
  margin: 0;
}

/* === Footer Improved === */
.footer-privacy {
  display: inline-block;
  margin-top: 10px;
  color: var(--gold);
  font-weight: 800;
}

.footer-cols {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr;
  gap: 32px;
  width: 100%;
}

.footer-cols h4 {
  color: var(--gold);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0 0 12px;
}

.footer-cols ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-cols li {
  margin: 6px 0;
}

.footer-cols a {
  color: #d8d3c5;
  transition: color .18s;
}

.footer-cols a:hover {
  color: var(--gold);
}

/* === Owner Panel === */
.owner-panel [hidden] {
  display: none;
}

/* === Mobile Nav Animation === */
@media (max-width: 1080px) {
  .nav {
    display: flex;
    position: absolute;
    right: 16px;
    top: 58px;
    background: rgba(255, 253, 246, .98);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 16px 35px rgba(23, 32, 27, .15);
    flex-direction: column;
    backdrop-filter: blur(14px);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
    visibility: hidden;
  }

  .nav.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
  }

  .icon-button {
    display: inline-flex;
  }
}

/* === Mobile Overrides === */
@media (max-width: 820px) {
  .brand span {
    font-size: 0;
    max-width: none;
    overflow: hidden;
  }

  .brand span::after {
    content: "Портал о 0.0 пиве";
    font-size: 15px;
    white-space: nowrap;
  }

  .topbar {
    gap: 10px;
  }

  .cookie-banner {
    grid-template-columns: 44px 1fr;
  }

  .cookie-banner .button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .hero h1 {
    font-size: 38px;
    line-height: 1.04;
    max-width: 100%;
  }

  .article-hero h1 {
    font-size: clamp(36px, 12vw, 54px);
    max-width: 100%;
    text-wrap: pretty;
  }

  .article-index .list-grid a {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .article-index .list-grid a > .article-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    grid-row: auto;
  }

  .footer-cols {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 430px) {
  .hero h1 {
    font-size: 32px;
  }
}

/* === Back to Top Button === */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 246, .92);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(23, 32, 27, .12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .25s, transform .25s, background .18s;
  pointer-events: none;
}

@media (max-width: 820px) {
  .back-to-top {
    display: none;
  }
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--gold);
  color: #1f1809;
}

/* === Reading Time Badge === */
.card .reading-time {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding: 0 16px 14px;
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ================================ */
/* === DARK THEME                === */
/* ================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e4e0d6;
    --muted: #9ca89e;
    --paper: #111916;
    --line: #2a3530;
    --cream: #1c2620;
  }

  body {
    background: var(--paper);
    color: var(--ink);
  }

  .topbar {
    background: rgba(17, 25, 22, .92);
    border-color: var(--line);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
  }

  .nav a, .icon-button {
    color: #c8d0ca;
  }

  .nav a:hover, .icon-button:hover {
    background: #1e2e26;
  }

  .card,
  .category-grid a,
  .list-grid a,
  .tool,
  .score-grid div,
  .idea-grid > div,
  .faq details,
  .steps span,
  .note-panel {
    background: #1a2420;
    border-color: var(--line);
  }

  .card:hover,
  .category-grid a:hover,
  .list-grid a:hover {
    box-shadow: 0 18px 42px rgba(0, 0, 0, .3);
  }

  .icon-card {
    background: linear-gradient(180deg, rgba(30, 46, 38, .75), rgba(17, 25, 22, 0) 42%), #1a2420;
  }

  .color-band {
    background: #152019;
  }

  .matrix table {
    background: #1a2420;
    border-color: var(--line);
  }

  .matrix th {
    background: #1e2e26;
    color: #c8d0ca;
  }

  .link-panel {
    background: #2a2518;
    border-color: #3d361f;
  }

  .mini-links a {
    background: #1a2420;
    border-color: var(--line);
  }

  .cookie-banner {
    background: rgba(17, 25, 22, .96);
    border-color: var(--line);
  }

  .back-to-top {
    background: rgba(17, 25, 22, .92);
    border-color: var(--line);
    color: var(--ink);
  }

  .tool input, .tool select,
  #articleDraft input, #articleDraft select, #articleDraft textarea {
    background: #1a2420;
    border-color: var(--line);
    color: var(--ink);
  }

  .tool output {
    background: #1e2e26;
  }

  .article-thumb {
    background: #2a2518;
  }

  .icon-button {
    background: #1a2420;
    border-color: var(--line);
  }

  @media (max-width: 1080px) {
    .nav {
      background: rgba(17, 25, 22, .98);
    }
  }
}
