/* ==========================================================================
   BED Blog Single Post Template Styles
   Targets Gutenberg blocks: core/cover, core/columns, Yoast TOC, bed/faq-item
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Colors */
  --bed-color-primary-dark: #272723;
  --bed-color-body-text: rgba(39, 39, 35, 0.72);
  --bed-color-muted: #b09ea3;
  --bed-color-border: #dadcea;
  --bed-color-white: #ffffff;
  --bed-color-toc-active-bg: #dfdfdf;
  --bed-color-faq-border: rgba(39, 39, 35, 0.16);
  --bed-color-card-shadow: rgba(0, 0, 0, 0.12);

  /* Typography */
  --bed-font-heading: "D-DIN", sans-serif;
  --bed-font-heading-exp: "D-DIN Exp", "D-DIN", sans-serif;
  --bed-font-body: "Roboto", sans-serif;

  /* Font Sizes */
  --bed-fs-h1: 30px;
  --bed-fs-h2: 36px;
  --bed-fs-h5: 24px;
  --bed-fs-body: 18px;
  --bed-fs-small: 14px;
  --bed-fs-faq-question: 20px;

  /* Spacing */
  --bed-section-gap: 88px;
  --bed-card-radius: 12px;
  --bed-image-radius: 12px;

  /* Shadows */
  --bed-card-shadow: 0px 0px 6.7px 1px rgba(0, 0, 0, 0.12);
}

/* --------------------------------------------------------------------------
   Base — scoped to single post body class
   -------------------------------------------------------------------------- */
.bed-blog-single {
  font-family: var(--bed-font-body);
  font-size: var(--bed-fs-body);
  font-weight: 500;
  line-height: 1.6;
  color: var(--bed-color-body-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Hide theme's default post title — hero already shows it */
.bed-blog-single .page-header {
  display: none;
}

/* --------------------------------------------------------------------------
   Hero — dynamic PHP-rendered section
   -------------------------------------------------------------------------- */
.bed-blog-hero {
  position: relative;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  min-height: 590px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--bed-color-primary-dark);
  overflow: hidden;
}

.bed-blog-hero__content {
  position: relative;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 295px 0 0 40px;
}

.bed-blog-hero__title {
  font-family: var(--bed-font-heading-exp);
  font-weight: 700;
  font-size: var(--bed-fs-h1);
  color: var(--bed-color-white);
  text-transform: uppercase;
  margin: 0 0 10px;
  line-height: 1.3;
  max-width: 660px;
}

.bed-blog-hero__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--bed-font-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 160%;
  color: var(--bed-color-white);
}

.bed-blog-hero__meta-separator {
  width: 1px;
  height: 31px;
  background-color: var(--bed-color-white);
}

/* --------------------------------------------------------------------------
   Two-Column Layout — core/columns with .bed-blog-layout class
   -------------------------------------------------------------------------- */
.wp-block-columns.bed-blog-layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 60px 40px 0;
  gap: 40px;
  align-items: flex-start;
}

/* Sidebar column — sticky, offset for fixed header */
.wp-block-columns.bed-blog-layout > .wp-block-column.bed-blog-sidebar {
  position: sticky;
  top: 140px;
  align-self: flex-start;
}

/* --------------------------------------------------------------------------
   Blog Content Typography — within the layout's content column
   -------------------------------------------------------------------------- */
.bed-blog-single .wp-block-columns.bed-blog-layout h2 {
  font-family: var(--bed-font-heading);
  font-weight: 700;
  font-size: var(--bed-fs-h2);
  line-height: 1.2;
  letter-spacing: -0.72px;
  color: var(--bed-color-primary-dark);
  margin-top: var(--bed-section-gap);
  margin-bottom: 24px;
}

.bed-blog-single .wp-block-columns.bed-blog-layout h2:first-child {
  margin-top: 0;
}

.bed-blog-single .wp-block-columns.bed-blog-layout p {
  font-family: var(--bed-font-body);
  font-weight: 500;
  font-size: var(--bed-fs-body);
  line-height: 1.6;
  color: var(--bed-color-body-text);
  margin-bottom: 20px;
}

.bed-blog-single .wp-block-columns.bed-blog-layout ul,
.bed-blog-single .wp-block-columns.bed-blog-layout ol {
  padding: 0;
  line-height: 1.6;
}

.bed-blog-single .wp-block-columns.bed-blog-layout ul {
  list-style-type: disc;
}

.bed-blog-single .wp-block-columns.bed-blog-layout ol {
  list-style-type: decimal;
}

.bed-blog-single .wp-block-columns.bed-blog-layout li {
  font-family: var(--bed-font-body);
  font-weight: 500;
  font-size: var(--bed-fs-body);
  line-height: 1.6;
  color: var(--bed-color-body-text);
  margin-bottom: 0;
}

.bed-blog-single .wp-block-columns.bed-blog-layout li:last-child {
  margin-bottom: 0;
}

/* Links in content */
.bed-blog-single .wp-block-columns.bed-blog-layout a:not(.bed-blog-toc__link) {
  color: var(--bed-color-primary-dark);
  text-decoration: underline;
  transition: opacity 0.2s ease;
}

.bed-blog-single
  .wp-block-columns.bed-blog-layout
  a:not(.bed-blog-toc__link):hover {
  opacity: 0.7;
}

/* Bold text */
.bed-blog-single .wp-block-columns.bed-blog-layout strong {
  font-weight: 700;
  color: var(--bed-color-primary-dark);
}

/* Images in blog content */
.bed-blog-single .wp-block-columns.bed-blog-layout .wp-block-image img {
  border-radius: var(--bed-image-radius);
  width: 100%;
  height: auto;
  display: block;
}

/* --------------------------------------------------------------------------
   Table of Contents — bed/table-of-contents block
   -------------------------------------------------------------------------- */
.bed-blog-toc {
  background: var(--bed-color-white);
  border-radius: var(--bed-card-radius);
  box-shadow: var(--bed-card-shadow);
  padding: 16px;
}

/* Static "Table of contents" heading via ::before */
.bed-blog-toc::before {
  content: "Table of contents";
  display: block;
  font-family: var(--bed-font-body);
  font-weight: 600;
  font-size: 16px;
  color: #000000;
  opacity: 0.56;
  margin: 0 0 16px;
  line-height: normal;
}

/* TOC list */
.bed-blog-toc ul,
.bed-blog-toc ul li {
  list-style: none !important;
  list-style-type: none !important;
}

.bed-blog-toc ul {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.bed-blog-toc li {
  margin: 0;
  padding: 0;
}

.bed-blog-toc a,
.bed-blog-toc a:hover,
.bed-blog-toc a:visited {
  display: inline;
  font-family: var(--bed-font-body);
  font-weight: 500;
  font-size: 14px;
  color: var(--bed-color-primary-dark);
  text-decoration: none !important;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  line-height: normal;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.bed-blog-toc a:hover {
  background-color: var(--bed-color-toc-active-bg);
}

.bed-blog-toc a.is-active {
  background-color: var(--bed-color-toc-active-bg);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   FAQ Accordion — bed/faq-item block
   -------------------------------------------------------------------------- */
.bed-blog-faq__item {
  border-bottom: 1px solid var(--bed-color-faq-border);
  padding: 0 0 22px;
  margin-bottom: 24px;
}

.bed-blog-faq__item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.bed-blog-faq__question {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  cursor: pointer;
  gap: 16px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 0;
  font-family: var(--bed-font-heading);
  font-weight: 700;
  font-size: var(--bed-fs-faq-question);
  color: var(--bed-color-primary-dark);
  line-height: 1.3;
  transition: opacity 0.2s ease;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.bed-blog-faq__question:hover {
  background-color: transparent;
  color: var(--bed-color-primary-dark);
  cursor: pointer;
}

.bed-blog-faq__question:focus-visible {
  outline: 2px solid var(--bed-color-primary-dark);
  outline-offset: 4px;
  border-radius: 4px;
}

.bed-blog-faq__question > span:first-child {
  flex: 1 1 0%;
  min-width: 0;
  max-width: calc(100% - 36px);
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

.bed-blog-faq__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  position: relative;
  transition: transform 0.3s ease;
  margin-top: 4px;
}

.bed-blog-faq__icon::before,
.bed-blog-faq__icon::after {
  content: "";
  position: absolute;
  background-color: var(--bed-color-primary-dark);
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

/* Horizontal bar */
.bed-blog-faq__icon::before {
  top: 50%;
  left: 0;
  width: 20px;
  height: 2px;
  transform: translateY(-50%);
}

/* Vertical bar */
.bed-blog-faq__icon::after {
  top: 0;
  left: 50%;
  width: 2px;
  height: 20px;
  transform: translateX(-50%);
}

.bed-blog-faq__item.is-open .bed-blog-faq__icon::after {
  transform: translateX(-50%) rotate(90deg);
  opacity: 0;
}

.bed-blog-faq__answer {
  max-height: 0;
  overflow: hidden;
  transition:
    max-height 0.35s ease,
    padding-top 0.35s ease;
  padding-top: 0;
}

.bed-blog-faq__item.is-open .bed-blog-faq__answer {
  max-height: 600px;
  padding-top: 16px;
}

.bed-blog-faq__answer p {
  font-family: var(--bed-font-body);
  font-weight: 500;
  font-size: var(--bed-fs-body);
  line-height: 1.6;
  color: var(--bed-color-primary-dark);
  opacity: 0.72;
  margin: 0;
}

/* --------------------------------------------------------------------------
   Related Articles
   -------------------------------------------------------------------------- */
.bed-blog-related {
  max-width: 1360px;
  margin: 80px auto 0;
  padding: 0 40px;
}

.bed-blog-related__title {
  font-family: var(--bed-font-heading);
  font-weight: 700;
  font-size: var(--bed-fs-h2);
  line-height: 1.2;
  letter-spacing: -0.72px;
  color: var(--bed-color-primary-dark);
  margin: 0 0 40px;
  text-align: left;
}

/* Slider wrapper */
.bed-blog-related__slider {
  position: relative;
}

/* Track — grid on desktop/tablet, slider on mobile */
.bed-blog-related__track {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* Card */
.bed-blog-related__card,
.bed-blog-related__card:hover,
.bed-blog-related__card:visited {
  border-radius: var(--bed-card-radius);
  box-shadow: var(--bed-card-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none !important;
  color: inherit;
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.bed-blog-related__card:hover {
  box-shadow: 0px 0px 12px 2px rgba(0, 0, 0, 0.16);
  transform: translateY(-2px);
}

.bed-blog-related__card *,
.bed-blog-related__card *:hover,
.bed-blog-related__card *:visited {
  text-decoration: none !important;
}

/* Image wrapper — anchor for the arrow */
.bed-blog-related__card-image-wrap {
  position: relative;
  width: 100%;
  height: 258px;
  background-color: #f0f0f0;
  overflow: hidden;
}

.bed-blog-related__card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Arrow buttons — hidden on desktop/tablet, visible on mobile only */
.bed-blog-related__arrow {
  display: none;
}

.bed-blog-related__card-body {
  padding: 24px;
  background: var(--bed-color-white);
  border: 1px solid var(--bed-color-border);
  border-top: none;
  border-radius: 0 0 var(--bed-card-radius) var(--bed-card-radius);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.bed-blog-related__card-category {
  font-family: var(--bed-font-body);
  font-weight: 400;
  font-size: var(--bed-fs-small);
  color: var(--bed-color-primary-dark);
  margin: 0 0 12px;
}

.bed-blog-related__card-divider {
  width: 100%;
  height: 1px;
  background-color: var(--bed-color-border);
  margin-bottom: 16px;
}

.bed-blog-related__card-title {
  font-family: var(--bed-font-heading);
  font-weight: 700;
  font-size: var(--bed-fs-h5);
  color: var(--bed-color-primary-dark);
  margin: 0 0 auto;
  line-height: 1.3;
  padding-bottom: 16px;
}

.bed-blog-related__card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--bed-font-body);
  font-weight: 500;
  font-size: var(--bed-fs-small);
}

.bed-blog-related__card-author {
  color: var(--bed-color-primary-dark);
}

.bed-blog-related__card-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: var(--bed-color-primary-dark);
  flex-shrink: 0;
}

.bed-blog-related__card-date,
.bed-blog-related__card-readtime {
  color: var(--bed-color-muted);
}

/* View All Articles Link */
.bed-blog-view-all {
  text-align: center;
  margin: 48px 0 80px;
}

.bed-blog-view-all__link {
  font-family: var(--bed-font-heading-exp);
  font-weight: 700;
  font-size: var(--bed-fs-h5);
  color: var(--bed-color-primary-dark);
  text-decoration: none !important;
  position: relative;
  display: inline-block;
}

.bed-blog-view-all__link::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--bed-color-primary-dark);
}

.bed-blog-view-all__link:hover {
  opacity: 0.7;
}

/* --------------------------------------------------------------------------
   WordPress Block Overrides
   -------------------------------------------------------------------------- */
.bed-blog-single .wp-block-group {
  margin-top: 0;
  margin-bottom: 0;
}

.bed-blog-single .wp-block-columns {
  margin-bottom: 0;
}

.bed-blog-single .wp-block-heading {
  margin-top: 0;
}

/* Smooth scroll for the entire page when TOC is used */
html.bed-smooth-scroll {
  scroll-behavior: smooth;
}

/* Screen reader only utility */
.bed-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --------------------------------------------------------------------------
   Responsive Styles
   -------------------------------------------------------------------------- */

/* Tablet */
@media (max-width: 1200px) {
  .wp-block-columns.bed-blog-layout {
    flex-direction: column;
    padding-top: 120px;
  }

  .wp-block-columns.bed-blog-layout > .wp-block-column.bed-blog-sidebar {
    width: 100%;
    position: static;
    order: -1;
    margin-bottom: 40px;
  }

  .bed-blog-related__track {
    grid-template-columns: repeat(2, 1fr);
  }

  .bed-blog-hero {
    min-height: 440px;
  }

  .bed-blog-hero__content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0 30px 0 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
  }
}

/* Mobile */
@media (max-width: 576px) {
  :root {
    --bed-fs-h1: 24px;
    --bed-fs-h2: 28px;
    --bed-fs-h5: 20px;
    --bed-fs-body: 16px;
    --bed-section-gap: 48px;
  }

  .bed-blog-hero {
    min-height: auto;
    height: 154px;
  }

  .bed-blog-hero__content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
  }

  .bed-blog-hero__title {
    font-size: 18px;
    line-height: 1.2;
    max-width: 100%;
    margin-bottom: 6px;
  }

  .bed-blog-hero__meta {
    font-size: 12px;
    gap: 8px;
  }

  .bed-blog-hero__meta-separator {
    height: 20px;
  }

  .wp-block-columns.bed-blog-layout {
    padding: 30px 6px 0;
    gap: 16px;
  }

  /* TOC mobile: smaller gap */
  .bed-blog-toc ul {
    gap: 16px;
  }

  .bed-blog-single .wp-block-columns.bed-blog-layout .wp-block-image img {
    max-height: 250px;
    object-fit: cover;
  }

  /* FAQ mobile */
  .bed-blog-faq__item {
    padding-left: 10px;
    padding-right: 10px;
  }

  .bed-blog-faq__question {
    font-size: 16px;
  }

  .bed-blog-related {
    padding: 0 16px;
  }

  /* Related: switch to slider on mobile */
  .bed-blog-related__track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    grid-template-columns: none;
  }

  .bed-blog-related__track::-webkit-scrollbar {
    display: none;
  }

  .bed-blog-related__card,
  .bed-blog-related__card:hover,
  .bed-blog-related__card:visited {
    flex: 0 0 100%;
    scroll-snap-align: start;
  }

  .bed-blog-related__arrow {
    display: flex;
    position: absolute;
    top: 120px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bed-color-white);
    border: 1px solid var(--bed-color-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    color: var(--bed-color-primary-dark);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }

  .bed-blog-related__arrow[hidden] {
    display: none;
  }

  .bed-blog-related__arrow:hover,
  .bed-blog-related__arrow:focus {
    background-color: var(--bed-color-white);
    color: var(--bed-color-primary-dark);
    outline: none;
  }

  .bed-blog-related__arrow--next {
    right: 10px;
  }

  .bed-blog-related__arrow--prev {
    left: 10px;
  }
}
