/* verba — Ukrainian proverbs corpus
   Brand: verba = Latin "words" ↔ верба (willow), the Ukrainian folk tree.
   Palette: linen paper, warm ink, willow-green primary + catkin-gold accent.
   Type: Spectral (proverbs + wordmark) · system sans (chrome) · mono (catalog №). */
@import url("/embroidery.css");
:root {
  --paper: #f4f1e8;
  --paper-2: #fbfaf4;
  --ink: #232520;
  --muted: #6f6a5c;
  --faint: #9a9384;
  --rule: #e2dccd;
  --willow: #5e7355;
  --willow-deep: #3c4a37;
  --catkin: #c79a4a;
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, monospace;
  --measure: 64ch;
  --wrap: 1080px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2.5rem); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
a { color: var(--willow); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--willow); outline-offset: 2px; border-radius: 2px; }

/* ---- Masthead ---- */
.masthead { padding-block: clamp(1.4rem, 4vw, 2.6rem) 1.4rem; }
.eyebrow {
  margin: 0 0 .9rem; font-size: .72rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--willow); font-weight: 600;
}
.eyebrow #mastCount { font-family: var(--mono); letter-spacing: .04em; }
.wordmark {
  display: flex; align-items: center; gap: .35rem; margin: 0;
  font-family: var(--serif); font-weight: 500; font-size: clamp(2.6rem, 8vw, 4.6rem);
  line-height: 1; letter-spacing: -.02em; color: var(--ink);
}
.wordmark .leaf { width: auto; height: .92em; flex: none; transform: rotate(-8deg); }
.wordmark .brand { color: var(--willow-deep); }
.wordmark .amp { color: var(--willow); font-style: italic; font-weight: 400; }
.standfirst {
  font-family: var(--serif); font-size: clamp(1rem, 2.2vw, 1.18rem); color: var(--muted);
  max-width: 48ch; margin: 1rem 0 0; line-height: 1.45;
}

/* ---- Hero (featured proverb = the thesis) ---- */
.hero { padding-block: clamp(2rem, 6vw, 3.6rem); }
.hero-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.5rem; align-items: start;
  background: var(--paper-2);
  border-left: 4px solid var(--willow);
  border-radius: 12px;
  padding: 1.8rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.02);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.hero-card:hover {
  transform: scale(1.005);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.04);
}
:root[data-theme="dark"] .hero-card {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}
:root[data-theme="dark"] .hero-card:hover {
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero-card {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  }
  :root:not([data-theme="light"]) .hero-card:hover {
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18);
  }
}
.hero-cat { font-family: var(--mono); font-size: .72rem; color: var(--faint); letter-spacing: .04em; }
.hero-text {
  font-family: var(--serif); font-weight: 500; font-size: clamp(1.55rem, 4.2vw, 2.55rem);
  line-height: 1.18; letter-spacing: -.01em; margin: .5rem 0 0; max-width: 22ch;
}
.hero-modern { font-family: var(--serif); font-style: italic; color: var(--muted); margin: .6rem 0 0; }
.hero-meta { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; font-size: .82rem; }
.hero-shuffle {
  font-family: var(--sans); font-size: .8rem; letter-spacing: .02em; cursor: pointer;
  background: none; border: 1px solid var(--ink); color: var(--ink); border-radius: 999px;
  padding: .5rem .95rem; white-space: nowrap; transition: background .15s, color .15s;
}
.hero-shuffle:hover { background: var(--ink); color: var(--paper); }

/* ---- Controls: search + filters ---- */
.controls { padding-block: .5rem 1rem; }
.search-wrap {
  position: relative; display: flex; align-items: baseline; gap: 1rem;
  border-bottom: 2px solid var(--ink); padding-bottom: .35rem;
  transition: border-color 0.25s ease;
}
.search-wrap:focus-within {
  border-color: var(--willow);
}
#q {
  flex: 1; min-width: 0; border: 0; background: none; font-family: var(--serif);
  font-size: clamp(1.1rem, 3vw, 1.4rem); color: var(--ink); padding: .2rem 0;
}
#q::placeholder { color: var(--faint); }
#q:focus { outline: none; }
.count { font-family: var(--mono); font-size: .76rem; color: var(--muted); white-space: nowrap; }

.filters { margin-top: 1.1rem; display: grid; gap: .8rem; }
.filter-group { display: grid; grid-template-columns: 5.5rem 1fr; gap: .4rem 1rem; align-items: start; }
.filter-label {
  font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
  padding-top: .35rem; font-weight: 600;
}
/* Themes collapse into a disclosure so they never dominate the viewport (esp. mobile) */
.theme-details { border-top: 1px solid var(--rule); padding-top: .7rem; }
.theme-summary { display: flex; align-items: center; gap: .6rem; cursor: pointer; list-style: none; padding: .1rem 0; }
.theme-summary::-webkit-details-marker { display: none; }
.theme-summary .filter-label { padding-top: 0; }
.theme-active { font-size: .82rem; color: var(--willow); font-weight: 600; }
.theme-toggle { margin-left: auto; font-size: .74rem; color: var(--faint); }
.theme-toggle::after { content: "показати теми ▾"; }
.theme-details[open] .theme-toggle::after { content: "сховати ▴"; }
.theme-details[open] .chips-themes { margin-top: .7rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem .4rem; }
.chip {
  font-family: var(--sans); font-size: .82rem; cursor: pointer; color: var(--muted);
  background: none; border: 1px solid transparent; border-radius: 999px;
  padding: .26rem .7rem; transition: color .12s, border-color .12s, background .12s;
}
.chip:hover { color: var(--ink); border-color: var(--rule); }
.chip.active { color: #fff; background: var(--willow); border-color: var(--willow); }
.chips-themes .chip { font-size: .8rem; padding: .24rem .6rem; }

/* ---- Results ---- */
#results { padding-block: 1.4rem clamp(2rem, 6vw, 4rem); }
.results-head {
  font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
  border-bottom: 1px solid var(--rule); padding-bottom: .5rem; margin-bottom: .3rem; font-weight: 600;
}
/* Result cards flow as a masonry of columns (CSS multi-column): each card stacks
   directly below the one above it, so columns have no fixed row height / no gaps.
   As many ~18.5rem columns as fit; a single column on narrow viewports. */
.results-grid {
  columns: 18.5rem;
  column-gap: clamp(.5rem, 1.4vw, .9rem);
}
.results-grid .entry {
  break-inside: avoid;                       /* keep each card whole within its column */
  margin: 0 0 clamp(.5rem, 1.4vw, .9rem);    /* vertical gap between stacked cards */
}
/* In a multi-column flow a hover transform moves the card out from under the cursor
   (and re-fragments the columns) → hard hover flicker. Keep the hover paint-only:
   no translate, and don't transition transform. */
.results-grid .entry { transition: background .18s ease, box-shadow .18s ease, border-color .18s ease; }
.results-grid .entry:hover { transform: none; }

/* ---- Fixed embroidery stripe pinned to the bottom edge, mirroring the top band ---- */
body { padding-bottom: calc(var(--emb-a-rows) * var(--emb-stitch)); }
body::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; pointer-events: none;
  height: calc(var(--emb-a-rows) * var(--emb-stitch));
  background: var(--emb-a) repeat-x left center / auto 100%;
}

/* ---- Hover reveal: a hidden cross-stitch motif (random per card) surfaces under a
   cursor-following pool of light. The radial mask IS the light — it reduces the
   motif's visibility outward from the cursor. JS sets --card-motif, --mx, --my. ---- */
.results-grid .entry { overflow: hidden; }
.results-grid .entry > * { position: relative; z-index: 1; }   /* keep text above the reveal */
.results-grid .entry::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  /* Longhand (NOT the `background` shorthand): a var() that resolves to a long
     %-encoded data-URI breaks shorthand parsing and drops the whole background. */
  background-image: var(--card-motif, var(--emb-a));
  background-repeat: repeat;            /* tile the motif in 2D */
  background-position: 0 0;
  opacity: 0; transition: opacity .3s ease;
  /* WHITE (not black): WebKit can treat the mask as luminance, where black = hide,
     which blanks the reveal. White → reveal in both alpha and luminance modes. */
  -webkit-mask-image: radial-gradient(circle 7rem at var(--mx, 50%) var(--my, 50%), #fff, rgba(255,255,255,.45) 50%, transparent 74%);
          mask-image: radial-gradient(circle 7rem at var(--mx, 50%) var(--my, 50%), #fff, rgba(255,255,255,.45) 50%, transparent 74%);
}
.results-grid .entry:hover::after { opacity: .6; }
/* Reduced-motion: keep the reveal AND its cursor-following pool — the pool tracks
   the user's own pointer (direct manipulation, not autonomous motion), so only the
   opacity fade is dropped. (Previously `display:none` disabled the reveal entirely.) */
@media (prefers-reduced-motion: reduce) {
  .results-grid .entry::after { transition: none; }
}
.entry {
  display: flex; flex-direction: column;
  padding: 1.2rem 1.2rem; border: 1px solid var(--rule); cursor: pointer;
  border-radius: 8px; margin-block: 0.4rem;
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.entry:hover {
  background: var(--paper-2);
  border-color: var(--rule);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.03);
}
:root[data-theme="dark"] .entry:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .entry:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,.15);
  }
}
.entry-text { font-family: var(--serif); font-size: 1.18rem; line-height: 1.4; }
.entry-modern { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 1rem; margin-top: .25rem; }
.entry-tags { margin-top: .55rem; display: flex; flex-wrap: wrap; gap: .35rem .8rem; align-items: center; }
.entry-src { margin-top: .3rem; }
/* Footer: action buttons, then the record № beneath them — both pinned bottom-right
   (the № is the least-important info, so it sits last and faint). */
.entry-foot { margin-top: auto; padding-top: .7rem; display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.entry-meta { font-family: var(--mono); font-size: .66rem; color: var(--faint); letter-spacing: .02em; }
.tag { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--willow); font-weight: 600; }
.tag-src { font-family: var(--mono); font-size: .68rem; letter-spacing: .02em; color: var(--faint); text-transform: none; font-weight: 400; }
.empty { font-family: var(--serif); font-style: italic; color: var(--muted); padding: 2.5rem 0; font-size: 1.1rem; }

/* ---- Detail dialog ---- */
.detail {
  border: none; border-radius: 16px 0 0 16px; padding: 0; max-width: 500px; width: 100%;
  background: var(--paper-2); color: var(--ink); box-shadow: -10px 0 40px rgba(26, 25, 22, 0.2);
  overflow-y: auto; box-sizing: border-box; overscroll-behavior: contain;
  position: fixed; top: 0; right: 0; bottom: 0; left: auto; margin: 0; height: 100vh; max-height: 100vh;
  transform: translateX(100%);
}
.detail::backdrop {
  background: rgba(26, 25, 22, 0.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: all 0.25s ease;
}
.detail[open] {
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.drawer-close-btn {
  position: absolute; top: 1rem; right: 1rem; width: 32px; height: 32px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--paper-2); color: var(--muted); cursor: pointer; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center; transition: background .12s, color .12s, border-color .12s; z-index: 10;
}
.drawer-close-btn:hover {
  background: var(--willow); color: #fff; border-color: var(--willow);
}
body.drawer-open {
  overflow: hidden;
}
.detail-inner {
  padding: clamp(1.2rem, 5vw, 2rem);
  padding-top: 3.2rem;
  position: relative;
}
.detail-cat { font-family: var(--mono); font-size: .72rem; color: var(--faint); }
.detail-text { font-family: var(--serif); font-weight: 500; font-size: clamp(1.35rem, 6vw, 1.7rem); line-height: 1.25; margin: .5rem 0 0; }
.detail-modern { font-family: var(--serif); font-style: italic; color: var(--muted); margin: .7rem 0 0; }
.detail-source-collapse {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
}
.detail-source-collapse summary {
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  user-select: none;
}
.detail-source-content {
  padding: 0 0.8rem 0.6rem;
  line-height: 1.45;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  margin-top: 0;
  padding-top: 0.5rem;
}
.detail-expl { margin: 1.1rem 0 0; padding-top: 1.1rem; border-top: 1px solid var(--rule); color: var(--ink); line-height: 1.55; }
.detail-variants { margin: 1.1rem 0 0; }
.detail-variants h4 { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin: 0 0 .5rem; }
.detail-variants li { font-family: var(--serif); color: var(--muted); margin: .3rem 0; line-height: 1.35; }
.detail-meta { margin: 1.2rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem .8rem; font-size: .78rem; color: var(--muted); }
.detail-close {
  margin-top: 1.4rem; font-family: var(--sans); font-size: .85rem; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 0; border-radius: 999px; padding: .55rem 1.3rem;
}
.detail-close:hover { background: var(--willow); }

/* ---- Colophon ---- */
.colophon { padding-block: 2rem 3rem; color: var(--muted); }
.col-stat { font-family: var(--mono); font-size: .76rem; color: var(--faint); margin: 0 0 .8rem; }
.col-version { font-family: var(--mono); font-size: .74rem; color: var(--faint); margin: -.4rem 0 .8rem; }
.col-sources { list-style: none; padding: 0; margin: 0 0 1rem; font-size: .85rem; display: grid; gap: .25rem; }
.col-sources li b { font-weight: 600; color: var(--ink); }
.col-note { font-size: .8rem; max-width: var(--measure); line-height: 1.5; margin: 0; }

/* ---- Responsive ---- */
@media (max-width: 620px) {
  .hero-card { grid-template-columns: 1fr; }
  .hero-shuffle { justify-self: start; }
  .filter-group { grid-template-columns: 1fr; gap: .3rem; }
  .filter-label { padding-top: 0; }
  /* Keep the full navigation on phones: the nav wraps onto its own row beneath the brand,
     with the language selector and theme toggle pushed to the right. */
  .topbar-inner { flex-wrap: wrap; gap: .25rem 1rem; }
  .topbar-nav { flex-basis: 100%; flex-wrap: wrap; justify-content: flex-start; gap: .55rem 1rem; }
  .topbar-nav .lang-switch { margin-left: auto; }
}

@media (prefers-reduced-motion: no-preference) {
  .hero-text, .hero-modern, .hero-meta { animation: rise .4s ease both; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

.sem-toggle { font-family: var(--sans); font-size: .76rem; letter-spacing: .02em; cursor: pointer;
  background: none; border: 1px solid var(--rule); color: var(--muted); border-radius: 999px;
  padding: .25rem .7rem; white-space: nowrap; transition: background .12s, color .12s, border-color .12s; }
.sem-toggle[aria-checked="true"] { background: var(--willow); color: #fff; border-color: var(--willow); }
.sem-toggle:disabled { opacity: .4; cursor: not-allowed; }
.entry-score, .sim-score { font-family: var(--mono); font-size: .68rem; color: var(--faint); }
.detail-similar { margin: 1.1rem 0 0; padding-top: 1.1rem; border-top: 1px solid var(--rule); }
.detail-similar h4 { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin: 0 0 .5rem; }
.detail-similar li { font-family: var(--serif); color: var(--ink); margin: .35rem 0; line-height: 1.35; cursor: pointer; }
.detail-similar li:hover { color: var(--willow); }
.sem-hint { font-family: var(--sans); font-size: .72rem; color: var(--faint); margin-top: .4rem; }

/* ---- About bibliography ---- */
.about-refs li { margin: .5rem 0; line-height: 1.5; }
.refs-download { font-size: .85rem; margin-top: 1rem; color: var(--muted); }

/* ---- Dark theme (auto via prefers-color-scheme + manual [data-theme] toggle) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #191c16; --paper-2: #22261f; --ink: #e9e5d8; --muted: #a8a392;
    --faint: #7f7b6c; --rule: #353a2e; --willow: #8fa882; --willow-deep: #bcd2af; --catkin: #d8aa54;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #191c16; --paper-2: #22261f; --ink: #e9e5d8; --muted: #a8a392;
  --faint: #7f7b6c; --rule: #353a2e; --willow: #8fa882; --willow-deep: #bcd2af; --catkin: #d8aa54;
  color-scheme: dark;
}

.theme-toggle-btn {
  width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--rule);
  background: var(--paper-2); color: var(--willow); cursor: pointer; flex: none;
  font-size: 1rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.theme-toggle-btn:hover { border-color: var(--willow); color: var(--ink); }

/* ---- Top navigation bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(244, 241, 232, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.3s ease, border-color 0.3s ease;
}
:root[data-theme="dark"] .topbar {
  background: rgba(25, 28, 22, 0.85);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar {
    background: rgba(25, 28, 22, 0.85);
  }
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .5rem; }
.topbar-brand { display: inline-flex; align-items: center; gap: .35rem; text-decoration: none;
  font-family: var(--serif); font-weight: 500; font-size: 1.1rem; color: var(--willow-deep); }
.topbar-brand .leaf { width: auto; height: 1.15em; transform: rotate(-8deg); }
.topbar-nav { display: flex; align-items: center; gap: 1.1rem; }
.topbar-link { font-family: var(--sans); font-size: .82rem; color: var(--muted); text-decoration: none; transition: color .12s; }
.topbar-link:hover { color: var(--willow); }

/* ---- Adaptivity: let the search row wrap on small screens ---- */
@media (max-width: 560px) {
  .search-wrap { flex-wrap: wrap; row-gap: .45rem; align-items: center; }
  #q { flex: 1 1 100%; }
}

.more-btn { display: block; margin: 1.4rem auto 0; font-family: var(--sans); font-size: .82rem; letter-spacing: .02em;
  cursor: pointer; background: none; border: 1px solid var(--rule); color: var(--ink); border-radius: 999px; padding: .55rem 1.4rem;
  transition: background .15s, color .15s, border-color .15s; }
.more-btn:hover { background: var(--willow); color: #fff; border-color: var(--willow); }

.saved-btn { font-family: var(--sans); font-size: .76rem; letter-spacing: .02em; cursor: pointer; background: none;
  border: 1px solid var(--rule); color: var(--muted); border-radius: 999px; padding: .25rem .7rem; white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s; }
.saved-btn.active, .saved-btn:hover { border-color: var(--willow); color: var(--willow); }
.entry-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.entry-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--faint);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
  transition: color 0.12s, transform 0.12s, background-color 0.12s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
}
.entry-action-btn:hover {
  color: var(--willow);
  background-color: rgba(94, 115, 85, 0.1);
  transform: scale(1.1);
}
.entry-save {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--faint);
  font-size: 0.95rem;
  line-height: 1;
  transition: color 0.12s, transform 0.12s, background-color 0.12s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
}
.entry-save:hover {
  color: var(--willow);
  background-color: rgba(94, 115, 85, 0.1);
  transform: scale(1.1);
}
.entry-save.on { color: var(--willow); }

.swipe-btn { font-family: var(--sans); font-size: .76rem; letter-spacing: .02em; cursor: pointer; background: var(--willow);
  color: #fff; border: 1px solid var(--willow); border-radius: 999px; padding: .25rem .8rem; white-space: nowrap; }
.swipe-btn:hover { background: var(--willow-deep); border-color: var(--willow-deep); }
body.swipe-open { overflow: hidden; }
.swipe[hidden] { display: none; }
.swipe { position: fixed; inset: 0; z-index: 50; background: var(--paper); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1.5rem; padding: 1.5rem; }
.sw-close { position: absolute; top: 1rem; right: 1rem; width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--paper-2); color: var(--muted); cursor: pointer; font-size: 1rem; }
.sw-card { max-width: 600px; width: 100%; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 12px;
  padding: clamp(1.8rem, 6vw, 3rem); cursor: pointer; touch-action: pan-y; box-shadow: 0 18px 50px rgba(0,0,0,.12); }
.sw-cat { font-family: var(--mono); font-size: .72rem; color: var(--faint); }
.sw-text { font-family: var(--serif); font-weight: 500; font-size: clamp(1.5rem, 5vw, 2.3rem); line-height: 1.2; margin: .6rem 0 0; }
.sw-modern { font-family: var(--serif); font-style: italic; color: var(--muted); margin: .7rem 0 0; }
.sw-tags { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: .35rem .8rem; align-items: center; }
.sw-actions { display: flex; gap: 1.1rem; }
.sw-act { width: 56px; height: 56px; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper-2);
  cursor: pointer; font-size: 1.3rem; line-height: 1; color: var(--muted); transition: transform .12s, color .12s, border-color .12s; }
.sw-act:hover { transform: translateY(-2px); }
.sw-save { color: #b4543f; } .sw-savebtn.on { color: #fff; background: var(--willow); border-color: var(--willow); }
.sw-share { color: var(--willow); }
.sw-hint { font-family: var(--sans); font-size: .74rem; color: var(--faint); margin: 0; }
.detail-share { margin-top: 1.2rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.detail-sharebtn { font-family: var(--sans); font-size: .82rem; cursor: pointer; background: none; border: 1px solid var(--willow);
  color: var(--willow); border-radius: 999px; padding: .45rem 1.1rem; }
.detail-sharebtn:hover { background: var(--willow); color: #fff; }
.detail-cardbtn { font-family: var(--sans); font-size: .82rem; cursor: pointer; background: none; border: 1px solid var(--willow); color: var(--willow); border-radius: 999px; padding: .45rem 1.1rem; text-decoration: none; }
.detail-cardbtn:hover { background: var(--willow); color: #fff; }
.flash { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%) translateY(1rem); z-index: 60;
  background: var(--ink); color: var(--paper); font-family: var(--sans); font-size: .82rem; padding: .55rem 1.1rem;
  border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.flash.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Language switcher ---- */
.lang-switch { display: inline-flex; }
.lang-menu { position: relative; font-family: var(--sans); }
.lang-menu summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .55rem; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink); background: var(--paper-2); user-select: none;
  transition: border-color .12s;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary::after { content: "▾"; font-size: .6rem; color: var(--faint); }
.lang-menu[open] summary::after { content: "▴"; }
.lang-menu summary:hover { border-color: var(--willow); }
.lang-menu .lang-flag { font-size: .95rem; line-height: 1; }
.lang-menu .lang-code { font-family: var(--mono); font-size: .72rem; font-weight: 600; letter-spacing: .03em; }
.lang-menu ul {
  position: absolute; top: calc(100% + .35rem); right: 0; z-index: 50;
  list-style: none; margin: 0; padding: .3rem 0;
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.14); min-width: 11rem; max-height: 72vh; overflow: auto;
  transform-origin: top right;
}
.lang-menu[open] ul {
  animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.lang-menu li a {
  display: flex; align-items: center; gap: .55rem; padding: .4rem .9rem;
  color: var(--ink); text-decoration: none; white-space: nowrap;
  transition: background .1s, color .1s;
}
.lang-menu li a .lang-name { color: var(--muted); font-size: .82rem; }
.lang-menu li a:hover { background: var(--willow); color: #fff; }
.lang-menu li a:hover .lang-name { color: rgba(255,255,255,.85); }
.lang-menu li a[aria-current="true"] { background: var(--paper); }
.lang-menu li a[aria-current="true"] .lang-code { color: var(--willow); }

/* ---- Proverb detail page (/p/:id) ---- */
.p-card { display: block; width: 100%; max-width: 640px; height: auto; border: 1px solid var(--rule); border-radius: 8px; margin: 0 0 1.4rem; }
.p-share { display: flex; gap: 1rem; align-items: center; margin: 1.4rem 0; font-family: var(--sans); font-size: .85rem; }
.p-share button { font-family: var(--sans); font-size: .85rem; cursor: pointer; background: none; border: 1px solid var(--willow); color: var(--willow); border-radius: 999px; padding: .4rem 1rem; transition: background .15s, color .15s; }
.p-share button:hover { background: var(--willow); color: #fff; }
.p-share a { color: var(--willow); text-decoration: none; border: 1px solid var(--rule); border-radius: 999px; padding: .4rem 1rem; transition: background .15s, color .15s; }
.p-share a:hover { background: var(--willow); color: #fff; border-color: var(--willow); }

/* ---- Blog ---- */
.article { max-width: 720px; padding-block: clamp(2rem,7vw,4.5rem); }
.article-back { font-family: var(--sans); font-size: .82rem; color: var(--willow); display:inline-block; margin-bottom: 1.4rem; }
.article-title { font-family: var(--serif); font-weight: 500; font-size: clamp(2rem,6vw,3rem); letter-spacing:-.02em; margin: 0 0 .3rem; }
.article-date { font-family: var(--mono); font-size: .78rem; color: var(--faint); margin: 0 0 2rem; }
.article p, .article li { line-height: 1.7; max-width: var(--measure); }
.article h2 { font-family: var(--serif); font-weight: 500; font-size: 1.5rem; margin: 2.2rem 0 .6rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.article img { max-width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 8px; margin: 1.2rem 0; }
.article a { color: var(--willow); }
.article blockquote { font-family: var(--serif); font-style: italic; color: var(--muted); border-left: 2px solid var(--willow); margin: 1.2rem 0; padding: .2rem 0 .2rem 1rem; }
.blog-index { padding-block: clamp(2rem,7vw,4.5rem); }
.blog-index h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(2rem,6vw,3rem); margin: 0 0 1.6rem; }
.blog-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.2rem; }
@media (min-width: 768px) {
  .blog-list { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
.blog-card a { display: block; text-decoration: none; color: var(--ink); border: 1px solid var(--rule); border-radius: 8px; padding: 1.1rem 1.3rem; transition: border-color .12s, background .12s; }
.blog-card a:hover { border-color: var(--willow); background: var(--paper-2); }
.blog-card-date { display: block; font-family: var(--mono); font-size: .74rem; color: var(--faint); }
.blog-card-title { display: block; font-family: var(--serif); font-size: 1.35rem; font-weight: 500; margin: .2rem 0 .3rem; }
.blog-card-lede { display: block; color: var(--muted); font-size: .92rem; line-height: 1.5; }

#latestBlog { padding-block: 1rem 1.5rem; }

/* ---- Card Customizer ---- */
.card-customizer {
  margin-top: 1.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.card-customizer h4 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.15rem;
  margin: 0 0 .5rem;
}
.customizer-layout {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.customizer-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  border-radius: 8px;
  overflow: hidden;
  padding: 1rem;
}
.customizer-preview img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  border: 1px solid var(--rule);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border-radius: 4px;
}
.customizer-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.control-field {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.control-field label {
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}
.control-field select {
  font-family: var(--sans);
  font-size: .88rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: .5rem .7rem;
  outline: none;
  cursor: pointer;
}
.control-field select:focus {
  border-color: var(--willow);
}
.customizer-actions {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-top: .5rem;
}
.customizer-actions .more-btn {
  text-align: center;
  display: block;
  text-decoration: none;
}
.customizer-actions button {
  justify-content: center;
}

/* ---- Embroidery chrome (рушник bands; pixels + stitch size in embroidery.css) ---- */
/* Decorative: empty pseudo-elements are ignored by assistive tech. One --emb-stitch
   drives every band/icon, so the stitch (cell) size is identical site-wide. */
.topbar::after {
  content: ""; display: block;
  height: calc(var(--emb-a-rows) * var(--emb-stitch));
  background: var(--emb-a) repeat-x left center / auto 100%;
}
.masthead::after {
  content: ""; display: block;
  height: calc(var(--emb-b-rows) * var(--emb-stitch));
  margin-top: clamp(1rem, 3vw, 1.6rem);
  background: var(--emb-b) repeat-x left center / auto 100%;
}
.colophon::before {
  content: ""; display: block;
  height: calc(var(--emb-b-rows) * var(--emb-stitch));
  margin-bottom: clamp(1.2rem, 3vw, 2rem);
  background: var(--emb-b) repeat-x left center / auto 100%;
}
.colophon::after {
  content: ""; display: block;
  height: calc(var(--emb-a-rows) * var(--emb-stitch));
  margin-top: clamp(1.2rem, 3vw, 2rem);
  background: var(--emb-a) repeat-x left center / auto 100%;
}

/* ---- Cross-stitch icons in the UI (classes generated in embroidery.css) ---- */
.topbar-link-ext::after {
  content: ""; display: inline-block; margin-left: .35em; vertical-align: -0.02em;
  width: calc(7 * var(--emb-stitch)); height: calc(6 * var(--emb-stitch));
  background: var(--ico-link) no-repeat center / contain;
}
#themeToggle { font-size: 0; line-height: 0; display: inline-grid; place-items: center; }
#themeToggle::before {
  content: ""; display: block;
  width: calc(7 * var(--emb-stitch)); height: calc(7 * var(--emb-stitch));
  background: var(--ico-moon) no-repeat center / contain;
}
:root[data-theme="dark"] #themeToggle::before { background-image: var(--ico-sun); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeToggle::before { background-image: var(--ico-sun); }
}
#savedBtn::before {
  content: ""; display: inline-block; margin-right: .45em; vertical-align: -0.02em;
  width: calc(7 * var(--emb-stitch)); height: calc(6 * var(--emb-stitch));
  background: var(--ico-heart) no-repeat center / contain;
}
.detail-cardbtn::before {
  content: ""; display: inline-block; margin-right: .45em; vertical-align: -0.08em;
  width: calc(9 * var(--emb-stitch)); height: calc(9 * var(--emb-stitch));
  background: var(--ico-image) no-repeat center / contain;
}
.search-wrap::before {
  content: ""; flex: none; align-self: center; margin-right: .1rem;
  width: calc(8 * var(--emb-stitch)); height: calc(8 * var(--emb-stitch));
  background: var(--ico-search) no-repeat center / contain;
}

/* ---- Embroidery Phase 2: hero frame, grid spines, swipe-deck bands ---- */
/* Hero: рушник rose bands top + bottom; clip to the card's rounded corners. */
.hero-card { position: relative; overflow: hidden; }
.hero-card::before, .hero-card::after {
  content: ""; position: absolute; left: 0; right: 0; height: calc(var(--emb-c-rows) * var(--emb-stitch));
  background: var(--emb-c) repeat-x left center / auto 100%; pointer-events: none;
}
.hero-card::before { top: 0; }
.hero-card::after { bottom: 0; transform: scaleY(-1); }
.hero-card { padding-block: calc(var(--emb-c-rows) * var(--emb-stitch) + 1.4rem); }

/* Grid entries: a thin vertical embroidery spine down the left gutter. */
.entry { position: relative; padding-left: calc(var(--emb-b-rows) * var(--emb-stitch) + 1.1rem); }
.entry::before {
  content: ""; position: absolute; left: .2rem; top: .7rem; bottom: .7rem;
  width: calc(var(--emb-b-rows) * var(--emb-stitch));
  background: var(--emb-bv) repeat-y top left / 100% auto; pointer-events: none;
}

/* Swipe-deck card: rose bands top + bottom, like the hero / share cards. */
.sw-card { position: relative; overflow: hidden; }
.sw-card::before, .sw-card::after {
  content: ""; position: absolute; left: 0; right: 0; height: calc(var(--emb-c-rows) * var(--emb-stitch));
  background: var(--emb-c) repeat-x left center / auto 100%; pointer-events: none;
}
.sw-card::before { top: 0; }
.sw-card::after { bottom: 0; transform: scaleY(-1); }
.sw-card { padding-block: calc(var(--emb-c-rows) * var(--emb-stitch) + 1.6rem); }

/* ---- Embroidery Phase 3: page-edge frame (wide screens) + empty/404 motif ---- */
@media (min-width: 1200px) {
  body::before, body::after {
    content: ""; position: fixed; top: 0; bottom: 0; z-index: 1;
    width: calc(var(--emb-b-rows) * var(--emb-stitch));
    background: var(--emb-bv) repeat-y top center / 100% auto; pointer-events: none;
  }
  body::before { left: 0; }
  body::after { right: 0; }
}
.empty::before {
  content: ""; display: block; height: calc(var(--emb-b-rows) * var(--emb-stitch));
  width: min(240px, 60%); margin: 0 auto 1.1rem;
  background: var(--emb-b) repeat-x center / auto 100%;
}

/* ---- Proverb-row action buttons → stitched icons (↗ 🖼 ♥) ---- */
.entry-share-btn, .entry-card-btn, .entry-save { font-size: 0; }
.entry-share-btn::before, .entry-card-btn::before, .entry-save::before {
  content: ""; display: block; background: no-repeat center / contain;
}
.entry-share-btn::before { width: calc(7 * var(--emb-stitch)); height: calc(6 * var(--emb-stitch)); background-image: var(--ico-link); }
.entry-card-btn::before  { width: calc(9 * var(--emb-stitch)); height: calc(9 * var(--emb-stitch)); background-image: var(--ico-image); }
.entry-save::before      { width: calc(7 * var(--emb-stitch)); height: calc(6 * var(--emb-stitch)); background-image: var(--ico-heart); opacity: .38; transition: opacity .12s; }
.entry-save.on::before   { opacity: 1; }

/* willow logo mark (pixel-art) */
/* willow mark renders from a tight (non-square) SVG, so square pixels match the
   masthead/embroidery scale; topbar mark enlarged so its stitches read at site scale. */
.topbar-brand .brandmark { width: auto; height: 3.4rem; flex: none; }
.wordmark .brandmark { width: auto; height: 0.93em; flex: none; vertical-align: -0.08em; }

/* Compact links between Verba directions on corpus and documentation pages. */
.direction-menu { position:relative; }
.direction-menu summary { cursor:pointer; }
.direction-menu>div { position:absolute; right:0; top:calc(100% + .8rem); z-index:60; min-width:11rem; display:grid; gap:.7rem; background:var(--paper); border:1px solid var(--rule); padding:1rem; box-shadow:0 8px 24px #0002; }
.direction-menu:not([open])>div { display:none; }
