/* stat/news.css - Teljes CSS a híránytű oldalhoz */

/* === CSS VÁLTOZÓK === */
/* === LIGHT MODE (default) === */
:root {
  --text: #111417;
  --muted: #5b6168;
  --highlight: #fff;
  --border: #ccc;
  --radius: 6px;

  --page-bg-1: #ffffff;
  --page-bg-2: #f8f9fa;
  --wave-fill: conic-gradient(
    from 0deg at 50% 50%,
    var(--wave-color) 0deg,
    var(--wave-color-2) 120deg,
    var(--wave-color) 240deg,
    var(--wave-color-2) 360deg
  );
  --wave-border-width: 0.5px;

  --hover-mix: 15%;
  --badge-mix: 10%;

  --newsage-bg: rgba(0, 0, 0, 0.05);
  --newsage-text: #666;
  --footer-bg: rgba(255, 255, 255, 0.8);
  --scoring-bg: rgba(0, 0, 0, 0.05);
  --scoring-summary-text: #555;
  --scoring-strong: #333;
  --scoring-score-strong: #444;

  --nav-btn-bg: #ffffff;
  --nav-btn-shadow: rgba(0, 0, 0, 0.1);
  --nav-line: #333;
  --nav-menu-bg: rgba(255, 255, 255, 0.98);

  --source-border: #ccc;
}

/* === DARK MODE === */
:root[data-theme="dark"] {
  --text: #eceef0;
  --muted: #9aa0a6;
  --border: #3a3a3d;

  --page-bg-1: #000000;
  --page-bg-2: #0a0a0a;
  --wave-fill: transparent;
  --wave-border-width: 1.5px;

  --hover-mix: 25%;
  --badge-mix: 35%;

  --newsage-bg: rgba(255, 255, 255, 0.08);
  --newsage-text: #b0b4ba;
  --footer-bg: rgba(0, 0, 0, 0.35);
  --scoring-bg: rgba(255, 255, 255, 0.06);
  --scoring-summary-text: #c5c8cc;
  --scoring-strong: #eceef0;
  --scoring-score-strong: #d5d8db;

  --nav-btn-bg: #0a0a0a;
  --nav-btn-shadow: rgba(0, 0, 0, 0.5);
  --nav-line: #eceef0;
  --nav-menu-bg: rgba(0, 0, 0, 0.98);

  --source-border: rgba(255, 255, 255, 0.15);
}

/* === ALAPOK === */
html {
  background: var(--page-bg-1);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding-top: 35px;
  font-family: "Mukta", system-ui, sans-serif;
  color: var(--text);
  line-height: 1.55;
  font-size: clamp(15px, 1.2vw, 17px);
}

a {
  color: inherit;
  text-decoration: none;
}

/* === LAYOUT === */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: clamp(14px, 2vw, 18px);
}

/* === BACKGROUND === */
#background-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background: linear-gradient(135deg, var(--page-bg-1) 0%, var(--page-bg-2) 25%, var(--page-bg-1) 50%, var(--page-bg-2) 100%);
  overflow: hidden;
}

#background-container::before,
#background-container::after {
  content: "";
  position: absolute;
  width: 120%;
  height: 120%;
  background: var(--wave-fill);
  border-radius: 50%;
  top: -10%;
  left: -10%;
  border: var(--wave-border-width) solid var(--wave-border);
  animation: waveRotate 60s linear infinite;
  opacity: 0.6;
}

#background-container::before {
  animation-duration: 45s;
  animation-direction: reverse;
  opacity: 0.4;
  width: 130%;
  height: 130%;
  top: -15%;
  left: -15%;
  z-index: -1;
}

#background-container::after {
  z-index: -2;
}

/* === TÉMAVÁLTÓ (light/dark) === */
/* Lives inside .nav-toggle-wrapper, right before the hamburger button */
#theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #000000;
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 2px 10px var(--nav-btn-shadow);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

:root[data-theme="dark"] #theme-toggle {
  background: #ffffff;
}

.theme-icon-sun { display: none; }
.theme-icon-moon { display: inline; }
:root[data-theme="dark"] .theme-icon-sun { display: inline; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }

.content-overlay {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

@keyframes waveRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* === HÁTTÉR IRÁNYTŰ === */
.background-compass {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 800px;
  height: 800px;
  transform: translate(33.33%, 33.33%);
  z-index: -1;
  opacity: 1;
  pointer-events: none;
  animation: compassRotate 60s linear infinite;
}

.background-compass img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes compassRotate {
  from { transform: translate(33.33%, 33.33%) rotate(0deg); }
  to { transform: translate(33.33%, 33.33%) rotate(360deg); }
}



/* === LOGO === */
.logo-container {
  text-align: center;
  margin-bottom: clamp(20px, 4vw, 32px);
  display: none;
}

.logo {
  width: 85%;
  max-width: 200px;
  height: auto;
  border-radius: var(--radius);
}

.logo-toggle {
  display: inline-block;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.logo-toggle:hover {
  opacity: 0.8;
}

/* === KATEGÓRIÁK === */
.category {
  overflow: hidden;
  word-wrap: break-word;
  scroll-margin-top: 60px;
}

.category-head {
  scroll-margin-top: 60px;
}

.category-head {
  position: relative;
  font-weight: 900;
  font-size: clamp(14px, 1.5vw, 16px);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #fff;
  padding: 12px 18px;
  margin-bottom: 8px;
  border-radius: 8px;
  overflow: hidden;
  clip-path: polygon(0 0, 100% 0, 95% 100%, 0 85%);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.category-head::before,
.category-head::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  z-index: -1;
  transform: rotate(-2deg) translateY(3px);
  opacity: 0.6;
}

.category-head::before {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(-4deg) translateY(6px);
}

.category-head::after {
  background: rgba(0, 0, 0, 0.1);
}

.list {
  display: grid;
  background: transparent;
  border-top-right-radius: 23px;
}

/* === HÍREK === */
/* Positioning context for the dismiss button and its guard (see .dismiss / .dismiss-guard
   below). Deliberately empty otherwise - no padding, no border, no margin of its own - so it
   contributes nothing to layout beyond what .item, its only in-flow child, already did. That's
   also why the collapse animation on .item (max-height/opacity/transform, further down) shrinks
   this wrapper too without any properties needed here: the wrapper's height is just the height
   of its one in-flow child, and the button/guard are position:absolute so they don't count. */
.item-wrap {
  position: relative;
  /* Clips the dismiss button's oversized hit area and the dead zone to this article's own box.
     Measured without it: the 76px dead zone reached 38px below the button's centre while the
     next article began at 22px, so a ~16px strip across the NEXT article's top-right corner
     swallowed taps and did nothing. Trading one article's mis-tap for the next article's
     tappability is not a trade worth making. The item itself already clips its own overflow,
     so this changes nothing about the collapse animation. */
  overflow: hidden;
}

.item {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px dashed var(--border);
  /* 0.6s: a design szerinti "organikus" tempó, és egyben az updateNewsGrid()
     700 ms-os takarítási időzítője alá kell férnie, különben a kifutó hírek
     az animáció közepén tűnnének el a DOM-ból. */
  transition: all 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
  max-height: 2000px; /* Large value for smooth collapse/expand animation */
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  word-wrap: break-word;
  word-break: break-word;
  /* --accent is set inline per item (category color); hover/badge tints
     derive from it via color-mix so they follow the light/dark theme
     automatically without any per-theme JS. */
  --hover-bg: color-mix(in srgb, var(--accent) var(--hover-mix), var(--page-bg-1));
  --badge-bg: color-mix(in srgb, var(--accent) var(--badge-mix), var(--page-bg-1));
}

/* .item is no longer a last child of anything - .item-wrap is (it's the direct child of
   .list now). Match against the wrapper and style the .item inside it. */
.item-wrap:last-child .item {
  border-bottom: 0;
}

@media (hover: hover) {
  .item:hover {
    background: var(--hover-bg);
  }
}

/* News animation: entering state (new items fade in - proliferation effect) */
.item[data-state="entering"] {
  opacity: 0;
  transform: scale(0.85);
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

/* A "Legújabb"-bal egy grid SORBAN lévő kategóriákból elrejtett duplikátumok.
   Csak abban a sorban fut, ahol a két példány egymás mellett látszana; a
   sortagság a hasábszámtól függ, ezért a kapcsolást JS számolja újra
   átméretezéskor (dedupeLatestRow). Elrejtés, nem törlés: az elemnek vissza
   kell tudnia jönni, és a frissítési diff a DOM-ból olvas.
   On the WRAPPER, not .item: the wrapper also holds the absolutely positioned dismiss button
   and its guard, and hiding only .item would leave those floating in the grid with nothing
   left to anchor to visually. */
.item-wrap[data-dup-hidden="true"] {
  display: none;
}

/* News animation: leaving state (old items fade out - apoptosis effect) */
.item[data-state="leaving"] {
  opacity: 0;
  transform: scale(0.85);
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.title {
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 4px;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: none;
}

.desc-source {
  margin-top: 6px;
  font-size: .95em;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  /* .dismiss used to be the last flex item in this row (margin-left:auto); now it's
     absolutely positioned in .item-wrap instead, floating over the item's right edge. This
     reserves the same space so the source/age badges never run underneath it. */
  padding-right: 30px;
}

.desc {
  display: inline;
  word-wrap: break-word;
  word-break: break-word;
}

.source {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--source-border);
  background: var(--badge-bg);
  color: var(--text);
  opacity: 0.9;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-age {
  display: inline-block;
  padding: 2px 8px;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--newsage-bg);
  color: var(--newsage-text);
  white-space: nowrap;
}

/* .dismiss is a SIBLING of <a class="item"> now, both children of .item-wrap (position:
   relative - see above), not nested inside the link. Nesting a button inside a link is invalid
   HTML and doubles up as a link+button for a screen reader; the sibling structure also lets
   .dismiss-guard sit between them in the stacking order (see below).
   Positioned to land where it always visually sat: the right end of the .desc-source row, near
   the item's own bottom-right corner (.desc-source is normally the last content in .item before
   its padding-bottom). Absolute position doesn't require .item-wrap to grow any padding/border
   of its own - it's measured from the wrapper's edges, which coincide with .item's edges since
   .item is the wrapper's only in-flow child. */
.dismiss {
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 28px;
  height: 28px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: .35;
  transition: opacity .2s ease, transform .2s ease;
}

/* The tap target, not the icon.
   Measured on a 390px viewport before this existed: the button was 28x20 px sitting inside a
   358x148 px link — 1.06% of it. The platform minimums are 44x44 (iOS) and 48x48 (Android), so
   on a phone a near-miss opened the article instead of dismissing it, which is what a reader
   actually reported.
   The icon stays 16px; only the hit area grows, via an absolutely positioned pseudo-element so
   the button's own box is untouched. The pseudo-element belongs to the button, so a tap on it
   still resolves through event.target.closest('.dismiss') in the delegated handler. */
.dismiss::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
}

/* The dead zone between the button's 48x48 hit area and this ring's edge: a near-miss lands
   here instead of on the link underneath, and nothing happens - the reader just tries again,
   instead of being taken to the article they were trying to dismiss. Centred on the same point
   as .dismiss (28px button, 76px guard: the guard extends (76-28)/2 = 24px past the button's
   own inset on every side). Stacked ABOVE .item (z-index 1 beats the link's default auto/0) but
   BELOW .dismiss (z-index 2), so a tap resolves to the guard only when it misses the button. No
   event handler of its own - event.target.closest('.dismiss') simply never matches it, and it
   isn't inside <a>, so it can't trigger navigation either. */
.dismiss-guard {
  position: absolute;
  right: -14px;
  bottom: -16px;
  width: 76px;
  height: 76px;
  z-index: 1;
}

.dismiss:hover,
.dismiss:focus-visible {
  opacity: 1;
  transform: scale(1.15);
}

/* The SVG must never swallow the click - the delegated handler resolves the click target via
   event.target.closest('.dismiss'), so the icon has to be transparent to pointer events. */
.dismiss-icon {
  width: 16px;
  height: 16px;
  pointer-events: none;
  overflow: visible;
}

/* Outline only, never filled: a solid thumb reads as a heavy blob at 16px. The hover feedback
   is the scale and opacity change on .dismiss above. `currentColor` rather than a literal black,
   so the icon follows the theme instead of disappearing into a dark background. */
.dismiss-icon {
  fill: none;
}

@media (prefers-reduced-motion: reduce) {
  .dismiss {
    transition: none;
  }
}

/* Set on <body> when window.NewsPreferences failed to load (e.g. a missed stat/ sync via
   upload-config.sh, which reaches production separately from the app deploy). Without this,
   every dismiss click is a silent no-op: the button's preventDefault() already fired, so the
   reader sees nothing happen and no error. Hiding the button instead is at least honest. */
.no-preferences .dismiss,
.no-preferences .dismiss-guard {
  display: none;
}

/* Apoptosis: a brief swell, then collapse. Deliberately distinct from data-state="leaving",
   which is how an item that merely aged out departs. */
.item[data-state="dismissed"] {
  animation: apoptosis .45s cubic-bezier(.4, 0, .2, 1) forwards;
  pointer-events: none;
}

@keyframes apoptosis {
  0%   { opacity: 1; transform: scale(1);    max-height: 2000px; }
  30%  { opacity: 1; transform: scale(1.06); max-height: 2000px; }
  100% { opacity: 0; transform: scale(.7);   max-height: 0;
         padding-top: 0; padding-bottom: 0; margin-top: 0; margin-bottom: 0; }
}

/* Export/import buttons live in .nav-menu-footer at the bottom of #mobile-nav-menu. */
.nav-menu-footer {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  padding: 16px 0 8px;
  margin-top: 12px;
  border-top: 1px solid var(--source-border);
}

.pref-io-btn {
  background: none;
  border: none;
  padding: 8px 12px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  opacity: .6;
  border-radius: 6px;
  transition: opacity .2s ease, background .2s ease;
}

.pref-io-btn:hover,
.pref-io-btn:focus-visible { opacity: 1; background: var(--nav-btn-shadow); }

/* Hidden, never removed - see the comment on dedupeLatestRow in hiranytu.ejs. An element
   taken out of the DOM looks "new" to the next refresh diff, animates back in, and the
   ping-pong never stops.
   On the WRAPPER, not .item - same reasoning as .item-wrap[data-dup-hidden="true"] above: the
   wrapper also holds the dismiss button and its guard. */
.item-wrap[data-pref-hidden="true"] { display: none; }
.category[data-pref-hidden="true"] { display: none; }

/* === KÉPEK === */
.item-image {
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  border-radius: 6px;
  margin-bottom: 6px;
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  opacity: 0;
  transform: scale(1.05);
  transition: opacity 0.9s ease-out, transform 0.9s ease-out;
}

.item-image img.loaded {
  opacity: 1;
  transform: scale(1);
}

.item:hover .item-image img.loaded {
  transform: scale(1.02);
}

/* === ÜZENETEK === */
.no-news {
  padding: 20px;
  text-align: center;
  color: var(--text);
}

/* === FOOTER === */
.footer {
  text-align: center;
  padding: clamp(20px, 4vw, 32px);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  border-top: 1px solid var(--border);
  margin-top: clamp(20px, 4vw, 32px);
  background: var(--footer-bg);
}

.footer-email {
  color: var(--muted);
  text-decoration: none;
}

.footer-copyright {
  opacity: 0.7;
}

.brand-strong {
  font-weight: 900;
}

/* === WORDMARK ===
   Built on the bedoBox.eSign shape: an accent dot dividing a light lead from a heavy
   tail, with a short rule beneath. The three accent colours (dot, á, ó) arrive as
   custom properties from pickWordmarkColours() and are re-rolled on every render —
   drawn without replacement from the news category palette, so no two of them ever
   match. Mukta loads 400/700/900; 900 is the heaviest available. */
.brand-wordmark {
  /* Light triple by default; the dark override below swaps in the other one. Both arrive
     inline from the server, so the theme toggle recolours instantly without a reload. */
  --bw-dot: var(--bw-dot-l);
  --bw-a: var(--bw-a-l);
  --bw-o: var(--bw-o-l);

  /* Block so the footer email starts on its own line, but shrink-to-fit so the ::after
     rule below measures 42% of the wordmark rather than 42% of the footer. */
  display: block;
  width: fit-content;
  margin: 0 auto 12px;
  font-family: 'Mukta', system-ui, sans-serif;
  font-size: clamp(26px, 5.5vw, 40px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* The category palette is tuned for coloured category headers, not for coloured text on
   the page background. Four of its eight entries fall below 3:1 against white (#f8f38d is
   1.15:1 — an invisible letter), so the light theme draws from a filtered pool. Against
   the near-black dark background all eight clear 4.6:1, so nothing is dropped there. */
:root[data-theme="dark"] .brand-wordmark {
  --bw-dot: var(--bw-dot-d);
  --bw-a: var(--bw-a-d);
  --bw-o: var(--bw-o-d);
}

.brand-wordmark .bw-tail { font-weight: 900; }
.brand-wordmark .bw-dot  { color: var(--bw-dot); font-weight: 900; }
.brand-wordmark .bw-a    { color: var(--bw-a); }
.brand-wordmark .bw-o    { color: var(--bw-o); }

.brand-wordmark::after {
  content: "";
  display: block;
  width: 42%;
  height: 3px;
  margin-top: 7px;
  border-radius: 1.5px;
  background: var(--bw-dot);
}

.footer-debug {
  color: var(--muted);
  font-size: 12px;
}

/* === SCORING DEBUG STÍLUSOK === */
.scoring-debug { margin-top: 8px; padding: 8px; background: var(--scoring-bg); border-radius: 4px; font-size: 11px; color: var(--muted); word-wrap: break-word; }
.scoring-summary { padding: 4px 0 6px 0; margin-bottom: 6px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--scoring-summary-text); }
.scoring-summary strong { color: var(--scoring-strong); }
.scoring-category { font-weight: bold; margin-bottom: 4px; }
.keyword-tag { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 4px; background: var(--badge-bg); border-radius: 3px; font-size: 10px; }
.scoring-categories { margin: 6px 0; }
.category-score { margin: 4px 0; padding: 3px 0; border-left: 2px solid var(--border); padding-left: 6px; }
.category-score strong { color: var(--scoring-score-strong); }
.category-keywords { margin: 3px 0 3px 8px; display: flex; flex-wrap: wrap; gap: 3px; }


/* === MOBIL NAVIGÁCIÓ === */
.nav-toggle-wrapper {
  position: fixed;
  top: 15px;
  right: 15px;
  z-index: 1002 !important;
  display: flex;
  gap: 8px;
}

#mobile-nav-toggle {
  display: flex;
  width: 40px;
  height: 40px;
  background: var(--nav-btn-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 8px;
  box-shadow: 0 2px 10px var(--nav-btn-shadow);

  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.3s ease;
}

#reorder-toggle {
  display: flex;
  width: 40px;
  height: 40px;
  background: var(--nav-btn-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 10px var(--nav-btn-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateX(10px);
  transition: all 0.3s ease;
  font-size: 20px;
  color: var(--text);
}

:root[data-theme="dark"] #reorder-toggle {
  border-color: #ffffff;
  color: #ffffff;
}

#reorder-toggle.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

#reorder-toggle.save-mode {
  background: #42d6a4 !important;
  border-color: #38c090 !important;
}

#reorder-toggle.save-mode .save-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 1.5s ease-in-out infinite;
}

#reorder-toggle.save-mode .save-icon svg {
  color: #333;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Reset toggle - a corner-anchored fixed element in the OPPOSITE corner from the toolbar
   (top-left, mirroring .nav-toggle-wrapper's top-right), deliberately physically distant from
   the reorder/theme/hamburger cluster so a mis-tap can't reach a destructive action. Still a
   child of .nav-toggle-wrapper in the DOM (see createMobileNav) - only its rendered position
   is pulled out via `position: fixed` of its own - so the rebuild logic, tab order and the
   visible-class show/hide wiring below are untouched. Hidden until the hamburger menu is
   opened, same mechanism as #reorder-toggle (opacity + visibility + translateX, toggled by the
   `visible` class), staggered to arrive after it (see RESET_REVEAL_DELAY_MS in createMobileNav).
   The translateX travels FROM the right (the toolbar's direction) and further than
   #reorder-toggle's, over a longer duration - reads as the same outward motion carrying on
   into the far corner, not a fresh pop-in. Needs its own z-index: as a fixed element it is no
   longer sized/stacked by the wrapper's flex box, so nothing but this declaration keeps it
   above the page content once it leaves the wrapper's stacking context. */
#reset-toggle {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1002;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  flex-shrink: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(40px);
  transition: all 0.45s ease;
}

#reset-toggle.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.reset-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--nav-btn-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 2px 10px var(--nav-btn-shadow);
  color: var(--text);
  cursor: pointer;
}

/* Filled arrowhead + dot, stroked ring - see the SVG markup in createMobileNav. currentColor
   throughout so it follows the theme, matching .dismiss-icon's pattern. */
.reset-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Two-step inline confirm, in place of the single button - no confirm(), see
   createMobileNav's renderResetConfirm. Pulses (reusing @keyframes pulse above) so the
   armed state is unmistakable even to a reader not looking directly at it, and auto-reverts
   to idle after ~5s (JS timer) since a toolbar has no "close the menu" gesture to cancel it. */
#reset-toggle.confirming {
  animation: pulse 1.5s ease-in-out infinite;
}

.reset-confirm-yes,
.reset-confirm-no {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 40px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  border-radius: 5px;
  box-shadow: 0 2px 10px var(--nav-btn-shadow);
  cursor: pointer;
  transition: filter 0.2s ease;
}

/* Confirming IS the destructive action - red, matching the old in-menu confirm's colour. */
.reset-confirm-yes {
  background: var(--nav-btn-bg);
  border: 1px solid #d9534f;
  color: #d9534f;
}

.reset-confirm-no {
  background: var(--nav-btn-bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.reset-confirm-yes:hover,
.reset-confirm-yes:focus-visible,
.reset-confirm-no:hover,
.reset-confirm-no:focus-visible {
  filter: brightness(1.1);
}

/* Same reasoning as `.no-preferences .dismiss` above: window.NewsPreferences failed to load,
   so the reset control's localStorage half would be dead. Hide it rather than leave a button
   that silently does nothing. */
.no-preferences #reset-toggle {
  display: none;
}

/* Mobilon jobb felső sarok */
@media (max-width: 768px) {
  .nav-toggle-wrapper {
    top: 15px;
    right: 15px;
  }

  #mobile-nav-toggle {
    transform: scale(0.5);
  }

  #reorder-toggle:not(.visible) {
    transform: scale(0.5) translateX(10px);
  }

  /* #reset-toggle is fixed to the top-left corner (see its base rule), not this row - only
     the entrance treatment (shrink+slide, scaling up to full size as .visible is added) is
     shared with #reorder-toggle. The 40px matches the base rule's longer travel. */
  #reset-toggle:not(.visible) {
    transform: scale(0.5) translateX(40px);
  }

  #mobile-nav-toggle.visible {
    opacity: 1;
    transform: scale(1);
  }

  #reorder-toggle.visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: scale(1) translateX(0) !important;
  }

  #reset-toggle.visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: scale(1) translateX(0) !important;
  }
}

/* Desktop-on jobbra igazítva, fix az oldal tetején */
@media (min-width: 769px) {
  .nav-toggle-wrapper {
    top: 15px;
    right: 15px;
  }

  #mobile-nav-toggle {
    transform: scale(0);
  }

  #reorder-toggle {
    transform: scale(0) translateX(10px);
  }

  /* #reset-toggle is fixed to the top-left corner (see its base rule), not this row - it
     needs its own bounce keyframe below (resetToggleBounce) because the travel distance
     (40px, not 10px) and duration (0.9s, not 0.6s - same 1.5x factor as the base rule's
     0.45s/0.3s) both differ from #reorder-toggle's. */
  #reset-toggle {
    transform: scale(0) translateX(40px);
  }

  #mobile-nav-toggle.visible {
    opacity: 1;
    transform: scale(1);
    animation: desktopNavBounce 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
  }

  #reorder-toggle.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateX(0);
    animation: desktopNavBounce 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
  }

  #reset-toggle.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateX(0);
    animation: resetToggleBounce 0.9s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
  }

  @keyframes desktopNavBounce {
    0% { transform: scale(0) translateX(10px); }
    70% { transform: scale(1.25) translateX(0); }
    100% { transform: scale(1) translateX(0); }
  }

  /* Same shape as desktopNavBounce, longer travel (40px) and duration (0.9s) - see the
     comment on #reset-toggle above. */
  @keyframes resetToggleBounce {
    0% { transform: scale(0) translateX(40px); }
    70% { transform: scale(1.25) translateX(0); }
    100% { transform: scale(1) translateX(0); }
  }
}

#mobile-nav-toggle .line { display: block; height: 2px; width: 100%; background: var(--nav-line); transition: transform 0.2s ease, opacity 0.2s ease; }
#mobile-nav-toggle.open .line1 { transform: translateY(6px) rotate(45deg); }
#mobile-nav-toggle.open .line2 { opacity: 0; }
#mobile-nav-toggle.open .line3 { transform: translateY(-6px) rotate(-45deg); }

/* Közös menü stílusok */
#mobile-nav-menu {
  position: fixed;
  top: 0;
  height: 100%;
  background: var(--nav-menu-bg);
  z-index: 1000;
  overflow-y: auto;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s 0.3s;
}

/* Mobilon teljes széles, felülről lefelé */
@media (max-width: 768px) {
  #mobile-nav-menu {
    top: 70px; /* Gombok alá (15px + 40px + 15px) */
    left: 0;
    width: 100%;
    height: calc(100% - 70px);
    padding: 20px 20px 20px;
    transform: translateY(-15px);
    z-index: 999; /* Gombok alá kerül (1002) */
  }

  #mobile-nav-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s;
  }
}

/* Desktop-on jobbról becsúszó, max 33% széles */
@media (min-width: 769px) {
  #mobile-nav-menu {
    top: 70px; /* Gomb alá pozícionálva (15px + 40px + 15px margin) */
    right: 0;
    width: 33.333%;
    height: calc(100% - 70px);
    padding: 20px;
    transform: translateX(100%);
    border-radius: 15px 0 0 15px; /* Bal felső és bal alsó sarok lekerekítve */
  }

  #mobile-nav-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s;
  }
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  margin-bottom: 12px;
  transition: transform 0.2s ease, filter 0.2s ease;
  outline: none;
}

.mobile-nav-item:hover,
.mobile-nav-item:focus {
  transform: scale(1.02);
  filter: brightness(1.1);
}

/* Move up button */
.move-up-btn {
  display: none; /* Hidden by default */
  width: 32px;
  height: 32px;
  background: var(--nav-btn-bg);
  border: 2px solid var(--muted);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  color: var(--nav-line);
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-left: 8px;
}

.move-up-btn:hover {
  background: var(--nav-line);
  color: var(--nav-btn-bg);
  transform: scale(1.1);
}

.move-up-btn:active {
  transform: scale(0.95);
}

/* Show move up buttons in reorder mode */
#mobile-nav-menu.reorder-mode .move-up-btn {
  display: flex;
}

/* Hide up arrow for first item (can't move up further) */
#mobile-nav-menu.reorder-mode .mobile-nav-item:first-child .move-up-btn {
  display: none;
}

/* Disable clicking on category links while reordering */
#mobile-nav-menu.reorder-mode .mobile-nav-link {
  pointer-events: none;
}

.mobile-nav-link {
  flex: 1;
  text-decoration: none;
  color: inherit;
  pointer-events: auto;
}

.mobile-nav-item .category-head {
  transform: none;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Toast üzenet */
.save-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.save-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* === RESPONSIVE BEÁLLÍTÁSOK === */
@media (max-width: 1200px) { .background-compass { width: 640px; height: 640px; opacity: 0.2; } }

@media (max-width: 768px) {
  .logo { width: 100%; max-width: 120px; }

  .category-head {
    padding: 14px 18px 12px 16px;
    margin-bottom: 8px;
    border-radius: 35px 1px 28px 8px;
    border-left-width: 12px;
    border-bottom-width: 2px;
    border-right-width: 18px;
    border-top-width: 6px;
    letter-spacing: 0.8px;
    transform: skewX(-3deg);
  }

  .background-compass { width: 480px; height: 480px; opacity: 0.15; }
  /* #mobile-nav-toggle { display: flex; } <-- EZT IS KIVETTEM, MERT FELJEBB KERÜLT */
  #background-container::before, #background-container::after { opacity: 0.65; }
  #background-container::before { opacity: 0.55; }
}

@media (max-width: 480px) { .background-compass { width: 320px; height: 320px; opacity: 0.12; } }

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  #background-container::before, #background-container::after, .background-compass { animation: none; }
  .logo-toggle, .item, #mobile-nav-toggle span { transition: none; }
  .category-head::before, .category-head::after { transform: none; }
  .item-image img { transition: none !important; transform: none !important; opacity: 1 !important; }
  .item[data-state="entering"],
  .item[data-state="leaving"] {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    max-height: none !important;
  }
  .item[data-state="dismissed"] { animation: none; opacity: 0; max-height: 0; }
}

/* Debug mode: visual indicators for animation states */
.item[data-state="entering"][data-debug="true"] {
  border: 5px solid #42d6a4 !important;
  background: rgba(66, 214, 164, 0.3) !important;
  box-shadow: 0 0 20px rgba(66, 214, 164, 0.5) !important;
}

.item[data-state="leaving"][data-debug="true"] {
  border: 5px solid #d73898 !important;
  background: rgba(215, 56, 152, 0.3) !important;
  box-shadow: 0 0 20px rgba(215, 56, 152, 0.5) !important;
}