/* Creator posts (SPEC 21): the channel's Videos / Posts tabs, post cards and their photo grids, the composer,
   the photo lightbox, the post page and Home's Posts shelf. Linked from the pages that show them; the design
   tokens (and their light-mode values) live in style.css, comment styles in style.css and comments.css. */

/* Channel tabs ------------------------------------------------------------ */

.channel-tabs { display: flex; gap: 4px; margin: -8px 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.channel-tabs a {
  padding: 10px 16px; margin-bottom: -1px; border-bottom: 2px solid transparent;
  font-weight: 700; font-size: 15px; color: var(--text-2); white-space: nowrap;
}
.channel-tabs a:hover { color: var(--text); }
.channel-tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }

/* Post cards -------------------------------------------------------------- */

.post-list { display: grid; gap: 16px; max-width: 680px; }
.post-card {
  display: grid; gap: 10px; min-width: 0; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.post-card.flash { animation: comment-flash 2.2s ease-out; }
.post-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.post-avatar { flex: none; }
.post-who { display: grid; gap: 1px; min-width: 0; }
.post-name-line { min-width: 0; overflow-wrap: anywhere; }
.post-name { font-weight: 700; }
.post-name:hover { text-decoration: underline; }
.post-meta { font-size: 13px; color: var(--text-2); }
.post-time:hover { color: var(--text); text-decoration: underline; }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.post-body.is-clamped { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 8; overflow: hidden; }
.post-body a { font-weight: 600; color: var(--accent-text); }
.post-body a:hover { text-decoration: underline; }
.post-more { justify-self: start; margin-top: -4px; font-size: 14px; font-weight: 700; color: var(--text-2); }
.post-more:hover { color: var(--text); text-decoration: underline; }
.post-full { padding: 20px 22px; }
.post-full .post-body { font-size: 16px; }

/* 1 photo: full width (a tall one is capped and letterboxed); 2: side by side; 3: one large + two small; 4: 2 x 2 */
.post-photos { display: grid; gap: 4px; border-radius: 10px; overflow: hidden; }
.post-photo {
  display: block; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 0;
  background: var(--surface-2); cursor: zoom-in;
}
.post-photo img { width: 100%; height: 100%; object-fit: cover; }
.post-photo:focus-visible { outline-offset: -3px; }
.photos-1 .post-photo img { height: auto; max-height: min(75vh, 640px); object-fit: contain; }
.photos-2 { grid-template-columns: 1fr 1fr; aspect-ratio: 16 / 10; }
.photos-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 16 / 10; }
.photos-3 .post-photo:first-child { grid-row: span 2; }
.photos-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 1 / 1; max-height: 680px; }

.post-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 2px 0 -6px -8px; }
.post-actions[hidden] { display: none; }
.post-react { display: inline-flex; align-items: center; }
.post-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 10px;
  border: 0; border-radius: 999px; background: none; color: var(--text-2);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.post-btn:hover { background: var(--surface-2); color: var(--text); }
.post-btn[aria-pressed="true"] { color: var(--accent-text); }
.post-btn[aria-pressed="true"] .icon-thumbs-up, .post-btn[aria-pressed="true"] .icon-thumbs-down { fill: currentColor; }
.post-btn:disabled { opacity: 0.55; cursor: default; }
.post-btn:disabled:hover { background: none; color: var(--text-2); }
.post-react[aria-busy="true"] .post-btn, .post-btn[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.post-count { font-variant-numeric: tabular-nums; }
.post-count:empty { display: none; }
.post-del:hover { background: var(--accent-soft); color: var(--danger-text); }

.post-edit-form { display: grid; gap: 10px; }
.post-edit-form textarea {
  display: block; width: 100%; min-height: 110px; padding: 11px 13px; resize: vertical;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.post-edit-form textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.post-edit-form .form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.post-list-more { margin-top: 16px; }
.post-list-more[aria-busy="true"] { opacity: 0.7; cursor: progress; }

/* Composer ---------------------------------------------------------------- */

.post-composer {
  display: grid; gap: 12px; max-width: 680px; margin-bottom: 20px; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.composer-main { display: flex; gap: 12px; }
.composer-main > .avatar { margin-top: 2px; }
.composer-field { flex: 1; min-width: 0; }
.composer-field textarea {
  display: block; width: 100%; min-height: 84px; padding: 10px 12px; resize: vertical;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.composer-field textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.composer-photos { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.composer-photo {
  display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.composer-thumb { display: grid; place-items: center; width: 88px; height: 88px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.composer-thumb img { width: 100%; height: 100%; object-fit: cover; }
.composer-thumb img:not([src]) { visibility: hidden; }
.composer-photo.is-preparing .composer-thumb { animation: composer-pulse 1.2s ease-in-out infinite; }
@keyframes composer-pulse { 50% { opacity: 0.55; } }
.composer-alt label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; }
.composer-alt input {
  display: block; width: 100%; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.composer-alt input:focus { border-color: var(--focus); }
.composer-remove { align-self: start; }
.composer-drop {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px;
  border: 1px dashed var(--line); border-radius: 10px;
}
.post-composer.drag .composer-drop { border-color: var(--accent); background: var(--accent-soft); }
.composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.composer-actions .btn[aria-disabled="true"] { opacity: 0.5; cursor: progress; } /* posting: still focusable */
.composer-status:empty { display: none; }

/* Lightbox ---------------------------------------------------------------- */

.lightbox {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: rgba(0, 0, 0, 0.94); color: #fff; overflow: hidden; overscroll-behavior: contain;
}
/* The page behind stays where it was: a swipe or the mouse wheel on a photo doesn't scroll the feed */
html:has(.lightbox[open]) { overflow: hidden; }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.94); }
.lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 16px; }
.lightbox-count { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lightbox .icon-btn { color: #fff; }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.lightbox-stage {
  display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; align-items: center; gap: 10px;
  min-height: 0; margin: 0; padding: 0 12px 16px; touch-action: pan-y; user-select: none;
}
.lightbox-stage img { max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; }
.lightbox-caption { max-width: 70ch; color: rgba(255, 255, 255, 0.85); font-size: 14px; text-align: center; overflow-wrap: anywhere; }
.lightbox-nav { position: absolute; top: 50%; width: 48px; height: 48px; margin-top: -24px; background: rgba(0, 0, 0, 0.55); }
.lightbox button.lightbox-nav { background: rgba(0, 0, 0, 0.55); }
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }

/* Post page --------------------------------------------------------------- */

.post-page-main { display: grid; gap: 8px; max-width: 720px; margin: 0 auto; }
.post-page-main .post-list, .post-page-main .post-card { max-width: none; }

/* Home: Posts shelf ------------------------------------------------------- */

.posts-shelf { margin-bottom: 30px; }
.posts-shelf .section-title { display: flex; align-items: center; gap: 8px; }
.posts-shelf-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.post-tile {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.post-tile-link { display: grid; gap: 8px; min-width: 0; }
.post-tile-link:hover .post-tile-text { text-decoration: underline; }
.post-tile-photo { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.post-tile-photo img { width: 100%; height: 100%; object-fit: cover; }
.post-tile-extra {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.78); color: #fff; font-size: 13px; font-weight: 700;
}
.post-tile-text {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; overflow: hidden;
  white-space: pre-line; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.45;
}
.post-tile-text.with-photo { -webkit-line-clamp: 2; }
.post-tile-by { display: flex; align-items: center; gap: 8px; margin-top: auto; font-size: 13px; min-width: 0; }
.post-tile-who { display: grid; min-width: 0; }
.post-tile-name-line { min-width: 0; overflow-wrap: anywhere; }
.post-tile-name { font-weight: 700; }
.post-tile-time { color: var(--text-2); }
.post-tile-stats { display: flex; gap: 14px; color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.post-tile-stats > span { display: inline-flex; align-items: center; gap: 4px; }

/* NoRep Studio › Posts ---------------------------------------------------- */

.studio-composer { margin-bottom: 18px; }
.studio-composer .post-composer { max-width: none; margin: 0; padding: 0; border: 0; background: none; }
.studio-post-thumb .thumb-fallback { color: rgba(255, 255, 255, 0.85); }

@media (max-width: 720px) {
  /* The shelf scrolls sideways on phones instead of stacking four tall cards */
  .posts-shelf-row {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(240px, 80%);
    position: relative; /* keeps the tiles' .visually-hidden text from widening the page */
    overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px;
  }
  .post-tile { scroll-snap-align: start; }
  .post-card { padding: 14px; }
  .post-full { padding: 16px; }
  .post-composer { padding: 14px; }
  .composer-main > .avatar { display: none; }
  .composer-photo { grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; }
  .composer-thumb { width: 64px; height: 64px; }
  .lightbox-nav { top: auto; bottom: 14px; margin-top: 0; }
  .lightbox.has-nav .lightbox-stage { padding-bottom: 76px; } /* the photo's description stays above the buttons */
}

@media (max-width: 480px) {
  .post-btn { padding: 6px 8px; }
  .composer-actions .btn { flex: 1 1 auto; }
}
