/* ==========================================================================
   Blog Post — Layout article, TOC, Code
   Style: Cyberpunk Terminal
========================================================================== */

.container {
  width: min(1600px, calc(100% - 64px));
  max-width: unset;
  padding-top: 36px;
  padding-bottom: 80px;
}

/* =========================
   Layout 2 colonnes
========================= */
.layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

/* =========================
   TOC
========================= */
.toc {
  position: sticky;
  top: var(--sticky-top);
  align-self: flex-start;
  max-height: calc(100vh - var(--sticky-top) - 24px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.toc-inner {
  border: 1px solid var(--border-mid);
  background: var(--panel);
  padding: 20px;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  position: relative;
}

/* Coin décoratif */
.toc-inner::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 12px; height: 12px;
  border-bottom: 1px solid var(--neon-cyan);
  border-left: 1px solid var(--neon-cyan);
  background: var(--panel);
}

.toc-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan);
  margin-bottom: 14px;
}

.toc-title::before { content: "// "; }

html[data-theme="light"] .toc-title { color: var(--neon-yellow); text-shadow: 0 0 4px var(--neon-yellow); }
html[data-theme="light"] .toc-inner::before { border-color: var(--neon-yellow); }

.toc-nav { display: flex; flex-direction: column; gap: 2px; }

.toc-link {
  display: block;
  text-decoration: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 6px 10px;
  border-left: 2px solid transparent;
  transition: color 150ms ease-out, border-left-color 150ms ease-out, background 150ms ease-out, text-shadow 150ms ease-out;
}

.toc-link:hover {
  color: var(--text);
  background: var(--panel2);
  border-left-color: var(--border-mid);
}

.toc-link.is-active {
  color: var(--neon-cyan);
  border-left-color: var(--neon-cyan);
  background: var(--accent-dim);
  text-shadow: 0 0 6px var(--neon-cyan);
  font-weight: 600;
}

html[data-theme="light"] .toc-link.is-active {
  color: var(--neon-yellow);
  border-left-color: var(--neon-yellow);
  text-shadow: none;
}

/* =========================
   Article
========================= */
.post { min-width: 0; width: 100%; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================
   Post header
========================= */
.post-header {
  margin-bottom: 36px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
  animation: fadeInUp 400ms cubic-bezier(0.0, 0.0, 0.2, 1) both;
  position: relative;
}

.post-header::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--neon-cyan);
  box-shadow: 0 0 8px var(--neon-cyan);
}

html[data-theme="light"] .post-header::after { background: var(--neon-yellow); box-shadow: 0 0 6px var(--neon-yellow); }

.post-header h1 {
  font-family: var(--font-heading);
  font-size: clamp(24px, 3.5vw, 38px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--text);
  margin-bottom: 20px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 12px;
  border: 1px solid var(--border-mid);
  color: var(--muted);
  background: var(--panel);
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 0 100%);
}

/* =========================
   Sections
========================= */
.section {
  margin-top: 20px;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 28px 32px;
  animation: fadeInUp 400ms cubic-bezier(0.0, 0.0, 0.2, 1) both;
  scroll-margin-top: calc(var(--sticky-top) + 16px);
  transition: border-color 200ms ease-out, box-shadow 200ms ease-out;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  position: relative;
}

/* Coin décoratif sur chaque section */
.section::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 12px; height: 12px;
  border-bottom: 1px solid var(--border-mid);
  border-left: 1px solid var(--border-mid);
  background: var(--panel);
  transition: border-color 200ms ease-out;
}

.section:hover {
  border-color: var(--border-mid);
  box-shadow: 0 0 20px rgba(0,229,255,0.04);
}

.section:hover::before {
  border-color: var(--neon-cyan);
}

html[data-theme="light"] .section:hover::before { border-color: var(--neon-yellow); }

.section h2 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section h2::before {
  content: "//";
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan);
  font-weight: 400;
  flex-shrink: 0;
}

html[data-theme="light"] .section h2::before { color: var(--neon-yellow); text-shadow: none; }

.section h3 {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--neon-yellow);
  margin: 24px 0 12px;
}

html[data-theme="light"] .section h3 { color: var(--neon-cyan); }

.section p, .section li {
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--muted);
}

.section li { margin-bottom: 6px; }

.section ul, .section ol { padding-left: 20px; }

.section :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-raised);
  color: var(--neon-cyan);
  padding: 2px 7px;
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
}

html[data-theme="light"] .section :not(pre) > code { color: var(--neon-yellow); }

/* =========================
   Liens
========================= */
a {
  color: var(--neon-cyan);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 150ms ease-out, text-shadow 150ms ease-out;
}

a:hover {
  color: var(--neon-yellow);
  text-shadow: 0 0 6px var(--neon-yellow);
}

html[data-theme="light"] a { color: var(--neon-cyan); }
html[data-theme="light"] a:hover { color: var(--neon-yellow); text-shadow: none; }

.links { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.links li { font-size: 15px; color: var(--muted); }

/* =========================
   Callouts
========================= */
.callout {
  margin: 24px 0;
  border-left: 3px solid var(--border-mid);
  background: var(--bg-raised);
  padding: 16px 20px;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
}

.callout__title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
  color: var(--text);
}

.callout--tip {
  border-left-color: var(--neon-cyan);
  box-shadow: inset 0 0 20px rgba(0,229,255,0.04);
}

.callout--warn {
  border-left-color: var(--neon-yellow);
  box-shadow: inset 0 0 20px rgba(252,238,10,0.04);
}

.callout p, .callout li, .callout ul {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
}

/* =========================
   Blocs de code
========================= */
.codeblock {
  position: relative;
  margin: 20px 0;
  border: 1px solid rgba(0,229,255,0.15);
  background: #020408;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,229,255,0.05);
  overflow: hidden;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
}

html[data-theme="light"] .codeblock {
  border: 1px solid rgba(0,104,136,0.2);
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}

/* Étiquette langue */
.codeblock::before {
  content: attr(data-lang);
  position: absolute;
  top: 10px;
  left: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan);
  pointer-events: none;
  opacity: 0.7;
}

/* Ligne de séparation header/code */
.codeblock::after {
  content: "";
  position: absolute;
  top: 34px;
  left: 0;
  width: 100%;
  height: 1px;
  background: rgba(0,229,255,0.1);
}

.codeblock__copy {
  position: absolute;
  top: 6px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid rgba(0,229,255,0.2);
  background: rgba(0,229,255,0.05);
  color: rgba(0,229,255,0.7);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 150ms ease-out, border-color 150ms ease-out, background 150ms ease-out, box-shadow 150ms ease-out;
}

.codeblock__copy:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(0,229,255,0.1);
  box-shadow: 0 0 8px rgba(0,229,255,0.2);
}

.codeblock__copy.is-copied {
  border-color: var(--neon-green);
  color: var(--neon-green);
  text-shadow: 0 0 6px var(--neon-green);
  background: rgba(0,255,159,0.05);
}

.codeblock__pre {
  margin: 0;
  padding: 44px 20px 20px;
  overflow-x: auto;
}

.codeblock__pre code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  color: inherit;
  background: transparent;
  padding: 0;
  border: none;
}

.codeblock__pre code.hljs { background: transparent !important; padding: 0 !important; color: inherit; }

.codeblock__pre::-webkit-scrollbar { height: 5px; }
.codeblock__pre::-webkit-scrollbar-thumb { background: rgba(0,229,255,0.2); }
.codeblock__pre::-webkit-scrollbar-track { background: transparent; }

pre:not(.codeblock__pre) {
  background: #020408;
  border: 1px solid rgba(0,229,255,0.1);
  padding: 18px 20px;
  margin: 18px 0;
  overflow-x: auto;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
}

pre:not(.codeblock__pre) code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  background: transparent;
  border: 0;
  padding: 0;
  color: #c8e6ea;
}

/* =========================
   Bouton retour en haut
========================= */
#backToTop {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 250ms ease-out, transform 250ms ease-out, visibility 250ms ease-out, box-shadow 150ms ease-out;
  background: var(--panel);
  border: 1px solid var(--border-mid);
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
}

#backToTop.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#backToTop:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
  transform: translateY(-2px);
}

/* =========================
   Post footer
========================= */
.post-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted2);
  letter-spacing: 0.05em;
}

/* =========================
   Commentaires
========================= */
.comments-section {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.comments-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 24px;
}

.comments-title {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent);
  margin: 0;
}

.comments-count {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--muted);
}

.comments-empty {
  font-size: .9rem;
  color: var(--muted2);
  margin-bottom: 32px;
}

.comment {
  border-left: 2px solid var(--border);
  padding: 12px 18px;
  margin-bottom: 16px;
  background: var(--bg-raised);
  border-radius: 0 6px 6px 0;
}

.comment-meta {
  display: flex;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 8px;
}

.comment-author {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--accent);
  font-weight: 600;
}

.comment-date {
  font-size: .75rem;
  color: var(--muted2);
}

.comment-body {
  font-size: .9rem;
  color: var(--fg);
  line-height: 1.6;
}

.comment-body p { margin: 0 0 6px; }

/* Alertes */
.comment-alert {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: .85rem;
  font-family: var(--font-mono);
  margin-bottom: 20px;
  border: 1px solid;
}
.comment-alert--ok      { color: #4ade80; border-color: #4ade8040; background: #4ade8010; }
.comment-alert--pending { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.comment-alert--rejected { color: var(--neon-pink); border-color: color-mix(in srgb, var(--neon-pink) 30%, transparent); background: color-mix(in srgb, var(--neon-pink) 5%, transparent); }

/* Formulaire */
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 32px;
}

.comment-input,
.comment-textarea {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: .85rem;
  padding: 10px 14px;
  box-sizing: border-box;
  transition: border-color .2s;
  outline: none;
  resize: vertical;
}

.comment-input:focus,
.comment-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}

.comment-form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.comment-hint {
  font-size: .75rem;
  color: var(--muted2);
  font-family: var(--font-mono);
}

.comment-submit {
  padding: 8px 24px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: .85rem;
  cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s;
  white-space: nowrap;
}

.comment-submit:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 50%, transparent);
}

/* =========================
   Responsive
========================= */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .toc {
    position: relative;
    top: auto;
    max-height: none;
  }

  .toc-inner {
    clip-path: none;
  }

  .toc-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .toc-link {
    border-left: none;
    border: 1px solid var(--border);
    font-size: 11px;
    padding: 4px 10px;
    clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 0 100%);
  }

  .toc-link.is-active {
    border-color: var(--neon-cyan);
    border-left-color: var(--neon-cyan);
    background: var(--accent-dim);
  }

  .section { padding: 20px 18px; }

  .post-header h1 { font-size: 22px; }
}
