/* /assets/css/worldnews.css */

/* ================================
   Full-bleed layout (no side padding)
================================ */
.worldnews{
  max-width: none;
  margin: 0;
  padding: 0px 10px;

  margin-left: -20px;
  margin-right: -20px;
}

@media (max-width: 480px){
  .worldnews{
    margin-left: -10px;
    margin-right: -10px;
  }
}
@media (min-width: 481px) and (max-width: 600px){
  .worldnews{
    margin-left: -15px;
    margin-right: -15px;
  }
}

/* ================================
   Box sizing fix
================================ */
.worldnews,
.worldnews *{
  box-sizing: border-box;
}

.worldnews__toprow{
  display: grid;
  grid-template-columns: 1.05fr 1.2fr;
  gap: 18px;
  align-items: start;
  padding: 0 0;
}

@media (max-width: 980px){
  .worldnews__toprow{
    grid-template-columns: 1fr;
  }
}

.worldnews__left,
.worldnews__right{
  padding: 0 16px;
}

@media (max-width: 980px){
  .worldnews__left,
  .worldnews__right{
    padding: 0 14px;
  }
}

.worldnews__title{
  font-size: 44px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 6px 0 18px;
  color: #1F2937;
}

.worldnews__filters{
  border: 1px solid rgba(17,24,39,0.12);
  border-radius: 18px;
  padding: 16px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.worldnews__filter{
  display: block;
  margin-bottom: 14px;
}

.worldnews__filterlabel{
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  color: rgba(31,41,55,0.92);
}

.worldnews__input{
  width: 100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 2px solid rgba(17,24,39,0.18);
  outline: none;
  background: #fff;
  color: #111827;
  font-size: 16px;
}

.worldnews__input:focus{
  border-color: rgba(14,165,233,0.55);
  box-shadow: 0 0 0 4px rgba(14,165,233,0.12);
}

.worldnews__filtermeta{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
  color: rgba(55,65,81,0.9);
  font-weight: 650;
}

.worldnews__metarow{
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}

.worldnews__legendrow{
  margin-top: 0;
  margin-left: auto;
  flex: 0 0 auto;
}

.worldnews__metalabel{
  color: rgba(55,65,81,0.7);
  font-weight: 650;
}

.worldnews__legendbtn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(17,24,39,0.14);
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 750;
  background: #fff;
  color: rgba(31,41,55,0.92);
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.worldnews__legendbtn:hover{
  background: rgba(17,24,39,0.03);
}

.worldnews__status{
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(17,24,39,0.12);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.9);
}

.worldnews__status--hidden{
  display: none;
}

.worldnews__statustitle{
  margin: 0;
  font-weight: 800;
  color: rgba(17,24,39,0.92);
}

.worldnews__statussub{
  margin: 2px 0 0;
  color: rgba(55,65,81,0.76);
  font-size: 13px;
}

.worldnews__statusright{
  display: grid;
  gap: 6px;
  justify-items: end;
  min-width: 180px;
}

.worldnews__tiny{
  font-size: 12px;
  color: rgba(55,65,81,0.7);
  font-weight: 700;
}

.worldnews__error{
  margin-top: 12px;
  border: 1px solid rgba(220,38,38,0.25);
  background: rgba(220,38,38,0.06);
  border-radius: 14px;
  padding: 12px 14px;
  color: rgba(127,29,29,0.95);
  font-weight: 650;
  white-space: pre-wrap;
}

/* ================================
   Map
================================ */
.worldnews__mapcard{
  border: 1px solid rgba(17,24,39,0.12);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.worldnews__map{
  height: 420px;
  width: 100%;
}

@media (max-width: 980px){
  .worldnews__map{
    height: 360px;
  }
}

/* Placeholder used when map becomes floating */
.worldnews__mapplaceholder{
  width: 100%;
}

/* =========================================================
   Floating map (ALL widths)
   - Must be UNDER the purple fixed nav bar
   - Must be BEHIND the navigation menu overlay (hamburger menu)
   - Must scale the entire Leaflet UI (controls, attribution, popups, etc.)
   ========================================================= */
.worldnews__mapcard--floating{
  position: fixed;
  right: 80px;
  left: auto;

  /* Place under fixed header */
  top: calc(var(--worldnews-fixed-header-h, 0px) + var(--worldnews-float-gap, 10px));

  /* Keep it behind the slide navigation menu overlay */
  z-index: 1200;

  /* Scale EVERYTHING (Leaflet controls, attribution, popups...) */
  transform: scale(0.5);
  transform-origin: top right;

  /* Keep the original aspect ratio by scaling the whole card.
     Width here is the "pre-scale" width. Visual width becomes half. */
  width: min(653px, 96vw);

  border-radius: 16px;
  box-shadow: 0 16px 46px rgba(0,0,0,0.22);
  border: 1px solid rgba(17,24,39,0.18);
}

/* Do NOT override height inside floating mode.
   The map keeps its original height; the whole card scales to half. */
.worldnews__mapcard--floating .worldnews__map{
  height: 420px;
}

@media (max-width: 980px){
  .worldnews__mapcard--floating .worldnews__map{
    height: 360px;
  }
}

/* ================================
   Table card
================================ */
.worldnews__tablecard{
  margin-top: 1px;
  border: 1px solid rgba(17,24,39,0.12);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
  overflow: hidden;
  margin-left: 0;
  margin-right: 0;
}

.worldnews__tablehead{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid rgba(17,24,39,0.10);
}

.worldnews__tabletitle{
  margin: 0;
  font-weight: 850;
  color: rgba(17,24,39,0.92);
  font-size: 16px;
}

.worldnews__tablemeta{
  margin: 0;
  color: rgba(55,65,81,0.65);
  font-weight: 700;
  font-size: 12px;
}

.worldnews__tablewrap{
  max-height: 75vh;
  overflow: auto;
}

.worldnews__table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  table-layout: fixed;
}

.worldnews__table thead th{
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid rgba(17,24,39,0.10);
  padding: 10px 12px;
  text-align: left;
  color: rgba(55,65,81,0.85);
  font-weight: 800;
  white-space: nowrap;
}

.worldnews__table tbody td{
  border-bottom: 1px solid rgba(17,24,39,0.06);
  padding: 10px 12px;
  vertical-align: top;
  color: rgba(17,24,39,0.88);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.worldnews__table tbody tr:hover{
  background: rgba(17,24,39,0.03);
  cursor: pointer;
}

.worldnews__rowhighlight{
  outline: 2px solid rgba(14,165,233,0.35);
  outline-offset: -2px;
  background: rgba(14,165,233,0.06) !important;
}

/* Column widths */
.col-no{
  width: 56px;
  white-space: nowrap;
  color: rgba(55,65,81,0.75);
  font-weight: 800;
}
.col-title{ width: 44%; }
.col-themes{ width: 10%; }
.col-country{ width: 10%; }
.col-tone{ width: 28%; }
.col-link{ width: 8%; text-align: center; }

.worldnews__table thead th.col-no{
  text-align: right;
  white-space: nowrap;
  font-weight: 650;
}

.worldnews__table tbody td.col-no{
  text-align: right;
  white-space: nowrap;
  font-weight: 400;
  color: rgba(55,65,81,0.78);
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
  word-break: normal;
}

/* Themes icons: allow wrap */
.worldnews__themesicons{
  display: inline;
  font-size: 18px;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.worldnews__themesicons--empty{
  color: rgba(107,114,128,0.7);
  font-weight: 800;
}

.worldnews__table td.col-country{
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Link icon */
.worldnews__linkicon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(17,24,39,0.12);
  text-decoration: none;
  color: rgba(17,24,39,0.85);
  background: #fff;
  font-weight: 900;
}

.worldnews__linkicon:hover{
  background: rgba(17,24,39,0.04);
}

.worldnews__linkicon--disabled{
  opacity: 0.5;
  cursor: default;
}

/* Tone bar (bar only) */
.worldnews__tonebarwrap{
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(17,24,39,0.08);
  overflow: hidden;
  border: 1px solid rgba(17,24,39,0.10);
}

.worldnews__tonebar{
  height: 100%;
  border-radius: 999px;
}

/* Footer */
.worldnews__credits{
  margin-top: 16px;
  color: rgba(55,65,81,0.7);
  font-size: 13px;
  padding: 0 16px;
}

.worldnews__creditsline{
  margin: 6px 0;
}

.worldnews__credits a{
  color: rgba(79,79,127,1);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

/* ================================
   Small screens: fix header overlap
================================ */
@media (max-width: 600px){
  .worldnews__table th,
  .worldnews__table td{
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }

  .worldnews__table thead th.col-themes,
  .worldnews__table thead th.col-country{
    white-space: normal !important;
    line-height: 1.1;
  }

  .worldnews__table thead th{
    font-size: 13px;
    padding: 10px 10px;
  }

  .col-title{ width: 46%; }
  .col-themes{ width: 14%; }
  .col-country{ width: 14%; }
  .col-tone{ width: 20%; }
  .col-link{ width: 6%; }
}

/* ================================
   Legend Overlay
================================ */
.worldnews__legendoverlay{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(17,24,39,0.35);
  backdrop-filter: blur(2px);
}

.worldnews__legendpanel{
  width: min(680px, 96vw);
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(17,24,39,0.14);
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  overflow: hidden;
}

.worldnews__legendhead{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(17,24,39,0.10);
}

.worldnews__legendtitle{
  font-weight: 900;
  color: rgba(17,24,39,0.92);
}

.worldnews__legendclose{
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(17,24,39,0.14);
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: rgba(17,24,39,0.85);
}

.worldnews__legendclose:hover{
  background: rgba(17,24,39,0.04);
}

.worldnews__legendbody{
  padding: 14px 16px 18px;
}

.worldnews__legendsection{
  margin-bottom: 14px;
}

.worldnews__legendlabel{
  font-weight: 900;
  color: rgba(17,24,39,0.88);
  margin-bottom: 8px;
}

.worldnews__legendlist{
  margin: 0;
  padding-left: 18px;
  color: rgba(55,65,81,0.82);
  font-weight: 650;
}

.worldnews__legendchip{
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(17,24,39,0.12);
  background: rgba(17,24,39,0.03);
  font-size: 12px;
  font-weight: 850;
  margin-right: 6px;
}

.worldnews__legendicon{
  font-size: 16px;
  margin-right: 8px;
}

.worldnews__legendnote{
  margin-top: 10px;
  color: rgba(55,65,81,0.68);
  font-size: 12px;
  font-weight: 650;
}

.worldnews__lede{
  margin: -8px 0 8px;
  color: rgba(55,65,81,0.82);
  font-weight: 650;
  max-width: 62ch;
}



/* ================================
   Refresh button (snapshot row)
================================ */
.worldnews__refreshbtn{
  margin-left: 10px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.15);
  background: #ffffff;
  color: #2b2b35;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 34px;
  font-size: 30px;
  user-select: none;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.worldnews__refreshbtn:hover{
  background: #f5f5f7;
  border-color: rgba(0,0,0,0.22);
  transform: translateY(-1px);
}

.worldnews__refreshbtn:active{
  transform: translateY(0px);
}

.worldnews__refreshbtn:disabled{
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* spinning while loading */
@keyframes worldnews-spin{
  from{ transform: rotate(0deg); }
  to  { transform: rotate(360deg); }
}
.worldnews__refreshbtn--spinning{
  animation: worldnews-spin 0.9s linear infinite;
}
