/* Regler — matcher forsiden: glass, cyan, runde elementer */

.page-rules .rules-page {
  position: relative;
  z-index: 1;
  padding: 6rem clamp(1.25rem, 4vw, 3rem) 4rem;
  min-height: calc(100dvh - 4.5rem);
}

.rules-page__inner {
  position: relative;
  max-width: 820px;
  margin: 0 auto;
}

.rules-page__header {
  text-align: center;
  margin-bottom: 2.75rem;
  animation: rules-in 0.65s ease both;
}

@keyframes rules-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rules-page__header {
    animation: none;
  }
}

.rules-page__eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan);
}

.rules-page__title {
  margin: 0 0 1rem;
  font-size: clamp(1.75rem, 4.5vw, 2.625rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

.rules-page__intro {
  margin: 0 auto;
  max-width: 38rem;
  color: rgba(241, 245, 249, 0.72);
  font-size: 1rem;
  line-height: 1.65;
}

/* Indholdsfortegnelse */
.rules-toc {
  margin-bottom: 3rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(22, 27, 38, 0.88);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}

.rules-toc__title {
  margin: 0 0 1.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(241, 245, 249, 0.5);
}

.rules-toc__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.625rem 1.25rem;
}

.rules-toc__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: 999px;
  color: rgba(241, 245, 249, 0.85);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.35;
  border: 1px solid transparent;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.rules-toc__link:hover,
.rules-toc__link.is-active {
  color: var(--text);
  background: rgba(59, 158, 255, 0.08);
  border-color: rgba(59, 158, 255, 0.22);
}

.rules-toc__link.is-active {
  color: var(--cyan);
}

.rules-toc__num {
  flex-shrink: 0;
  min-width: 1.625rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(148, 163, 184, 0.8);
}

.rules-toc__link:hover .rules-toc__num,
.rules-toc__link.is-active .rules-toc__num {
  color: var(--cyan);
}

/* Sektioner */
.rules-sections {
  display: flex;
  flex-direction: column;
  gap: 3.25rem;
}

.rule-section {
  scroll-margin-top: 6rem;
}

.rule-section__head {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.rule-section__eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
}

.rule-section__title {
  margin: 0;
  font-size: clamp(1.375rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.rule-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(22, 27, 38, 0.82);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.rule-list__item {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  align-items: start;
  gap: 0 1rem;
  padding: 1.125rem 1.375rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.15s;
}

.rule-list__item:last-child {
  border-bottom: none;
}

.rule-list__item:hover {
  background: rgba(59, 158, 255, 0.04);
}

.rule-list__id {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 1.75rem;
  padding: 0 0.375rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1;
  border-radius: 999px;
  background: rgba(59, 158, 255, 0.1);
  border: 1px solid rgba(59, 158, 255, 0.2);
}

.rule-list__body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  padding-top: 0.1rem;
}

.rule-list__heading {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.rule-list__text {
  margin: 0;
  font-size: 0.875rem;
  color: rgba(148, 163, 184, 0.95);
  line-height: 1.55;
  white-space: pre-wrap;
}

.rules-empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  border: 1px dashed rgba(59, 158, 255, 0.25);
  border-radius: 16px;
  background: rgba(22, 27, 38, 0.78);
}

/* Toolbar — editors */
.rules-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.625rem;
  margin: 0 0 1.5rem;
  padding: 0.875rem 1rem;
  border: 1px solid rgba(59, 158, 255, 0.22);
  border-radius: 999px;
  background: rgba(22, 27, 38, 0.9);
}

.rules-toolbar[hidden] {
  display: none;
}

.rules-toolbar__status {
  margin-right: auto;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: 0.02em;
}

/* Editor */
.rules-editor {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rules-editor__hint {
  margin: 0;
  padding: 0.875rem 1.125rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(22, 27, 38, 0.88);
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}

.rules-editor__hint code {
  padding: 0.1rem 0.35rem;
  background: rgba(59, 158, 255, 0.1);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--cyan);
}

.rules-editor__sections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rules-editor__section {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 1.125rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(22, 27, 38, 0.88);
}

.rules-editor__section-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.rules-editor__items {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding-left: 0.75rem;
  border-left: 2px solid rgba(59, 158, 255, 0.2);
}

.rules-editor__item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(13, 15, 20, 0.78);
}

.rules-editor__item-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.rules-editor__input,
.rules-editor__textarea {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(13, 15, 20, 0.65);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color 0.2s;
}

.rules-editor__textarea {
  border-radius: 12px;
}

.rules-editor__input:focus,
.rules-editor__textarea:focus {
  outline: none;
  border-color: var(--cyan);
}

.rules-editor__input--small {
  flex: 0 0 5rem;
}

.rules-editor__input--id {
  flex: 0 0 9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
}

.rules-editor__input--title {
  flex: 1;
  font-weight: 600;
}

.rules-editor__textarea {
  min-height: 4.5rem;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.rules-editor__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(22, 27, 38, 0.8);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.rules-editor__btn:hover {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(59, 158, 255, 0.35);
}

.rules-editor__btn--danger {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.125rem;
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
  border-radius: 999px;
}

.rules-editor__btn--danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.55);
}

.rules-editor__btn--add,
.rules-editor__add-section {
  align-self: flex-start;
  border-style: dashed;
  border-color: rgba(59, 158, 255, 0.35);
  background: transparent;
  color: var(--cyan);
}

.rules-editor__btn--add:hover,
.rules-editor__add-section:hover {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--cyan);
}

@media (max-width: 640px) {
  .page-rules .rules-page {
    padding-top: 5.25rem;
  }

  .rules-toc__grid {
    grid-template-columns: 1fr;
  }

  .rule-list__item {
    grid-template-columns: 1fr;
    gap: 0.625rem;
  }

  .rule-list__id {
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
