/* Cyber News RSS Hub — Front-end Styles
   ================================================== */

/* ── CSS Custom Properties ──────────────────────── */
:root {
  --cnrh-primary:     #0073aa;
  --cnrh-primary-h:   #005c8a;
  --cnrh-bg:          #f8fafc;
  --cnrh-card-bg:     #ffffff;
  --cnrh-border:      #e2e8f0;
  --cnrh-text:        #1a202c;
  --cnrh-text-muted:  #718096;
  --cnrh-source-bg:   #ebf8ff;
  --cnrh-source-text: #2b6cb0;
  --cnrh-radius:      10px;
  --cnrh-shadow:      0 2px 8px rgba(0,0,0,.08);
  --cnrh-shadow-h:    0 4px 16px rgba(0,0,0,.14);
  --cnrh-gap:         1.25rem;
  --cnrh-img-ratio:   56.25%; /* 16:9 */
  --cnrh-ticker-duration: 60s;
}

.cnrh-dark {
  --cnrh-bg:          #0f172a;
  --cnrh-card-bg:     #1e293b;
  --cnrh-border:      #334155;
  --cnrh-text:        #f1f5f9;
  --cnrh-text-muted:  #94a3b8;
  --cnrh-source-bg:   #1e3a5f;
  --cnrh-source-text: #90cdf4;
  --cnrh-shadow:      0 2px 8px rgba(0,0,0,.35);
  --cnrh-shadow-h:    0 4px 16px rgba(0,0,0,.5);
  --cnrh-primary:     #63b3ed;
  --cnrh-primary-h:   #90cdf4;
}

/* ── Grid ───────────────────────────────────────── */
.cnrh-grid {
  display: grid;
  gap: var(--cnrh-gap);
  background: var(--cnrh-bg);
  padding: var(--cnrh-gap);
  border-radius: var(--cnrh-radius);
}

.cnrh-cols-1 { grid-template-columns: 1fr; }
.cnrh-cols-2 { grid-template-columns: repeat(2, 1fr); }
.cnrh-cols-3 { grid-template-columns: repeat(3, 1fr); }
.cnrh-cols-4 { grid-template-columns: repeat(4, 1fr); }

.cnrh-list .cnrh-card {
  display: grid;
  grid-template-columns: 200px 1fr;
}

.cnrh-list .cnrh-card__image-wrapper {
  --cnrh-img-ratio: 100%;
  border-radius: var(--cnrh-radius) 0 0 var(--cnrh-radius);
}

@media (max-width: 1024px) {
  .cnrh-cols-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .cnrh-cols-3,
  .cnrh-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cnrh-list .cnrh-card { grid-template-columns: 1fr; }
  .cnrh-list .cnrh-card__image-wrapper { border-radius: var(--cnrh-radius) var(--cnrh-radius) 0 0; }
}
@media (max-width: 540px) {
  .cnrh-cols-2,
  .cnrh-cols-3,
  .cnrh-cols-4 { grid-template-columns: 1fr; }
}

/* ── Card ───────────────────────────────────────── */
.cnrh-card {
  background:    var(--cnrh-card-bg);
  border:        1px solid var(--cnrh-border);
  border-radius: var(--cnrh-radius);
  box-shadow:    var(--cnrh-shadow);
  overflow:      hidden;
  display:       flex;
  flex-direction: column;
  transition:    box-shadow .2s ease, transform .2s ease;
}

.cnrh-card:hover {
  box-shadow: var(--cnrh-shadow-h);
  transform:  translateY(-2px);
}

/* Image */
.cnrh-card__image-link { display: block; overflow: hidden; }

.cnrh-card__image-wrapper {
  position:       relative;
  padding-top:    var(--cnrh-img-ratio);
  overflow:       hidden;
  background:     var(--cnrh-border);
}

.cnrh-card__image {
  position:   absolute;
  inset:      0;
  width:      100%;
  height:     100%;
  object-fit: cover;
  transition: transform .35s ease;
}

.cnrh-card:hover .cnrh-card__image { transform: scale(1.04); }

/* Body */
.cnrh-card__body {
  padding:       1rem;
  flex:          1;
  display:       flex;
  flex-direction: column;
  gap:           .5rem;
}

.cnrh-card__source {
  display:       inline-block;
  font-size:     .7rem;
  font-weight:   700;
  text-transform: uppercase;
  letter-spacing: .06em;
  background:    var(--cnrh-source-bg);
  color:         var(--cnrh-source-text);
  padding:       2px 8px;
  border-radius: 99px;
  align-self:    flex-start;
}

.cnrh-card__title {
  margin:      0;
  font-size:   1rem;
  line-height: 1.45;
}

.cnrh-card__title a {
  color:           var(--cnrh-text);
  text-decoration: none;
  transition:      color .15s;
}
.cnrh-card__title a:hover { color: var(--cnrh-primary); }

.cnrh-card__excerpt {
  margin:      0;
  font-size:   .875rem;
  color:       var(--cnrh-text-muted);
  line-height: 1.6;
  flex:        1;
}

/* Footer */
.cnrh-card__footer {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             .5rem;
  margin-top:      auto;
  padding-top:     .75rem;
  border-top:      1px solid var(--cnrh-border);
}

.cnrh-card__date {
  font-size: .78rem;
  color:     var(--cnrh-text-muted);
}

.cnrh-card__readmore {
  display:         inline-flex;
  align-items:     center;
  gap:             4px;
  font-size:       .8rem;
  font-weight:     600;
  color:           var(--cnrh-primary);
  text-decoration: none;
  transition:      color .15s, gap .15s;
  white-space:     nowrap;
}
.cnrh-card__readmore:hover { color: var(--cnrh-primary-h); gap: 7px; }

/* ── Ticker ─────────────────────────────────────── */
.cnrh-ticker {
  display:    flex;
  align-items: stretch;
  overflow:   hidden;
  background: var(--cnrh-card-bg);
  border:     1px solid var(--cnrh-border);
  border-radius: var(--cnrh-radius);
  height:     44px;
}

.cnrh-ticker__label {
  display:      flex;
  align-items:  center;
  padding:      0 1rem;
  background:   var(--cnrh-primary);
  color:        #fff;
  font-size:    .78rem;
  font-weight:  700;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space:  nowrap;
  flex-shrink:  0;
}

.cnrh-ticker__viewport {
  flex:     1;
  overflow: hidden;
  position: relative;
}

.cnrh-ticker__track {
  display:       flex;
  align-items:   center;
  white-space:   nowrap;
  animation:     cnrh-ticker var(--cnrh-ticker-duration) linear infinite;
  will-change:   transform;
}

.cnrh-ticker:hover .cnrh-ticker__track { animation-play-state: paused; }

@keyframes cnrh-ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.cnrh-ticker__item {
  display:         inline-block;
  padding:         0 1.5rem;
  font-size:       .875rem;
  color:           var(--cnrh-text);
  text-decoration: none;
  transition:      color .15s;
}
.cnrh-ticker__item:hover { color: var(--cnrh-primary); }

.cnrh-ticker__sep {
  color:      var(--cnrh-text-muted);
  flex-shrink: 0;
}

/* ── Featured ───────────────────────────────────── */
.cnrh-featured {
  display:       grid;
  grid-template-columns: 2fr 1fr;
  gap:           var(--cnrh-gap);
  background:    var(--cnrh-bg);
  padding:       var(--cnrh-gap);
  border-radius: var(--cnrh-radius);
}

@media (max-width: 768px) {
  .cnrh-featured { grid-template-columns: 1fr; }
}

.cnrh-featured__hero {
  background:    var(--cnrh-card-bg);
  border:        1px solid var(--cnrh-border);
  border-radius: var(--cnrh-radius);
  overflow:      hidden;
  display:       flex;
  flex-direction: column;
  box-shadow:    var(--cnrh-shadow);
}

.cnrh-featured__hero-image-link { display: block; }

.cnrh-featured__hero-image {
  width:      100%;
  height:     260px;
  object-fit: cover;
  display:    block;
  transition: transform .35s;
}
.cnrh-featured__hero:hover .cnrh-featured__hero-image { transform: scale(1.03); }

.cnrh-featured__hero-body { padding: 1.25rem; display: flex; flex-direction: column; gap: .6rem; flex: 1; }

.cnrh-featured__hero-title {
  margin:      0;
  font-size:   1.35rem;
  line-height: 1.35;
}
.cnrh-featured__hero-title a { color: var(--cnrh-text); text-decoration: none; }
.cnrh-featured__hero-title a:hover { color: var(--cnrh-primary); }

.cnrh-featured__hero-excerpt { font-size: .9rem; color: var(--cnrh-text-muted); line-height: 1.6; margin: 0; }

/* Sidebar */
.cnrh-featured__sidebar { display: flex; flex-direction: column; gap: .75rem; }

.cnrh-featured__sidebar-item {
  display:       flex;
  gap:           .75rem;
  align-items:   flex-start;
  background:    var(--cnrh-card-bg);
  border:        1px solid var(--cnrh-border);
  border-radius: var(--cnrh-radius);
  padding:       .75rem;
  box-shadow:    var(--cnrh-shadow);
  transition:    box-shadow .2s;
}
.cnrh-featured__sidebar-item:hover { box-shadow: var(--cnrh-shadow-h); }

.cnrh-featured__sidebar-thumb-link { flex-shrink: 0; }

.cnrh-featured__sidebar-thumb {
  width:         80px;
  height:        60px;
  object-fit:    cover;
  border-radius: 6px;
  display:       block;
}

.cnrh-featured__sidebar-body { flex: 1; min-width: 0; }

.cnrh-featured__sidebar-title {
  margin:      0 0 .3rem;
  font-size:   .875rem;
  line-height: 1.4;
}
.cnrh-featured__sidebar-title a { color: var(--cnrh-text); text-decoration: none; }
.cnrh-featured__sidebar-title a:hover { color: var(--cnrh-primary); }

/* ── Carousel ───────────────────────────────────── */
.cnrh-carousel {
  position:      relative;
  background:    var(--cnrh-bg);
  border-radius: var(--cnrh-radius);
  padding:       var(--cnrh-gap) 0;
  overflow:      hidden;
}

.cnrh-carousel__track-wrapper { overflow: hidden; padding: 0 var(--cnrh-gap); }

.cnrh-carousel__track {
  display:    flex;
  gap:        var(--cnrh-gap);
  transition: transform .4s cubic-bezier(.25,.1,.25,1);
  will-change: transform;
}

.cnrh-carousel__slide { flex-shrink: 0; }

.cnrh-carousel__btn {
  position:      absolute;
  top:           50%;
  transform:     translateY(-50%);
  background:    var(--cnrh-card-bg);
  border:        1px solid var(--cnrh-border);
  border-radius: 50%;
  width:         40px;
  height:        40px;
  font-size:     1.4rem;
  line-height:   1;
  cursor:        pointer;
  box-shadow:    var(--cnrh-shadow);
  z-index:       2;
  transition:    background .15s, box-shadow .15s;
  display:       flex;
  align-items:   center;
  justify-content: center;
  color:         var(--cnrh-text);
}
.cnrh-carousel__btn:hover { background: var(--cnrh-primary); color: #fff; box-shadow: var(--cnrh-shadow-h); }
.cnrh-carousel__btn--prev { left:  .5rem; }
.cnrh-carousel__btn--next { right: .5rem; }

.cnrh-carousel__dots {
  display:         flex;
  justify-content: center;
  gap:             6px;
  margin-top:      .75rem;
}
.cnrh-carousel__dot {
  width:         8px;
  height:        8px;
  border-radius: 50%;
  background:    var(--cnrh-border);
  cursor:        pointer;
  transition:    background .2s;
}
.cnrh-carousel__dot--active { background: var(--cnrh-primary); }

/* ── Utility ────────────────────────────────────── */
.cnrh-empty,
.cnrh-notice {
  padding:       1.25rem;
  text-align:    center;
  color:         var(--cnrh-text-muted);
  font-size:     .9rem;
  border:        1px dashed var(--cnrh-border);
  border-radius: var(--cnrh-radius);
}

/* ── Feed Wrapper ───────────────────────────────── */
.cnrh-feed-wrap { position: relative; }

/* ── Search ─────────────────────────────────────── */
.cnrh-search-wrap { margin-bottom: var(--cnrh-gap); }

.cnrh-search {
  width:         100%;
  padding:       .6rem 1rem;
  border:        1px solid var(--cnrh-border);
  border-radius: var(--cnrh-radius);
  background:    var(--cnrh-card-bg);
  color:         var(--cnrh-text);
  font-size:     .9rem;
  outline:       none;
  transition:    border-color .2s, box-shadow .2s;
  box-sizing:    border-box;
}

.cnrh-search:focus {
  border-color: var(--cnrh-primary);
  box-shadow:   0 0 0 3px rgba(0,115,170,.15);
}

.cnrh-card--hidden { display: none !important; }

/* ── Load More ───────────────────────────────────── */
.cnrh-load-more-wrap {
  display:         flex;
  justify-content: center;
  margin-top:      calc(var(--cnrh-gap) * 1.5);
}

.cnrh-load-more-btn {
  padding:     .65rem 2rem;
  background:  var(--cnrh-primary);
  color:       #fff;
  border:      none;
  border-radius: var(--cnrh-radius);
  font-size:   .9rem;
  font-weight: 600;
  cursor:      pointer;
  transition:  background .2s, transform .1s;
}

.cnrh-load-more-btn:hover  { background: var(--cnrh-primary-h); }
.cnrh-load-more-btn:active { transform: scale(.97); }
.cnrh-load-more-btn:disabled { opacity: .5; cursor: not-allowed; }

.cnrh-load-more-btn.cnrh-loading::after {
  content:      '';
  display:      inline-block;
  width:        12px;
  height:       12px;
  border:       2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation:    cnrh-spin .6s linear infinite;
  margin-left:  .5rem;
  vertical-align: middle;
}

@keyframes cnrh-spin { to { transform: rotate(360deg); } }
