/* ==========================================================================
   Architecture Inspector — Styles
   ========================================================================== */

/* ── Design Tokens ── */

:root {
  --bg:             #ffffff;
  --bg-card:        #fafafa;
  --bg-inset:       #f4f4f4;
  --border:         #e6e6e6;
  --border-strong:  #d0d0d0;
  --text:           #141414;
  --text-emphasis:  #222222;
  --text-secondary: #5e5e5e;
  --text-muted:     #a0a0a0;

  --font-sans:  'SF Pro Display', 'SF Pro', -apple-system, 'Inter', sans-serif;
  --font-text:  'SF Pro Text', 'SF Pro', -apple-system, 'Inter', sans-serif;
  --font-mono:  'SF Mono', 'JetBrains Mono', monospace;

  --radius:     10px;
  --radius-sm:  6px;

  --transition-fast: 0.15s ease;
  --transition-mid:  0.25s ease;
  --transition-slow: 0.3s ease;
}

[data-theme="dark"] {
  --bg:             #111111;
  --bg-card:        #191919;
  --bg-inset:       #1f1f1f;
  --border:         #2c2c2c;
  --border-strong:  #3a3a3a;
  --text:           #ebebeb;
  --text-emphasis:  #b0b0b0;
  --text-secondary: #8a8a8a;
  --text-muted:     #505050;
}


/* ── Reset & Base ── */

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

body {
  font-family: var(--font-text);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body.has-diagram-modal { overflow: hidden; }


/* ── Layout ── */

.page {
  max-width: 840px;
  margin: 0 auto;
  padding: 60px 40px 80px;
}


/* ── Shared: pill button (theme toggle, expand, copy-all) ── */

.btn-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.btn-pill:hover {
  color: var(--text);
  border-color: var(--border-strong);
}


/* ── Theme Toggle ── */

.theme-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 17px;
  z-index: 10;
}

[data-theme="light"] .theme-btn .ti-sun  { display: none; }
[data-theme="dark"]  .theme-btn .ti-moon { display: none; }


/* ── Cover ── */

.cover {
  position: relative;
  margin-bottom: 48px;
}

.cover h1 {
  font-family: var(--font-sans);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -1.8px;
  line-height: 1.1;
}

.cover-sub {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 12px;
  max-width: 600px;
  line-height: 1.6;
}


/* ── Copy All Button ── */

.copy-all-btn {
  position: absolute;
  top: 0;
  right: 0;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  gap: 6px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.copy-all-btn i { font-size: 15px; }
.copy-all-btn.is-copied { color: var(--text); border-color: var(--border-strong); }


/* ── Section ── */

.section { margin-top: 48px; }

.section-title {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title i {
  color: var(--text);
  font-size: 16px;
}

.section-intro {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
}

.section-intro strong { color: var(--text-emphasis); }
.section-intro em     { font-style: italic; }

.section-intro code,
.acc-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-inset);
  padding: 2px 6px;
  border-radius: 4px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.acc-body code {
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 3px;
  word-break: break-word;
  overflow-wrap: anywhere;
}


/* ── About (rich-text prose) ── */

.about {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.about p { margin-bottom: 14px; }
.about p:last-child { margin-bottom: 0; }

.about strong { color: var(--text-emphasis); }
.about em     { font-style: italic; }

.about code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-inset);
  padding: 2px 6px;
  border-radius: 4px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.about h3 {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-top: 20px;
  margin-bottom: 8px;
}

.about h3:first-child { margin-top: 0; }

.about ul, .about ol {
  margin: 8px 0 14px 20px;
  font-size: 14px;
}

.about li { margin-bottom: 4px; }


/* ── Card ── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 12px;
  overflow: hidden;
}


/* ── File Tree ── */

.ft { list-style: none; }

.ft ul {
  list-style: none;
  margin-left: 16px;
  border-left: 1px solid var(--border);
}

.ft li {
  padding: 3px 0 3px 16px;
  position: relative;
  font-size: 13px;
}

.ft li::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 13px;
  width: 12px;
  border-top: 1px solid var(--border);
}

.ft > li            { padding-left: 0; }
.ft > li::before    { display: none; }

.ft .n {
  font-family: var(--font-mono);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ft .n i { font-size: 14px; color: var(--text); }

.ft .d {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 6px;
}


/* ── Tool Cards ── */

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 8px;
  transition: border-color var(--transition-fast);
}

.tool-card:hover { border-color: var(--border-strong); }

.tool-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.tool-top i { font-size: 16px; color: var(--text-secondary); }

.tool-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.tool-cmd {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--text-secondary);
  overflow-x: auto;
}

.tool-deps {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

.tool-params       { margin-top: 10px; font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.tool-params table { width: 100%; border-collapse: collapse; margin-top: 6px; }

.tool-params th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--border);
}

.tool-params tr:last-child td { border-bottom: none; }

.tool-params td {
  padding: 5px 8px 5px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.tool-params td:first-child {
  font-family: var(--font-mono);
  font-weight: 500;
  white-space: nowrap;
}


/* ── Diagram ── */

.diagram-container {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  overflow-x: auto;
}

.diagram-container.is-vertical .mermaid-host svg {
  width: 100% !important;
  height: auto !important;
  max-width: none;
}

.mermaid-host svg { max-width: none; height: auto; }

.nodeLabel,
.edgeLabel {
  font-family: Inter, sans-serif !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
}


/* ── Diagram Expand Button ── */

.diagram-expand-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  gap: 5px;
  z-index: 2;
}

.diagram-expand-btn i { font-size: 14px; }


/* ── Diagram Modal ── */

.diagram-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.diagram-modal.is-visible { opacity: 1; }

.diagram-modal__panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 92vw;
  height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
}

.diagram-modal__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-secondary);
}

.diagram-modal__zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.diagram-modal__zoom-controls button {
  border-radius: 6px;
  width: 30px;
  height: 30px;
  font-size: 16px;
}

.diagram-modal__zoom-pct {
  min-width: 44px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.diagram-modal__close {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.diagram-modal__close:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.diagram-modal__viewport {
  flex: 1;
  overflow: auto;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.diagram-modal__viewport::-webkit-scrollbar { display: none; }
.diagram-modal__viewport.is-dragging        { cursor: grabbing; }

.diagram-modal__canvas {
  transform-origin: center center;
  transition: transform var(--transition-fast);
}

.diagram-modal__canvas svg {
  max-width: none !important;
  height: auto !important;
}


/* ── Data Tables ── */

.section > table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.section > table th {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  background: rgba(128,128,128,0.06);
  border-bottom: 1px solid var(--border);
}

.section > table td {
  padding: 0.55rem 0.75rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(128,128,128,0.08);
}

.section > table tr:last-child td {
  border-bottom: none;
}

.section > table td:first-child {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}


/* ── Accordion ── */

.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.acc-item { border-bottom: 1px solid var(--border); }
.acc-item:last-child { border-bottom: none; }

.acc-summary {
  cursor: pointer;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
  user-select: none;
  transition: opacity var(--transition-slow);
}

.acc-summary:hover { opacity: 0.7; }

.acc-icon {
  font-size: 16px;
  color: var(--text-muted);
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  transition: transform var(--transition-mid);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.acc-item.is-open .acc-icon { transform: rotate(90deg); }

.acc-collapse {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height var(--transition-slow), opacity var(--transition-mid);
}

.acc-item.is-open .acc-collapse { opacity: 1; }

.acc-body {
  padding: 0 20px 20px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  min-width: 0;
  overflow-wrap: anywhere;
}

.acc-detail {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
}


/* ── Workflow Steps ── */

.wf-step {
  padding: 6px 0;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
}

.wf-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-inset);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
}


/* ── Reveal Animation ── */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  filter: blur(6px);
  transition: opacity 0.5s ease, transform 0.5s ease, filter 0.5s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}


/* ── Responsive ── */

/* --- Tablet (481–1024px) --- */

@media (max-width: 1024px) {
  .page { padding: 48px 32px 64px; }

  .diagram-container { padding: 20px; }

  .diagram-modal__panel {
    width: 96vw;
    height: 90vh;
    border-radius: 10px;
  }

  .diagram-modal__viewport { padding: 24px; }
}

/* --- Mobile (≤480px) --- */

@media (max-width: 480px) {

  /* Layout */
  .page { padding: 32px 16px 48px; }

  /* Cover */
  .cover { margin-bottom: 36px; }
  .cover h1 { font-size: 28px; letter-spacing: -1px; }
  .cover-sub { font-size: 14px; margin-top: 10px; }

  .copy-all-btn {
    position: static;
    margin-top: 14px;
    width: fit-content;
  }

  /* Theme toggle — hide on mobile, use system preference */
  .theme-btn { display: none; }

  /* Sections */
  .section { margin-top: 36px; }
  .section-title { font-size: 12px; letter-spacing: 1px; }
  .section-intro { font-size: 14px; }

  /* About */
  .about { font-size: 14px; }
  .about code { font-size: 12px; }

  /* Cards */
  .card { padding: 16px; }

  /* File tree — prevent overflow */
  .ft li { font-size: 12px; }

  .ft .n {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .ft .d {
    display: block;
    margin-left: 20px;
    margin-top: 2px;
    font-size: 11px;
  }

  .ft ul { margin-left: 12px; }
  .ft li { padding-left: 12px; }
  .ft li::before { width: 8px; }

  /* Tool cards */
  .tool-card { padding: 14px 16px; }
  .tool-top { font-size: 13px; flex-wrap: wrap; }

  .tool-cmd {
    font-size: 11px;
    word-break: break-all;
    overflow-wrap: anywhere;
  }

  .tool-params td:first-child { white-space: normal; }

  .tool-params table { font-size: 11px; }

  .tool-params th,
  .tool-params td { padding: 4px 6px 4px 0; }

  /* Diagrams */
  .diagram-container { padding: 16px 12px; }
  .diagram-expand-btn { padding: 4px 8px; font-size: 10px; }

  .diagram-modal__panel {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .diagram-modal__panel { flex-direction: column-reverse; }

  .diagram-modal__toolbar {
    border-bottom: none;
    border-top: 1px solid var(--border);
  }

  .diagram-modal__viewport {
    padding: 16px;
    align-items: safe center;
    justify-content: safe center;
  }
  .diagram-modal__canvas { margin: auto; }

  /* Accordion */
  .acc-summary { padding: 14px 16px; font-size: 13px; }
  .acc-body { padding: 0 16px 16px; font-size: 13px; }
  .acc-detail { padding: 10px 12px; font-size: 12px; }

  /* Data tables — horizontal scroll, no squishing */
  .section > table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .section > table::-webkit-scrollbar { display: none; }
  .section > table th,
  .section > table td { white-space: nowrap; }

  /* Workflow steps — inline text reflow */
  .wf-step {
    gap: 8px;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .wf-step code {
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}
