/**
 * Cineverse Modular Stylesheet: Single Blog Posts & General Articles
 * Loaded conditionally on is_singular('post')
 */

/* --- Single Posts & General Article Styles (Migrated from style.css) --- */

/*
------------
Single Post Style
------------
*/

/* Post Content Wrapper Background */
#post-body  {
    background-color: var(--flex-gray-300);
}

#post-body .post-header-breadcrumbs {
    grid-column: 1 / -1;
    grid-row: 1 / span 1;
    gap: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

nav.rank-math-breadcrumb a, nav.rank-math-breadcrumb .last {
    background: var(--flex-gray-1);
    color: var(--primary-text-color);
}

#post-body .post-featured-image-wrapper {
  display: grid;
  grid-template-areas: "stack";
  grid-column: 1 / -1;
  width: 100%;
  height: 700px;
  padding: 0 2rem;
  box-sizing: border-box;
  overflow: hidden;
}

#post-body .post-feature-img {
  grid-area: stack;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: var(--cs-border);
  border-radius: 8px;
  box-shadow: var(--cs-shadow-1);
}

#post-body article p {
    color: var(--primary-text-color);
}

#post-wrapper .rbtoc {
    margin-bottom: 2rem;
}

#post-wrapper .toc-content a {
    position: relative;
    display: block;
    color: var(--heading-color);
    padding-top: 7px;
    padding-bottom: 7px;
    opacity: 1;
    transition: var(--effect);
    break-inside: avoid-column;
}

#post-wrapper .toc-content a:hover {
    color: var(--cs-brand);
    opacity: 0.8;
}

/* 2. The Article as a Subgrid */
/* This allows the children of article to align to the .cs-wrap columns */
.cs-wrap > article {
  grid-column: 1 / -1; /* Article spans all 12 columns */
  display: grid;
  grid-template-columns: subgrid;
  gap: 1rem;
}

/* 3. Assigning Elements to the Grid */

/* Main Content Area (e.g., Columns 1 to 8) */
.post-body-article {
  grid-column: 1 / span 8;
}

/* Sidebar Area (e.g., Columns 9 to 12) */
.post-sidebar-col,
.cs-sticky__sidebar {
  grid-column: 9 / span 4;
}

/* Metadata HUD (e.g., centered 6 columns) */
.post-header-meta {
  grid-column: 4 / span 6;
}

/* Use display: contents if you ever have a div that wraps these but shouldn't 
   interfere with the grid alignment */
.some-intermediate-wrapper {
  display: contents;
}

/* Bottom of Post CinesistDB Tag Box */
#post-wrapper #cinesist-db-links-box {
    display: flex;
    background-color: var(--flex-gray-100);
    border-radius: 12px;
    padding: 20px 25px;
    margin-top: 30px;
    margin-block-start: 2rem !important;
    border-top: 3px solid var(--cs-brand);
    box-shadow: var(--shadow-1);
    flex-direction: column;
    gap: 1rem;
}

/* Wrapper to hold icon and heading together */
.csdb-header-wrapper {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

/* Reset margins so they don't break the alignment */
.csdb-emblem, 
#tagged-in-cinesistdb {
    margin: 0 !important;
}

/* 3. Ensure the icon maintains its size */
.csdb-emblem {
    flex-shrink: 0;
}

#post-wrapper #cinesist-db-links-box .cinesist-border-brand {
  margin: 0;
}

/* DB Category Tags */
#post-wrapper #cinesist-db-links-box  .cinesist-db-links-list .cinesist-db-tag-link {
    background: var(--flex-gray-40);
  border-color: var(--cs-brand);
    color: var(--heading-color);
  border-top-width: 1px;
  border-left-width: 2px;
  border-right-width: 2px;
  border-bottom-width: 0px;
  border-style: solid;
}

#post-wrapper #cinesist-db-links-box .links-box-heading {
    display: inline-flex;
    gap: var(--cs-space-1);
    margin-bottom: 0 !important;
    /* display: inline-block; */
}

/* Adding Personality to Tags Block */
.wp-block-post-terms__prefix::before {content: "🏷️";font-size: var(--cs-icon-size-md);}

.topic-wrapper a[rel="tag"] {
  color: var(--primary-text-color);
  text-decoration: none;
  border: 2px solid var(--black-to-white-300);
}

.topic-wrapper a[rel="tag"]:hover {
  color: var(--cs-brand-400);
  text-decoration: none;
  border: 2px solid var(--cs-brand-600);
}

.topic-wrapper a[rel="tag"]:hover {
  color: var(--cs-brand)
}
/* 
########################################
New Post Template Styles
########################################
*/

/* Container CSS Grid definitions */
article.cs-post-grid {
  display: grid;
  width: 100%;
  max-width: 100%;
  column-gap: 40px;
  row-gap: 24px;
  grid-template-columns: minmax(24px, 1fr) minmax(500px, 875px) 310px minmax(24px, 1fr);
  grid-template-rows: auto auto auto 1fr;
  grid-template-areas: 
    ". cs-crumbs   cs-crumbs  ."
    ". cs-feature  cs-feature ."
    ". cs-meta     cs-sidebar ."
    ". cs-body     cs-sidebar .";
}

/* Area assignments */
.cs-post-grid--crumbs {
  grid-area: cs-crumbs;
  width: 100%;
}

.cs-post-grid--feature {
  grid-area: cs-feature;
  width: 100%;
  display: grid;
  grid-template-areas:
    "stack";
  height: 600px;
  position: relative;
  overflow: hidden;
  border: var(--cs-border);
  border-radius: 12px;
  box-shadow: var(--cs-shadow-1);
}

.cs-post-grid--feature .post-feature-img {
  grid-area: stack;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.cs-post-grid--feature .post-feature-overlay {
  grid-area: stack;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 40px;
  z-index: 2;
  border: var(--cs-border);
  box-shadow: var(--cs-shadow-1);
}

.cs-post-grid--meta {
  grid-area: cs-meta !important;
  width: 100%;
}

/* Container for the avatar and byline */
.post-header-meta.cs-post-grid--meta {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 5px; /* The breathing area you requested */
    width: 100%;
}

/* Avatar styling */
.article-writer-av.wp-block-avatar {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Byline text (Name, Date, Time) */
.article-writer-name,
.article-publish-date,
.article-publish-time {
    display: inline !important; /* Forces them onto one line */
    margin: 0 !important;       /* Removes conflicting margins */
}

/* Emphasis on the Author Name */
.article-writer-name {
    font-weight: 600;
}
.article-writer-name a {
  color: var(--cs-brand);
  text-decoration: underline;
}
.article-writer-name a:hover {
  color: var(--cs-brand-600);
  text-decoration: underline;
}

/* Adding "— Publ a {
}shed" prefix via CSS if you can't edit the HTML */
.article-publish-date::before {
    content: "— Published ";
    margin-right: 2px;
}

#cs-post-body.cs-post-grid--body {
  grid-area: cs-body;
  width: 100%;
  border-radius: var(--round-5);
  background-color: var(--flex-gray-7);
  border: 1px solid var(--cs-brand-30);
  box-shadow: 0 5px 30px var(--shadow-7);
}

.post-sidebar-col {
  width: 345px;
  max-width: 345px;
}
.cs-post-grid--sidebar {
  grid-area: cs-sidebar;
  width: 345px;
  max-width: 100%;
}

aside#cs-post-sidebar .cs-sticky__sidebar {padding-bottom: 0;padding-block-end: 0;}

aside#cs-post-sidebar.post-sidebar-col.cs-post-grid--sidebar {
  width: 100%;
  grid-row: 4;
  max-width: 100%;
  padding-inline: 0;
  padding-bottom: 0;
}

aside#cs-post-sidebar .post-scripts {
    visibility: hidden;
    display: none;
}

aside#cs-post-sidebar .cs-trending-widget {
  padding: 0;
  padding-bottom: 0;
  padding-block-end: 0 !important;
  top: 0;
  background-color: var(--toc-bg, var(--flex-gray-7));
  box-shadow: 0 5px 30px var(--shadow-7);
  border: var(--cs-border);
  border-radius: var(--round-5);
}

aside#cs-post-sidebar .cs-trending-widget .cinesist-border-brand {margin: 0;}

/* Sticky Quick Action Sidebar positioning on Desktop */
.cs-post-grid--actions {
  grid-area: cs-body;
  justify-self: start;
  align-self: start;
  position: sticky;
  top: 100px;
  margin-left: -90px !important; /* Shifts the action bar into the auto left-gutter */
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 50px !important;
  pointer-events: auto !important;
}

.cs-post-grid--actions .user-action-bar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

/* Responsive Overrides */
@media (max-width: 1024px) {
  article.cs-post-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
    grid-template-areas:
      "cs-crumbs"
      "cs-feature"
      "cs-meta"
      "cs-body"
      "cs-sidebar" !important;
    gap: 24px 0 !important;
    padding: 0 20px !important;
  }
  
  .cs-post-grid--crumbs {
    grid-area: cs-crumbs;
  }
  .cs-post-grid--feature {
    grid-area: cs-feature;
    height: 400px; /* shorter featured image on tablets/mobiles */
  }
  .cs-post-grid--meta {
    grid-area: cs-meta;
  }
  .cs-post-grid--body {
    grid-area: cs-body;
  }
  .cs-post-grid--sidebar {
    grid-area: cs-sidebar;
    display: block !important;
  }
  
  .cs-post-grid--actions {
    grid-area: auto !important;
    position: relative !important;
    top: 0 !important;
    margin-left: 0 !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    margin-bottom: 20px !important;
  }
  
  .cs-post-grid--actions .user-action-bar {
    flex-direction: row !important;
    justify-content: center !important;
    gap: 15px !important;
  }
}

@media (max-width: 767px) {
  .cs-post-grid--feature {
    height: 300px;
  }
}
aside .gb-looper-a9c86a9f {
  row-gap: var(--cs-space-3)
}

aside#cs-post-sidebar .trending-widget-wrapper {
    display: flex;
    max-height: 100%;
    row-gap: var(--cs-space-3);
    position: relative;
    flex-direction: column;
    padding-inline: var(--cs-space-2);
    padding-block: var(--cs-space-4);
}

aside .trending-widget-heading {
  margin-block-end: 0;
}

article .trending-widget-card {
  width: auto;
  grid-template-columns: 1fr 2fr;
  background-color: var(--flex-gray-1);
  border: var(--cs-border);
  border-radius: 0.25rem;
  padding: var(--cs-space-2);
}

article .trending-image-wrapper {
  aspect-ratio: 1/1;
  width: 100px;
}

.cs-line-clamp-3 {
  display: -webkit-box !important;
  font-size: var(--cs-font-size-h5) !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 3 !important;
  overflow: hidden !important;
}

article .trending-widget-card-title a {
    color: var(--primary-text-color);
}
article .trending-widget-card-title a:hover {
    color: var(--cs-brand);
    text-decoration: underline;
}

/* 
########################################
Post Footer & Comments Layout Styles
########################################
*/

section#post-footer {
    background-color: var(--flex-gray-200);
}

/* Parent Footer Grid */
.cs-post-footer {
  display: grid !important;
  width: 100% !important;
  max-width: 1225px !important; /* matches 875 + 310 + 40 gap */
  margin: 0 auto !important;
  grid-template-columns: 1fr 310px !important;
  grid-template-areas:
    "cs-threads     cs-threads"
    "cs-recommended cs-recommended" !important;
  column-gap: 40px !important;
  row-gap: 24px !important;
}

/* Intermediate wrapper display: contents to pass grid participation to children */
.cs-post-footer--contents {
  display: contents !important;
}

/* Area assignments */
.cs-post-footer--threads {
  grid-area: cs-threads !important;
  width: 100% !important;
}

.cs-post-footer--recommended {
  grid-area: cs-recommended !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
}

/* Comment Threads Nested Grid Layout */
.cs-post-footer--comments {
  display: grid !important;
  width: 100% !important;
  grid-template-columns: 1fr 310px !important;
  column-gap: 40px !important;
  row-gap: 20px !important;
}

#post-footer #respond .comment-form-comment textarea {
  background-color: var(--flex-gray-200);
}
#post-footer #respond .comment-form-comment textarea:focus {
  background: var(--flex-gray-100);
}

div#respond .comment-respond {
    grid-column: 1 / -1;
}

/* Force Comments Header & Title to be full width across comments grid */
.cs-post-footer--comments .post-comments-header,
.cs-post-footer--comments .cs-review-comments-title {
  grid-column: 1 / 1 !important;
}

/* Force Comments list, pagination, and form to stack in left column */
.cs-post-footer--comments .comment-template,
.cs-post-footer--comments .navigation,
.cs-post-footer--comments .comments-pagination,
.cs-post-footer--comments .cs-review-comments-form,
.cs-post-footer--comments .comment-respond {
  grid-column: 1 !important;
}

/* Responsive Footer styling */
@media (max-width: 1024px) {
  .cs-post-footer {
    grid-template-columns: 1fr !important;
    grid-template-areas: 
      "cs-threads"
      "cs-popular"
      "cs-recommended" !important;
    gap: 24px 0 !important;
    padding: 0 20px !important;
  }
  
  .cs-post-footer--comments {
    grid-template-columns: 1fr !important;
    gap: 20px 0 !important;
  }
  
  .cs-post-footer--comments .post-comments-header,
  .cs-post-footer--comments .cs-review-comments-title,
  .cs-post-footer--comments .comment-template,
  .cs-post-footer--comments .navigation,
  .cs-post-footer--comments .comments-pagination,
  .cs-post-footer--comments .cs-review-comments-form,
  .cs-post-footer--comments .comment-respond {
    grid-column: 1 !important;
  }
}

/* Hide extra break tags that WordPress wpautop adds to operative info */
.cs-logged-in-as br:nth-of-type(2) {
  display: none !important;
}


