/* Loon — Stylesheet */

/* Font */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,600;1,400&family=IBM+Plex+Serif:ital,wght@0,400;0,600;0,700;1,400&display=swap');

:root {
  --bg: #faf9f7;
  --fg: #1a1a1a;
  --muted: #666;
  --accent: #4a5fd7;
  --border: #e0ddd8;
  --black: #1a1a1a;
  --white: #f0efed;
  --font-serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --font-sans: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --fg: #c8c4bc;
    --muted: #7a7770;
    --accent: #7b8fea;
    --border: #2a2926;
    --white: #1c1b19;
  }
  .syntax-keyword  { color: #a48de0; }
  .syntax-string   { color: #6ba7d4; }
  .syntax-comment  { color: #555; }
  .syntax-builtin  { color: #d4896e; }
  .syntax-number   { color: #c4a243; }
  .syntax-function { color: #7b8fea; }
  .syntax-paren    { color: #444; }
}

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

/* Base */
html { font-size: 16px; }
body {
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* Links */
a {
  color: var(--fg);
  text-decoration-color: var(--border);
  text-underline-offset: 0.15em;
  transition: color 0.15s, text-decoration-color 0.15s;
}
a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--fg);
  border-radius: 3px;
  font: 0.85rem var(--font-mono);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn:hover {
  opacity: 0.9;
  color: var(--bg);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.btn:active { transform: translateY(0); box-shadow: none; }

.btn-secondary {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 3px;
  font: 0.85rem var(--font-mono);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.btn-secondary:hover {
  border-color: var(--fg);
  background: rgba(128, 128, 128, 0.06);
  text-decoration: none;
  transform: translateY(-1px);
}
.btn-secondary:active { transform: translateY(0); }

/* Code blocks */
.code-block {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font: 0.85rem/1.7 var(--font-mono);
  color: var(--fg);
}
.code-block pre { margin: 0; font: inherit; color: inherit; }

.copyable { cursor: pointer; user-select: all; position: relative; }
.copyable:hover { border-color: var(--muted); }
.copyable.copied::after {
  content: 'copied';
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font: 0.75rem var(--font-mono);
  color: var(--muted);
}

.code-block-label {
  font: 0.78rem var(--font-mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* Syntax highlighting — muted academic palette */
.syntax-keyword  { color: #6d45c3; font-weight: 600; }
.syntax-string   { color: #2e6fad; }
.syntax-comment  { color: #9a9590; font-style: italic; }
.syntax-builtin  { color: #a0522d; font-weight: 600; }
.syntax-number   { color: #8b6914; }
.syntax-function { color: #4a5fd7; }
.syntax-paren    { color: #b0aaa2; }

/* Section labels — mono uppercase */
.section-label {
  font: 600 0.78rem var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* Editor / Playground */
.editor-wrapper {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.editor-title { font: 0.78rem var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.editor-run {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  font-family: var(--font-mono);
  transition: color 0.15s, border-color 0.15s;
}
.editor-run:hover { color: var(--fg); border-color: var(--fg); }
.editor-body { display: grid; grid-template-columns: 1fr 1fr; }
.editor-textarea {
  width: 100%;
  min-height: 300px;
  padding: 1.25rem 1.5rem;
  background: var(--white);
  color: var(--fg);
  border: none;
  outline: none;
  resize: none;
  font: 0.85rem/1.7 var(--font-mono);
  tab-size: 2;
}
.editor-body { align-items: stretch; }
.editor-body > * { min-height: 100%; }
.editor-textarea:focus { box-shadow: inset 0 0 0 1px var(--accent); }
.editor-output-panel { border-left: 1px solid var(--border); background: var(--bg); }
.editor-output-label {
  padding: 0.5rem 1rem;
  font: 0.78rem var(--font-mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.editor-output {
  padding: 1.25rem 1.5rem;
  font: 0.85rem/1.7 var(--font-mono);
  white-space: pre-wrap;
  color: var(--fg);
  min-height: 260px;
}

/* Doc Layout */
.doc-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  padding: 2rem 1.25rem;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-wordmark {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-decoration: none;
  margin-bottom: 2rem;
}
.sidebar-wordmark:hover { color: var(--accent); }

.sidebar-section { margin-bottom: 1.5rem; }

.sidebar-section-label {
  font: 600 0.7rem var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.sidebar-link {
  display: block;
  font: 0.85rem var(--font-mono);
  color: var(--fg);
  text-decoration: none;
  padding: 0.2rem 0 0.2rem 0.5rem;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.sidebar-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.sidebar-link-active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.sidebar-placeholder {
  display: block;
  font: 0.85rem var(--font-mono);
  color: var(--muted);
  opacity: 0.5;
  padding: 0.2rem 0 0.2rem 0.5rem;
  cursor: default;
}

.doc-content {
  flex: 1;
  min-width: 0;
  max-width: 720px;
  padding: 0 2rem;
  margin: 0 auto;
}

/* Home page: allow wider content for hero */
.doc-content:has(.hero) {
  max-width: 860px;
}

/* Hover */
.tour-step:hover { border-color: var(--muted); }
.card:hover { border-color: var(--muted); }

/* Nested code blocks in cards — no double border/radius */
div > .code-block:first-child {
  border-radius: 4px 4px 0 0;
  border-bottom: none;
}

/* Responsive */
@media (max-width: 800px) {
  html { font-size: 15px; }
  .editor-body { grid-template-columns: 1fr; }
  .editor-output-panel { border-left: none; border-top: 1px solid var(--border); }
  .sidebar { display: none; }
  .doc-content { padding: 0 1.5rem; }
}

/* Doc page styles */
.doc-note { margin-bottom: 1.5rem; }

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Landing page — Hero */
.hero {
  position: relative;
  min-height: 80vh;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 4rem 0;
}

.hero-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.hero-bg-snippet {
  position: absolute;
  font: 0.72rem/1.6 var(--font-mono);
  color: var(--muted);
  white-space: pre;
  opacity: 0;
}

.hero-bg-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.3rem;
  opacity: 0.6;
}

/* 8 snippets with staggered timing and varied durations */
.hero-bg-snippet--1 { top: 2%; left: 0%; animation: snippet-a 6s ease-in-out 0s infinite; }
.hero-bg-snippet--2 { top: 6%; right: 0%; animation: snippet-b 7s ease-in-out 1.5s infinite; }
.hero-bg-snippet--3 { top: 35%; left: 2%; animation: snippet-a 5.5s ease-in-out 3s infinite; }
.hero-bg-snippet--4 { top: 50%; right: 2%; animation: snippet-b 6.5s ease-in-out 2s infinite; }
.hero-bg-snippet--5 { top: 72%; left: 0%; animation: snippet-a 7s ease-in-out 4.5s infinite; }
.hero-bg-snippet--6 { bottom: 5%; right: 0%; animation: snippet-b 5s ease-in-out 1s infinite; }
.hero-bg-snippet--7 { top: 20%; right: 5%; animation: snippet-a 6s ease-in-out 3.5s infinite; }
.hero-bg-snippet--8 { top: 60%; left: 5%; animation: snippet-b 5.5s ease-in-out 5s infinite; }

@keyframes snippet-a {
  0%, 100% { opacity: 0; transform: translateY(4px); }
  15%, 85% { opacity: 0.3; transform: translateY(0); }
}
@keyframes snippet-b {
  0%, 100% { opacity: 0; transform: translateY(-4px); }
  15%, 85% { opacity: 0.3; transform: translateY(0); }
}

@media (prefers-color-scheme: dark) {
  @keyframes snippet-a {
    0%, 100% { opacity: 0; transform: translateY(4px); }
    15%, 85% { opacity: 0.22; transform: translateY(0); }
  }
  @keyframes snippet-b {
    0%, 100% { opacity: 0; transform: translateY(-4px); }
    15%, 85% { opacity: 0.22; transform: translateY(0); }
  }
}

.hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  align-items: center;
  width: 100%;
}

.hero-text {
  max-width: 480px;
}

.hero-wordmark {
  font-family: var(--font-mono);
  font-size: 5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--fg);
  line-height: 1;
  margin-bottom: 1.5rem;
}

.hero-tagline {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--fg);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.hero-sub {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 2rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.hero-install {
  margin-top: 0;
}

.hero-install .code-block {
  font-size: 0.8rem;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
}

.hero-loon {
  position: absolute;
  width: 90%;
  max-width: 800px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.09;
  pointer-events: none;
  z-index: 0;
}
@media (prefers-color-scheme: dark) {
  .hero-loon {
    filter: invert(1);
    opacity: 0.15;
  }
}

@media (max-width: 800px) {
  .hero { min-height: auto; padding: 3rem 0; }
  .hero-content { text-align: center; }
  .hero-loon { display: none; }
  .hero-wordmark { font-size: 3.5rem; }
  .hero-bg-snippet { display: none; }
}

/* Landing page — Tour sections */
.tour {
  padding: 3rem 0 2rem;
  border-top: 1px solid var(--border);
}

.tour-section {
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border);
}

.tour-section:last-child { border-bottom: none; }

.tour-section-head {
  margin-bottom: 1rem;
}

.tour-section-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.tour-section-desc {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.7;
  max-width: 540px;
  margin-bottom: 1rem;
}

.tour-section-link {
  display: inline-block;
  font: 0.82rem var(--font-mono);
  color: var(--accent);
  text-decoration: none;
}
.tour-section-link:hover { text-decoration: underline; }

.tour-section-code {
  margin-top: 1rem;
}

@media print {
  .footer, .btn, .btn-secondary { display: none; }
  body { background: white; color: black; }
}
