/* Feshar TV — the channel page. Loads style.css first for shared bits.

   A feed of loops, one card after another, with the channels along the top.
   On a phone each card fills the screen and you flick between them; on a
   desk the cards sit in a column down the middle with room beside them. */

.tv-body {
  background: var(--tv-bg);
  /* dvh, not vh: on phones vh is taller than the visible area. */
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ---------- Header ---------- */
.tv-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px 6px; flex: none; }
.tv-link.make { background: var(--yellow); white-space: nowrap; }
.view-pick { display: flex; }
.view-pick button { width: 40px; padding: 5px 0; display: flex; align-items: center; justify-content: center; }
.view-pick .ico { width: 19px; height: 19px; }

/* ---------- Search and channels ---------- */
.tv-bar { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 18px 10px; min-width: 0; }
.tv-search {
  flex: none; display: flex; align-items: center; gap: 6px; width: 230px;
  background: var(--panel); border: var(--bw-sm) solid var(--ink); border-radius: 999px;
  padding: 0 12px; height: 36px; color: var(--muted);
}
.tv-search:focus-within { color: var(--text); box-shadow: 0 0 0 2px var(--yellow); }
.tv-search .ico { width: 17px; height: 17px; flex: none; }
.tv-search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text);
  font: inherit; font-weight: var(--wt-strong); font-size: 13px;
}
.tv-search input::placeholder { color: var(--muted); }
.chan-strip {
  flex: 1; min-width: 0; display: flex; gap: 6px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chan-strip::-webkit-scrollbar { display: none; }
.chan {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  font-family: var(--font-display); font-weight: var(--wt-strong); font-size: 13px; text-transform: uppercase;
  background: var(--panel); color: var(--muted); border: var(--bw-sm) solid var(--ink);
}
.chan:hover { color: var(--text); }
.chan.on { background: var(--yellow); color: var(--ink); box-shadow: var(--sh-sm); }
.chan .n { font-size: 11px; opacity: .6; font-variant-numeric: tabular-nums; }
.chan.on .n { opacity: .75; }
:root[data-theme="newsprint"] .chan.on { background: #000; color: #fff; }
.chan.kw { color: var(--text); border-color: var(--ink); }
.chan.kw .spark { color: var(--pink); }
.chan.kw.on { background: var(--pink); color: var(--on-pink); }
.chan.kw.on .spark { color: var(--yellow); }
.chan.today { box-shadow: var(--sh-sm); }
.chan.extra { background: var(--cyan); color: var(--ink); }
.chan .x { font-size: 14px; line-height: 1; opacity: .7; margin-inline-start: 2px; }

/* The invitation to draw a word, beside that word's tag on the card. */
.tag-go {
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: var(--wt-strong);
  background: var(--yellow); color: var(--ink); border: var(--bw-sm) solid var(--ink);
}
.tag-go .ico { width: 14px; height: 14px; flex: none; }
.tag-go span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 11em; }
.tag-go:hover { filter: brightness(1.06); }
.tag-go:active { transform: translateY(var(--press)); }
:root[data-theme="newsprint"] .tag-go { background: #000; color: #fff; }

/* ---------- The feed ---------- */
.tv-main { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.feed {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  scroll-snap-type: y mandatory; scroll-padding-top: 10px;
  padding: 4px 16px 40px; display: flex; flex-direction: column; align-items: center; gap: 22px;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

/* Three columns, so the drawing sits in the middle of the screen: what the
   loop is on one side, the reactions on the other. */
.card {
  scroll-snap-align: start; scroll-snap-stop: always;
  width: 100%; max-width: 1340px; display: grid; align-items: start;
  grid-template-columns: minmax(0, 1fr) min(520px, 46vw) auto minmax(0, 1fr); gap: 18px;
}
.card-art-wrap { position: relative; max-width: 100%; justify-self: center; display: flex; order: 2; }
.card .react { order: 3; }
.card-meta { order: 1; }
/* The buttons line up with the foot of the drawing, like the words do. */
.card .react { justify-self: start; align-self: end; padding-bottom: 4px; }
/* The comments take the fourth column. With nothing in it the drawing
   sits in the middle; with comments open it shifts left, as a reel does. */
.cm-beside {
  order: 4; justify-self: start; align-self: stretch; width: 380px;
  display: flex; flex-direction: column; gap: 10px; min-height: 0;
  max-height: min(620px, calc(100dvh - 200px));
  background: var(--panel); border: var(--bw-sm) solid var(--ink); border-radius: 18px;
  padding: 12px 14px 14px; box-shadow: var(--sh-md);
}
.cm-beside .cm { flex: 1; min-height: 0; }
.cm-beside .cm-list { flex: 1; overflow-y: auto; padding-inline-end: 4px; }
.cm-beside .cm-text { font-size: 14px; }
.card-meta { justify-self: end; align-self: end; }
.card-art {
  position: relative; display: block; overflow: hidden; text-decoration: none;
  background: var(--paper); border: var(--bw) solid var(--ink); border-radius: 16px;
  box-shadow: var(--sh-lg);
}
.card-art img {
  display: block; width: auto; height: auto; object-fit: contain; background: var(--paper);
  max-width: 100%; max-height: min(620px, calc(100dvh - 200px));
}
.card-art.still img { filter: none; }
a.card-art:hover { filter: brightness(1.03); }
a.card-art:active { transform: translateY(1px); }
  /* On a phone the words go under the drawing, so top alignment is right. */
.stamp {
  position: absolute; top: 8px; inset-inline-start: 8px; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: var(--wt-strong); font-variant-numeric: tabular-nums;
  background: #fff; color: #17131f; border: var(--bw-sm) solid var(--ink); border-radius: 999px; padding: 3px 9px;
  direction: ltr; unicode-bidi: isolate;
}
.stamp .ico { width: 13px; height: 13px; }
.stamp.pick { inset-inline-start: auto; inset-inline-end: 8px; background: var(--yellow); }
.stamp.pick .ico { fill: currentColor; }
.stamp.local { top: auto; bottom: 8px; background: var(--yellow); }
.stamp.kw { top: auto; bottom: 8px; inset-inline-start: 8px; background: var(--pink); color: var(--on-pink); cursor: pointer; }
.stamp.kw:hover { filter: brightness(1.08); }
.card-tags .tag.kw { background: var(--pink); color: var(--on-pink); }

/* Reactions in a column beside the drawing. */
.react { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; }
.react-btn {
  width: 50px; height: 50px; border-radius: 50%; color: var(--text);
  background: var(--panel); border: var(--bw-sm) solid var(--ink);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--sh-sm);
}
.react-btn .ico { width: 24px; height: 24px; }
.react-btn:hover:not(:disabled) { background: var(--panel-2); }
.react-btn:active:not(:disabled) { transform: translateY(var(--press)); box-shadow: none; }
.react-btn.like.on { background: var(--pink); color: var(--on-pink); }
.react-btn.like.on .ico { fill: currentColor; }
.react-btn.up.on { background: var(--green); color: var(--on-green); }
.react-btn.down.on { background: var(--red); color: var(--strong-fg); }
.react-score {
  font-family: var(--font-display); font-weight: var(--wt-strong); font-size: 17px;
  font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate;
}

/* Who, what, and where to go next. */
.card-meta { width: max-content; max-width: 340px; display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }
.card-title { margin: 0; font-family: var(--font-display); font-weight: var(--wt-strong); font-size: 25px; line-height: 1.15; overflow-wrap: anywhere; }
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-who { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; min-width: 0; }
.card-who img { width: 40px; height: 40px; border-radius: 50%; border: var(--bw-sm) solid var(--ink); background: var(--panel-2); flex: none; object-fit: cover; }
.card-who b { font-weight: var(--wt-strong); font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-who:hover b { text-decoration: underline; }
.card-facts { margin: 0; font-size: 13px; color: var(--muted); font-weight: var(--wt-strong); }
.card-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.card-tags .tag { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-tags .tag { cursor: pointer; }
.card-tags .tag:hover { background: var(--cyan); color: var(--ink); }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.card-actions .pill-btn { height: 34px; padding: 0 12px; font-size: 12px; text-decoration: none; }
.pill-btn.danger { background: var(--red); color: var(--strong-fg); }

/* The end of a channel is an invitation, not a wall. */
.card.tail { flex-direction: column; align-items: center; gap: 12px; padding: 30px 0 20px; text-align: center; }
.tail-big { margin: 0; font-family: var(--font-display); font-weight: var(--wt-strong); font-size: 22px; }
.tail-small { margin: 0; color: var(--muted); }
.card.empty { min-height: 60vh; }

/* Which card you are on, tucked in the corner. */
.count {
  position: absolute; bottom: 12px; inset-inline-end: 16px; z-index: 5;
  font-weight: var(--wt-strong); font-size: 12px; font-variant-numeric: tabular-nums;
  direction: ltr; unicode-bidi: isolate; pointer-events: none;
  background: var(--panel); color: var(--muted); border: var(--bw-sm) solid var(--ink);
  border-radius: 999px; padding: 3px 10px;
}

/* The comment button sits with the other reactions. */
.react-btn.say .ico { fill: none; }
.cm-count { font-size: 13px; }

/* ---------- Hiding a loop ---------- */
.card-hide { background: var(--panel); color: var(--red); border: var(--bw-sm) solid var(--red); }
.card-hide:hover { background: var(--red); color: var(--strong-fg); }
.hide-modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: var(--scrim); padding: 18px; overflow: auto;
}
.hide-box {
  width: min(460px, 100%); display: flex; flex-direction: column; gap: 10px;
  background: var(--panel); border: var(--bw) solid var(--ink); border-radius: var(--r-panel);
  padding: 18px; box-shadow: var(--sh-lg);
}
.hide-box h2 { margin: 0; font-family: var(--font-display); font-weight: var(--wt-strong); font-size: 21px; }
.hide-sub { margin: 0; font-size: 13px; color: var(--muted); font-weight: var(--wt-strong); }
.hide-reasons { display: flex; flex-direction: column; gap: 6px; }
.why {
  text-align: start; padding: 9px 12px; border-radius: 12px; font-size: 14px; font-weight: var(--wt-strong);
  background: var(--panel-2); color: var(--text); border: var(--bw-sm) solid var(--ink);
}
.why:hover { filter: brightness(1.1); }
.why.on { background: var(--red); color: var(--strong-fg); }
#hide-own {
  width: 100%; resize: vertical; font: inherit; font-weight: var(--wt-body);
  background: var(--panel-2); color: var(--text);
  border: var(--bw-sm) solid var(--ink); border-radius: 12px; padding: 10px 12px;
}
#hide-own::placeholder { color: var(--muted); }
.hide-note { margin: 0; font-size: 13px; font-weight: var(--wt-strong); color: var(--red); min-height: 1em; }
.hide-acts { display: flex; gap: 8px; justify-content: flex-end; }
.hide-acts .pill-btn { height: 42px; padding: 0 16px; }

/* ---------- Grid ---------- */
.grid-wall {
  flex: 1; min-height: 0; overflow-y: auto; padding: 4px 18px 30px;
  display: grid; gap: 12px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.grid-item { background: var(--paper); border: var(--bw) solid var(--ink); border-radius: 12px; overflow: hidden; position: relative; aspect-ratio: 1; box-shadow: var(--sh-sm); }
.grid-item img { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--paper); }
.grid-item:hover { transform: translateY(-2px); }
.grid-cap {
  position: absolute; inset-inline: 0; bottom: 0; padding: 4px 8px; font-size: 11px; font-weight: var(--wt-strong);
  background: var(--ink); color: var(--paper); text-align: start;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grid-item .stamp { top: 6px; inset-inline-start: 6px; font-size: 10px; padding: 2px 7px; }

/* ---------- Narrow screens: one loop per screen, flick between them ---------- */
@media (max-width: 760px) {
  .tv-top { padding: 8px 8px 4px; gap: 4px; min-width: 0; }
  /* Five buttons and a logo do not fit a phone. The look is set once on the
     drawing page; the rest shrink to their icons. */
  .tv-top .theme-pick { display: none; }
  .tv-top .head-right { gap: 4px; min-width: 0; flex-wrap: nowrap; }
  .view-pick button { width: 34px; }
  .tv-top .auth-btn { padding: 0 12px; }
  .tv-top .wordmark { display: none; }
  .tv-link.make span { display: none; }
  /* …except where it is the whole invitation. */
  .card.tail .tv-link.make span { display: inline; }
  .tv-link.make { padding: 0 12px; }
  .tv-bar { padding: 4px 10px 8px; gap: 6px; }
  .tv-search { width: 44px; padding: 0 12px; transition: width .15s; }
  .tv-search:focus-within, .tv-search.filled { width: 170px; }
  .feed { padding: 0 8px 8px; gap: 8px; scroll-padding-top: 0; }
  /* No room for three columns on a phone: the drawing, then the words,
     with the reactions over the corner of the drawing. */
  .card { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 100%; justify-content: flex-start; }
  .card-art-wrap { order: 1; }
  .card .react { order: 2; }
  .card-meta { order: 3; justify-self: stretch; align-self: start; max-width: none; }
  .card-art-wrap { width: 100%; display: block; }
  .card-art { width: 100%; }
  .card-art img { width: 100%; max-width: none; max-height: 60vh; max-height: 60dvh; margin: 0 auto; }
  .card .react {
    position: absolute; inset-inline-end: 8px; bottom: 8px; z-index: 3; gap: 4px; align-self: auto;
  }
  .react-btn { width: 44px; height: 44px; }
  .react-score { background: var(--panel); border: var(--bw-sm) solid var(--ink); border-radius: 999px; padding: 1px 9px; font-size: 14px; }
  .card-meta { max-width: none; width: 100%; padding: 0 4px; gap: 7px; }
  .card-title { font-size: 19px; }
  .card.tail { min-height: 50vh; justify-content: center; }
  .grid-wall { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; padding: 4px 10px 20px; }
  .count { bottom: 8px; }
}
