/* [r17 2026-11-14] pop_compact_v1 - '리서치 인기 종목' one-line items (front page /, /research strip).
   Owner feedback: the 5-across card strip squeezed the stock name away (721-1023px), and on the phone each card took
   three lines ('1 / 현대차 / 새 리포트 1') with only 2.5 cards in view.
   1 the name comes first: it never keeps fewer than 6 Korean characters; rank, change mark and badge give way first.
   2 one line per item: [rank] [name] [change] [badge]; the badge is full ('새 리포트 N') in a wide item and short ('새 N')
     in a narrow one - decided by the item's own width (container query), media-query fallback below.
   3 columns follow the width of the block (1 / 2 / 4 / 5), all 10 at once, no carousel, the pager is hidden.
     2 columns read top-down (1-5 | 6-10), 4 and 5 columns read across.
   4 the desktop side panel (>=1024, 352px column) keeps its 5-row pages and its working pager; only the item line changes.
   Linked only when the flag pop_compact_v1 is on (ui_simple_heads_v1.py). Role tokens only - light and dark alike.
   No inline sizes are relied on, so the 5-minute refresh (track.innerHTML) keeps the same layout. */

html body.ui-v5 .v6-pop:not(.v6-pop-daily){container:pc1pop / inline-size}
html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-item{container:pc1item / inline-size}

/* ---- the item line (every width, every form) ---- */
html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-a{display:flex;flex-wrap:nowrap;align-items:center;gap:6px;min-height:40px;padding:6px 4px;min-width:0;box-sizing:border-box}
html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-a:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;border-radius:6px}
html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-rank{order:1;flex:0 0 auto;min-width:1.5em}
html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-name{order:2;flex:1 1 auto;min-width:min(6.6em, 100%);font-size:15px;line-height:1.35;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;-webkit-line-clamp:unset}
html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-d{order:3;flex:0 0 auto;min-width:1.7em;margin-left:0;text-align:right;white-space:nowrap}
html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new{order:4;flex:0 1 auto;min-width:0;overflow:hidden;white-space:nowrap}
html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-src{order:5}
/* the pager hides itself when both buttons are disabled (all rows fit) - visibility keeps the head row height */
html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-nav:has(> .v6-pop-btn[data-dir="-1"]:disabled):has(> .v6-pop-btn[data-dir="1"]:disabled){visibility:hidden}

/* ---- grid form: every width below the desktop side panel, and any block 600px or wider (the /research strip) ---- */
@media (max-width:1023.98px){
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-track{display:grid;grid-auto-flow:row;grid-template-columns:minmax(0,1fr);grid-template-rows:none;grid-auto-columns:auto;column-gap:16px;row-gap:0;margin:0;padding:0;overflow:visible;scroll-snap-type:none;border-top:1px solid var(--line)}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-item{border:0;border-bottom:1px solid var(--line-soft);border-radius:0;background:transparent;scroll-snap-align:none}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-nav{display:none}
}
@container pc1pop (min-width:600px){
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-track{display:grid;grid-auto-flow:row;grid-template-columns:minmax(0,1fr);grid-template-rows:none;grid-auto-columns:auto;column-gap:16px;row-gap:0;margin:0;padding:0;overflow:visible;scroll-snap-type:none;border-top:1px solid var(--line)}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-item{border:0;border-bottom:1px solid var(--line-soft);border-radius:0;background:transparent;scroll-snap-align:none}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-nav{display:none}
}
/* columns by the block's own width: 2 (top-down) from 320px, 4 from 796px, 5 from 999px; below 320px one column */
@media (max-width:1023.98px){
  @container pc1pop (min-width:320px){
    html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-track{grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:repeat(5,auto);grid-auto-flow:column;column-gap:12px}
  }
}
@container pc1pop (min-width:796px){
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-track{grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:none;grid-auto-flow:row;column-gap:16px}
}
@container pc1pop (min-width:999px){
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-track{grid-template-columns:repeat(5,minmax(0,1fr))}
}

/* ---- narrow item: short badge '새 N', tighter line (the number comes from data-n, added with the stylesheet link) ---- */
@container pc1item (max-width:239.98px){
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-a{gap:4px;padding:6px 2px}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-rank{min-width:1.25em;font-size:12.5px}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-name{font-size:14px}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-d{min-width:0;font-size:11.5px}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-d.new{font-size:10px;letter-spacing:0}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new{font-size:0;padding:0 4px;line-height:18px}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new::after{content:"새";content:"새" / "";font-size:10.5px;color:var(--fg-2)}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new[data-n]::after{content:"새 " attr(data-n);content:"새 " attr(data-n) / ""}
}

/* ---- very narrow item (2 columns on a 360-375px phone): the badge becomes a small round number, gaps tighten ---- */
@container pc1item (max-width:179.98px){
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-a{gap:3px}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new{flex:0 0 auto;min-width:16px;padding:0 3px;border:0;border-radius:999px;background:var(--accent-tint);line-height:16px;text-align:center;box-sizing:border-box}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new::after{content:"";font-size:10px;font-weight:700;color:var(--accent)}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new[data-n]::after{content:attr(data-n);content:attr(data-n) / ""}
  html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new:not([data-n]){min-width:8px;width:8px;height:8px;padding:0}
}

/* ---- fallback for browsers without container queries: decided by the page width ---- */
@supports not (container-type:inline-size){
  @media (max-width:720px){
    html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-track{grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:repeat(5,auto);grid-auto-flow:column;column-gap:12px}
    html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-a{gap:4px;padding:6px 2px}
    html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-name{font-size:14px}
    html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new{font-size:0;padding:0 4px;line-height:18px}
    html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new::after{content:"새";font-size:10.5px;color:var(--fg-2)}
    html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-new[data-n]::after{content:"새 " attr(data-n)}
  }
  @media (min-width:721px) and (max-width:1023.98px){
    html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-track{grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:repeat(5,auto);grid-auto-flow:column;column-gap:16px}
  }
  @media (max-width:359.98px){
    html body.ui-v5 .v6-pop:not(.v6-pop-daily) .v6-pop-track{grid-template-columns:minmax(0,1fr);grid-template-rows:none;grid-auto-flow:row}
  }
}
