/* assets/css/pages.css */

/* =========================
   HOME / GLOBAL PAGE BLOCKS
========================= */

.home-shell {
  display: grid;
  gap: 22px;
}

.home-block {
  min-width: 0;
}

.hero-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 34px;
  background:
    radial-gradient(circle at top right, rgba(143, 92, 255, 0.13), transparent 38%),
    linear-gradient(135deg, rgba(21, 18, 45, 0.96), rgba(10, 10, 22, 0.98));
  box-shadow: var(--shadow-card);
  padding: 34px;
  min-height: 380px;
  isolation: isolate;
}

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 220px);
  gap: 28px;
  align-items: center;
}

.hero-left {
  min-width: 0;
}

.hero-left h2 {
  max-width: 560px;
  margin-bottom: 18px;
  font-size: clamp(2.1rem, 3.6vw, 3.5rem);
  line-height: 1.02;
  font-weight: 900;
}

.hero-left h2 span {
  color: var(--purple-soft);
}

.hero-sub {
  max-width: 640px;
}

.hero-right {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-logo {
  display: block;
  width: min(100%, 190px);
  max-width: 190px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.32));
}

.hero-sub,
.candidature-desc,
.rule-section-text,
.list-item p {
  color: var(--text-dim);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
}

.hero-inline-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.home-grid,
.staff-grid,
.home-video-list,
.subrules,
.subcategory-stack,
.staff-list,
.rules-search-results {
  display: grid;
  gap: 16px;
}

.home-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  align-items: stretch;
}

#rulesOverview,
#ruleSubrules,
#subcategoryRules {
  display: grid;
  gap: 18px;
}

/* =========================
   BADGES / CHIPS
========================= */

.hero-badge,
.tag,
.staff-pill,
.candidature-count,
.subcategory-count,
.rule-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  white-space: normal;
}

.hero-badge {
  margin-bottom: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #d8cffd;
}

.tag {
  background: rgba(92, 184, 255, 0.08);
  color: var(--blue);
  border: 1px solid rgba(92, 184, 255, 0.14);
}

.rule-chip.category {
  background: rgba(143, 92, 255, 0.14);
  color: #ceb8ff;
}

.rule-chip.subcategory {
  background: rgba(92, 184, 255, 0.12);
  color: #bfe6ff;
}

.rule-chip.rule {
  background: rgba(110, 234, 167, 0.1);
  color: #bff6d7;
}

.btn.secondary,
.ghost-btn,
.tag,
.staff-pill,
.candidature-count,
.rule-chip,
.village-btn {
  color: #f2edff;
}

/* =========================
   CARDS BASE
========================= */

.mini-stat,
.home-card,
.category-card,
.lore-card,
.search-result-card,
.list-item,
.candidature-item,
.rule-section,
.subcategory-link-card,
.video-card,
.staff-account-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(17, 16, 36, 0.92);
  box-shadow: var(--shadow-card);
}

.home-card,
.category-card,
.lore-card,
.search-result-card,
.subcategory-link-card,
.list-item,
.village-btn,
.reaction-btn,
.mini,
.ghost-btn,
.btn {
  -webkit-tap-highlight-color: transparent;
}

.home-card:hover,
.category-card:hover,
.lore-card:hover,
.search-result-card:hover,
.subcategory-link-card:hover,
.list-item:hover,
.village-btn:hover {
  border-color: var(--line-hover);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.home-card:focus-visible,
.category-card:focus-visible,
.lore-card:focus-visible,
.search-result-card:focus-visible,
.subcategory-link-card:focus-visible,
.village-btn:focus-visible,
.reaction-btn:focus-visible,
.mini:focus-visible,
.ghost-btn:focus-visible,
.btn:focus-visible,
.subrule-head:focus-visible,
.lore-toc-link:focus-visible {
  outline: 2px solid rgba(176, 140, 255, 0.75);
  outline-offset: 3px;
}

.mini-stat {
  min-width: 0;
  padding: 14px 16px;
}

.mini-stat-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.76rem;
  text-transform: uppercase;
  color: var(--text-dim);
}

.mini-stat-value {
  display: block;
  min-width: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  overflow-wrap: anywhere;
}

.home-card,
.category-card,
.lore-card {
  position: relative;
  display: flex;
  width: 100%;
  overflow: hidden;
}

.home-card {
  min-height: 200px;
  padding: 22px;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 14px;
  text-align: left;
  background: linear-gradient(180deg, rgba(15, 14, 32, 0.94), rgba(10, 10, 22, 0.98));
}

.home-card > * {
  position: relative;
  z-index: 2;
}

.home-card h3 {
  margin: 0;
  color: #fff;
  font-size: 1.18rem;
  line-height: 1.2;
}

.home-card p {
  margin: 0;
  color: var(--text-dim);
  line-height: 1.7;
}

.home-arrow,
.subcategory-link-arrow {
  color: var(--purple-soft);
  font-size: 1.15rem;
  line-height: 1;
  transition: transform 0.18s var(--ease);
}

.home-card:hover .home-arrow,
.subcategory-link-card:hover .subcategory-link-arrow,
.rule-category-card:hover .subcategory-link-arrow {
  transform: translateX(3px);
}

.home-card-top,
.candidature-item-top,
.list-item-top,
.subcategory-link-head,
.search-result-top,
.rule-section-head,
.staff-account-top,
.candidature-editor-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.home-icon,
.index-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.index-badge {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  box-shadow: 0 4px 14px rgba(143, 92, 255, 0.24);
}

/* =========================
   IMAGE CARDS
========================= */

.card-bg-image,
.lore-card .card-cover-image {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.card-bg-image {
  opacity: 0.42;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: brightness(0.82);
}

.lore-card .card-cover-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.52;
  filter: brightness(0.62);
}

.category-card .card-bg-image,
.candidature-item .card-bg-image {
  opacity: 0.46;
  filter: brightness(0.84);
}

.lore-card::after,
.candidature-item::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7, 7, 18, 0.22), rgba(7, 7, 18, 0.48));
}

.category-card,
.lore-card {
  min-height: 132px;
  padding: 22px;
  text-align: center;
  background: linear-gradient(180deg, rgba(10, 10, 26, 0.68), rgba(8, 8, 20, 0.78));
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lore-card {
  min-height: 220px;
  align-items: stretch;
  justify-content: flex-start;
  gap: 12px;
  text-align: left;
  background: linear-gradient(180deg, rgba(15, 14, 30, 0.94), rgba(9, 9, 20, 0.98));
}

.category-card > *,
.lore-card > *,
.candidature-item > * {
  position: relative;
  z-index: 3;
}

.category-card h4,
.lore-card h4 {
  margin: 10px 0 6px;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.category-card p,
.lore-card p {
  margin: 0;
  color: #d8d1f0;
  line-height: 1.55;
  font-size: 0.94rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.lore-card .index-badge {
  margin: 0 0 8px;
}

.lore-card h4 {
  margin: 0;
  text-align: left;
}

.lore-card p {
  text-align: left;
  color: #e1daf8;
  line-height: 1.68;
}

.lore-card .card-reactions {
  margin-top: auto;
  position: relative;
  z-index: 3;
  justify-content: flex-start;
}

.lore-card .reaction-btn {
  background: rgba(10, 10, 22, 0.48);
  border-color: rgba(255, 255, 255, 0.08);
  color: #f2edff;
}

/* =========================
   RULES
========================= */

.rules-hero {
  padding: 20px 24px;
  background: var(--bg-card);
}

.rules-header {
  align-items: end;
  margin-bottom: 0;
}

.rules-heading {
  display: grid;
  gap: 10px;
  max-width: 720px;
}

.rules-kicker,
.rules-lead {
  display: none;
}

.rules-search-bar {
  width: min(420px, 100%);
}

.rules-category-grid,
.rules-search-results {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.rules-reader-panel,
.rule-category-card,
.search-result-card,
.subcategory-link-card,
.rule-section {
  background: var(--bg-card);
}

.rules-reader-panel {
  max-width: 1040px;
  margin: 0 auto;
}

.rules-reader-panel .reader-top {
  margin-bottom: 0;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#ruleReaderTitle,
#subcategoryReaderTitle {
  margin: 0;
  font-size: clamp(1.45rem, 2.1vw, 2rem);
  line-height: 1.15;
}

.rule-category-card {
  min-height: 170px;
  padding: 18px;
  gap: 14px;
  justify-content: space-between;
  text-align: left;
  align-items: stretch;
  border-color: rgba(143, 92, 255, 0.12);
  background: linear-gradient(180deg, rgba(17, 16, 36, 0.98), rgba(10, 10, 22, 0.98));
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.rule-category-card:hover {
  transform: translateY(-2px);
}

.rule-category-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, rgba(176, 140, 255, 0.85), rgba(90, 50, 184, 0.2));
  opacity: 0.9;
  pointer-events: none;
}

.rule-category-card-head,
.rule-category-card-top,
.rule-category-footer,
.rule-category-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rule-category-card-head,
.rule-category-card-top,
.rule-category-footer {
  justify-content: space-between;
}

.rule-category-copy {
  display: grid;
  flex: 1 1 auto;
  gap: 8px;
  min-width: 0;
}

.rule-category-copy h4,
.rule-category-card h4 {
  margin: 0;
  color: #fff;
  font-size: 1.2rem;
  line-height: 1.2;
  text-align: left;
  text-shadow: none;
}

.rule-category-copy p,
.rule-category-card p {
  margin: 0;
  color: var(--text-dim);
  line-height: 1.65;
  text-align: left;
  text-shadow: none;
}

.rule-category-stats,
.rule-category-footer {
  display: none;
}

.rule-category-card-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #f3efff;
  font-weight: 700;
}

.index-badge.subtle {
  width: auto;
  height: auto;
  margin: 0;
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #dfdaf0;
}

.reader-body,
.subrule-content {
  color: #e9e3ff;
  line-height: 1.9;
}

.subrule {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
}

.subrule-head {
  width: 100%;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-align: left;
  font-weight: 800;
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.subrule-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.24s var(--ease);
}

.subrule.open .subrule-head {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.subrule-content {
  padding: 14px 18px 18px;
  background: rgba(8, 8, 18, 0.45);
}

.subrule-arrow {
  flex: 0 0 auto;
  opacity: 0.72;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}

.subrule.open .subrule-arrow {
  transform: rotate(180deg);
  opacity: 1;
}

.search-hit {
  color: #fff;
  background: rgba(143, 92, 255, 0.22);
  border-radius: 6px;
  padding: 0 4px;
}

.search-result-card,
.subcategory-link-card,
.rule-section {
  padding: 18px;
}

.search-result-card {
  display: grid;
  gap: 10px;
  text-align: left;
}

.search-result-top {
  justify-content: flex-start;
}

.search-result-title {
  color: #fff;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.4;
}

.search-result-path {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.65;
}

.rule-section {
  display: grid;
  gap: 14px;
}

.rule-section-head h4,
.subcategory-link-card h5 {
  margin: 0;
  color: #fff;
}

.rule-section-text {
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
}

.subcategory-link-card {
  text-align: left;
}

.subcategory-link-card p {
  margin: 6px 0 0;
  color: var(--text-dim);
  line-height: 1.65;
}

.subcategory-link-side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.no-results {
  text-align: center;
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
}

/* =========================
   STAFF
========================= */

.staff-grid {
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  align-items: start;
}

.staff-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
  margin-bottom: 16px;
}

.staff-list {
  max-height: 620px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.staff-permissions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.permission-item,
.staff-account-card,
.candidature-editor-list,
.candidature-staff-names {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.staff-account-meta,
.entry-parent-label,
.empty-preview {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.55;
}

.staff-account-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.staff-perm-chip {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(143, 92, 255, 0.11);
  border: 1px solid rgba(143, 92, 255, 0.18);
  color: #dfd5ff;
  font-size: 0.78rem;
  font-weight: 700;
}

/* =========================
   CANDIDATURES
========================= */

.candidature-item {
  position: relative;
  overflow: hidden;
  padding: 18px;
  background: linear-gradient(180deg, rgba(8, 8, 20, 0.82), rgba(10, 10, 24, 0.9));
}

.candidature-item h4 {
  margin: 0;
  color: #fff;
  font-size: 1.06rem;
  font-weight: 900;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.42);
}

.candidature-desc {
  color: #d8d1f0;
  font-size: 0.92rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.42);
}

.candidature-staff-names {
  margin-top: 12px;
  background: rgba(110, 234, 167, 0.08);
  border-color: rgba(110, 234, 167, 0.18);
  color: #f4fffb;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
}

.candidature-editor-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 16px;
}

.candidature-editor-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(143, 92, 255, 0.12);
  border: 1px solid rgba(143, 92, 255, 0.2);
}

.candidature-editor-chip-name {
  overflow-wrap: anywhere;
}

.candidature-editor-chip-remove {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: transparent;
  color: #fff;
}

.candidature-editor-empty {
  color: var(--text-dim);
}

.candidature-village-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: 100%;
}

.candidature-village-hint {
  color: var(--text-dim);
  line-height: 1.6;
}

.village-btn {
  position: relative;
  min-width: 0;
  min-height: 240px;
  width: 100%;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(100px, 140px) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(135deg, rgba(20, 18, 44, 0.96), rgba(10, 10, 24, 0.98));
  box-shadow: var(--shadow-card);
  text-align: left;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.village-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(143, 92, 255, 0.12), transparent 52%);
  opacity: 0.9;
  pointer-events: none;
}

.village-btn:hover {
  transform: translateY(-3px);
}

.village-btn-media,
.village-btn-copy {
  position: relative;
  z-index: 1;
}

.village-btn-media {
  display: flex;
  align-items: center;
  justify-content: center;
}

.village-btn-media img {
  display: block;
  width: min(100%, 132px);
  max-height: 132px;
  object-fit: contain;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.3));
}

.village-btn-copy {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.village-btn-label {
  font-size: clamp(1.7rem, 2vw, 2.3rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #fff;
}

.village-btn-subtitle {
  color: var(--text-dim);
  line-height: 1.7;
  font-size: 0.98rem;
}

.village-btn-konoha {
  background:
    radial-gradient(circle at top right, rgba(123, 220, 164, 0.13), transparent 42%),
    linear-gradient(135deg, rgba(18, 34, 30, 0.96), rgba(10, 15, 18, 0.99));
}

.village-btn-kiri {
  background:
    radial-gradient(circle at top right, rgba(102, 195, 255, 0.14), transparent 42%),
    linear-gradient(135deg, rgba(17, 28, 45, 0.96), rgba(8, 13, 22, 0.99));
}

.village-btn.active {
  border-color: rgba(143, 92, 255, 0.42);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 18px 36px rgba(90, 64, 165, 0.24);
}

.village-btn.active::before {
  background: linear-gradient(135deg, rgba(143, 92, 255, 0.28), rgba(255, 255, 255, 0.04) 58%);
}

/* =========================
   REACTIONS / VIDEO
========================= */

.card-reactions,
.reader-reactions,
.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  transition: background 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease);
}

.reaction-btn.active {
  background: rgba(143, 92, 255, 0.15);
  color: var(--purple-soft);
}

.reaction-btn.loading {
  pointer-events: none;
  opacity: 0.72;
}

.video-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.video-card h4 {
  margin: 0;
  color: #fff;
  font-size: 1rem;
}

.video-embed {
  display: block;
}

/* =========================
   RICH TEXT
========================= */

.rich-line,
.rich-h1,
.rich-h2,
.rich-h3,
.rich-section-title {
  color: #ece7ff;
}

.rich-line {
  line-height: 1.82;
  overflow-wrap: anywhere;
}

.rich-line strong,
.rich-h1 strong,
.rich-h2 strong,
.rich-h3 strong,
.rich-section-title strong {
  color: #fff;
}

.rich-spacer {
  height: 10px;
}

.rich-h1,
.rich-h2,
.rich-h3 {
  font-weight: 900;
  line-height: 1.25;
}

.rich-h1 {
  font-size: 1.5rem;
}

.rich-h2 {
  font-size: 1.18rem;
}

.rich-h3 {
  font-size: 1.02rem;
}

.rich-image {
  margin: 12px 0;
}

.rich-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.rich-section-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--purple-soft);
}

/* =========================
   SERVER STATUS
========================= */

.server-status-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.server-status-inline.online {
  color: #dfffe9;
}

.server-status-inline.online::before {
  content: "●";
  font-size: 0.92rem;
  line-height: 1;
  color: var(--green);
  text-shadow: 0 0 10px rgba(110, 234, 167, 0.45);
}

/* =========================
   LORE READER + TOC
========================= */

.lore-reader-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  width: 100%;
  min-width: 0;
}

/* Quand le lore n’a pas de sommaire, le contenu prend toute la largeur */
.lore-reader-layout.no-toc {
  grid-template-columns: minmax(0, 1fr);
}

.lore-reader-layout.no-toc .lore-reader-panel {
  grid-column: 1 / -1;
  width: 100%;
}

.lore-toc {
  position: relative;
  align-self: start;
  z-index: 10;
  width: 220px;
  min-width: 220px;
}

.lore-toc:not(.show) {
  display: none;
}
.lore-toc-panel {
  width: 220px;
  padding: 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  background: var(--bg-card);
}

.lore-toc.is-floating .lore-toc-panel {
  position: fixed;
  top: var(--lore-toc-top, 20px);
  left: var(--lore-toc-left, 0px);
  width: var(--lore-toc-width, 220px);
  z-index: 50;
}

.lore-toc-title {
  margin-bottom: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.lore-toc-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
}

.lore-toc-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  text-align: left;
  transition: background 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease);
}

.lore-toc-link:hover,
.lore-toc-link.active {
  color: #fff;
  border-color: rgba(143, 92, 255, 0.22);
  background: rgba(143, 92, 255, 0.12);
}

.lore-toc-index {
  color: var(--purple-soft);
  font-size: 0.76rem;
  font-weight: 800;
}

.lore-reader-panel {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.lore-cover {
  margin: 0;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.lore-cover img {
  display: block;
  width: 100%;
  max-height: 320px;
  height: auto;
  object-fit: cover;
}

.lore-summary {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  line-height: 1.75;
}

.lore-section-block {
  display: grid;
  gap: 12px;
  padding: 18px 0;
  scroll-margin-top: 90px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.lore-section-block:first-of-type {
  padding-top: 0;
  border-top: none;
}

.lore-section-body {
  display: grid;
  gap: 2px;
}

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

@media (max-width: 1100px) {
  .home-grid,
  .staff-grid,
  .hero-inline-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .candidature-village-picker {
    grid-template-columns: 1fr;
  }

  .village-btn {
    min-height: 210px;
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 16px;
    padding: 20px;
  }

  .lore-reader-layout {
    grid-template-columns: 1fr;
  }

  .lore-toc {
    position: static;
    top: auto;
    order: -1;
    width: 100%;
    min-width: 0;
    z-index: auto;
  }

  .lore-toc.is-floating .lore-toc-panel {
    position: static;
    top: auto;
    left: auto;
    width: 100%;
    z-index: auto;
  }

  .lore-toc-panel {
    width: 100%;
    max-height: none;
    overflow: visible;
  }

  .lore-toc-list {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    overflow: visible;
    padding-right: 0;
  }

  .rules-header {
    align-items: stretch;
  }

  .rules-search-bar {
    width: 100%;
  }

  .rule-category-card-top,
  .rule-category-card-head,
  .rule-category-footer,
  .subcategory-link-head {
    align-items: flex-start;
  }

  .rule-category-stats,
  .subcategory-link-side {
    justify-content: flex-start;
    justify-items: start;
  }
}

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

  .hero-panel {
    padding: 24px;
    min-height: 0;
  }

  .hero-right {
    order: -1;
  }

  .hero-logo {
    width: min(100%, 150px);
    max-width: 150px;
  }
}

@media (max-width: 640px) {
  .candidature-editor-add,
  .staff-permissions-grid,
  .staff-toolbar,
  .home-grid,
  .card-grid {
    grid-template-columns: 1fr !important;
  }

  .rules-hero,
  .rules-reader-panel,
  .search-result-card,
  .subcategory-link-card,
  .rule-section,
  .rule-category-card {
    padding: 18px;
  }

  .rule-category-card {
    min-height: auto;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-sub,
  .home-card p,
  .mini-stat-value {
    overflow-wrap: anywhere;
  }

  .village-btn {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .village-btn-copy {
    justify-items: center;
  }

  .village-btn-media img {
    max-height: 108px;
  }
}

/* =========================
   FIX HOME VIDEOS - 3 PAR LIGNE
   À METTRE TOUT EN BAS DU FICHIER
========================= */

.home-video-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(143, 92, 255, 0.10), transparent 42%),
    linear-gradient(180deg, rgba(14, 13, 30, 0.92), rgba(8, 8, 20, 0.96));
  box-shadow: var(--shadow-card);
}

.home-video-panel .page-header {
  margin-bottom: 18px;
}

.home-video-list {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 14px !important;
  align-items: stretch;
}

.video-card {
  min-width: 0;
  padding: 12px !important;
  display: grid !important;
  grid-template-rows: auto auto auto;
  gap: 10px !important;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(20, 18, 42, 0.92), rgba(10, 10, 22, 0.98));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
  overflow: hidden;
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.video-card:hover {
  transform: translateY(-2px);
  border-color: rgba(176, 140, 255, 0.32);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.42),
    0 0 24px rgba(143, 92, 255, 0.12);
}

.video-card h4 {
  margin: 0;
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.25;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-embed {
  display: block !important;
  width: 100% !important;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 16px;
  background: #000;
}

.video-card .card-reactions {
  margin-top: 0;
}

.video-card .reaction-btn {
  padding: 5px 9px;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.045);
}


/* Mobile : 1 vidéo par ligne */
@media (max-width: 640px) {
  .home-video-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .home-video-list {
    grid-template-columns: 1fr !important;
  }

  .video-card {
    padding: 10px !important;
  }
}

/* =========================
   REDUCED MOTION / FPS SAFE
========================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}