/* =========================================================================
   NAV.CSS – Jednotný navigační design systém (Fantasy DnD theme)
   Všechny navigační prvky: navbar, sidebary, breadcrumbs, cross-nav, search
   ========================================================================= */

/* ---- Dekorativní proměnné ---- */
:root {
  --nav-glow: rgba(201, 162, 39, 0.15);
  --nav-glow-strong: rgba(201, 162, 39, 0.25);
  --nav-border-ornament: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold-light) 50%, var(--gold) 80%, transparent);
  --nav-diamond: "◆";
  --nav-arrow: "›";
}

/* =========================================================================
   HLAVNÍ NAVBAR
   ========================================================================= */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 20, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.5rem;
  gap: 1rem;
}

/* Dekorativní spodní linka navbaru - zlatý gradient */
.navbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--nav-border-ornament);
  opacity: 0.5;
}

/* Brand s dekorativní runou */
.navbar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.2s, text-shadow 0.2s;
}
.navbar__brand:hover {
  color: var(--gold-light);
  text-shadow: 0 0 12px rgba(201, 162, 39, 0.4);
}
.navbar__rune {
  font-size: 1.3rem;
  filter: drop-shadow(0 0 4px rgba(201, 162, 39, 0.3));
}

/* Navigační odkazy */
.navbar__links {
  display: flex;
  list-style: none;
  gap: 0.15rem;
}

.nav-link {
  display: block;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.9rem;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, text-shadow 0.2s;
  position: relative;
}

/* Dekorativní spodní indikátor na hover */
.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--gold);
  border-radius: 1px;
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

.nav-link:hover {
  color: var(--gold-light);
  background: rgba(201, 162, 39, 0.06);
  text-shadow: 0 0 8px rgba(201, 162, 39, 0.2);
}
.nav-link:hover::after {
  transform: scaleX(1);
}

.nav-link.active {
  color: var(--gold);
  text-shadow: 0 0 10px rgba(201, 162, 39, 0.3);
}
.nav-link.active::after {
  transform: scaleX(1);
  background: var(--gold-light);
  box-shadow: 0 0 6px rgba(201, 162, 39, 0.4);
}

/* Zvýrazněný odkaz (Tvůrce postavy) */
.nav-link--highlight {
  border: 1px solid rgba(39, 174, 96, 0.4);
  color: #6fd99e !important;
  background: rgba(39, 174, 96, 0.08);
}
.nav-link--highlight::after {
  background: #6fd99e;
}
.nav-link--highlight:hover {
  background: var(--green-bright);
  color: var(--text-dark) !important;
  border-color: var(--green-bright);
  text-shadow: none;
}
.nav-link--highlight.active {
  color: #6fd99e !important;
  border-color: var(--green-bright);
  background: rgba(39, 174, 96, 0.15);
}

/* --- Soubojová navigace (bojový odkaz) --- */
.nav-link--combat {
  border: 1px solid rgba(192, 57, 43, 0.45);
  color: #f1948a !important;
  background: rgba(192, 57, 43, 0.08);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.nav-link--combat::after { background: #e74c3c; }
.nav-link--combat:hover {
  background: #c0392b;
  color: #fff !important;
  border-color: #e74c3c;
  text-shadow: 0 0 6px rgba(0,0,0,0.5);
}
.nav-link--combat.active {
  color: #f9c2bb !important;
  border-color: #e74c3c;
  background: rgba(192, 57, 43, 0.2);
}

/* Mobilní toggle */
.navbar__toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  color: var(--gold);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  transition: border-color 0.2s, background 0.2s;
}
.navbar__toggle:hover {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.08);
}

/* =========================================================================
   SEARCH BOX
   ========================================================================= */
.search-box {
  position: relative;
  margin-left: auto;
  margin-right: 0.5rem;
}

.search-input {
  font-family: 'Crimson Text', serif;
  font-size: 0.88rem;
  background: rgba(18, 18, 30, 0.8);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.35rem 0.75rem 0.35rem 2rem;
  width: 200px;
  transition: border-color 0.2s, width 0.2s, box-shadow 0.2s;
  outline: none;
}
.search-input:focus {
  border-color: var(--gold);
  width: 280px;
  box-shadow: 0 0 12px rgba(201, 162, 39, 0.15), inset 0 0 4px rgba(201, 162, 39, 0.05);
}
.search-input::placeholder {
  color: var(--text-dim);
}

.search-box__icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.85rem;
  pointer-events: none;
  transition: color 0.2s;
}
.search-input:focus ~ .search-box__icon,
.search-box:focus-within .search-box__icon {
  color: var(--gold);
}

/* Search výsledky dropdown */
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid rgba(201, 162, 39, 0.2);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 16px rgba(201, 162, 39, 0.08);
  z-index: 200;
  display: none;
}
.search-results.open { display: block; }

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.85rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid rgba(107, 84, 0, 0.3);
  transition: background 0.2s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover {
  background: rgba(201, 162, 39, 0.08);
}

.search-result-item__title {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  color: var(--gold-light);
}
.search-result-item__snippet {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.search-result-item__type {
  display: inline-block;
  font-size: 0.65rem;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: rgba(201, 162, 39, 0.08);
  color: var(--text-muted);
  border: 1px solid rgba(201, 162, 39, 0.15);
  align-self: flex-start;
}

.search-results__footer {
  padding: 0.5rem 0.75rem;
  text-align: center;
  font-size: 0.8rem;
  border-top: 1px solid rgba(107, 84, 0, 0.3);
}
.search-results__footer a { color: var(--gold); }

/* =========================================================================
   SDÍLENÉ SIDEBAR KOMPONENTY
   ========================================================================= */

/* Dekorativní titul sidebaru s ornamentem ── ◆ ── */
.rules-sidebar__title,
.lore-sidebar__title {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  text-align: center;
  position: relative;
}

/* Ornamentální linka pod titulem */
.rules-sidebar__title::after,
.lore-sidebar__title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--nav-border-ornament);
  opacity: 0.5;
}

/* Sdílená ikonová pozice */
.nav-icon-slot,
.lore-nav__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5em;
  flex-shrink: 0;
  font-size: 1em;
  line-height: 1;
  vertical-align: middle;
}

/* =========================================================================
   RULES SIDEBAR NAVIGACE
   ========================================================================= */
.rules-nav__list {
  list-style: none;
  position: relative;
}

/* Vertikální vodící linka - tenčí, subtilnější */
.rules-nav__list::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5rem;
  bottom: calc(0.3rem + 0.6em);
  width: 1px;
  background: linear-gradient(180deg, var(--border-dim), rgba(107, 84, 0, 0.2));
}

.rules-nav__list a {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-left: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-family: 'Crimson Text', serif;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s, background 0.2s, text-shadow 0.2s;
  position: relative;
}

.rules-nav__list a:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201, 162, 39, 0.04);
  text-shadow: 0 0 8px rgba(201, 162, 39, 0.15);
}

.rules-nav__list a.active {
  border-color: var(--gold-light);
  color: var(--gold-light);
  background: rgba(201, 162, 39, 0.08);
  font-weight: 600;
}

/* =========================================================================
   LORE SIDEBAR NAVIGACE
   ========================================================================= */
.lore-nav__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

/* Vertikální vodící linka */
.lore-nav__list::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 1px;
  background: linear-gradient(180deg, var(--border-dim), rgba(107, 84, 0, 0.2));
  bottom: calc(0.4rem + 0.6em);
}

.lore-nav__list a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-left: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-family: 'Crimson Text', serif;
  transition: border-color 0.2s, color 0.2s, background 0.2s, text-shadow 0.2s;
  text-decoration: none;
}

.lore-nav__list a:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201, 162, 39, 0.04);
  text-shadow: 0 0 8px rgba(201, 162, 39, 0.15);
}

.lore-nav__list a.active {
  border-color: var(--gold-light);
  color: var(--gold-light);
  background: rgba(201, 162, 39, 0.08);
  font-weight: 600;
}

/* =========================================================================
   SUBMENU TOGGLE (sdílený pro rules i lore sidebar)
   ========================================================================= */

.nav-item-row {
  display: flex;
  align-items: center;
  gap: 0;
}
.nav-item-row > a {
  flex: 1;
  min-width: 0;
}

.submenu-toggle {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.4rem 0.55rem;
  transition: transform 0.25s ease, color 0.2s;
  line-height: 1;
  border-radius: 3px;
}
.submenu-toggle:hover {
  color: var(--gold);
  background: rgba(201, 162, 39, 0.06);
}
.submenu-toggle.expanded {
  transform: rotate(90deg);
  color: var(--gold);
}

/* Rules sublists */
.rules-nav__sublist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: none;
  border-left: 1px solid rgba(201, 162, 39, 0.1);
  margin-left: 0.75rem;
}
.rules-nav__sublist.open { display: block; }
.rules-nav__sublist a {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem 0.25rem 1rem;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  transition: border-color 0.2s, color 0.2s;
}
.rules-nav__sublist a:hover {
  color: var(--gold);
  border-color: rgba(201, 162, 39, 0.3);
}
/* Active subsection — driven by scrollspy. Gold accent + faint gold tint
   so the user always knows which sub-block they're currently reading. */
.rules-nav__sublist a.active {
  color: var(--gold-light);
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.06);
  font-weight: 600;
  text-shadow: 0 0 6px rgba(201, 162, 39, 0.18);
}

/* Lore sublists */
.lore-nav__sublist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: none;
  border-left: 1px solid rgba(201, 162, 39, 0.1);
  margin-left: 0.75rem;
}
.lore-nav__sublist.open { display: block; }
.lore-nav__sublist a {
  padding-left: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-left: 2px solid transparent;
}
.lore-nav__sublist a:hover {
  color: var(--gold);
  border-color: rgba(201, 162, 39, 0.3);
}
.lore-nav__sublist a.active {
  color: var(--gold-light);
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.06);
  font-weight: 600;
  text-shadow: 0 0 6px rgba(201, 162, 39, 0.18);
}

/* Nav item row for lore toggle integration */
.lore-nav__list .nav-item-row {
  display: flex;
  align-items: center;
}
.lore-nav__list .nav-item-row > a {
  flex: 1;
  min-width: 0;
}

/* Divider mezi sekcemi */
.lore-nav__divider {
  height: 1px;
  background: var(--nav-border-ornament);
  margin: 0.6rem 0.75rem;
  opacity: 0.4;
}

/* =========================================================================
   SIDEBAR ZPĚT ODKAZ (sdílený)
   ========================================================================= */
.sidebar-back-link {
  margin-top: 1rem;
  padding-top: 0.75rem;
  position: relative;
}
.sidebar-back-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--nav-border-ornament);
  opacity: 0.3;
}
.sidebar-back-link a {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.sidebar-back-link a:hover {
  color: var(--gold);
}

/* When the back link sits at the TOP of the sidebar (above the nav list),
   flip the divider to the bottom of the link and tighten spacing so it
   reads as a header element rather than a footer. */
.sidebar-back-link--top {
  margin-top: 0;
  margin-bottom: 0.85rem;
  padding-top: 0;
  padding-bottom: 0.6rem;
}
.sidebar-back-link--top::before { display: none; }
.sidebar-back-link--top::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--nav-border-ornament);
  opacity: 0.3;
}

/* =========================================================================
   BREADCRUMB NAVIGACE
   ========================================================================= */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  position: relative;
}

/* Jemná spodní dekorativní linka */
.breadcrumb::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.2), transparent 80%);
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.breadcrumb a:hover { color: var(--gold); }

.breadcrumb__sep {
  color: var(--gold);
  opacity: 0.5;
  font-size: 0.7rem;
}

.breadcrumb__current {
  color: var(--gold-light);
  font-weight: 600;
}

/* =========================================================================
   CROSS-NAV (přepínání mezi pravidlovými stránkami)
   ========================================================================= */
.cross-nav {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  position: relative;
}

/* Spodní ornamentální linka */
.cross-nav::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--nav-border-ornament);
  opacity: 0.3;
}

.cross-nav__link {
  font-size: 0.78rem;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-dim);
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s, background 0.2s, box-shadow 0.2s;
  position: relative;
}

.cross-nav__link:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201, 162, 39, 0.06);
}

.cross-nav__link--active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-dim);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.15);
}

/* =========================================================================
   RESPONSIVE NAVIGACE
   ========================================================================= */

/* Search-toggle button (mobile only — hidden on desktop) */
.navbar__search-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(201, 162, 39, 0.3);
  color: var(--gold);
  font-size: 1.1rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.navbar__search-toggle:hover,
.navbar__search-toggle[aria-expanded="true"] {
  background: rgba(201, 162, 39, 0.1);
  border-color: var(--gold);
}

@media (max-width: 900px) {
  .rules-sidebar { display: none; }
}

@media (max-width: 640px) {
  .navbar {
    padding: 0.5rem 1rem;
    position: relative;
    gap: 0.5rem;
  }
  .navbar::after { height: 1px; }

  .navbar__toggle { display: block; }
  .navbar__search-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .navbar__links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(10, 10, 20, 0.97);
    border-bottom: 2px solid;
    border-image: var(--nav-border-ornament) 1;
    padding: 0.5rem;
    z-index: 99;
  }
  .navbar__links.open { display: flex; }

  .nav-link::after { display: none; }
  .nav-link {
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    border-left: 2px solid transparent;
  }
  .nav-link:hover { border-left-color: var(--gold); }
  .nav-link.active { border-left-color: var(--gold-light); }

  /* Mobile search: hidden by default; .open class shows it as a full-width row
     under the navbar that pushes the menu below it */
  .search-box {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.6rem 0.8rem;
    background: rgba(10, 10, 20, 0.97);
    border-bottom: 1px solid rgba(201, 162, 39, 0.2);
    z-index: 98;
  }
  .search-box.open { display: block; }
  .search-input {
    width: 100%;
    font-size: 1rem;
    padding: 0.6rem 0.75rem 0.6rem 2.2rem;
  }
  .search-input:focus { width: 100%; }
  .search-box__icon { left: 1.2rem; font-size: 1rem; }
  .search-results {
    left: 0.8rem;
    right: 0.8rem;
    min-width: 0;
    max-height: 70vh;
  }
}

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