/* News Page CSS - Styles specific to news/index.php and news/view.php */

/* ============================================
   News Article
   ============================================ */
.news-article {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* ============================================
   News Excerpt - Modern Styling
   ============================================ */
.news-excerpt {
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--color-text-light);
  font-style: italic;
  margin: var(--spacing-md) 0 var(--spacing-lg) 0;
  padding: var(--spacing-lg);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.08) 0%, rgba(157, 78, 221, 0.08) 100%);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--border-radius);
  border: 1px solid rgba(6, 182, 212, 0.2);
  position: relative;
  overflow: hidden;
}

.news-excerpt::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, 
    rgba(6, 182, 212, 0.4) 0%,
    rgba(157, 78, 221, 0.4) 100%);
  opacity: 0.6;
}

/* ============================================
   News Content Styling for Public Display
   ============================================ */
.news-image {
  margin: var(--spacing-lg) 0;
  text-align: center;
  display: block;
}

.news-image img {
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: block;
  max-width: 100%;
  margin: 20px 0;
  /* Match preview styles exactly */
}

/* For images with inline styles, respect those dimensions completely */
.news-image img[style*="width"] {
  max-width: 100%;
  width: inherit;
}

.news-image img[style*="height"] {
  height: inherit;
}

/* Force img inline styles to override everything */
.news-image img[style] {
  max-width: 100%;
  width: auto;
}

/* Styling for images extracted from image-text-layout */
.image-side {
  margin: var(--spacing-lg) 0;
  text-align: center;
  display: block;
}

.image-side img {
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: block;
  max-width: 100%;
  margin: 0 auto;
  height: auto;
}

.image-side .image-placeholder {
  border: 2px dashed var(--color-border);
  border-radius: var(--border-radius);
  padding: var(--spacing-lg);
  background: rgba(var(--color-primary-rgb), 0.05);
  color: var(--color-text-muted);
  font-style: italic;
}

.news-image-caption {
  margin-top: var(--spacing-sm);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  clear: both; /* Ensure caption goes below the image */
}

/* ============================================
   Hide Editor Controls in News Articles
   ============================================ */
/* Hide editor controls in news articles only (not in editor) */
.news-item .news-item-content-text .image-controls-toggle,
.news-item .news-item-content-text .resize-handle,
.news-item .news-item-content-text .text-controls-toggle {
  display: none;
}

/* Remove hover effects in news articles only */
.news-item .news-item-content-text .image-block:hover,
.news-item .news-item-content-text .video-block:hover {
  border-color: transparent;
  background: transparent;
}

.news-item .news-item-content-text .image-block figcaption:hover,
.news-item .news-item-content-text .video-block figcaption:hover {
  border-color: transparent;
  background: transparent;
}

/* Remove borders in news articles only */
.news-item .news-item-content-text .image-block figcaption,
.news-item .news-item-content-text .video-block figcaption {
  border: none;
  background: transparent;
}

.news-item .news-item-content-text .image-block,
.news-item .news-item-content-text .video-block {
  border: none;
}

/* ============================================
   News Text Content
   ============================================ */
.news-text-block {
  /* No special styling - just normal text content */
  margin: 0;
  padding: 0;
  background: none;
  border: none;
}

.news-text-content {
  /* No special styling - inherit from parent */
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

.news-text-content h2 {
  color: var(--color-text);
  margin-bottom: var(--spacing-md);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.news-text-content h3 {
  color: var(--color-text);
  margin-bottom: var(--spacing-sm);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.news-text-content strong {
  color: var(--color-text);
  font-weight: 600;
}

.news-text-content em {
  color: var(--color-text-muted);
  font-style: italic;
}

/* ============================================
   News List and Items - Modern Styling
   ============================================ */
.news-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.news-item {
  padding: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  position: relative;
  border-radius: var(--border-radius);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: var(--spacing-md);
}

/* Make news item clickable when wrapped in anchor */
.news-item-clickable {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.news-item-clickable:hover {
  text-decoration: none;
  color: inherit;
}

.news-item-clickable:hover *,
.news-item-clickable:focus-visible * {
  text-decoration: none;
  text-decoration-color: transparent;
  text-underline-offset: 0;
}

.news-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, 
    rgba(157, 78, 221, 0.6) 0%,
    rgba(6, 182, 212, 0.6) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
}

.news-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(157, 78, 221, 0.2);
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.news-item:hover::before {
  opacity: 1;
}

/* Remove hover effects for news items in article view (view.php) */
.news-article .news-item,
.news-view-page .news-view-card > .news-item,
.news-page .news-view-card > .news-item {
  cursor: default;
  pointer-events: none;
}

.news-article .news-item:hover,
.news-view-page .news-view-card > .news-item:hover,
.news-page .news-view-card > .news-item:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.06);
  transform: none;
  box-shadow: none;
}

.news-article .news-item:hover::before,
.news-view-page .news-view-card > .news-item:hover::before,
.news-page .news-view-card > .news-item:hover::before {
  opacity: 0;
}

/* Re-enable pointer events for interactive elements inside */
.news-article .news-item a,
.news-view-page .news-view-card > .news-item a,
.news-page .news-view-card > .news-item a {
  pointer-events: auto;
  cursor: pointer;
}

.news-item:last-child {
  padding-bottom: var(--spacing-lg);
  margin-bottom: 0;
}

.news-item--pinned {
  border-left: 4px solid rgba(234, 179, 8, 0.6);
  padding-left: var(--spacing-md);
  background: rgba(234, 179, 8, 0.05);
  border-color: rgba(234, 179, 8, 0.3);
}

.news-item--pinned::before {
  background: linear-gradient(180deg, 
    rgba(234, 179, 8, 0.8) 0%,
    rgba(234, 179, 8, 0.4) 100%);
  opacity: 1;
}

.news-item-pin {
  position: absolute;
  top: var(--spacing-md);
  left: var(--spacing-md);
  font-size: 1rem;
  line-height: 1;
  opacity: 0.8;
}

.news-item-content {
  position: relative;
  padding-left: var(--spacing-md);
}

.news-item--pinned .news-item-content {
  padding-left: calc(var(--spacing-md) + 4px);
}

.news-item-title h2,
.news-item-title h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 var(--spacing-sm) 0;
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.news-item-title {
  color: var(--color-text);
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
}

.news-item-clickable:hover .news-item-title {
  color: var(--color-primary);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.news-item-excerpt {
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--color-text-light);
  margin: var(--spacing-sm) 0 var(--spacing-md) 0;
}

.news-item-meta {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-md);
}

.news-item-footer {
  margin-top: var(--spacing-md);
}

.news-tag {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text);
  margin-right: var(--spacing-xs);
  margin-bottom: var(--spacing-xs);
}

.news-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
}

/* ============================================
   News Item Content Text
   ============================================ */
/* Clearfix for floated images */
.news-item-content-text::after {
  content: "";
  display: table;
  clear: both;
}

/* Ensure text flows around floated images */
.news-item-content-text {
  overflow: hidden; /* Creates new block formatting context */
  max-width: 100%; /* Prevent text from overflowing */
  line-height: 1.65;
  font-size: 1.0625rem;
}

/* Stycken: tydligt större avstånd mellan block än mellan rader inom samma stycke */
.news-item-content-text p,
.news-item-content-text .news-text-content > div:not(.image-text-layout) {
  margin: 0 0 2em 0;
  line-height: 1.6;
}

.news-item-content-text p:last-child,
.news-item-content-text .news-text-content > div:not(.image-text-layout):last-child {
  margin-bottom: 0;
}

/* Styckesbrytning från renderNewsContent (dubbel radbrytning i källan) */
.news-item-content-text .news-para-break {
  display: block;
  height: 0;
  margin-bottom: 1.25em;
}

/* Avstånd mellan textblock, bilder m.m. */
.news-item-content-text .news-text-block + .news-text-block,
.news-item-content-text .news-text-block + figure,
.news-item-content-text figure + .news-text-block {
  margin-top: var(--spacing-lg);
}

.news-item-content-text h2,
.news-item-content-text h3 {
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-md);
}

.news-item-content-text h2:first-child,
.news-item-content-text h3:first-child {
  margin-top: 0;
}

/* ============================================
   Image Alignment Classes
   ============================================ */
.image-block.align-left {
  float: left;
  margin-right: var(--spacing-md);
  max-width: 50%;
}

.image-block.align-left img {
  max-width: 100%;
  height: auto;
}

.image-block.align-right {
  float: right;
  margin-left: var(--spacing-md);
  max-width: 50%;
}

.image-block.align-right img {
  max-width: 100%;
  height: auto;
}

.image-block.align-center {
  text-align: center;
  margin: var(--spacing-lg) auto;
  max-width: 100%;
}

.image-block.align-center img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.image-block.align-full {
  width: 100%;
  margin: var(--spacing-lg) 0;
}

.image-block.align-full img {
  width: 100%;
  height: auto;
}

/* ============================================
   Image-Text Layout in News Content
   ============================================ */
.news-item-content-text .image-text-layout {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
}

.news-item-content-text .image-text-layout .image-side {
  border: none;
  background: none;
  margin: 0;
  padding: 0;
  max-width: 250px;
}

.news-item-content-text .image-text-layout .layout-controls {
  display: none;
}

.news-item-content-text .image-text-layout .text-side {
  padding: 0;
  min-height: 0;
}

/* Hide empty paragraphs and breaks in public news view */
.news-item-content-text .image-text-layout .text-side p:empty,
.news-item-content-text .image-text-layout .text-side br:only-child {
  display: none;
}

/* Override with more specific selectors for public view */
.news-item-content-text .image-text-layout .text-side p {
  font-style: normal;
  margin: 0 0 1em 0;
}

/* ============================================
   Category tabs (horisontell scroll)
   ============================================ */
.news-category-scroll-wrap {
  width: 100%;
  min-width: 0;
  margin-bottom: var(--spacing-md);
  border-radius: 12px;
  overflow: hidden;
  background: var(--nav-chrome-bg, rgba(20, 18, 28, 0.96));
  border: 1px solid var(--nav-chrome-border, rgba(255, 255, 255, 0.08));
  backdrop-filter: blur(var(--nav-chrome-blur, 12px));
  -webkit-backdrop-filter: blur(var(--nav-chrome-blur, 12px));
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.news-index-page .news-category-tabs.home-feed-tabs {
  margin: 0;
  width: 100%;
  max-width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.news-index-page .news-category-tabs.home-feed-tabs::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.news-index-page .news-category-tabs .home-feed-tab.tab-link {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.8125rem;
  padding: 0.7rem 0.85rem;
  letter-spacing: 0.02em;
}

/* Legacy chip strip (behålls om den används någon annanstans) */
.news-category-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-md);
  width: 100%;
  min-width: 0;
}

.news-page-lede a {
  color: var(--color-primary);
  font-weight: 600;
}

.news-view-meta {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

.news-view-card .news-item-title {
  font-size: 1.75rem;
  line-height: 1.25;
}

/* ============================================
   Responsive Design
   ============================================ */
/* Make image+text layout stack vertically on mobile */
@media (max-width: 768px) {
  .news-item-content-text .image-text-layout[style] {
    flex-direction: column !important;
    gap: 1em !important;
  }
  
  .news-item-content-text .image-text-layout .image-side {
    max-width: 100% !important;
    width: 100% !important;
  }
  
  .news-item {
    padding: var(--spacing-md);
  }
  
  .news-item-content {
    padding-left: 0;
  }
  
  .news-item--pinned .news-item-content {
    padding-left: var(--spacing-md);
  }

  .news-category-strip .btn-sm {
    font-size: 0.8125rem;
    padding: var(--spacing-xs) var(--spacing-sm);
  }
}

/* ============================================
   Modern Card Styling for News Page
   ============================================ */
/* Main news card */
.news-page .news-main-card,
.news-page .news-view-card,
.news-index-page .news-main-card,
.news-view-page .news-view-card,
.news-card-modern.news-main-card,
.news-card-modern.news-view-card {
  position: relative;
  background: linear-gradient(135deg, rgba(30, 30, 30, 0.6) 0%, rgba(30, 30, 30, 0.5) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 
              0 0 0 1px rgba(157, 78, 221, 0.1) inset;
}

.news-page .news-main-card::before,
.news-page .news-view-card::before,
.news-index-page .news-main-card::before,
.news-view-page .news-view-card::before,
.news-card-modern.news-main-card::before,
.news-card-modern.news-view-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    rgba(157, 78, 221, 0.03) 0%, 
    transparent 30%,
    transparent 70%,
    rgba(6, 182, 212, 0.03) 100%);
  border-radius: 12px;
  pointer-events: none;
  z-index: 0;
}

.news-page .news-main-card > *,
.news-page .news-view-card > *,
.news-index-page .news-main-card > *,
.news-view-page .news-view-card > *,
.news-card-modern.news-main-card > *,
.news-card-modern.news-view-card > * {
  position: relative;
  z-index: 1;
}

/* Card header modern styling */
.news-page .news-main-card > .card-header {
  position: relative;
  padding-bottom: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.news-page .news-main-card > .card-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%,
    rgba(157, 78, 221, 0.3) 50%,
    transparent 100%);
}

.news-page .news-main-card > .card-header .h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--color-text) 0%, var(--color-text-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Modern button styling in news items */
.news-item-footer .btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.news-item-footer .btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%);
  transition: left 0.5s ease;
}

.news-item-footer .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(157, 78, 221, 0.2);
}

.news-item-footer .btn:hover::before {
  left: 100%;
}

/* Category filter chips */
.news-category-strip .btn-ghost {
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.news-category-strip .btn-ghost.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(157, 78, 221, 0.15) 100%);
  border-color: rgba(157, 78, 221, 0.35);
  color: var(--color-primary);
}

/* ============================================
   Modern card + list (matchar startsidan)
   ============================================ */
.news-card-modern {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(30, 30, 30, 0.6) 0%, rgba(30, 30, 30, 0.5) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
              0 0 0 1px rgba(157, 78, 221, 0.1) inset;
}

.news-card-modern::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    rgba(157, 78, 221, 0.4) 0%,
    rgba(6, 182, 212, 0.4) 100%);
  opacity: 0.6;
  z-index: 1;
}

.news-card-modern::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
    rgba(157, 78, 221, 0.02) 0%,
    transparent 50%,
    rgba(6, 182, 212, 0.02) 100%);
  pointer-events: none;
  z-index: 0;
}

.news-card-modern > * {
  position: relative;
  z-index: 1;
}

.news-item-modern {
  padding: var(--spacing-md);
  border-radius: var(--border-radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: var(--spacing-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

a.news-item-modern.news-item-clickable {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.news-item-modern.news-item-clickable:hover,
a.news-item-modern.news-item-clickable:focus-visible {
  text-decoration: none;
  color: inherit;
}

.news-item-modern.news-item-clickable .news-item-title {
  color: var(--color-text);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.4;
  margin: 0 0 var(--spacing-xs);
  transition: color 0.2s ease;
}

a.news-item-modern.news-item-clickable:hover .news-item-title,
a.news-item-modern.news-item-clickable:focus-visible .news-item-title {
  color: var(--color-primary);
}

.news-item-modern::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg,
    rgba(157, 78, 221, 0.6) 0%,
    rgba(6, 182, 212, 0.6) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.news-item-modern:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(157, 78, 221, 0.2);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.news-item-modern:hover::before {
  opacity: 1;
}

.news-item-modern.news-item--pinned {
  border-color: rgba(234, 179, 8, 0.3);
  background: rgba(234, 179, 8, 0.05);
}

.news-item-modern.news-item--pinned::before {
  background: linear-gradient(180deg,
    rgba(234, 179, 8, 0.8) 0%,
    rgba(234, 179, 8, 0.4) 100%);
}

.news-item-modern .news-item-title a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.4;
  transition: color 0.2s ease;
}

.news-item-modern .news-item-title a:hover {
  color: var(--color-primary);
}

.news-index-page .news-category-scroll-wrap,
.news-view-page .news-view-card {
  width: 100%;
  min-width: 0;
}

.news-index-page .community-form-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.news-view-page .news-view-card {
  padding: var(--spacing-md);
}

.news-view-page .news-article {
  max-width: none;
  margin: 0;
  padding: 0;
}

.news-view-page .news-item-modern {
  margin-bottom: 0;
  border: none;
  background: transparent;
  transform: none;
  box-shadow: none;
}

.news-view-page .news-item-modern::before,
.news-view-page .news-item-modern:hover {
  transform: none;
  box-shadow: none;
  background: transparent;
  border-color: transparent;
}

.news-view-page .news-item-modern:hover::before {
  opacity: 0;
}

