/* ============================================================================
   câmara escura — folha de estilo (tema pitch-black, layout compacto)
   ============================================================================ */

:root {
  --bg: #000000;
  --surface: #0d0d0d;
  --surface-2: #161616;
  --line: #2a2a2a;
  --line-soft: rgba(255, 255, 255, 0.08);
  --ink: #ffffff;
  --ink-dim: #c0c0c0;
  --ink-faint: #888888;
  --safelight: #5b9bd5;
  --safelight-glow: rgba(91, 155, 213, 0.55);
  --safelight-glow-soft: rgba(91, 155, 213, 0.22);
  --radius: 3px;
  --indent-step: 20px;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Karla', sans-serif;
  line-height: 1.6;
}
.page {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) 1.5rem 6rem;
}
a, button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--safelight); outline-offset: 3px; }

/* 3. CABEÇALHO */
.site-header { margin-bottom: clamp(2.5rem, 6vw, 4.5rem); }
.mark { display: flex; align-items: baseline; gap: 0.65rem; }
.mark-glow {
  width: 9px; height: 9px; border-radius: 50%; background: var(--safelight);
  box-shadow: 0 0 10px 2px var(--safelight-glow), 0 0 26px 8px var(--safelight-glow-soft);
  flex: none; transform: translateY(-4px);
}
@media (prefers-reduced-motion: no-preference) {
  .mark-glow { animation: flicker 1.8s ease-out both; }
}
@keyframes flicker { 0%{opacity:.25} 7%{opacity:1} 9%{opacity:.35} 13%{opacity:1} 100%{opacity:1} }
.mark h1 {
  font-family: 'Newsreader', serif; font-style: italic; font-weight: 500;
  font-size: clamp(1.6rem, 4vw, 2.1rem); margin: 0; letter-spacing: 0.01em;
}
.tagline {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.78rem; color: var(--ink-faint);
  margin: 0.65rem 0 0; letter-spacing: 0.01em; max-width: 34ch;
}
.eyebrow {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--ink-faint); margin: 0 0 1.1rem;
  padding-bottom: 0.9rem; border-bottom: 1px solid var(--line-soft);
}
.frame-tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem;
  color: var(--safelight); letter-spacing: 0.03em;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color .2s ease;
}
.frame-tag:hover {
  color: var(--ink);
}

/* 4. IMAGENS */
.thumb, .op-image, .reply-image {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
}
.thumb img, .op-image img, .reply-image img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.thumb::after, .op-image::after, .reply-image::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: .45;
  pointer-events: none;
}
.tone-sepia  { background: linear-gradient(150deg, #2a2a2a, #3a3a3a 45%, #1a1a1a); }
.tone-forest { background: linear-gradient(150deg, #1a2a1a, #2a3a2a 45%, #0d1a0d); }
.tone-dust   { background: linear-gradient(150deg, #2a1a2a, #3a2a3a 45%, #1a0d1a); }

.thumb {
  aspect-ratio: 4 / 5;
  transition: box-shadow .25s ease, transform .25s ease;
  display: flex;
  align-items: flex-end;
  padding: 0.6rem;
}
.thumb .frame-tag {
  position: relative; z-index: 1;
  background: rgba(0,0,0,0.6);
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
}
.op-image {
  aspect-ratio: 16 / 10;
  max-width: 480px;
  margin-bottom: 1rem;
}

/* ========== MINIATURAS E LIGHTBOX ========== */
.reply-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}
.thumb-item {
  background: none;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  width: 48px;
  height: 48px;
  flex: none;
  transition: box-shadow .2s ease, transform .2s ease;
}
.thumb-item:hover,
.thumb-item:focus-visible {
  box-shadow: 0 0 0 1px var(--safelight-glow-soft), 0 4px 10px -4px rgba(0,0,0,.6);
  transform: translateY(-1px);
}
.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#lightbox-modal[hidden] {
  display: none;
}
.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
}
.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 1;
}
.lightbox-content img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line);
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--line-soft);
  color: var(--ink);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: background .2s ease, color .2s ease;
  z-index: 2;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(91,155,213,0.8);
  color: #fff;
}
.lightbox-close {
  top: -10px;
  right: -10px;
}
.lightbox-prev {
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
}
.lightbox-next {
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
}

/* 5. CATÁLOGO */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.6rem 1.4rem;
}
.thread-card {
  background: none; border: none; padding: 0; text-align: left;
  color: inherit; cursor: pointer; display: block; width: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  .thread-card { animation: riseIn .5s ease both; }
  .thread-card:nth-child(2) { animation-delay: .06s; }
  .thread-card:nth-child(3) { animation-delay: .12s; }
}
@keyframes riseIn { from{opacity:0; transform:translateY(8px)} to{opacity:1; transform:translateY(0)} }
.thread-card:hover .thumb,
.thread-card:focus-visible .thumb {
  box-shadow: 0 0 0 1px var(--safelight-glow-soft), 0 10px 26px -14px rgba(0,0,0,.7);
  transform: translateY(-2px);
}
.thread-card h3 {
  font-family: 'Newsreader', serif; font-weight: 500; font-size: 1.05rem;
  margin: 0.85rem 0 0.3rem; line-height: 1.35;
}
.thread-card .meta {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem;
  color: var(--ink-faint); margin: 0;
}

/* 6. THREAD */
.back-link {
  background: none; border: none; color: var(--ink-dim);
  font-family: 'IBM Plex Mono', monospace; font-size: 0.78rem;
  cursor: pointer; padding: 0.3rem 0; margin-bottom: 2rem;
  display: inline-block; transition: color .2s ease;
}
.back-link:hover { color: var(--safelight); }
#thread-view[hidden], #catalog-view[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  #thread-view, #catalog-view { animation: fadeInUp .35s ease both; }
}
@keyframes fadeInUp { from{opacity:0; transform:translateY(6px)} to{opacity:1; transform:translateY(0)} }
.op { padding-bottom: 2rem; border-bottom: 1px solid var(--line-soft); }
.op-top { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 0.9rem; }
.op-top time { font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem; color: var(--ink-faint); }
.op h2 {
  font-family: 'Newsreader', serif; font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 2rem); margin: 0 0 1rem; line-height: 1.3;
}
.op p, .reply-card p { margin: 0; font-size: 0.98rem; color: var(--ink); }

/* 7. RESPOSTAS */
.replies { margin-top: 2.25rem; }

.reply-row {
  margin-bottom: 1.85rem;
  position: relative;
}

.reply-card {
  margin-left: calc(var(--depth, 0) * var(--indent-step));
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.1rem 1.05rem;
  position: relative;
  z-index: 1;
}

/* NOVO: contêiner flex para os itens superiores */
.reply-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.parent-header {
  font-family: 'Karla', sans-serif;
  font-style: italic;
  font-size: 0.85rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: color .2s ease;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.parent-header:hover {
  color: var(--ink) !important;
}

.reply-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}
.reply-meta time {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: var(--ink-faint);
}

/* contador de respostas */
.reply-count-btn {
  background: none;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--safelight);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  padding: 0.15rem 0.6rem;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
  white-space: nowrap;
}
.reply-count-btn:hover {
  background: var(--safelight-glow-soft);
  color: var(--ink);
}

.footnote {
  font-family: 'Newsreader', serif; font-style: italic; font-size: 0.88rem;
  color: var(--ink-faint); margin-top: 2.75rem; padding-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
}

/* 8. TELA PEQUENA */
@media (max-width: 480px) {
  :root { --indent-step: 14px; }
  .reply-card { padding: 1rem; }
  .parent-header { font-size: 0.8rem; }
  .thumb-item {
    width: 40px;
    height: 40px;
  }
  .reply-top {
    gap: 0.4rem;
  }
}