/* ═══════════════════════════════════════════════════
   L'Art du Prompt — Shared Stylesheet
   Each page overrides --accent, --accent-light, --accent-dark
   ═══════════════════════════════════════════════════ */

/* ── Base Variables ───────────────────────────────── */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1a1d27;
  --muted: #5c6370;
  --border: #e5e7eb;
  --code-bg: #1e1e2e;
  --code-text: #cdd6f4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

/* ── Reset ────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

.container {
  width: min(880px, 92%);
  margin: 0 auto;
}

/* ── Skip Navigation (Accessibility) ─────────────── */
.skip-nav {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 8px 8px;
  z-index: 999;
  font-size: 0.9rem;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-nav:focus {
  top: 0;
}

/* ── Header ───────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
}

nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

nav a {
  display: inline-block;
  text-decoration: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

nav a:hover, nav a:focus-visible {
  background: var(--accent-light);
  color: var(--accent);
  outline: none;
}

.nav-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* ── Theme & Search Toggles ──────────────────────── */
.theme-toggle, .search-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted);
  transition: all 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover, .search-toggle:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Sidebar TOC ──────────────────────────────────── */
.side-toc {
  position: fixed;
  top: 86px;
  right: 16px;
  width: 240px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 14px;
  z-index: 90;
}

.side-toc h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 10px;
}

.side-toc ul { list-style: none; display: grid; gap: 2px; }

.side-toc a {
  text-decoration: none;
  color: var(--muted);
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  border-left: 2px solid transparent;
  transition: all 0.2s;
}

.side-toc a:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-num {
  display: inline-block;
  width: 20px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8rem;
}

@media (max-width: 1300px) {
  .side-toc { display: none; }
}

/* ── Main ─────────────────────────────────────────── */
main { padding: 28px 0 60px; }

/* ── Hero ─────────────────────────────────────────── */
.hero {
  border-radius: 16px;
  padding: 48px 36px;
  margin-bottom: 24px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 12px;
  position: relative;
}

.hero p {
  color: rgba(255,255,255,0.88);
  font-size: 1.1rem;
  max-width: 600px;
  position: relative;
}

.hero .badge {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.hero .breadcrumb,
.nav-breadcrumb {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  position: relative;
  font-size: 0.9rem;
}

.hero .breadcrumb a,
.nav-breadcrumb a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: color 0.2s;
}

.hero .breadcrumb a:hover,
.nav-breadcrumb a:hover {
  color: #fff;
}

.hero .breadcrumb span,
.nav-breadcrumb span {
  color: rgba(255,255,255,0.4);
}

/* ── Sections ─────────────────────────────────────── */
section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  margin-bottom: 20px;
}

section h2 {
  font-size: 1.35rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

section h2 .sec-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.section-intro {
  color: var(--muted);
  margin-bottom: 20px;
  font-size: 0.97rem;
}

h3 {
  font-size: 1.05rem;
  margin: 24px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

h3:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 16px;
}

h4 {
  font-size: 0.95rem;
  margin: 16px 0 6px;
}

p, li {
  color: var(--text);
  font-size: 0.95rem;
}

ul, ol {
  padding-left: 22px;
  margin: 8px 0 12px;
}

li { margin-bottom: 4px; }

/* ── Code Blocks ──────────────────────────────────── */
pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.65;
  margin: 10px 0 14px;
  border: 1px solid #313244;
  position: relative;
}

pre .label {
  position: absolute;
  top: 8px;
  right: 10px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.5);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-family: inherit;
}

code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

:not(pre) > code {
  background: var(--accent-light);
  color: var(--accent-dark);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.87rem;
}

/* ── Prompt Cards ─────────────────────────────────── */
.prompt-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 12px 0;
  overflow: hidden;
}

.prompt-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.85rem;
}

.prompt-bad .prompt-card-header {
  background: #fef2f2;
  color: var(--danger);
  border-bottom: 1px solid #fecaca;
}

.prompt-good .prompt-card-header {
  background: #ecfdf5;
  color: var(--success);
  border-bottom: 1px solid #a7f3d0;
}

.prompt-ok .prompt-card-header {
  background: #fffbeb;
  color: var(--warning);
  border-bottom: 1px solid #fde68a;
}

.prompt-info .prompt-card-header {
  background: #eff6ff;
  color: var(--info);
  border-bottom: 1px solid #bfdbfe;
}

.prompt-card pre {
  margin: 0;
  border: none;
  border-radius: 0;
}

/* ── Callouts ─────────────────────────────────────── */
.callout {
  border-radius: 10px;
  padding: 14px 18px;
  margin: 14px 0;
  font-size: 0.92rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.callout-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }

.callout-tip {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.callout-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.callout-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.callout-important {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.callout-example {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* ── Tables ───────────────────────────────────────── */
table, .compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.9rem;
}

th, td,
.compare-table th, .compare-table td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

th, .compare-table th {
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 600;
  font-size: 0.85rem;
}

tr:nth-child(even) td,
.compare-table tr:nth-child(even) td {
  background: #fafafa;
}

/* ── Principle Grid ───────────────────────────────── */
.principle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 14px 0;
}

.principle-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  background: #fafafe;
  transition: box-shadow 0.2s;
}

.principle-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.principle-card .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.principle-card h4 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.principle-card p {
  font-size: 0.87rem;
  color: var(--muted);
}

/* ── Shortcut kbd ─────────────────────────────────── */
kbd {
  display: inline-block;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 0.82rem;
  box-shadow: 0 1px 0 #d1d5db;
  color: var(--text);
}

/* ── Level Bar (progress indicator) ───────────────── */
.level-bar {
  display: flex;
  gap: 3px;
  margin: 4px 0 8px;
}

.level-bar span {
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
}

.level-bar .filled { background: var(--accent); }

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

/* ── Use Case Card ────────────────────────────────── */
.use-case {
  border: 1px solid var(--accent-light);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  background: #f0fdf4;
}

.use-case strong {
  color: var(--accent-dark);
}

/* ── Workflow Timeline ────────────────────────────── */
.workflow-timeline {
  position: relative;
  padding-left: 32px;
  margin: 18px 0;
}

.workflow-timeline::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--accent), var(--accent-light));
  border-radius: 3px;
}

.wf-step {
  position: relative;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.wf-step::before {
  content: attr(data-step);
  position: absolute;
  left: -32px;
  top: 14px;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.wf-step h4 {
  font-size: 0.95rem;
  color: var(--accent-dark);
  margin-bottom: 6px;
}

.wf-step p, .wf-step ul {
  font-size: 0.88rem;
  color: var(--muted);
}

.wf-step ul { margin-left: 16px; margin-top: 4px; }

/* ── Before/After ─────────────────────────────────── */
.before-after {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}

.before-after > div {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.ba-header {
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ba-before .ba-header { background: #fef2f2; color: #991b1b; }
.ba-after .ba-header { background: #f0fdf4; color: #065f46; }

.before-after pre { margin: 0; border-radius: 0; font-size: 0.82rem; }

@media (max-width: 680px) {
  .before-after { grid-template-columns: 1fr; }
}

/* ── Footer ───────────────────────────────────────── */
footer {
  text-align: center;
  padding: 28px 0;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* ── Scroll to Top ────────────────────────────────── */
.scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  z-index: 80;
  transition: transform 0.2s;
}

.scroll-top:hover { transform: scale(1.1); }

/* ── Progress Bar ─────────────────────────────────── */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  z-index: 200;
  width: 0%;
  transition: width 0.1s linear;
}

/* ── Copy Button ──────────────────────────────────── */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: 'Segoe UI', system-ui, sans-serif;
  transition: all 0.2s;
  z-index: 5;
}

.copy-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.copy-btn.copied {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

/* ── Search Overlay ───────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.search-overlay.active { display: flex; }

.search-box {
  background: var(--surface);
  border-radius: 16px;
  width: min(600px, 90%);
  max-height: 70vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.search-input-wrap svg {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1.05rem;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}

.search-input::placeholder { color: var(--muted); }

.search-results {
  overflow-y: auto;
  max-height: calc(70vh - 60px);
  padding: 8px;
}

.search-result {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}

.search-result:hover, .search-result.active {
  background: var(--accent-light);
}

.search-result-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--accent);
}

.search-result-excerpt {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

.search-result-excerpt mark {
  background: #fef08a;
  color: #1a1d27;
  border-radius: 2px;
  padding: 0 2px;
}

.search-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.search-kbd {
  font-size: 0.72rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--muted);
  font-family: inherit;
}

/* ── Dark Mode ────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #181a20;
  --surface: #23262f;
  --text: #e4e6ed;
  --muted: #9ca3af;
  --border: #333842;
  --code-bg: #14141e;
  --code-text: #cdd6f4;
}

[data-theme="dark"] header {
  background: rgba(24,26,32,0.92);
}

[data-theme="dark"] .hero {
  filter: brightness(0.88);
}

[data-theme="dark"] .prompt-bad .prompt-card-header { background: #2d1b1b; border-color: #5c2626; }
[data-theme="dark"] .prompt-good .prompt-card-header { background: #1b2d22; border-color: #265c38; }
[data-theme="dark"] .prompt-ok .prompt-card-header { background: #2d2a1b; border-color: #5c5226; }
[data-theme="dark"] .prompt-info .prompt-card-header { background: #1b232d; border-color: #26425c; }

[data-theme="dark"] .callout { border-color: var(--border); }
[data-theme="dark"] .callout-tip { background: #1b2d22; }
[data-theme="dark"] .callout-warning { background: #2d2a1b; }
[data-theme="dark"] .callout-important { background: #2d1b1b; }
[data-theme="dark"] .callout-info { background: #1b232d; }

[data-theme="dark"] .side-toc { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .principle-card { background: var(--surface); }
[data-theme="dark"] tr:nth-child(even) td { background: var(--surface); }
[data-theme="dark"] .use-case { background: #1b2d22; }
[data-theme="dark"] .ba-before .ba-header { background: #2d1b1b; }
[data-theme="dark"] .ba-after .ba-header { background: #1b2d22; }
[data-theme="dark"] .before-after > div { border-color: var(--border); }
[data-theme="dark"] .wf-step { background: var(--surface); border-color: var(--border); }

[data-theme="dark"] kbd {
  background: #333842;
  border-color: #4a5060;
  box-shadow: 0 1px 0 #4a5060;
  color: var(--text);
}

/* ── Print ────────────────────────────────────────── */
@media print {
  header, .side-toc, .scroll-top, .progress-bar,
  .search-overlay, .nav-actions, .skip-nav { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; line-height: 1.5; }
  .container { width: 100%; max-width: none; }
  .hero { break-inside: avoid; padding: 20px; }
  section { break-inside: avoid; border: 1px solid #ccc; page-break-inside: avoid; }
  pre { white-space: pre-wrap; word-wrap: break-word; font-size: 9pt; }
  a { color: #000; text-decoration: underline; }
  .callout { break-inside: avoid; }
  .footer-links { display: none; }
}

/* ── Reduced Motion ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 680px) {
  .hero { padding: 32px 22px; }
  .hero h1 { font-size: 1.6rem; }
  section { padding: 20px 16px; }
  .principle-grid { grid-template-columns: 1fr; }
  nav ul { display: none; }
}
