/* thread-view.css — the reading experience itself. */

/* ---- OP panel (fixed, in the sidebar) ----
   The panel itself pins the board tag; everything else — subject, meta,
   comment, image — lives in a separately scrollable region, so a very long
   OP comment can always be scrolled and read in full instead of getting
   clipped by the sidebar's fixed height. */

.op-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.op-panel__scroll {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-right: var(--space-2xs);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.board-tag {
  text-align: left;
  font-family: var(--font-sans);
  font-size: var(--fs-label);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-md);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: color var(--duration-fast) ease;
}

.board-tag:hover {
  color: var(--color-accent);
}

.board-tag__title {
  color: var(--color-text-soft);
  font-size: 0.72rem;
}

.op-label {
  font-family: var(--font-sans);
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-2xs);
  display: flex;
  align-items: center;
  gap: 6px;
}

.op-subject {
  font-size: var(--fs-op-subject);
  font-weight: 500;
  line-height: 1.25;
  margin: 0 0 var(--space-sm);
}

.op-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.op-comment {
  font-size: var(--fs-op-comment);
  line-height: 1.55;
  color: var(--color-text-soft);
}

.op-comment--standalone {
  font-size: calc(var(--fs-op-comment) * 1.08);
  color: var(--color-text);
}

.op-panel__media {
  margin-top: var(--space-md);
  aspect-ratio: 4 / 3;
}

/* ---- Post flags ---- */

.post-flag {
  width: 16px;
  height: 12px;
  object-fit: cover;
  border-radius: 1px;
  display: inline-block;
  vertical-align: middle;
  box-shadow: 0 0 0 1px var(--color-border);
}

/* ---- Reply stream viewport ---- */

.reply-stream__viewport {
  width: 100%;
  max-width: var(--content-max-width);
  height: 100%;
  overflow: hidden;
  position: relative;
}

.reply-stream__inner {
  position: relative;
  padding: 45vh 0;
  will-change: transform;
}

/* Soft blurred depth-fade at the top/bottom of the reading column — a
   real blur (not just a color gradient) so the reply stream reads like
   it's falling away into depth, echoing the per-reply focus blur. */
.reply-stream__edge {
  position: absolute;
  left: 0;
  right: 0;
  height: 22vh;
  pointer-events: none;
  z-index: 3;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  mask-image: linear-gradient(var(--edge-direction), var(--color-bg) 0%, transparent 100%);
  -webkit-mask-image: linear-gradient(var(--edge-direction), var(--color-bg) 0%, transparent 100%);
  background: linear-gradient(var(--edge-direction), var(--color-bg) 0%, transparent 100%);
}

.reply-stream__edge--top {
  top: 0;
  --edge-direction: to bottom;
}

.reply-stream__edge--bottom {
  bottom: 0;
  --edge-direction: to top;
}

/* ---- Quote tree / threading overlay ---- */

.quote-tree {
  position: absolute;
  top: 0;
  left: -34px;
  pointer-events: none;
  overflow: visible;
}

.tree-line {
  stroke: var(--color-line);
  stroke-width: 1;
  fill: none;
}

.tree-line--spine {
  opacity: 0.7;
}

.tree-line--branch {
  opacity: 0.55;
}

.tree-line--hub {
  opacity: 0.3;
  stroke-dasharray: 2 3;
}

body.hide-tree .quote-tree {
  display: none;
}

/* ---- Individual reply ---- */

.reply {
  max-width: var(--content-max-width);
  padding: 0 var(--space-md);
  margin-bottom: var(--reply-gap);
  will-change: transform, filter, opacity, margin-left;
  transition: margin-left var(--duration-medium) var(--ease-camera);
}

/* Indentation only applies while tree mode is on — toggling it off returns
   every reply to a flat column instantly. */
body:not(.hide-tree) .reply {
  margin-left: var(--tree-indent, 0px);
}

.reply--hub-child {
  /* A subtle marker (not deep nesting) for replies inside a mass-reply
     hub, so the relationship is still visible without the layout blowing
     out sideways on a busy /v/-style thread. */
  border-left: 1px dashed var(--color-line);
  padding-left: calc(var(--space-md) - 1px);
}

body.hide-tree .reply--hub-child {
  border-left: none;
  padding-left: var(--space-md);
}

.reply__no {
  font-family: var(--font-sans);
  font-size: var(--fs-reply-no);
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  margin: 0 0 var(--space-2xs);
  display: flex;
  align-items: center;
  gap: 6px;
}

.reply__body {
  font-size: var(--fs-reply-body);
  line-height: 1.4;
  color: var(--color-text);
}

.reply__body .post-ref {
  color: var(--color-accent);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration-fast) ease;
}

.reply__body .post-ref:hover {
  border-color: var(--color-accent);
}

.reply__body .greentext {
  color: var(--color-greentext);
}

.reply__body s {
  background: var(--color-accent);
  color: var(--color-accent);
  cursor: pointer;
  border-radius: 1px;
}

.reply__body s.revealed {
  background: transparent;
  color: inherit;
}

/* Linkified / embedded external links */
.ext-link {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: var(--color-line);
  text-underline-offset: 2px;
  cursor: pointer;
  transition: text-decoration-color var(--duration-fast) ease;
}

.ext-link:hover {
  text-decoration-color: currentColor;
}

/* ---- Attached media ----
   Every attachment is framed at a consistent ratio (so the stream reads as
   an even column) and shown at full resolution, windowed-loaded near the
   focused reply. Click to expand it uncropped in the lightbox. */

.reply__media {
  margin: var(--space-md) 0 0;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 2px;
  background: var(--color-border);
  background-size: cover;
  background-position: center;
  cursor: zoom-in;
  position: relative;
}

.reply__media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-overlay);
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
}

.reply__media:hover::after {
  opacity: 0.08;
}

.reply__media-img,
.reply__media-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity var(--duration-medium) ease;
}

.reply__media.is-loaded .reply__media-img,
.reply__media video {
  opacity: 1;
}

body.hide-images .reply__media {
  display: none;
}

/* ---- Loading / error states inside the OP panel ---- */

.op-panel .loading,
.op-panel .error {
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  color: var(--color-text-muted);
}

.op-panel .error {
  color: var(--color-error);
}

.link-button {
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  color: var(--color-accent);
  text-decoration: underline;
  margin-top: var(--space-xs);
}

/* ---- Lightbox: full, uncropped media, with a cinematic expand ----
   `.lightbox__flight` is a throwaway proxy element that motion.js animates
   from the clicked thumbnail's exact screen position to the final centered
   box (transform + opacity + filter only — no layout properties are ever
   animated). `.lightbox__body` sits at the destination the whole time and
   simply crossfades in as the flight clone fades out. */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
}

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

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 9, 8, 0.92);
  opacity: 0;
}

.lightbox__flight {
  position: fixed;
  background-size: cover;
  background-position: center;
  will-change: transform, filter, opacity;
  pointer-events: none;
}

.lightbox__body {
  position: fixed;
  display: flex;
}

.lightbox__body img,
.lightbox__body video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 2px;
}

.lightbox__close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  color: #fff;
  opacity: 0.75;
  transition: opacity var(--duration-fast) ease;
  z-index: 1;
}

.lightbox__close:hover {
  opacity: 1;
}

/* ---- Embed viewer: smart link preview ---- */

.embed-viewer {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

.embed-viewer__backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-camera);
}

.embed-viewer__panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(560px, 92vw);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-camera);
}

.embed-viewer.is-open {
  pointer-events: auto;
}

.embed-viewer.is-open .embed-viewer__backdrop {
  opacity: 1;
}

.embed-viewer.is-open .embed-viewer__panel {
  transform: translateX(0);
}

.embed-viewer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.embed-viewer__host {
  font-family: var(--font-sans);
  font-size: var(--fs-label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 4px;
}

.embed-viewer__title {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--color-text);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.embed-viewer__actions {
  display: flex;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.embed-viewer__open,
.embed-viewer__close {
  color: var(--color-text-muted);
  padding: 4px;
  transition: color var(--duration-fast) ease;
}

.embed-viewer__open:hover,
.embed-viewer__close:hover {
  color: var(--color-text);
}

.embed-viewer__body {
  flex: 1;
  min-height: 0;
  position: relative;
}

.embed-viewer__frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--color-bg);
}

.embed-viewer__loading,
.embed-viewer__blocked {
  padding: var(--space-lg) var(--space-md);
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  color: var(--color-text-muted);
  text-align: center;
}

.embed-viewer__blocked-link {
  display: inline-block;
  margin-top: var(--space-sm);
  color: var(--color-accent);
  text-decoration: underline;
}
