﻿/* FancyBox2D FCC Script Learning Center - Shared Stylesheet */
:root {
  --sidebar-bg: #1a237e;
  --sidebar-hover: #283593;
  --sidebar-active: #3949ab;
  --sidebar-text: #e8eaf6;
  --sidebar-width: 280px;
  --accent: #006600;
  --accent-light: #e8f5e9;
  --code-bg: #f5f5f5;
  --code-border: #e0e0e0;
  --text-primary: #212121;
  --text-secondary: #616161;
  --border-color: #e0e0e0;
  --bg-white: #ffffff;
  --bg-light: #fafafa;
  --header-height: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text-primary);
  background: var(--bg-light);
  line-height: 1.6;
}

/* ===== Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.sidebar-header .subtitle {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  margin-top: 2px;
}

.sidebar-search {
  padding: 10px 16px;
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 0.85rem;
  outline: none;
  transition: background 0.2s;
}

.sidebar-search input::placeholder { color: rgba(255,255,255,0.4); }
.sidebar-search input:focus { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.4); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* Tree */
.tree-item {
  user-select: none;
}

.tree-label {
  display: flex;
  align-items: center;
  padding: 5px 16px 5px 0;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--sidebar-text);
  border-left: 3px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-label:hover { background: var(--sidebar-hover); }

.tree-label.active {
  background: var(--sidebar-active);
  border-left-color: #64b5f6;
  color: #fff;
  font-weight: 500;
}

.tree-toggle {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 8px;
  font-size: 0.65rem;
  transition: transform 0.2s;
  color: rgba(255,255,255,0.5);
}

.tree-toggle-spacer {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-left: 8px;
}

.tree-toggle.expanded { transform: rotate(90deg); }

.tree-icon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}

.tree-children {
  display: none;
  padding-left: 0;
  border-left: 1px solid rgba(255,255,255,0.08);
  margin-left: 20px;
}

.tree-children.open { display: block; }

.tree-placeholder {
  font-size: 0.82rem;
  font-style: italic;
  color: #9e9e9e;
}

.tree-leaf { padding-left: 4px; }

/* Depth-based indentation */
.depth-0 > .tree-label { padding-left: 6px; }
.depth-1 > .tree-label { padding-left: 10px; }
.depth-2 > .tree-label { padding-left: 14px; }
.depth-3 > .tree-label { padding-left: 18px; }
.depth-4 > .tree-label { padding-left: 22px; }

/* Type badges in tree */
.type-badge {
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  flex-shrink: 0;
  font-weight: 500;
  text-transform: uppercase;
}

.type-badge.syntax { background: #1b5e20; color: #c8e6c9; }
.type-badge.method { background: #e65100; color: #ffe0b2; }
.type-badge.property { background: #4a148c; color: #e1bee7; }
.type-badge.function { background: #01579b; color: #b3e5fc; }
.type-badge.event { background: #b71c1c; color: #ffcdd2; }

/* ===== Content Panel ===== */
.content-panel {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  padding: 32px 40px;
  max-width: 960px;
}

.content-welcome {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.content-welcome h2 { font-size: 1.5rem; color: var(--text-primary); margin-bottom: 12px; }
.content-welcome p { font-size: 1rem; }

/* Entry detail */
.entry-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--accent);
}

.entry-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.entry-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.entry-meta .meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.entry-type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #fff;
}

.entry-type-badge.syntax { background: #1b5e20; }
.entry-type-badge.method { background: #e65100; }
.entry-type-badge.property { background: #4a148c; }
.entry-type-badge.function { background: #01579b; }
.entry-type-badge.event { background: #b71c1c; }
.entry-type-badge.section { background: var(--sidebar-bg); }
.entry-type-badge.subsection { background: #37474f; }
.entry-type-badge.method_group { background: #e65100; }
.entry-type-badge.object { background: #00695c; }

.entry-section {
  margin-bottom: 24px;
}

.entry-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.entry-desc {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
}

/* Code blocks */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 14px 18px;
  font-family: "Cascadia Code", "Fira Code", "Consolas", "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 8px 0;
}

.code-block .kw { color: #0000ff; }
.code-block .str { color: #a31515; }
.code-block .num { color: #098658; }
.code-block .cmt { color: #008000; }
.code-block .fn { color: #795e26; }

/* Params table */
.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 8px 0;
}

.params-table th {
  background: var(--accent-light);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--border-color);
}

.params-table td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  vertical-align: top;
}

.params-table tr:nth-child(even) td { background: #fafafa; }

/* Example section */
.example-block {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 16px;
  margin: 8px 0;
}

.example-block pre {
  background: #fff;
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 12px 16px;
  font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Children list */
.children-list {
  margin: 8px 0;
}

.child-link {
  display: inline-block;
  padding: 4px 12px;
  margin: 3px 4px;
  background: var(--accent-light);
  border: 1px solid #c8e6c9;
  border-radius: 4px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  transition: all 0.15s;
}

.child-link:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ===== Mobile ===== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--sidebar-bg);
  color: #fff;
  z-index: 200;
  align-items: center;
  padding: 0 16px;
}

.mobile-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  margin-right: 12px;
}

.mobile-header h1 { font-size: 1rem; font-weight: 600; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    top: var(--header-height);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .content-panel {
    margin-left: 0;
    padding: 16px;
    padding-top: calc(var(--header-height) + 16px);
  }
}

/* ===== Scrollbar for content ===== */
.content-panel::-webkit-scrollbar { width: 6px; }
.content-panel::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* ===== No results ===== */
.no-results {
  padding: 20px 16px;
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
  text-align: center;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 4px; }

/* ===== Index page specific ===== */
.hero {
  background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #3949ab 100%);
  color: #fff;
  padding: 80px 40px;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.hero p {
  font-size: 1.1rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 32px;
}

.hero-btn {
  display: inline-block;
  padding: 12px 32px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.2s;
}

.hero-btn:hover { background: #008800; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  padding: 60px 40px;
  max-width: 1100px;
  margin: 0 auto;
}

.feature-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 28px 24px;
  transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.feature-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.feature-card h3 {
  font-size: 1.1rem;
  color: var(--sidebar-bg);
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.feature-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.index-footer {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
}
