/* ========================================
   RESET & BASE STYLES
   ======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #2c3e50;
  background-color: #f8f9fa;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: #3498db;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #2980b9;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

ul {
  list-style: none;
}

/* ========================================
   WRAPPER & LAYOUT
   ======================================== */

.wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================
   HEADER
   ======================================== */

.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  padding: 1rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.header__logo {
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
}

.header__logo a {
  color: #ffffff;
  display: block;
}

.header__logo img {
  max-height: 50px;
  width: auto;
}

.header__toggle {
  display: none;
  padding: 0.5rem;
  color: #ffffff;
}

.header__toggle svg {
  stroke: currentColor;
}

.header .nav {
  flex: 1;
}

.header .nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: flex-end;
}

.header .nav a {
  color: #ffffff;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.header .nav a:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

/* Header with categories in logo area */
.header--categories .header__inner {
  flex-wrap: wrap;
}

.header--categories .nav {
  width: 100%;
  order: 3;
  margin-top: 1rem;
}

.header--categories .nav ul {
  justify-content: flex-start;
}

/* ========================================
   CATEGORY TRAY (Top Menu)
   ======================================== */

.tray {
  background-color: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tray__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.tray ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.75rem 0;
}

.tray a {
  color: #555;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.tray a:hover {
  background-color: #f0f0f0;
  color: #667eea;
}

/* ========================================
   MOBILE NAVIGATION
   ======================================== */

.smallnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  overflow-y: auto;
}

.smallnav__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.5rem;
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}

.smallnav ul {
  max-width: 400px;
  margin: 5rem auto 2rem;
  padding: 0 1.5rem;
}

.smallnav li {
  margin-bottom: 0.5rem;
}

.smallnav a {
  display: block;
  padding: 1rem;
  background-color: #ffffff;
  color: #2c3e50;
  border-radius: 8px;
  font-weight: 500;
}

.smallnav a:hover {
  background-color: #667eea;
  color: #ffffff;
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */

.main {
  flex: 1;
  padding: 2rem 0;
}

.main__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* ========================================
   CONTENT & SIDEBAR LAYOUT
   ======================================== */

.content {
  min-width: 0;
}

.sidebar {
  background-color: #ffffff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.sidebar h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: #2c3e50;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #667eea;
}

.sidebar > *:not(:last-child) {
  margin-bottom: 2rem;
}

.sidebar .nav ul {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar .nav a {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  color: #555;
}

.sidebar .nav a:hover {
  background-color: #f8f9fa;
  color: #667eea;
}

.sidebar .nav svg {
  margin-right: 0.5rem;
  flex-shrink: 0;
}

/* ========================================
   SEARCH FORM
   ======================================== */

.search-form {
  background-color: #ffffff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 2rem;
}

.search-form form {
  display: flex;
  gap: 0.75rem;
}

.search-form input[type="text"] {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.search-form input[type="text"]:focus {
  outline: none;
  border-color: #667eea;
}

.search-form input[type="submit"] {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.search-form input[type="submit"]:hover {
  transform: translateY(-2px);
}

/* ========================================
   ARTICLES GRID
   ======================================== */

.articles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.article {
  background-color: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.article:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.article__image {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background-color: #f0f0f0;
}

.article__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.article:hover .article__image img {
  transform: scale(1.05);
}

.article__title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 1rem 1.5rem 0.75rem;
}

.article__title a {
  color: #2c3e50;
}

.article__title a:hover {
  color: #667eea;
}

.article__perex {
  margin: 0 1.5rem 0.75rem;
  color: #555;
  line-height: 1.6;
}

.article__category {
  margin: 0 1.5rem 0.5rem;
  font-size: 0.875rem;
  color: #888;
}

.article__category a {
  color: #667eea;
  font-weight: 500;
}

.article__date {
  margin: 0 1.5rem 1.5rem;
  font-size: 0.875rem;
  color: #888;
}

/* ========================================
   TOP ARTICLES SECTION
   ======================================== */

.top {
  background-color: #ffffff;
  padding: 2rem 0;
  margin-bottom: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.top__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.top .article {
  box-shadow: none;
}

/* ========================================
   BOTTOM SECTION (Similar Articles)
   ======================================== */

.bottom {
  background-color: #ffffff;
  padding: 2rem 0;
  margin-bottom: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bottom__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.bottom .article {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* ========================================
   FULL ARTICLE (POST PAGE)
   ======================================== */

.text {
  background-color: #ffffff;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 2rem;
}

.text__title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1.5rem;
  color: #2c3e50;
}

.text__cover {
  margin-bottom: 2rem;
  border-radius: 8px;
  overflow: hidden;
}

.text__cover img {
  width: 100%;
  height: auto;
}

.text__body {
  font-size: 1.0625rem;
  line-height: 1.8;
  color: #333;
}

.text__body h2 {
  font-size: 1.75rem;
  margin: 2rem 0 1rem;
  color: #2c3e50;
  font-weight: 700;
}

.text__body h3 {
  font-size: 1.375rem;
  margin: 1.5rem 0 0.75rem;
  color: #2c3e50;
  font-weight: 600;
}

.text__body p {
  margin-bottom: 1.25rem;
}

.text__body ul,
.text__body ol {
  margin: 1.25rem 0;
  padding-left: 2rem;
}

.text__body ul {
  list-style: disc;
}

.text__body ol {
  list-style: decimal;
}

.text__body li {
  margin-bottom: 0.5rem;
}

.text__body a {
  color: #667eea;
  text-decoration: underline;
}

.text__body img {
  margin: 1.5rem 0;
  border-radius: 8px;
}

.text__body blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid #667eea;
  background-color: #f8f9fa;
  font-style: italic;
  color: #555;
}

.text__body iframe {
  margin: 1.5rem 0;
  border-radius: 8px;
}

/* Table of Contents */
.table-of-content {
  background-color: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  border: 1px solid #e0e0e0;
}

.table-of-content span {
  display: block;
  font-weight: 700;
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
  color: #2c3e50;
}

.table-of-content ul {
  list-style: none;
  padding-left: 0;
}

.table-of-content li {
  margin-bottom: 0.5rem;
}

.table-of-content a {
  color: #667eea;
}

/* Article Info */
.text__info {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid #e0e0e0;
  font-size: 0.9375rem;
  color: #666;
}

.text__info p {
  margin-bottom: 0.5rem;
}

.text__info a {
  color: #667eea;
  font-weight: 500;
}

.text__date,
.text__category,
.text__author,
.text__tags {
  margin-bottom: 0.5rem;
}

/* Author image in text */
img.author {
  float: right;
  margin: 0 0 1rem 1.5rem;
  max-width: 200px;
  border-radius: 8px;
}

/* ========================================
   PAGINATION
   ======================================== */

.pagination {
  margin: 2rem 0;
}

.pagination ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.pagination li {
  display: inline-block;
}

.pagination a,
.pagination__active {
  display: block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.pagination a {
  background-color: #ffffff;
  color: #667eea;
  border: 1px solid #e0e0e0;
}

.pagination a:hover {
  background-color: #667eea;
  color: #ffffff;
  border-color: #667eea;
}

.pagination__active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  border: 1px solid transparent;
}

/* ========================================
   SIDEBAR WIDGETS
   ======================================== */

.sidebar .article {
  box-shadow: none;
  border: 1px solid #e0e0e0;
}

.sidebar .article__image {
  aspect-ratio: 16 / 9;
}

.sidebar .article__title {
  font-size: 1rem;
  margin: 0.75rem 1rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tags li a {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background-color: #f0f0f0;
  color: #555;
  border-radius: 20px;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.tags li a:hover {
  background-color: #667eea;
  color: #ffffff;
}

.tags svg {
  width: 16px;
  height: 16px;
  margin-right: 0.5rem;
}

.promo {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.promo li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.promo svg {
  flex-shrink: 0;
  margin-top: 0.25rem;
  stroke: #667eea;
}

.promo a {
  color: #555;
}

.promo a:hover {
  color: #667eea;
}

.authors {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.authors li a {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background-color: #f8f9fa;
  border-radius: 6px;
  color: #555;
  transition: all 0.2s ease;
}

.authors li a:hover {
  background-color: #667eea;
  color: #ffffff;
}

.authors svg {
  width: 20px;
  height: 20px;
  margin-right: 0.75rem;
  stroke: currentColor;
}

/* ========================================
   PREFOOTER (Bottom Sidebar)
   ======================================== */

.prefooter {
  background-color: #f8f9fa;
  padding: 2rem 0;
  border-top: 1px solid #e0e0e0;
}

.prefooter__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.prefooter .sidebar {
  background-color: transparent;
  padding: 0;
  box-shadow: none;
}

.prefooter .sidebar > div {
  background-color: #ffffff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ========================================
   FOOTER
   ======================================== */

.footer {
  background-color: #2c3e50;
  color: #ffffff;
  padding: 2rem 0;
  margin-top: auto;
}

.footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
}

.footer p {
  margin-bottom: 0.5rem;
  font-size: 0.9375rem;
  opacity: 0.9;
}

/* ========================================
   POPUP
   ======================================== */

.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #ffffff;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 3000;
  display: none;
}

.popup::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: -1;
}

.popup #close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #f0f0f0;
  font-size: 1.5rem;
  line-height: 1;
  color: #555;
  transition: all 0.2s ease;
}

.popup #close:hover {
  background-color: #667eea;
  color: #ffffff;
}

/* ========================================
   RESPONSIVE DESIGN - TABLET
   ======================================== */

@media (min-width: 640px) {
  .articles {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .top__inner {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .bottom__inner {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .prefooter__inner {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  html {
    font-size: 17px;
  }
  
  .text {
    padding: 3rem;
  }
  
  .text__title {
    font-size: 2.5rem;
  }
  
  .popup {
    max-width: 600px;
  }
}

/* ========================================
   RESPONSIVE DESIGN - DESKTOP
   ======================================== */

@media (min-width: 1024px) {
  .header__toggle {
    display: none;
  }
  
  .main__inner {
    grid-template-columns: 1fr 320px;
  }
  
  .articles {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .top__inner {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .bottom__inner {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .prefooter__inner {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1023px) {
  .header .nav {
    display: none;
  }
  
  .header__toggle {
    display: block;
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.similar {
  background-color: #fff9e6;
  border-left: 4px solid #ffc107;
}

/* Print Styles */
@media print {
  .header,
  .tray,
  .sidebar,
  .prefooter,
  .footer,
  .pagination,
  .search-form {
    display: none;
  }
  
  .main__inner {
    grid-template-columns: 1fr;
  }
  
  body {
    background-color: #ffffff;
  }
}