/* «Зільник» - травник: тулбар, фільтри, сітка, модалка, кольори. */

:root { --header-h: 59px; }

/* атрибут hidden сильніший за display компонентів */
[hidden] { display: none !important; }

.app-main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 28px 48px;
}
body.no-scroll { overflow: hidden; }

/* ---- Пошук (липкий під шапкою сайту) ---- */
.toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 12px;
  background: rgba(10, 22, 17, .93);
  backdrop-filter: blur(10px);
}
.search-input { flex: 1; }
.reset-btn { flex: 0 0 auto; }

/* ---- Фільтри ---- */
.filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 0 18px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 16px;
}
.filter-group {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.fg-label {
  flex: 0 0 104px;
  padding-top: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
  user-select: none;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  cursor: pointer;
  transition: all .2s ease;
}
.chip:hover { border-color: var(--green); color: var(--text); }
.chip.active {
  border-color: var(--gold);
  color: var(--gold-soft);
  background: rgba(201, 169, 97, .10);
}
.chip.disabled { opacity: .45; cursor: not-allowed; }
.chip.disabled:hover { border-color: var(--line); color: var(--text-dim); }
.chip-count { font-size: 11px; color: var(--text-faint); }
.chip.active .chip-count { color: inherit; opacity: .7; }
.chip-sym { opacity: .9; }
.chip-x { font-size: 11px; opacity: .7; }

/* стихії - кольори токенів */
.chip .el-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
}
.chip[data-element="Вода"] .el-dot    { background: var(--el-water); }
.chip[data-element="Вогонь"] .el-dot  { background: var(--el-fire); }
.chip[data-element="Повітря"] .el-dot { background: var(--el-air); }
.chip[data-element="Земля"] .el-dot   { background: var(--el-earth); }
.chip.active[data-element="Вода"]    { color: var(--el-water); border-color: var(--el-water); background: rgba(90,167,209,.12); }
.chip.active[data-element="Вогонь"]  { color: var(--el-fire); border-color: var(--el-fire); background: rgba(217,121,82,.12); }
.chip.active[data-element="Повітря"] { color: var(--el-air); border-color: var(--el-air); background: rgba(168,195,217,.12); }
.chip.active[data-element="Земля"]   { color: var(--el-earth); border-color: var(--el-earth); background: rgba(176,141,87,.12); }

/* відмітки */
.chip.chip-mark.active {
  border-color: var(--green-soft);
  color: var(--green-pale);
  background: rgba(47, 157, 99, .12);
}

/* ---- Енергії: dropdown ---- */
.powers-picker {
  position: relative;
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}
.powers-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  color: var(--text-dim);
  cursor: pointer;
  transition: all .2s ease;
}
.powers-toggle:hover { border-color: var(--green); color: var(--text); }
.powers-toggle .caret { font-size: 10px; transition: transform .2s ease; }
.powers-toggle.open { border-color: var(--gold); color: var(--gold-soft); }
.powers-toggle.open .caret { transform: rotate(180deg); }

.powers-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  width: min(360px, calc(100vw - 56px));
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.powers-menu input { margin-bottom: 8px; }
.powers-list {
  max-height: 290px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.power-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.power-item:hover { background: var(--surface-2); color: var(--text); }
.power-item.selected { color: var(--green-pale); }
.pi-check { flex: 0 0 14px; width: 14px; color: var(--green-soft); font-size: 12px; }
.pi-name { flex: 1; }
.pi-count { font-size: 11.5px; color: var(--text-faint); }
.powers-empty { padding: 14px 10px; font-size: 13.5px; color: var(--text-faint); text-align: center; }

.chip.chip-power.active {
  border-color: rgba(87, 185, 129, .5);
  color: var(--green-pale);
  background: rgba(47, 157, 99, .10);
}

/* ---- Алфавітний покажчик ---- */
.alpha-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 16px;
}
.alpha-letter {
  min-width: 28px;
  padding: 4px 7px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-dim);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.alpha-letter:hover:not(:disabled):not(.active) { color: var(--text); border-color: var(--line); }
.alpha-letter.active {
  color: var(--gold-soft);
  border-color: var(--gold);
  background: rgba(201, 169, 97, .10);
}
.alpha-letter:disabled { opacity: .22; cursor: default; }
.alpha-all {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 4px 13px;
  color: var(--text-faint);
}

/* ---- Лічильник ---- */
.count-line {
  min-height: 1.5em;
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text-faint);
}

/* ---- Сітка карток ---- */
.herb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.herb-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.herb-card:hover,
.herb-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--line);
  outline: none;
}

.card-img {
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  overflow: hidden;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }

.img-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--line);
  background: var(--surface-2);
}
.img-placeholder svg { width: 46px; height: 46px; }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 16px 13px;
}
.card-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text);
}
.card-latin {
  margin-top: -4px;
  font-style: italic;
  font-size: 13px;
  color: var(--text-faint);
}
.card-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 8px;
}
.card-powers { display: flex; flex-wrap: wrap; gap: 5px; }
.badge-more { color: var(--text-faint); }

.card-marks { display: flex; gap: 6px; flex: 0 0 auto; }
.mark-btn {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  cursor: pointer;
  filter: grayscale(.75);
  opacity: .75;
  transition: all .2s ease;
}
.mark-btn:hover { filter: none; opacity: 1; border-color: var(--green); }
.mark-btn.active { filter: none; opacity: 1; }
.mark-btn.active[data-mark="in_garden"] {
  border-color: var(--green-soft);
  background: rgba(47, 157, 99, .16);
  box-shadow: 0 0 0 2px rgba(47, 157, 99, .3);
}
.mark-btn.active[data-mark="is_dried"] {
  border-color: var(--gold);
  background: rgba(201, 169, 97, .16);
  box-shadow: 0 0 0 2px rgba(201, 169, 97, .3);
}
.mark-btn.active[data-mark="ritual_done"] {
  border-color: var(--el-fire);
  background: rgba(217, 121, 82, .16);
  box-shadow: 0 0 0 2px rgba(217, 121, 82, .3);
}

/* ---- Скелетон і порожній стан ---- */
.skeleton-card {
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  background: var(--surface);
  overflow: hidden;
  padding-bottom: 6px;
}
.sk-img { aspect-ratio: 16 / 10; }
.sk-line { height: 13px; border-radius: 6px; margin: 12px 16px 0; }
.sk-shimmer {
  background: linear-gradient(100deg, var(--surface-2) 40%, #1e3a28 50%, var(--surface-2) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.empty-state {
  grid-column: 1 / -1;
  padding: 80px 20px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--text-dim);
}

/* ---- Модальна картка ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background: rgba(4, 9, 6, .72);
  backdrop-filter: blur(7px);
  animation: overlay-in .2s ease;
}
@keyframes overlay-in { from { opacity: 0; } }

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 880px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: panel-in .25s ease;
}
@keyframes panel-in { from { transform: translateY(14px); opacity: 0; } }

.modal-close {
  position: sticky;
  top: 14px;
  float: right;
  z-index: 5;
  width: 34px; height: 34px;
  margin: 14px 14px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: all .2s ease;
}
.modal-close:hover { border-color: var(--gold); color: var(--gold-soft); }

.modal-loading {
  padding: 90px 24px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-dim);
}

.modal-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 26px;
  padding: 26px 28px 32px;
}
.modal-img {
  position: sticky;
  top: 22px;
  align-self: start;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.modal-img img { width: 100%; height: 100%; object-fit: cover; }
.modal-img .img-placeholder svg { width: 72px; height: 72px; }

.modal-info h2 {
  margin: 0 0 2px;
  font-size: 34px;
  line-height: 1.1;
  color: var(--text);
}
.modal-aliases { margin-bottom: 8px; font-size: 14px; color: var(--text-dim); }
.modal-sci { font-size: 14.5px; color: var(--text-dim); line-height: 1.7; }
.modal-sci em { color: var(--green-pale); }
.sci-codes { margin-left: 2px; font-size: 10px; color: var(--gold); font-style: normal; }
.sci-sep { margin: 0 7px; color: var(--text-faint); }
.sci-footnote { margin-top: 3px; font-size: 11.5px; color: var(--text-faint); font-style: italic; }
.modal-badges { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 2px; }

.m-section { margin-top: 18px; }
.m-label {
  margin: 0 0 8px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.powers-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.deities-line {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--gold-soft);
}
.parts-list { margin: 0; padding: 0; list-style: none; font-size: 14.5px; color: var(--text-dim); }
.parts-list li { padding: 2px 0; }

.ritual-block {
  padding: 11px 15px;
  background: rgba(201, 169, 97, .07);
  border-left: 2px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14.5px;
  color: var(--text);
  white-space: pre-line;
}

.uses-list { margin: 0; padding: 0; list-style: none; }
.uses-list li {
  position: relative;
  padding: 6px 0 6px 22px;
  font-size: 14.5px;
  color: var(--text);
  border-bottom: 1px dashed var(--line-soft);
}
.uses-list li:last-child { border-bottom: 0; }
.uses-list li::before {
  content: '❧';
  position: absolute;
  left: 0; top: 5px;
  color: var(--gold);
}

.modal-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 14px;
}
.modal-links .links-label { color: var(--text-faint); }
.page-ref { color: var(--text-dim); font-size: 13.5px; }

.modal-marks { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.mark-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 9px 11px;
  border-radius: 5px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .2s ease;
}
.mark-toggle:hover { border-color: var(--green); color: var(--text); }
.mark-toggle.disabled { opacity: .5; cursor: not-allowed; }
.mark-toggle.active[data-mark="in_garden"] {
  border-color: var(--green-soft);
  color: var(--green-pale);
  background: rgba(47, 157, 99, .14);
  box-shadow: 0 0 0 2px rgba(47, 157, 99, .25);
}
.mark-toggle.active[data-mark="is_dried"] {
  border-color: var(--gold);
  color: var(--gold-soft);
  background: rgba(201, 169, 97, .14);
  box-shadow: 0 0 0 2px rgba(201, 169, 97, .25);
}
.mark-toggle.active[data-mark="ritual_done"] {
  border-color: var(--el-fire);
  color: var(--el-fire);
  background: rgba(217, 121, 82, .14);
  box-shadow: 0 0 0 2px rgba(217, 121, 82, .25);
}
.mt-emoji { font-size: 16px; }

/* ---- Кольори: кнопка + шухляда ---- */
.colors-fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 90;
  width: 54px; height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 22px;
  background: var(--surface-2);
  border: 1px solid var(--gold);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.colors-fab:hover { transform: translateY(-3px) scale(1.05); }

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(4, 9, 6, .6);
  backdrop-filter: blur(4px);
  animation: overlay-in .2s ease;
}
.colors-drawer {
  position: fixed;
  top: 0; right: 0;
  z-index: 120;
  height: 100%;
  width: min(420px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform .25s ease;
  overflow-y: auto;
}
.colors-drawer.open { transform: translateX(0); }
.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}
.drawer-head h2 { margin: 0; font-size: 26px; color: var(--gold-soft); }
.drawer-close {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all .2s ease;
}
.drawer-close:hover { border-color: var(--gold); color: var(--gold-soft); }

.colors-list { padding: 16px 22px 30px; display: flex; flex-direction: column; gap: 16px; }
.color-item { display: flex; align-items: flex-start; gap: 14px; }
.color-swatch {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  margin-top: 3px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, .25);
}
.color-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}
.color-meanings { font-size: 13.5px; color: var(--text-dim); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 200;
  transform: translateX(-50%) translateY(8px);
  max-width: min(440px, calc(100vw - 40px));
  padding: 12px 20px;
  background: var(--surface-2);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 14px;
  color: var(--text);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast a { color: var(--gold-soft); text-decoration: underline; }

/* ---- Адаптив ---- */
@media (max-width: 760px) {
  .app-main { padding: 14px 16px 40px; }
  .filter-group { flex-direction: column; gap: 7px; }
  .fg-label { flex: none; padding-top: 0; }
  .modal-overlay { padding: 12px; }
  .modal-panel { max-height: calc(100vh - 24px); }
  .modal-grid {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 18px 18px 26px;
  }
  .modal-img { position: static; aspect-ratio: 16 / 10; }
  .modal-info h2 { font-size: 28px; }
  .colors-fab { right: 16px; bottom: 16px; width: 48px; height: 48px; font-size: 19px; }
  .alpha-letter { min-width: 24px; font-size: 14px; padding: 3px 5px; }
}
