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

:root {
    --primary: #f7931a;
    --secondary: #4a90e2;
    --dark: #1a1a2e;
    --darker: #0f0f1e;
    --light: #f5f5f5;
    --success: #27ae60;
    --danger: #e74c3c;
    --text: #333;
    --border: #ddd;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--light);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: var(--dark);
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo h1 {
    color: var(--primary);
    font-size: 24px;
    margin: 0;
}

.logo .tagline {
    font-size: 12px;
    color: #aaa;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 25px;
}

.main-nav a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
}

.main-nav a:hover {
    color: var(--primary);
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn {
    padding: 8px 20px;
    border-radius: 5px;
    text-decoration: none;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #e68310;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.user-menu {
    position: relative;
}

.user-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
}

.user-toggle img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 5px;
    min-width: 200px;
    margin-top: 0; /* remove gap to avoid hover flicker */
    z-index: 1000; /* ensure it renders above header */
}

.user-menu:hover .dropdown,
.user-menu.open .dropdown {
    display: block;
}

.dropdown a {
    display: block;
    padding: 12px 20px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.3s;
}

.dropdown a:hover {
    background: var(--light);
}

.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

/* Crypto Ticker */
.crypto-ticker-wrapper {
    background: var(--darker);
    color: white;
    padding: 8px 0 4px; /* tighter bottom to create ~4px gap to hero */
    overflow: hidden;
}

.sticky-ticker {
    position: sticky;
    top: 0;
    z-index: 99;
}

.crypto-ticker {
    display: flex;
    gap: 30px;
    animation: scroll 30s linear infinite;
    white-space: nowrap;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.coin-name {
    font-weight: bold;
    color: var(--primary);
}

.coin-change.positive {
    color: var(--success);
}

.coin-change.negative {
    color: var(--danger);
}

@keyframes scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Banner Slider */
.banner-slider {
    position: relative;
    margin: 10px 0;
    height: 300px;
    border-radius: 10px;
    overflow: hidden;
}

.banner-slide {
    display: none;
    width: 100%;
    height: 100%;
}

.banner-slide.active {
    display: block;
}

.banner-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Ad Spaces */
.ad-space {
    background: #f9f9f9;
    border: 1px dashed var(--border);
    padding: 0;
    margin: 10px 0;
    text-align: center;
    border-radius: 5px;
}
/* Ensure header ad has no frame and is left-aligned */
.header-ad.ad-space {
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    text-align: left !important;
}

/* Hero Row: left ad + banner */
.hero-row {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    align-items: stretch;
    margin-top: 0; /* rely on ticker's 4px bottom padding */
}

.header-ad {
    height: 250px; /* match banner height */
    display: flex;
    align-items: flex-start; /* top align ad content */
    justify-content: flex-start; /* left align ad content */
    overflow: hidden;
}

/* Remove default ad-space vertical margin inside hero */
.hero-row .header-ad {
    margin: 0;
}

/* Banner Slider */
.banner-slider {
    position: relative;
    margin: 0; /* no extra vertical margin; rely on hero-row gap */
    height: 250px; /* match left ad height */
    border-radius: 10px;
    overflow: hidden;
}

.banner-slide {
    display: none;
    width: 100%;
    height: 100%;
}

.banner-slide.active {
    display: block;
}

.banner-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Content Layout */
.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 30px;
    margin: 0; /* remove extra vertical space around posts container */
}

.main-content {
    background: white;
    padding: 16px 24px 24px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Posts Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 8px;
}

.post-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.post-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

/* Reserve consistent aspect-ratio to reduce CLS on post cards */
.post-image {
    aspect-ratio: 3 / 2;
}

.post-content {
    padding: 20px;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #666;
}

.author-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.post-content h2 {
    font-size: 20px;
    margin: 10px 0;
}

.post-content h2 a {
    color: var(--text);
    text-decoration: none;
}

.post-content h2 a:hover {
    color: var(--primary);
}
.post-content ul {
    margin: 16px 0 16px 24px;
}
.post-content li {
    margin: 6px 0;
}

.post-stats {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: #666;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.widget {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.widget h3 {
    margin-bottom: 15px;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
}

.popular-posts {
    list-style: none;
}

.popular-posts li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.popular-posts li:last-child {
    border-bottom: none;
}

.popular-posts a {
    color: var(--text);
    text-decoration: none;
    display: flex;
    justify-content: space-between;
}

.popular-posts .views {
    font-size: 12px;
    color: #999;
}

/* Footer */
.site-footer {
    background: var(--dark);
    color: white;
    padding: 40px 0 20px;
    margin-top: 50px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-section h3 {
    color: var(--primary);
    margin-bottom: 15px;
}

.footer-section ul {
    list-style: none;
}

.footer-section a {
    color: #ccc;
    text-decoration: none;
    line-height: 2;
}

.footer-section a:hover {
    color: var(--primary);
}

.social-links {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.social-links a {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border-radius: 50%;
    transition: background 0.3s;
}

.social-links a:hover {
    background: var(--secondary);
}

.newsletter-form {
    display: flex;
    margin-top: 15px;
}

.newsletter-form input {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px 0 0 5px;
}

.newsletter-form button {
    background: var(--primary);
    border: none;
    padding: 10px 20px;
    border-radius: 0 5px 5px 0;
    color: white;
    cursor: pointer;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #444;
    color: #aaa;
    font-size: 14px;
}

.disclaimer-note {
    font-size: 12px;
    margin-top: 10px;
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 1000;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .main-nav {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .posts-grid {
        grid-template-columns: 1fr;
    }
    
    .crypto-ticker {
        gap: 15px;
    }
    
    .banner-slider {
        height: 250px;
        margin: 24px 0; /* keep comfortable spacing on mobile */
    }
}

/* Hero Row: Header Ad + Banner Slider */
.hero-row {
  /* Hero Grid Layout (top-level overrides to fix nesting and spacing) */
  .hero-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
      "leftad righttop"
      "leftad rightcontent";
    column-gap: 16px;
    row-gap: 8px; /* tighter vertical spacing */
    align-items: start;
  }
  .hero-grid .header-ad { grid-area: leftad; }
  .hero-grid .banner-slider { grid-area: righttop; }
  .hero-grid .content-wrapper { grid-area: rightcontent; }
  
  /* Remove ad frame and centering just for the left header ad slot */
  .hero-grid .header-ad.ad-space {
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    text-align: left;
  }
  .hero-grid .header-ad {
    width: 300px;
    aspect-ratio: 300 / 250;
  }
  
  /* Make the right banner auto-size to creative height, no frame */
  .hero-grid .banner-slider {
    /* enforce desktop width for 728x90 creatives */
    width: 728px !important;
    max-width: 728px;
    }
    .hero-grid .banner-slider img {
    width: 728px;
    height: 90px;
    }
    @media (min-width: 1024px) {
    .hero-grid .banner-slider,
    .hero-grid .banner-slider img {
    width: 100% !important;
    height: auto !important;
    }
    }
    
  /* Ensure content sits tight under the banner */
  .hero-grid .content-wrapper { margin-top: 0; margin-bottom: 0; }
  .main-content h1 { margin-top: 0; }
  
  /* Responsive stacking */
  @media (max-width: 1024px) {
    .hero-grid {
      grid-template-columns: 1fr;
      grid-template-rows: auto auto auto;
      grid-template-areas:
        "righttop"
        "leftad"
        "rightcontent";
    }
    .hero-grid .banner-slider { max-width: 100%; }
  }
  
  /* Prevent heading margin from creating gap under hero */
  .main-content h1 { margin-top: 0; }
  .main-content {
    background: white;
    padding: 0 24px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
  .posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 0;
  }
  .post-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
  }
  .post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  }
  .post-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
  }
  .post-content {
    padding: 20px;
  }
  .post-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #666;
  }
  .author-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
  }
  .post-content h2 {
    font-size: 20px;
    margin: 10px 0;
  }
  .post-content h2 a {
    color: var(--text);
    text-decoration: none;
  }
  .post-content h2 a:hover {
    color: var(--primary);
  }
  .post-stats {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: #666;
  }
  .popular-posts {
    list-style: none;
  }
  .popular-posts li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .popular-posts li:last-child {
    border-bottom: none;
  }
  .popular-posts a {
    color: var(--text);
    text-decoration: none;
    display: flex;
    justify-content: space-between;
  }
  .popular-posts .views {
    font-size: 12px;
    color: #999;
  }
  .hero-row .header-ad iframe,
  .hero-row .header-ad ins,
  .hero-row .header-ad img { display: block; }
  .hero-row .banner-slider {
    flex: 1 1 auto;
    height: 90px; /* align with 728x90 ad height */
    margin: 0;
    border-radius: 8px;
  }
  .hero-row .banner-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  /* Overrides to improve hero-row banner fit and spacing */
  .hero-row { align-items: flex-start; flex-wrap: nowrap; justify-content: flex-start; }
  .hero-row .banner-slider { padding: 0; background: #f9f9f9; border: 1px dashed var(--border); }
  .hero-row .banner-slide img { object-fit: contain; object-position: center; }
  .hero-row + .content-wrapper { margin-top: 0 !important; }
}

/* Hero Grid Layout (top-level) */
.hero-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: auto auto;
  grid-template-areas:
    "leftad righttop"
    "leftad rightcontent";
  column-gap: 16px;
  row-gap: 8px;
  align-items: start;
  margin: 0;
}
.hero-grid .header-ad { grid-area: leftad; width: 360px; height: 90px; aspect-ratio: 4 / 1; justify-content: flex-start; }
.hero-grid .header-ad.ad-space {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  text-align: left !important;
}
.hero-grid .banner-slider {
  grid-area: righttop;
  max-width: 360px;
  width: 360px;
  height: auto !important;
  min-height: 90px; /* reserve space so content doesn’t jump up */
  aspect-ratio: 4 / 1;
  margin: 0 !important;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  display: inline-block;
  justify-self: start;
  overflow: visible;

  .hero-grid .banner-slider .banner-slide { display: none; }
  .hero-grid .banner-slider .banner-slide.active { display: block; }
  .hero-grid .banner-slider img {
    display: block;
    max-width: 100%;
    object-fit: contain;
  }
  @media (max-width: 1024px) {
    .hero-grid .banner-slider {
      width: 100% !important;
      max-width: 100% !important;
      aspect-ratio: auto;
    }
    .hero-grid .banner-slider img {
      width: 100% !important;
      height: auto !important;
    }
  }
  .hero-grid .banner-slider img {
    width: 100% !important;
    height: auto !important;
  }


  /* Ensure content sits tight under the banner */
  .hero-grid .content-wrapper { margin-top: 0; margin-bottom: 0; }
  .main-content h1 { margin-top: 0; }
  
  /* Responsive stacking */
  @media (max-width: 1024px) {
    .hero-grid {
      grid-template-columns: 1fr;
      grid-template-rows: auto auto auto;
      grid-template-areas:
        "righttop"
        "leftad"
        "rightcontent";
    }
    .hero-grid .banner-slider { max-width: 100%; }
  }
  
  /* Prevent heading margin from creating gap under hero */
  .main-content h1 { margin-top: 0; }
  .main-content {
    background: white;
    padding: 0 24px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
  .posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 0;
  }
  .post-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
  }
  .post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  }
  .post-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
  }
  .post-content {
    padding: 20px;
  }
  .post-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #666;
  }
  .author-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
  }
  .post-content h2 {
    font-size: 20px;
    margin: 10px 0;
  }
  .post-content h2 a {
    color: var(--text);
    text-decoration: none;
  }
  .post-content h2 a:hover {
    color: var(--primary);
  }
  .post-stats {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: #666;
  }
  .popular-posts {
    list-style: none;
  }
  .popular-posts li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .popular-posts li:last-child {
    border-bottom: none;
  }
  .popular-posts a {
    color: var(--text);
    text-decoration: none;
    display: flex;
    justify-content: space-between;
  }
  .popular-posts .views {
    font-size: 12px;
    color: #999;
  }
  .hero-row .header-ad iframe,
  .hero-row .header-ad ins,
  .hero-row .header-ad img { display: block; }
  .hero-row .banner-slider {
    flex: 1 1 auto;
    height: 90px; /* align with 728x90 ad height */
    margin: 0;
    border-radius: 8px;
  }
  .hero-row .banner-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  /* Overrides to improve hero-row banner fit and spacing */
  .hero-row { align-items: flex-start; flex-wrap: nowrap; justify-content: flex-start; }
  .hero-row .banner-slider { padding: 0; background: #f9f9f9; border: 1px dashed var(--border); }
  .hero-row .banner-slide img { object-fit: contain; object-position: center; }
  .hero-row + .content-wrapper { margin-top: 0 !important; }
}

/* Final overrides: equalize and center top ads, large screens */
@media (min-width: 1024px) {
  .hero-grid {
    display: grid;
    grid-template-columns: 728px 1fr !important;
    grid-template-rows: auto auto;
    grid-template-areas:
      "leftad righttop"
      "content content";
    gap: 16px;
    align-items: start;
  }
  .hero-grid .header-ad { grid-area: leftad; }
  .hero-grid .banner-slider { grid-area: righttop; }
  .hero-grid .content-wrapper { grid-area: content; }

  .hero-grid .header-ad,
  .hero-grid .banner-slider {
    width: 728px !important;
    height: 90px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
  }

  .hero-grid .header-ad img,
  .hero-grid .header-ad iframe,
  .hero-grid .header-ad ins,
  .hero-grid .banner-slider img,
  .hero-grid .banner-slider picture,
  .hero-grid .banner-slider video,
  .hero-grid .banner-slider iframe {
    max-width: 100% !important;
    width: 100% !important;
    height: 90px !important;
    object-fit: cover !important;
    display: block !important;
  }
}