/* Regler page — DestinyRP-style layout, Navigate cyan/blue theme */

.rules-page {
  position: relative;
  padding: 4rem var(--pad-x) 6rem;
  overflow: hidden;
}

.rules-page::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: min(800px, 100%);
  height: 400px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(37, 99, 235, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

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

.rules-page__header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.rules-page__title {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rules-page__intro {
  margin: 0 auto;
  max-width: 36rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

#rules-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.rule-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.rule-section--open {
  border-color: rgba(92, 225, 255, 0.25);
  box-shadow: 0 0 0 1px rgba(92, 225, 255, 0.08), 0 8px 32px rgba(0, 0, 0, 0.25);
}

.rule-section__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.125rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.rule-section__trigger:hover {
  background: var(--surface-hover);
}

.rule-section--open .rule-section__trigger {
  color: var(--cyan);
  background: rgba(37, 99, 235, 0.08);
  border-bottom: 1px solid var(--border);
}

.rule-section__title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rule-section__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(92, 225, 255, 0.1);
  border: 1px solid rgba(92, 225, 255, 0.2);
}

.rule-section__count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.rule-section__chevron {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  transition: transform 0.25s ease;
}

.rule-section__chevron svg {
  width: 12px;
  height: 12px;
}

.rule-section--open .rule-section__chevron {
  transform: rotate(180deg);
}

.rule-section__panel {
  padding: 0;
}

.rule-section__panel[hidden] {
  display: none;
}

.rule-section--open .rule-section__panel {
  display: block;
}

.rule-section__label {
  font-weight: 600;
}

.rule-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Destiny-style row: number left, title + text right */
.rule-list__item {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  align-items: start;
  gap: 0 0.875rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

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

.rule-list__item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.rule-list__id {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1.35;
  padding-top: 0.1rem;
}

.rule-list__body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

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

.rule-list__text {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
  white-space: pre-wrap;
}

.rules-empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Toolbar — only visible to editors */
.rules-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(92, 225, 255, 0.25);
  border-radius: var(--radius);
  background: rgba(37, 99, 235, 0.08);
}

.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.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}

.rules-editor__hint code {
  padding: 0.1rem 0.35rem;
  background: var(--surface-hover);
  border-radius: 4px;
  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: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.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(92, 225, 255, 0.2);
}

.rules-editor__item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.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.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color 0.2s;
}

.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.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  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: var(--surface-hover);
}

.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.3);
  background: rgba(239, 68, 68, 0.08);
}

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

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

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