/* ==========================================================================
   rssnews.io workspace: featured block and right rail discovery panels
   Workspace redesign, phase 2 (2026-10-31). js/featured.js, js/rail.js.
   Spec: WORKSPACE-PHASE2-SPEC.md §4; brief §4.2, §5, §7.2, §10.2.

   Tokens only from editorial.css (--ink --muted --rule --surface --paper
   --hover --accent --font-ui --r-*) and the section dots in workspace.css.
   Loaded after editorial.css, before workspace.css.

   Layout stability: the featured container's height and the rail slots'
   heights are fixed by CSS before any data arrives; nothing inside them
   changes their outer size when it renders.
   ========================================================================== */

/* custom.css sets every p/li/span/div to 1rem/1.6. Inside these components
   they follow their parent (specificity 0,0,1, loaded later); every class
   rule below still wins. */
:where(.ws-featured, .ws-rail-panel) :is(p, li, span, div) {
  font-size: inherit;
  line-height: inherit;
}

/* ==========================================================================
   Featured: one principal story + up to three more
   ========================================================================== */
.ws-featured {
  position: relative;
  margin: 0 0 24px;
  container-type: inline-size;
  container-name: wsf;
}
.ws-featured[hidden],
.ws-featured[data-state="empty"] { display: none; }

/* Reserved height: 1+3 from 768px, the principal alone below */
@media (min-width: 768px) {
  .ws-featured { height: 312px; }
}
@media (max-width: 767px) {
  .ws-featured { height: clamp(200px, 56vw, 260px); margin-bottom: 16px; }
}

/* Before the first render: a calm placeholder in the same shape */
.ws-featured:empty::before {
  content: "";
  display: block;
  height: 100%;
  border-radius: var(--r-panel);
  background: var(--hover);
}
@media (min-width: 768px) {
  .ws-featured:empty::before {
    border-radius: 0;
    background:
      linear-gradient(var(--hover), var(--hover)) 0 0 / calc(53% - 6px) 100% no-repeat,
      linear-gradient(var(--hover), var(--hover)) 100% 0 / calc(47% - 6px) calc(33.333% - 8px) no-repeat,
      linear-gradient(var(--hover), var(--hover)) 100% 50% / calc(47% - 6px) calc(33.333% - 8px) no-repeat,
      linear-gradient(var(--hover), var(--hover)) 100% 100% / calc(47% - 6px) calc(33.333% - 8px) no-repeat;
  }
}

.wsf-grid {
  display: grid;
  grid-template-columns: minmax(0, 53fr) minmax(0, 47fr);
  gap: 12px;
  height: 100%;
}
.wsf-grid[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
/* Phones: the principal alone (the others stay in the DOM, unloaded: lazy) */
@media (max-width: 767px) {
  .wsf-grid { grid-template-columns: minmax(0, 1fr); }
  .ws-featured .wsf-side { display: none; }
}

.wsf-item {
  position: relative;
  min-width: 0;
  margin: 0;
  font-family: var(--font-ui);
}
.wsf-item p { margin: 0; }

/* The headline link covers its card: one tab stop, the headline is the name */
.wsf-link {
  color: inherit;
  text-decoration: none;
}
.wsf-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
}
.wsf-link:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.wsf-link:focus { outline: none; }
.wsf-link:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wsf-sep { margin: 0 6px; }
.wsf-section {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
}
.wsf-section .ws-dot { margin: 0 6px 0 0; }
.wsf-time,
.wsf-count,
.wsf-source { white-space: nowrap; }
.wsf-byline {
  display: flex;
  align-items: baseline;
  min-width: 0;
  overflow: hidden;
}
.wsf-byline .wsf-source {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wsf-kicker {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
}

/* ---------- Principal: picture, dark gradient under the text only ---------- */
/* The overlay is in flow at the bottom (not positioned), so the headline
   link's ::after covers the whole card; the picture sits behind it. */
.wsf-principal {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  overflow: hidden;
  border-radius: var(--r-panel);
  /* Shows when the picture fails: the overlay text stays on dark */
  background: #1C2633;
  isolation: isolate;
}
.wsf-media {
  position: absolute;
  inset: 0;
  z-index: -1;
  margin: 0;
}
.wsf-media img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}
.wsf-overlay {
  /* 36px of fade above the text; every line of text sits on >= 0.8 black
     (white text >= 9:1 whatever the picture) */
  padding: 36px 20px 16px;
  color: #FFFFFF;
  background: linear-gradient(to top,
    rgba(10, 14, 20, 0.88) 0,
    rgba(10, 14, 20, 0.8) calc(100% - 36px),
    rgba(10, 14, 20, 0) 100%);
}
.wsf-principal .wsf-kicker,
.wsf-principal .wsf-byline {
  font-size: 13px;
  line-height: 18px;
  color: rgba(255, 255, 255, 0.92);
}
.wsf-principal .wsf-title {
  margin: 4px 0 6px;
  font: 700 22px/1.25 var(--font-headline);
  letter-spacing: -0.005em;
  color: #FFFFFF;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.wsf-principal .ws-dot { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85); }
/* overflow:hidden clips anything outside the card: the ring goes inside */
.wsf-principal .wsf-link:focus-visible::after { outline-color: #FFFFFF; outline-offset: -4px; box-shadow: inset 0 0 0 6px rgba(10, 14, 20, 0.6); }

/* ---------- The others: thumb + headline + source/time ---------- */
.wsf-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  height: 100%;
}
.wsf-secondary {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  column-gap: 12px;
  align-items: start;
  border-radius: var(--r-img);
}
.wsf-thumb {
  width: 112px;
  height: 84px;
  margin: 0;
  overflow: hidden;
  border-radius: var(--r-img);
  background: var(--hover);
}
.wsf-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}
.wsf-thumb[data-failed] { display: none; }
.wsf-secondary:has(.wsf-thumb[data-failed]) { grid-template-columns: minmax(0, 1fr); }
.wsf-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: var(--ink);
}
.wsf-secondary .wsf-kicker,
.wsf-secondary .wsf-byline {
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}
.wsf-secondary .wsf-section { color: var(--ink); }
/* 3 lines fit the 96px row with the kicker and the byline (16 + 56.6 + 16 + gaps) */
.wsf-secondary .wsf-title {
  margin: 0;
  font: 600 14.5px/1.3 var(--font-headline);
  color: var(--ink);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.wsf-secondary .wsf-link:focus-visible::after { outline-offset: 3px; border-radius: var(--r-img); }

/* ---------- Bookmark toggle (phases 3-4): above the card's stretched link ---------- */
.wsf-bookmark {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.wsf-bookmark svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}
.wsf-bookmark[aria-pressed="true"] svg { fill: currentColor; }
.wsf-bookmark:focus { outline: none; }
.wsf-bookmark:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Principal: top right, on its own dark disc (white on >= 0.62 black: 6.9:1+) */
.wsf-principal .wsf-bookmark {
  top: 10px;
  right: 10px;
  color: #FFFFFF;
  background: rgba(10, 14, 20, 0.62);
}
.wsf-principal .wsf-bookmark:hover { background: rgba(10, 14, 20, 0.8); }
.wsf-principal .wsf-bookmark:focus-visible { outline-color: #FFFFFF; outline-offset: -3px; box-shadow: 0 0 0 2px rgba(10, 14, 20, 0.8); }
/* The others: at the end of the source/time line, which leaves it room */
.wsf-secondary .wsf-bookmark { right: -6px; bottom: -8px; }
.wsf-secondary .wsf-bookmark:hover { color: var(--ink); background: var(--hover); }
.wsf-secondary .wsf-bookmark[aria-pressed="true"] { color: var(--accent); }
.wsf-secondary:has(.wsf-bookmark) .wsf-byline { padding-right: 30px; }
@media (pointer: coarse) {
  .wsf-principal .wsf-bookmark { top: 4px; right: 4px; width: 44px; height: 44px; }
  .wsf-secondary .wsf-bookmark { width: 40px; height: 40px; right: -10px; bottom: -12px; }
}

/* Narrow main column (1200-1439 with both rails): smaller thumbs, smaller principal type */
@container wsf (max-width: 700px) {
  .wsf-secondary { grid-template-columns: 88px minmax(0, 1fr); column-gap: 10px; }
  .wsf-thumb { width: 88px; height: 66px; }
  .wsf-principal .wsf-title { font-size: 19px; }
  .wsf-overlay { padding: 36px 16px 14px; }
}

/* Phones: the principal alone, compact */
@media (max-width: 767px) {
  .wsf-overlay { padding: 32px 14px 12px; }
  .wsf-principal .wsf-title { font-size: 17px; line-height: 1.28; margin: 3px 0 4px; }
  .wsf-principal .wsf-kicker,
  .wsf-principal .wsf-byline { font-size: 12px; line-height: 16px; }
}

/* ==========================================================================
   Right rail panels (#right-sidebar is laid out from 1200px)
   Panels reuse workspace.css's .side-section surface; these rules sit at
   (1,2,0)+ to outrank its (1,1,1) h2/p rules.
   ========================================================================== */

/* Reserved before js/rail.js draws (first paint): the drawn panels have the
   same fixed-height structure */
#ws-rail-quicknav:empty { min-height: 336px; }
#ws-rail-sources:empty { min-height: 313px; }
#ws-rail-stories:empty { min-height: 465px; }

#right-sidebar .ws-rail-panel .ws-rail-title {
  margin: 0;
  font: 700 16px/1.3 var(--font-headline);
  color: var(--ink);
}
/* One line, always: the panels' heights are fixed */
#right-sidebar .ws-rail-panel .ws-rail-sub {
  height: 17px;
  margin: 2px 0 12px;
  overflow: hidden;
  font: 400 12.5px/17px var(--font-ui);
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
#right-sidebar .ws-rail-panel .ws-rail-sub.is-empty { visibility: hidden; }
#right-sidebar .ws-rail-panel ul,
#right-sidebar .ws-rail-panel ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- Γρήγορη πλοήγηση ---------- */
#right-sidebar .ws-qn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
#right-sidebar .ws-qn-tool { grid-column: 1 / -1; }
#right-sidebar .ws-qn-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 18px 16px;
  column-gap: 6px;
  align-items: center;
  height: 46px;
  /* 1200px: a 108px tile leaves 76px for "Τεχνολογία" (70px at 13px) */
  padding: 5px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--r-ui);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}
#right-sidebar .ws-qn-tool .ws-qn-tile {
  grid-template-rows: 34px;
  height: 40px;
  padding-top: 2px;
  padding-bottom: 2px;
}
#right-sidebar .ws-qn-tile:hover { background: var(--hover); border-color: var(--rule-strong); }
#right-sidebar .ws-qn-tile .ws-dot { grid-row: 1; margin: 0; }
#right-sidebar .ws-qn-icon {
  grid-row: 1;
  width: 14px;
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}
#right-sidebar .ws-qn-label {
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  font: 600 13px/18px var(--font-ui);
  text-overflow: ellipsis;
  white-space: nowrap;
}
#right-sidebar .ws-qn-count {
  grid-row: 2;
  grid-column: 2;
  min-height: 16px;
  font: 400 12px/16px var(--font-ui);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ---------- Πηγές ειδήσεων ---------- */
#right-sidebar .ws-src-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 28px;
  gap: 4px 8px;
}
#right-sidebar .ws-src-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 28px;
  font: 400 12.5px/18px var(--font-ui);
  color: var(--ink);
}
#right-sidebar .ws-src-item.is-skeleton::before {
  content: "";
  display: block;
  width: 70%;
  height: 12px;
  border-radius: 3px;
  background: var(--hover);
}
#right-sidebar .ws-src-fav {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--fav-plate);
}
#right-sidebar .ws-src-fav img {
  display: block;
  width: 16px;
  height: 16px;
  max-width: none;
}
#right-sidebar .ws-src-fav.is-fallback {
  background: var(--hover);
  font: 700 11px/18px var(--font-ui);
  color: var(--muted);
}
/* Each outlet links to its feed (phases 3-4) */
#right-sidebar .ws-src-link {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 28px;
  color: inherit;
  text-decoration: none;
}
#right-sidebar .ws-src-link:hover .ws-src-name { text-decoration: underline; text-underline-offset: 3px; }
#right-sidebar .ws-src-more {
  margin: 10px 0 0;
  font: 600 13px/18px var(--font-ui);
}
#right-sidebar .ws-src-all {
  display: inline-block;
  padding: 3px 0;
  color: var(--red);
  text-decoration: none;
}
#right-sidebar .ws-src-all:hover { text-decoration: underline; text-underline-offset: 3px; }
#right-sidebar .ws-src-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Ιστορίες με τις περισσότερες δημοσιεύσεις ---------- */
#right-sidebar .ws-st-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* border 1 + 8 + 38 + 2 + 16 + 8 (border-box): placeholder and data rows match */
  min-height: 73px;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
}
#right-sidebar .ws-st-item:first-child { border-top: 0; padding-top: 0; min-height: 64px; }
#right-sidebar .ws-st-item.is-skeleton::before,
#right-sidebar .ws-st-item.is-skeleton::after {
  content: "";
  display: block;
  height: 12px;
  margin: 4px 0;
  border-radius: 3px;
  background: var(--hover);
}
#right-sidebar .ws-st-item.is-skeleton::after { width: 60%; }

/* A failed endpoint keeps the panel's height (js/rail.js also pins the list to the
   height it had); these minimums are the placeholder heights: 6 x 28 + 5 x 4, and
   64 + 4 x 73 */
#right-sidebar .ws-src-list.is-failed { min-height: 188px; }
#right-sidebar .ws-st-list.is-failed { min-height: 356px; }
#right-sidebar .ws-rail-failed {
  grid-column: 1 / -1;
  font: 400 13px/18px var(--font-ui);
  color: var(--muted);
}
#right-sidebar .ws-st-link {
  min-height: 38px;
  font: 600 14px/19px var(--font-headline);
  color: var(--ink);
  text-decoration: none;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
#right-sidebar .ws-st-link:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
#right-sidebar .ws-st-count {
  font: 400 12px/16px var(--font-ui);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

@media (prefers-reduced-motion: no-preference) {
  #right-sidebar .ws-qn-tile { transition: background-color 0.12s ease, border-color 0.12s ease; }
}

@media (pointer: coarse) {
  #right-sidebar .ws-qn-tile { min-height: 46px; }
}

@media (forced-colors: active) {
  .wsf-bookmark { border: 1px solid ButtonText; color: ButtonText; background: ButtonFace; }
  .wsf-overlay { background: Canvas; color: CanvasText; }
  .wsf-principal .wsf-title,
  .wsf-principal .wsf-kicker,
  .wsf-principal .wsf-byline { color: CanvasText; }
  .wsf-link:focus-visible::after { outline-color: Highlight; }
  #right-sidebar .ws-qn-tile { border-color: CanvasText; }
}
