/**
 * Version 4.2.2: viewport-contained full blog reader with independent article scrolling.
 */

/* The dashboard shell stays fixed. Only the white blog reader pane scrolls. */
html.had-document-page,
html.had-document-page body.single-post.had-theme {
  width: 100%;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.single-post.had-theme .had-app-shell {
  height: 100dvh !important;
  min-height: 560px !important;
  overflow: hidden !important;
}
body.admin-bar.single-post.had-theme .had-app-shell {
  height: calc(100dvh - 32px) !important;
}
body.single-post.had-theme .had-shell-body {
  height: calc(100dvh - var(--had-topbar)) !important;
  min-height: 0 !important;
  align-items: stretch !important;
  overflow: hidden !important;
}
body.admin-bar.single-post.had-theme .had-shell-body {
  height: calc(100dvh - var(--had-topbar) - 32px) !important;
}
body.single-post.had-theme .had-sidebar {
  position: relative !important;
  top: auto !important;
  height: 100% !important;
  min-height: 0 !important;
  align-self: stretch !important;
}
body.single-post.had-theme .had-workspace {
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.single-post.had-theme .had-blog-single-screen {
  width: 100%;
  height: 100% !important;
  min-height: 0 !important;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px 14px 12px !important;
  overflow: hidden !important;
}

/* Compact title band gives the article more usable vertical space. */
body.single-post.had-theme .had-blog-single-header {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  padding: 16px clamp(20px, 2.6vw, 38px) 17px;
  border: 1px solid #1d5265;
  background: linear-gradient(145deg, #062838, #075d66);
}
body.single-post.had-theme .had-blog-single-header h1 {
  max-width: 1120px;
  margin: 8px 0 10px;
  font-size: clamp(27px, 2.75vw, 46px);
  line-height: 1.06;
  text-wrap: balance;
}
body.single-post.had-theme .had-blog-single-meta {
  gap: 8px;
  font-size: 10px;
}
body.single-post.had-theme .had-blog-return-top {
  margin-bottom: 2px;
  white-space: nowrap;
}

/* Full-width reader stage. */
.had-blog-reader-stage {
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(43, 93, 112, .72);
  background: #eef4f6;
  box-shadow: 0 18px 45px rgba(0, 0, 0, .2);
}

body.single-post.had-theme .had-blog-single-article {
  width: 100% !important;
  max-width: none !important;
  height: 100%;
  min-height: 0;
  margin: 0 !important;
  padding: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #16889a #d9e6ea;
  background: #f7fafb;
  color: #25404a;
  box-shadow: none !important;
  outline: none;
}
body.single-post.had-theme .had-blog-single-article:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(10, 169, 186, .45) !important;
}
body.single-post.had-theme .had-blog-single-article::-webkit-scrollbar {
  width: 12px;
}
body.single-post.had-theme .had-blog-single-article::-webkit-scrollbar-track {
  background: #d9e6ea;
}
body.single-post.had-theme .had-blog-single-article::-webkit-scrollbar-thumb {
  border: 3px solid #d9e6ea;
  border-radius: 999px;
  background: #16889a;
}

.had-blog-single-inner {
  width: 100%;
  min-height: 100%;
  padding: clamp(28px, 3.3vw, 54px) clamp(68px, 6vw, 98px) 54px clamp(32px, 4.7vw, 72px);
}
.had-blog-single-inner > figure,
.had-blog-single-copy,
.had-blog-single-inner > .had-blog-engagement,
.had-blog-single-actions {
  width: min(100%, 1260px);
  margin-left: auto;
  margin-right: auto;
}
body.single-post.had-theme .had-blog-single-inner > figure {
  margin-top: 0;
  margin-bottom: 34px;
}
body.single-post.had-theme .had-blog-single-inner > figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 68vh;
  object-fit: contain;
  background: #edf3f5;
}
body.single-post.had-theme .had-blog-single-copy {
  font-size: 16px;
  line-height: 1.82;
  overflow-wrap: anywhere;
}

/* Always-visible controls scroll only the article pane. */
.had-blog-scroll-controls {
  position: absolute;
  z-index: 8;
  top: 50%;
  right: 18px;
  display: grid;
  justify-items: center;
  gap: 8px;
  transform: translateY(-50%);
  filter: drop-shadow(0 8px 18px rgba(0, 35, 46, .22));
}
.had-blog-scroll-controls button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #0e8fa2;
  border-radius: 4px;
  background: #073846;
  color: #f4ffff;
  box-shadow: inset 0 0 0 1px rgba(110, 235, 244, .08);
  transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease;
}
.had-blog-scroll-controls button:hover,
.had-blog-scroll-controls button:focus-visible {
  border-color: #25d8e6;
  background: #086477;
  outline: none;
  transform: scale(1.06);
}
.had-blog-scroll-controls button:disabled {
  cursor: default;
  opacity: .3;
  transform: none;
}
.had-blog-scroll-controls .dashicons {
  width: 20px;
  height: 20px;
  font-size: 20px;
}
.had-blog-scroll-meter {
  width: 4px;
  height: 92px;
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(7, 56, 70, .2);
  box-shadow: inset 0 0 0 1px rgba(7, 56, 70, .18);
}
.had-blog-scroll-meter i {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, #22d3ee, #0c8296);
  box-shadow: 0 0 8px rgba(34, 211, 238, .55);
  transition: height .12s linear;
}

/* Keep the controls unobtrusive when the article does not overflow. */
.had-blog-reader-stage:not(.is-scrollable) .had-blog-scroll-controls {
  display: none;
}

@media (max-width: 900px) {
  body.single-post.had-theme .had-sidebar {
    position: fixed !important;
    top: var(--had-topbar) !important;
    height: auto !important;
  }
  body.admin-bar.single-post.had-theme .had-sidebar {
    top: calc(var(--had-topbar) + 46px) !important;
  }
  body.single-post.had-theme .had-blog-single-screen {
    padding: 8px !important;
    gap: 8px;
  }
  body.single-post.had-theme .had-blog-single-header {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 18px;
  }
  body.single-post.had-theme .had-blog-single-header h1 {
    font-size: clamp(24px, 7vw, 38px);
  }
  body.single-post.had-theme .had-blog-return-top {
    justify-self: start;
  }
  .had-blog-single-inner {
    padding: 26px 62px 42px 24px;
  }
  .had-blog-scroll-controls {
    right: 12px;
  }
}

@media (max-width: 782px) {
  body.admin-bar.single-post.had-theme .had-app-shell {
    height: calc(100dvh - 46px) !important;
  }
  body.admin-bar.single-post.had-theme .had-shell-body {
    height: calc(100dvh - var(--had-topbar) - 46px) !important;
  }
}

@media (max-width: 560px) {
  body.single-post.had-theme .had-blog-single-header {
    padding: 12px 14px;
  }
  body.single-post.had-theme .had-blog-single-header h1 {
    margin-bottom: 7px;
  }
  .had-blog-single-inner {
    padding: 22px 52px 36px 18px;
  }
  .had-blog-scroll-controls {
    right: 8px;
    gap: 6px;
  }
  .had-blog-scroll-controls button {
    width: 36px;
    height: 36px;
  }
  .had-blog-scroll-meter {
    height: 66px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.single-post.had-theme .had-blog-single-article {
    scroll-behavior: auto;
  }
  .had-blog-scroll-controls button,
  .had-blog-scroll-meter i {
    transition: none;
  }
}
