/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Base Typography & Body */
body {
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.6;
  color: #222;
  background-color: #f2f2f2;
}

body a {
  color: inherit;
}

h1, h2 {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

h1 {
  font-size: 2.4rem;
  margin: 0;
}

h2 {
  font-size: 1.6rem;
  margin-bottom: 16px;
}

p {
  margin-bottom: 16px;
}

/* Header & Navigation Bar */
.logo {
  background-color: #333;
  text-align: center;
  padding: 15px;
}

.logo a {
  color: white;
  text-decoration: none;
}

.navbar {
  background-color: #333;
  padding: 0 16px;
}

.nav-links {
  list-style-type: none;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.nav-links li {
  display: flex;
  align-items: center;
}

.nav-links a,
.nav-links button {
  display: block;
  color: white;
  background-color: #333;
  text-align: center;
  text-decoration: none;
  font-family: sans-serif;
}

.nav-links a {
  padding: 14px 20px;
}

.nav-links a:hover,
.nav-links button:hover {
  background-color: #555;
  color: #fff;
}

.nav-links a.active,
.nav-links a[aria-current="page"],
.logo a.active {
  background-color: #555;
  font-weight: 700;
  border-bottom: 3px solid #64b5f6;
}

/* TOC Toggle Button */
.toc-toggle {
  background-color: #333;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  color: white;
  font-size: 1.1rem;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.toc-toggle:hover {
  background-color: #444;
}

/* Layout Containers & Shared Card Styles */
.content-section {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 16px;
}

.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 32px;
}

.feature-row.top-space {
  margin-top: 24px;
}

.philosophy-box,
.sheet-preview-box,
.testimonials-box,
.panel-section,
.rule-section,
.toc-panel details {
  background-color: #ffffff;
  border: 1px solid #ddd;
  border-radius: 16px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.05);
}

.philosophy-box,
.sheet-preview-box,
.testimonials-box,
.panel-section,
.rule-section {
  padding: 28px;
}

.philosophy-box,
.sheet-preview-box {
  flex: 1 1 320px;
  min-width: 280px;
}

.testimonials-box {
  width: 100%;
}

.sheet-image-placeholder {
  min-height: 320px;
  border: 2px dashed #ccc;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  background-color: #fcfcfc;
  padding: 24px;
  margin-top: 16px;
  text-align: center;
}

.testimonial-list {
  display: grid;
  gap: 16px;
}

.testimonial-card {
  background-color: #fff;
  border: 1px solid #dadada;
  border-radius: 10px;
  padding: 18px;
}

.testimonial-author {
  margin-top: 12px;
  font-size: 0.95rem;
  color: #555;
  font-style: italic;
}

/* Main Rules & Sidebar Layout */
.page-layout,
.rules-page {
  display: flex;
  gap: 24px;
  max-width: 1400px;
  width: calc(100% - 40px);
  margin: 32px auto;
  padding: 0 16px;
  align-items: flex-start;
  min-width: 0;
}

.sidebar-panel,
.toc-panel {
  width: auto;
  min-width: 4.2rem;
  flex-shrink: 0;
  position: sticky;
  top: 96px;
  align-self: flex-start;
}

.content-panel,
.rules-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.panel-section,
.rule-section {
  border-radius: 18px;
}

/* Table of Contents Panel */
.toc-panel details {
  width: 260px;
  border-radius: 18px;
  padding: 20px;
  transition: width 0.55s ease, opacity 0.32s ease, transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-origin: center center;
  will-change: transform, width, opacity;
  overflow: hidden;
}

.toc-panel details:not([open]) {
  width: 0;
  min-width: 0;
  padding: 0;
  border: none;
  box-shadow: none;
  opacity: 0;
  transform: translateX(-12px) translateY(-6px) scale(0.1) rotate(-5deg);
  overflow: hidden;
}

.toc-panel details[open] {
  transform: none;
  width: 260px;
}

.toc-panel details.collapsing,
.toc-panel details.expanding {
  transform: translate(var(--swoop-dx, -12px), var(--swoop-dy, -6px)) scale(0.14) rotate(-6deg);
  opacity: 0.18;
}

.toc-panel details.collapsing .toc-title,
.toc-panel details.collapsing .toc-links,
.toc-panel details.expanding .toc-title,
.toc-panel details.expanding .toc-links {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.toc-panel details.expanding .toc-title,
.toc-panel details.expanding .toc-links {
  transition-delay: 0.12s;
}

.toc-panel summary {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  list-style: none;
  margin-bottom: 16px;
}

.toc-panel summary::-webkit-details-marker {
  display: none;
}

.toc-panel summary .toc-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.toc-panel details:not([open]) .toc-title,
.toc-panel details:not([open]) .toc-links,
.toc-panel details:not([open]) summary {
  display: none;
  opacity: 0;
}

.toc-panel details:not([open]) summary::after {
  content: '\276F';
  font-size: 1.2rem;
  margin-left: 0.35rem;
}

.toc-panel details[open] summary::after {
  content: '\276E';
  margin-left: 0.6rem;
}

.toc-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toc-links a {
  display: block;
  padding: 10px 14px;
  border-radius: 12px;
  text-decoration: none;
  color: #333;
  background-color: #f7f9fc;
  transition: background-color 0.2s ease;
}

.toc-links a:hover {
  background-color: #e8eef6;
}

/* Rule Elements, Action Boxes & Example Cards */
.example-box {
  margin: 18px 0;
  padding: 18px 22px;
  border-radius: 16px;
  background: #f4f7fe;
  border: 1px solid #d7e0f2;
}

.example-box h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.1rem;
}

.action-list {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.action-box {
  background: #f8fafc;
  border: 1px solid #d6deea;
  border-radius: 14px;
  padding: 16px 18px;
}

.action-box h4 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.action-subbox {
  margin-top: 10px;
  padding: 10px 14px;
  border-left: 3px solid #8da4c2;
  background: #ffffff;
  border-radius: 10px;
}

.action-subbox h5 {
  margin-bottom: 4px;
  font-size: 0.98rem;
}

.example-box > :last-child,
.action-box > :last-child,
.action-subbox > :last-child {
  margin-bottom: 0;
}

/* Tables */
.rule-table {
  width: 100%;
  max-width: 420px;
  border-collapse: collapse;
  margin: 12px 0 20px;
  background: #f8fafc;
  border: 1px solid #d6deea;
  border-radius: 12px;
  overflow: hidden;
}

.rule-table th,
.rule-table td {
  padding: 10px 14px;
  border: 1px solid #d6deea;
  text-align: center;
}

.rule-table th {
  background: #eef3f8;
  font-weight: 700;
}

.rule-table td {
  background: #ffffff;
}

/* Common Helper Utility Classes */
.rule-list {
  margin-left: 20px;
  line-height: 1.8;
  margin-bottom: 16px;
}

.tree-list,
.tree-list ul {
  margin-left: 20px;
  line-height: 1.8;
}

.rule-note {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 12px;
}

/* Responsive Styles */
@media (max-width: 900px) {
  .page-layout,
  .rules-page {
    flex-direction: column;
  }

  .sidebar-panel,
  .toc-panel {
    width: 100%;
    position: static;
    top: auto;
  }

  .sidebar-panel details,
  .sidebar-panel details:not([open]),
  .toc-panel details,
  .toc-panel details:not([open]) {
    width: 100%;
    min-width: 0;
  }

  .sidebar-panel summary,
  .toc-panel summary {
    justify-content: space-between;
  }

  .sidebar-panel details:not([open]) .toc-title,
  .toc-panel details:not([open]) .toc-title {
    opacity: 1;
  }
}

@media (max-width: 800px) {
  .feature-row {
    flex-direction: column;
  }
}
