/* ─── Reset ──────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Fonts & base ───────────────────────────────────────────────────────── */

:root {
  --parchment:      #f5e6c8;
  --parchment-dark: #e8d4a8;
  --ink:            #2a1608;
  --ink-light:      #5c3a1e;
  --gold:           #c9a84c;
  --gold-dark:      #8b6914;
  --red:            #6b1a1a;
  --sidebar-bg:     #1a0e07;
  --sidebar-border: #3d2810;
  --body-bg:        #120a04;
  --shadow:         rgba(0,0,0,0.75);
  --font-heading:   'Cinzel', Georgia, serif;
  --font-body:      'EB Garamond', Georgia, serif;
  --sidebar-width:  260px;
}

html { font-size: 18px; }

body {
  font-family: var(--font-body);
  background-color: var(--body-bg);
  background-image:
    radial-gradient(ellipse at 30% 20%, #2a1408 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, #1a0c04 0%, transparent 60%);
  color: var(--ink);
  min-height: 100vh;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-border) transparent;
}

.sidebar-brand {
  padding: 1.6rem 1.4rem 1.2rem;
  border-bottom: 1px solid var(--sidebar-border);
  text-align: center;
}

.brand-name {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  text-decoration: none;
  transition: color 0.2s;
}
.brand-name:hover { color: #e8c56a; }

.brand-sub {
  display: block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #7a5c3a;
  margin-top: 0.3rem;
}

.nav-list {
  list-style: none;
  padding: 0.8rem 0;
  flex: 1;
}

.nav-list li a {
  display: block;
  padding: 0.45rem 1.4rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: #c4a882;
  text-decoration: none;
  letter-spacing: 0.02em;
  border-left: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s, padding-left 0.2s;
}

.nav-list li a:hover,
.nav-list li a.active {
  color: var(--gold);
  border-left-color: var(--gold);
  padding-left: 1.8rem;
}

/* ─── Main content area ──────────────────────────────────────────────────── */

.main {
  flex: 1;
  padding: 2.5rem 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ─── Parchment page ─────────────────────────────────────────────────────── */

.parchment {
  width: 100%;
  max-width: 820px;
  background-color: var(--parchment);
  /* Aged paper effect: subtle gradient + grain */
  background-image:
    radial-gradient(ellipse at 50% 0%,   rgba(180,120,40,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(120, 70,20,0.10) 0%, transparent 60%),
    radial-gradient(ellipse at 0%  50%,  rgba(160,100,30,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 50%, rgba(160,100,30,0.06) 0%, transparent 50%);
  box-shadow:
    0 4px 60px var(--shadow),
    0 1px 6px  rgba(0,0,0,0.5),
    inset 0 0 120px rgba(139,90,43,0.10),
    inset 0 0  30px rgba(139,90,43,0.06);
  border-radius: 2px;
  animation: pageIn 0.4s ease both;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.parchment-inner {
  padding: 3rem 3.5rem 4rem;
  position: relative;
}

/* Decorative inner border — aged frame feel */
.parchment-inner::before {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(139,90,43,0.22);
  border-radius: 1px;
  pointer-events: none;
}

/* ─── GM badge ───────────────────────────────────────────────────────────── */

.gm-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff;
  background: var(--red);
  padding: 0.2em 0.7em;
  border-radius: 2px;
  margin-bottom: 1.4rem;
}

/* ─── Typography ─────────────────────────────────────────────────────────── */

.content h1 {
  font-family: var(--font-heading);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  text-align: center;
  margin-bottom: 0.3rem;
  line-height: 1.2;
}

/* Decorative rule beneath H1 */
.content h1::after {
  content: '— ✦ —';
  display: block;
  font-size: 0.9rem;
  letter-spacing: 0.3em;
  color: var(--gold-dark);
  margin-top: 0.5rem;
  margin-bottom: 1.6rem;
  font-weight: 400;
}

.content h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ink-light);
  margin-top: 2.2rem;
  margin-bottom: 0.7rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(139,90,43,0.25);
}

.content h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-light);
  margin-top: 1.6rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.content h4 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  font-style: italic;
  color: var(--ink);
  margin-top: 1.2rem;
  margin-bottom: 0.4rem;
}

.content p {
  font-size: 1rem;
  line-height: 1.78;
  color: var(--ink);
  margin-bottom: 0.9rem;
}

.content strong { font-weight: 600; color: var(--ink); }
.content em     { font-style: italic; color: var(--ink-light); }

/* ─── Links ──────────────────────────────────────────────────────────────── */

.content a {
  color: var(--gold-dark);
  text-decoration: underline;
  text-decoration-color: rgba(139,105,20,0.35);
  text-underline-offset: 2px;
  transition: color 0.2s, text-decoration-color 0.2s;
}
.content a:hover {
  color: #6b3d0a;
  text-decoration-color: rgba(107,61,10,0.6);
}

.unresolved {
  color: #999;
  font-style: italic;
}

/* ─── Lists ──────────────────────────────────────────────────────────────── */

.content ul, .content ol {
  margin: 0.5rem 0 0.9rem 1.4rem;
  line-height: 1.75;
}
.content li { margin-bottom: 0.25rem; }
.content li p { margin-bottom: 0.2rem; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.92rem;
  background: rgba(255,255,255,0.18);
}

.content th {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-light);
  background: rgba(139,90,43,0.10);
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(139,90,43,0.22);
  text-align: left;
}

.content td {
  padding: 0.45rem 0.8rem;
  border: 1px solid rgba(139,90,43,0.18);
  vertical-align: top;
  line-height: 1.55;
}

.content tr:nth-child(even) td {
  background: rgba(139,90,43,0.04);
}

/* First-column label style (two-col info tables) */
.content td:first-child:has(+ td) {
  font-weight: 500;
  color: var(--ink-light);
  white-space: nowrap;
  width: 1%;
}

/* ─── Horizontal rule ────────────────────────────────────────────────────── */

.content hr {
  border: none;
  text-align: center;
  margin: 2rem 0;
  color: var(--gold-dark);
  font-size: 1rem;
  letter-spacing: 0.4em;
}
.content hr::before { content: '· · · · ·'; }

/* ─── Blockquotes ────────────────────────────────────────────────────────── */

.content blockquote {
  border-left: 3px solid var(--gold-dark);
  background: rgba(139,90,43,0.06);
  padding: 0.7rem 1.1rem;
  margin: 1rem 0;
  font-style: italic;
  color: var(--ink-light);
}

/* ─── Code ───────────────────────────────────────────────────────────────── */

.content code {
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  background: rgba(42,22,8,0.08);
  padding: 0.1em 0.35em;
  border-radius: 2px;
  color: var(--ink);
}

.content pre {
  background: rgba(42,22,8,0.08);
  border: 1px solid rgba(139,90,43,0.2);
  border-radius: 3px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 1rem 0;
}
.content pre code {
  background: none;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.55;
}

/* ─── Callout blocks ─────────────────────────────────────────────────────── */

.callout {
  border-radius: 3px;
  border-left: 4px solid;
  margin: 1.4rem 0;
  overflow: hidden;
}

.callout-title {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.4rem 0.9rem;
}

.callout-body {
  padding: 0.6rem 0.9rem 0.7rem;
  font-size: 0.94rem;
  line-height: 1.65;
}
.callout-body p:last-child { margin-bottom: 0; }

/* warning / danger → red (GM notes) */
.callout-warning, .callout-danger, .callout-failure {
  border-color: #8b1a1a;
  background: #fdf2f2;
}
.callout-warning .callout-title,
.callout-danger  .callout-title,
.callout-failure .callout-title {
  background: #8b1a1a;
  color: #fff;
}

/* info / abstract / note → blue-grey */
.callout-info, .callout-abstract, .callout-note {
  border-color: #2d5986;
  background: #f0f4f9;
}
.callout-info     .callout-title,
.callout-abstract .callout-title,
.callout-note     .callout-title {
  background: #2d5986;
  color: #fff;
}

/* success / tip → muted green */
.callout-success, .callout-tip {
  border-color: #2d6b3f;
  background: #f0f7f2;
}
.callout-success .callout-title,
.callout-tip     .callout-title {
  background: #2d6b3f;
  color: #fff;
}

/* ─── Images ─────────────────────────────────────────────────────────────── */

.wiki-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.4rem auto;
  border: 1px solid rgba(139,90,43,0.3);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

/* ─── Mermaid diagrams ───────────────────────────────────────────────────── */

.mermaid {
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(139,90,43,0.18);
  border-radius: 3px;
  padding: 1rem;
  margin: 1.4rem 0;
  overflow-x: auto;
  text-align: center;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 820px) {
  .sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    z-index: 100;
  }
  .sidebar.open { display: flex; }

  .main { padding: 1rem; }

  .parchment-inner { padding: 1.8rem 1.4rem 2.5rem; }

  .parchment-inner::before { inset: 8px; }
}

/* ─── Mobile nav toggle ──────────────────────────────────────────────────── */

.nav-toggle {
  display: none;
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  width: 44px; height: 44px;
  background: var(--gold-dark);
  color: var(--parchment);
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 101;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

@media (max-width: 820px) {
  .nav-toggle { display: flex; }
}

/* ─── Gate page ──────────────────────────────────────────────────────────── */

.gate-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.gate-parchment {
  max-width: 440px;
  width: 100%;
}

.gate-parchment .parchment-inner {
  text-align: center;
  padding: 3rem 2.5rem;
}

.gate-seal {
  display: block;
  font-size: 2.8rem;
  margin-bottom: 0.6rem;
  filter: sepia(1) saturate(2);
}

.gate-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  margin-bottom: 0;
}

/* suppress the ::after ornament on gate title */
.gate-title::after { content: none; }

.gate-desc {
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--ink-light);
  font-style: italic;
  margin: 0.8rem 0 1.8rem;
  line-height: 1.6;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.gate-input {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.6rem 1rem;
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(139,90,43,0.4);
  border-radius: 2px;
  color: var(--ink);
  text-align: center;
  letter-spacing: 0.08em;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.gate-input:focus {
  border-color: var(--gold-dark);
  background: rgba(255,255,255,0.65);
}

.gate-submit {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--parchment);
  background: var(--gold-dark);
  border: none;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.2s;
}
.gate-submit:hover { background: #a07820; }

.gate-error {
  font-style: italic;
  font-size: 0.88rem;
  color: var(--red);
  min-height: 1.2rem;
}

/* ─── GM mode indicator in sidebar ──────────────────────────────────────── */

.gm-indicator {
  margin-top: auto;
  padding: 0.75rem 1.4rem;
  border-top: 1px solid var(--sidebar-border);
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: #8b3a3a;
  cursor: pointer;
  transition: color 0.2s;
  user-select: none;
}
.gm-indicator:hover { color: #c05050; }
