/*
 * desktop-sidebar.css
 * 3-column ad layout — DESKTOP ONLY (min-width: 1280px)
 * Mobile view is completely unchanged.
 * Do not touch blog.css — all overrides are scoped here.
 */

/* ═══════════════════════════════════════════════════
   MOBILE GUARD — screens narrower than 1280px
   Sidebars are hidden; no ad content bleeds into view.
   Layout is a simple full-width block stack.
   ═══════════════════════════════════════════════════ */

/* Hide both sidebars completely on mobile/tablet */
.ds-sidebar-left,
.ds-sidebar-right {
  display: none !important;
}

/* Prevent the layout wrapper from causing horizontal overflow */
.ds-layout {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Main content column fills full width on mobile */
.ds-main-col {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}


/* ═══════════════════════════════════════════════════
   DESKTOP LAYOUT SHELL
   ═══════════════════════════════════════════════════ */
@media (min-width: 1280px) {

  /* Prevent horizontal scroll at body level */
  body { overflow-x: hidden; }

  /* Expand main container for 3-col layout */
  main#main-content.container {
    max-width: 1520px;
    width: 100%;
    padding: 0 16px;
    box-sizing: border-box;
  }

  /* 3-column grid: fixed 300px sidebars | flexible article center */
  .ds-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 300px;
    gap: 20px;
    align-items: stretch; /* sidebars stretch to article height */
    width: 100%;
    box-sizing: border-box;
    overflow-x: unset;
  }

  .ds-main-col {
    grid-column: 2;
    min-width: 0;
    overflow: hidden;
    width: auto;
  }

  .ds-sidebar-left  {
    display: flex !important;
    flex-direction: column;
    gap: 16px;
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    overflow: hidden;
  }
  .ds-sidebar-right {
    display: flex !important;
    flex-direction: column;
    gap: 16px;
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
    overflow: hidden;
  }

  /* .ds-sticky was position:sticky but that breaks inside overflow:hidden parent.
     Now just a transparent pass-through for the flex column layout. */
  .ds-sticky {
    display: contents; /* children participate directly in sidebar flex layout */
  }

  /* ds-sidebar-flow: same — contents pass directly into flex layout */
  .ds-sidebar-flow {
    display: contents;
  }


  /* AD BLOCK */
  .ds-ad-block {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 22px 0 0;
    text-align: center;
    box-shadow: var(--card-shadow);
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
  }

  .ds-ad-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-meta);
    font-weight: 700;
    margin-bottom: 8px;
    display: block;
    padding: 0 8px;
  }

  /* ── AD UNIT BASE ──────────────────────────────────── */
  .ds-ad-unit {
    display: block;
    margin: 0 auto;
    box-sizing: border-box;
    /* Default: quiet placeholder — no shimmer yet (slot not visible) */
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-light);
    transition: background 0.3s ease;
    overflow: hidden;
    position: relative;
  }

  /* Slot is visible and actively loading — show skeleton shimmer */
  .ds-ad-unit.ds-ad-loading {
    background: linear-gradient(
      90deg,
      var(--bg-primary)   25%,
      var(--border-light) 50%,
      var(--bg-primary)   75%
    );
    background-size: 200% 100%;
    animation: ds-shimmer 1.6s ease-in-out infinite;
  }

  /* Ad has loaded — kill shimmer, remove border, show content */
  .ds-ad-unit.ds-ad-loaded {
    background: transparent;
    border: none;
    border-radius: 0;
    animation: none;
    overflow: visible;
  }

  @keyframes ds-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  /* ── EXACT SIZE CLASSES ─────────────────────────────
     min-height = real ad pixel height so no layout shift.
     width / max-width constrains horizontal footprint.
     height: auto lets the ad expand naturally if needed.
  ─────────────────────────────────────────────────── */
  .ds-ad-300x250 {
    width: 300px;
    max-width: 100%;
    min-height: 250px;
    height: auto;
  }

  .ds-ad-160x600 {
    width: 160px;
    min-height: 600px;
    height: auto;
  }

  .ds-ad-160x300 {
    width: 160px;
    min-height: 300px;
    height: auto;
  }

  .ds-ad-320x50 {
    max-width: 320px;
    width: 100%;
    min-height: 50px;
    height: auto;
  }

  .ds-ad-728x90 {
    max-width: 728px;
    width: 100%;
    min-height: 90px;
    height: auto;
  }

  .ds-ad-468x60 {
    max-width: 468px;
    width: 100%;
    min-height: 60px;
    height: auto;
  }

  .ds-ad-native {
    max-width: 100%;
    width: 100%;
    min-height: 80px;
    height: auto;
    overflow: hidden;
    position: relative;
  }

  .ds-ad-native > div {
    max-width: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  /* SECTION BLOCK */
  .ds-section-block {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--card-shadow);
    box-sizing: border-box;
    width: 100%;
  }

  .ds-block-title {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 6px;
  }

  /* RECOMMENDED ARTICLE CARDS */
  .ds-rec-card {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    padding: 9px 0;
    border-bottom: 1px solid var(--border-light);
    text-decoration: none;
    transition: opacity 0.15s;
    min-width: 0;
  }
  .ds-rec-card:last-child { border-bottom: none; padding-bottom: 0; }
  .ds-rec-card:hover { opacity: 0.72; }

  .ds-rec-img {
    width: 54px;
    height: 54px;
    min-width: 54px;
    border-radius: 7px;
    object-fit: cover;
    background: var(--bg-primary);
  }

  .ds-rec-info { flex: 1; min-width: 0; }

  .ds-rec-cat {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 3px;
    display: block;
  }

  .ds-rec-title {
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    margin-bottom: 2px;
  }

  .ds-rec-desc {
    font-size: 10px;
    color: var(--text-meta);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* TABLE OF CONTENTS */
  .ds-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
  }

  .ds-toc-item a {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 11px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 5px 6px;
    border-radius: 7px;
    transition: background 0.15s, color 0.15s;
    line-height: 1.4;
    min-width: 0;
    word-break: break-word;
  }
  .ds-toc-item a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }

  .ds-toc-num {
    font-size: 9px;
    font-weight: 800;
    color: var(--accent);
    background: var(--accent-muted);
    border-radius: 4px;
    padding: 2px 5px;
    flex-shrink: 0;
    min-width: 22px;
    text-align: center;
    margin-top: 2px;
  }
}
