/* ============================================================
   Dark Night Theme — Nuages de Pi
   Palette: #0f1117 deep bg · #1a1d2e surface · #4f8ef7 accent
   ============================================================ */

:root {
  --bg-deep:       #0f1117;
  --bg-surface:    #1a1d2e;
  --bg-elevated:   #242840;
  --bg-overlay:    rgba(15, 17, 23, 0.85);

  --accent:        #4f8ef7;
  --accent-dim:    rgba(79, 142, 247, 0.14);
  --accent-glow:   rgba(79, 142, 247, 0.25);
  --accent-hover:  #6ba3f9;
  --accent-active: #3a7de8;

  --text-primary:   #ffffff;
  --text-secondary: #a0aec0;
  --text-muted:     #5a6480;

  --border:         rgba(79, 142, 247, 0.22);
  --border-subtle:  rgba(255, 255, 255, 0.07);

  --shadow-sm:    0 2px 8px  rgba(0, 0, 0, 0.35);
  --shadow:       0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow:  0 0 20px   rgba(79, 142, 247, 0.18);

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;

  --ease: 0.18s ease;

  --nav-height: 56px;
  --font-mono: 'Courier New', 'Fira Code', monospace;
}

/* ── Reset & base ───────────────────────────────────────────── */

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

html {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg-deep);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Scrollbar ──────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Navigation ─────────────────────────────────────────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  padding: 0 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  user-select: none;
}

.nav-brand-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: color var(--ease), background var(--ease);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--accent-dim);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.nav-badge {
  margin-left: 8px;
}

/* ── Canvas wrapper ─────────────────────────────────────────── */

.canvas-wrapper {
  background: #090d14;
  line-height: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--border-subtle);
}

.canvas-wrapper canvas {
  display: block;
  max-width: 100%;
}

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

.page-content {
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.page-content-full {
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* ── Cards ──────────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow), var(--shadow-glow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-title-bar {
  width: 3px;
  height: 1.1rem;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

.card-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.65;
}

.card-text + .card-text { margin-top: 10px; }

/* ── Stats grid ─────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.stat-item {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  text-align: center;
  transition: border-color var(--ease);
}

.stat-item:hover { border-color: var(--border); }

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 5px;
}

/* ── Buttons ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--ease), color var(--ease),
              border-color var(--ease), box-shadow var(--ease);
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-primary:active {
  background: var(--accent-active);
  border-color: var(--accent-active);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--accent-dim);
}

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 11px 24px; font-size: 0.95rem; }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ── Controls row ───────────────────────────────────────────── */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* ── Inputs ─────────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="search"],
input[type="password"],
textarea,
select {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color var(--ease), box-shadow var(--ease);
  -webkit-appearance: none;
}

input::placeholder,
textarea::placeholder { color: var(--text-muted); }

input[type="text"]:hover,
input[type="number"]:hover,
input[type="email"]:hover,
input[type="search"]:hover,
textarea:hover,
select:hover {
  border-color: rgba(79, 142, 247, 0.35);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a0aec0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

input[type="range"] {
  background: transparent;
  -webkit-appearance: none;
  height: 4px;
  border: none;
  padding: 0;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -6px;
  box-shadow: 0 0 6px var(--accent-glow);
  transition: box-shadow var(--ease);
}

input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ── Badge / tag ────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid rgba(79, 142, 247, 0.3);
  background: var(--accent-dim);
  color: var(--accent);
}

.badge-green  { background: rgba(72,199,142,0.12); color:#48c78e; border-color:rgba(72,199,142,0.3); }
.badge-amber  { background: rgba(255,185,56,0.12);  color:#ffb938; border-color:rgba(255,185,56,0.3); }
.badge-purple { background: rgba(167,102,253,0.12); color:#a766fd; border-color:rgba(167,102,253,0.3); }

/* ── Divider ────────────────────────────────────────────────── */

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 20px 0;
}

/* ── Modals ─────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: min(520px, calc(100vw - 48px));
  box-shadow: var(--shadow), var(--shadow-glow);
  transform: translateY(16px) scale(0.97);
  transition: transform 0.22s ease;
}

.modal-backdrop.is-open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.modal-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  transition: color var(--ease), background var(--ease);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--accent-dim);
}

.modal-body {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.65;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

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

.code-block {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  line-height: 1.7;
  overflow-x: auto;
  margin-top: 14px;
}

/* ── Pi digit table ─────────────────────────────────────────── */

.pi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 12px;
}

.pi-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border-subtle);
}

.pi-table td {
  padding: 8px 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

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

.pi-table td:first-child {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 600;
}

.pi-table tr:hover td {
  background: rgba(79, 142, 247, 0.04);
}

/* ── Slider row ─────────────────────────────────────────────── */

.slider-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.slider-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  min-width: 36px;
  text-align: right;
}
