/* assets/style.css | 深色棕橙主题，适配 Dawn Quest 官网 */

:root {
  --bg-body: #120c07;          /* 整体背景：很深的棕黑色 */
  --bg-card: #1b120b;          /* 卡片背景：稍微浅一点的棕色 */
  --bg-card-soft: #22160d;
  --border-subtle: #2b1a10;
  --border-strong: #3b2313;

  --accent: #ff8a00;           /* 主色：橙色按钮、链接等 */
  --accent-soft: #3b2411;
  --accent-soft2: #2c1a0f;

  --accent-green: #22c55e;
  --accent-yellow: #f59e0b;

  --callout-info-bg: #132231;
  --callout-info-border: #38bdf8;
  --callout-note-bg: #2a1424;
  --callout-note-border: #f472b6;
  --callout-warning-bg: #3a280f;
  --callout-warning-border: #fbbf24;

  --text-main: #f9fafb;
  --text-muted: #d1d5db;
  --text-soft: #9ca3af;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --shadow-soft: 0 16px 35px rgba(0, 0, 0, 0.8);
  --shadow-tiny: 0 2px 5px rgba(0, 0, 0, 0.65);

  --sidebar-width: 260px;
  --header-height: 56px;
}

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

html {
  scroll-behavior: smooth;
}

body.wiki-body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at top, #21160f 0, #120c07 50%, #080605 100%);
}

/* Header */

.wiki-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.6);
  background: linear-gradient(to bottom, #1d130b, #140d08);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.85);
}

.wiki-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.wiki-logo {
  font-weight: 700;
  text-decoration: none;
  color: #ffddaa;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.wiki-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.text-highlight {
  color: #fed7aa;
  background: rgba(250, 204, 21, 0.14);
  padding: 0 0.2em;
  border-radius: 3px;
}

.text-orange { color: #f97316; }
.text-red    { color: #ef4444; }
.text-green  { color: #22c55e; }
.text-blue   { color: #38bdf8; }

/* 折叠块补充样式 */
details.wiki-fold > summary {
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  list-style: none;
  user-select: none;
  font-size: 14px;
  color: #f9fafb;
}

details.wiki-fold[open] > summary {
  background: rgba(249, 115, 22, 0.25);
}

details.wiki-fold > summary::-webkit-details-marker {
  display: none;
}

details.wiki-fold > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease-out;
}

details.wiki-fold[open] > summary::before {
  transform: rotate(90deg);
}

details.wiki-fold .fold-body {
  margin-top: 8px;
  padding: 10px 12px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
}

/* Buttons */

.btn-ghost {
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #1f130b;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  box-shadow: var(--shadow-tiny);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: #ffe4b5;
  background: #2b180c;
}

.btn-primary {
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: #111827;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 0 #7a4600, 0 0 0 1px #000;
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 3px 0 #7a4600, 0 0 0 1px #000;
}

/* Main layout */

.wiki-main {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

.wiki-sidebar {
  width: var(--sidebar-width);
  border-right: 1px solid #000;
  background: radial-gradient(circle at top, #23140b 0, #140b07 45%, #0a0603 100%);
  padding: 0.75rem 0.75rem 1.5rem;
  overflow-y: auto;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03);
}

.wiki-content {
  flex: 1;
  padding: 1.25rem 1.5rem 2.5rem;
}

.wiki-content-inner {
  max-width: 920px;
  margin: 0 auto;
}

/* Navigation */

.wiki-nav-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a1622a;
  margin-bottom: 0.5rem;
  padding: 0 0.25rem;
}

.wiki-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  margin-bottom: 2px;
}

.nav-link,
.nav-group-toggle {
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.38rem 0.55rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: #d1d5db;
  text-decoration: none;
}

.nav-link {
  padding-left: 0.75rem;
}

.nav-link:hover,
.nav-group-toggle:hover {
  background: #2c180b;
  color: #ffe4b5;
}

.nav-link.is-active {
  background: #3a210d;
  color: #ffe7bf;
  font-weight: 600;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 138, 0, 0.4);
}

.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.nav-group-toggle {
  font-weight: 500;
  color: #f3f4f6;
}

.nav-group-caret {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-left: 0.25rem;
}

.nav-sublist {
  margin-left: 0.25rem;
  padding-left: 0.4rem;
  border-left: 1px dashed rgba(255, 255, 255, 0.05);
  margin-top: 2px;
  display: none;
}

.nav-item.nav-group-open > .nav-sublist {
  display: block;
}

.nav-item.nav-level-1 {
  margin-top: 0.25rem;
}

/* Article */

.breadcrumb {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 0.75rem;
}

.breadcrumb-current {
  color: #e5e7eb;
}

.wiki-article {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.5rem 1.75rem 2rem;
  border: 1px solid rgba(0, 0, 0, 0.85);
}

.article-title {
  margin: 0 0 0.25rem;
  font-size: 1.55rem;
  line-height: 1.3;
  color: #ffe7c1;
}

.article-meta {
  font-size: 0.8rem;
  color: #a1a1aa;
  margin-bottom: 1rem;
}

.md-content {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-main);
}

/* Typography inside markdown */

.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4,
.md-content h5,
.md-content h6 {
  margin-top: 1.4rem;
  margin-bottom: 0.45rem;
  font-weight: 600;
  color: #ffe7bf;
}

.md-content h2 {
  font-size: 1.25rem;
}

.md-content h3 {
  font-size: 1.05rem;
}

.md-content p {
  margin: 0.4rem 0;
}

.md-content ul,
.md-content ol {
  padding-left: 1.2rem;
  margin: 0.4rem 0 0.6rem;
}

.md-content li {
  margin: 0.15rem 0;
}

.md-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed rgba(255, 138, 0, 0.6);
}

.md-content a:hover {
  border-bottom-style: solid;
}

.md-content blockquote {
  margin: 0.7rem 0;
  padding: 0.5rem 0.8rem;
  border-left: 3px solid #4b5563;
  background: #171114;
  color: #d4d4d8;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Code */

.md-content code {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  font-size: 0.85em;
  background: #1f2933;
  padding: 0.08rem 0.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid #374151;
  color: #e5e7eb;
}

.md-content pre {
  background: #020617;
  color: #e5e7eb;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 0.9rem 0;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.15);
}

.md-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

/* Divider */

.md-content hr {
  border: none;
  border-top: 1px solid #312015;
  margin: 1.2rem 0;
}

/* Tables (New Added) */

.wiki-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.9rem;
  color: var(--text-main);
  background: #160f0a;
}

.wiki-table th,
.wiki-table td {
  border: 1px solid var(--border-subtle);
  padding: 0.6rem 0.8rem;
  text-align: left; /* 默认对齐，JS解析器会内联样式覆盖特殊对齐 */
}

.wiki-table th {
  background: var(--bg-card-soft);
  color: #ffe7bf; /* 呼应标题色 */
  font-weight: 600;
  border-bottom: 2px solid var(--border-strong);
}

.wiki-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03); /* 极淡的斑马纹 */
}

.wiki-table tr:hover {
  background: rgba(255, 138, 0, 0.05); /* 鼠标悬停时泛微橙光 */
}

/* Images & figures */

.md-image {
  margin: 1rem auto;
  text-align: center;
}

.md-image img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-tiny);
  border: 1px solid rgba(0, 0, 0, 0.8);
}

.md-image figcaption {
  font-size: 0.8rem;
  color: #a1a1aa;
  margin-top: 0.35rem;
}

/* Callouts */

.callout {
  margin: 0.9rem 0;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  position: relative;
  background: #191719;
}

.callout::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}

.callout-title {
  font-weight: 500;
  margin-bottom: 0.15rem;
  font-size: 0.9rem;
}

/* info（蓝色，冷一点） */
.callout.callout-info {
  background: var(--callout-info-bg);
  border-color: var(--callout-info-border);
}

.callout.callout-info::before {
  background: var(--callout-info-border);
}

/* note（偏粉紫，很适合“温馨提示”） */
.callout.callout-note {
  background: var(--callout-note-bg);
  border-color: var(--callout-note-border);
}

.callout.callout-note::before {
  background: var(--callout-note-border);
}

/* warning（偏黄橙，适合重要提醒） */
.callout.callout-warning {
  background: var(--callout-warning-bg);
  border-color: var(--callout-warning-border);
}

.callout.callout-warning::before {
  background: var(--callout-warning-border);
}

/* Details / collapsible */

.md-content details {
  margin: 0.7rem 0;
  border-radius: var(--radius-md);
  border: 1px solid #362010;
  background: #1a100a;
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-tiny);
}

.md-content details[open] {
  background: #24140b;
}

.md-content details summary {
  cursor: pointer;
  list-style: none;
  font-weight: 500;
  font-size: 0.9rem;
  color: #e5e7eb;
}

.md-content details summary::-webkit-details-marker {
  display: none;
}

.md-content details summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.4rem;
  transition: transform 0.15s ease;
  color: var(--accent);
}

.md-content details[open] summary::before {
  transform: rotate(90deg);
}

.md-content details > *:not(summary) {
  margin-top: 0.4rem;
}

/* Back to top */

.back-to-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.5rem;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid #000;
  background: #2b180b;
  box-shadow: var(--shadow-tiny);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #facc15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Mobile */

.nav-toggle {
  border: 1px solid #000;
  background: #2b180b;
  border-radius: var(--radius-md);
  padding: 0.25rem 0.55rem;
  font-size: 0.85rem;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 0.25rem;
  color: #ffd9a0;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 15;
}

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

  .wiki-main {
    position: relative;
  }

  .wiki-sidebar {
    position: fixed;
    inset: var(--header-height) auto 0 0;
    width: 260px;
    max-width: 80%;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 16;
    box-shadow: 0 0 30px rgba(0, 0, 0, 1);
  }

  body.sidebar-open .wiki-sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .wiki-content {
    padding: 1rem 0.9rem 2.25rem;
  }

  .wiki-article {
    padding: 1.1rem 1rem 1.5rem;
  }
}

/* Editor page */

.editor-body {
  background: radial-gradient(circle at top, #23140b 0, #120c07 50%, #050404 100%);
}

.editor-tag {
  font-size: 0.8rem;
  color: #ffdd99;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #3a210d;
  margin-left: 0.4rem;
  border: 1px solid #000;
}

.editor-warning {
  max-width: 1000px;
  margin: 0.75rem auto 0;
  background: #3a280f;
  border-radius: var(--radius-md);
  border: 1px solid #fbbf24;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  color: #fef3c7;
  box-shadow: var(--shadow-tiny);
}

.editor-main {
  max-width: 1180px;
  margin: 0.85rem auto 1.5rem;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1rem;
}

.editor-sidebar {
  background: var(--bg-card-soft);
  border-radius: var(--radius-lg);
  border: 1px solid #000;
  padding: 1rem 1rem 1.2rem;
  box-shadow: var(--shadow-soft);
  align-self: flex-start;
}

.editor-section-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: #ffe4b5;
}

.field {
  display: block;
  margin-bottom: 0.75rem;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  color: #d1d5db;
  margin-bottom: 0.25rem;
}

.field-input {
  width: 100%;
  padding: 0.4rem 0.45rem;
  border-radius: var(--radius-md);
  border: 1px solid #3b2313;
  font-size: 0.9rem;
  background: #120b07;
  color: #f9fafb;
}

.field-input::placeholder {
  color: #6b7280;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 138, 0, 0.4);
}

.editor-generate-btn {
  width: 100%;
  margin-top: 0.4rem;
}

.editor-note {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  color: #e5e7eb;
}

.editor-note ol {
  padding-left: 1.1rem;
  margin: 0.3rem 0 0;
}

/* 工作区 */

.editor-workspace {
  display: grid;
  grid-template-rows: minmax(240px, 1fr) minmax(240px, 1fr);
  gap: 0.75rem;
}

.editor-editor-pane,
.editor-preview-pane {
  background: var(--bg-card-soft);
  border-radius: var(--radius-lg);
  border: 1px solid #000;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
}

.editor-pane-header {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid #2a1910;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #e5e7eb;
}

.editor-textarea {
  flex: 1;
  border: none;
  padding: 0.7rem 0.9rem 0.85rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 160px;
  background: #120b07;
  color: #f9fafb;
}

.editor-textarea:focus {
  outline: none;
}

.editor-preview-article {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: none;
  border: none;
  padding: 0.9rem 1rem 1.1rem;
  background: transparent;
}

.editor-preview-title {
  font-size: 0.82rem;
  color: #cbd5f5;
}

/* Editor responsive */

@media (max-width: 960px) {
  .editor-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-sidebar {
    order: 1;
  }

  .editor-workspace {
    order: 2;
  }
}

@media (max-width: 640px) {
  .editor-workspace {
    grid-template-rows: auto auto;
  }

  .editor-preview-article {
    padding: 0.75rem 0.7rem 0.9rem;
  }
}
