/* ============================================================
   BLOG EXTRA STYLES
   Additional styles for SSR blog application
   Image zoom modal, search page, and shared utilities
   ============================================================ */

/* ── Reading Progress Bar ── */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary) 0%, #a78bfa 100%);
  z-index: 9999;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

/* ── Skip to Content ── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.visually-hidden.focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: var(--space-3) var(--space-4);
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--color-primary);
  color: white;
  font-weight: 700;
  z-index: 10000;
}

/* ── Header Gap ── */
.header-gap {
  height: 0;
}

/* ── Scroll-to-Top Button ── */
#scroll-top-btn {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(108, 62, 244, 0.35);
  opacity: 0;
  transform: translateY(12px) scale(0.88);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
  pointer-events: none;
  z-index: 1000;
}
#scroll-top-btn.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#scroll-top-btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-2px) scale(1.05);
}
#scroll-top-btn:active {
  transform: scale(0.96);
}

/* ── Image Zoom Modal ── */
.image-zoom-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.image-zoom-modal.open {
  opacity: 1;
  pointer-events: auto;
}
.image-zoom-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 20, 0.88);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
.image-zoom-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 1;
  transform: scale(0.88);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.image-zoom-modal.open .image-zoom-container {
  transform: scale(1);
}
.image-zoom-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: block;
}
.image-zoom-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  color: var(--color-text-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  transition: background 0.2s ease, transform 0.2s ease;
  z-index: 2;
}
.image-zoom-close:hover {
  background: var(--color-primary);
  color: white;
  transform: scale(1.1);
}

/* ── Article Images (zoomable) ── */
.article-image {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  display: block;
  margin: 0 auto;
}
.article-image--zoomable {
  cursor: zoom-in;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.article-image--zoomable:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-lg);
}
.article-image-figure {
  margin: var(--space-6) 0;
}
.article-image-caption {
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
  font-style: italic;
}

/* ── Graph / Process Image with Lightbox Zoom ── */
.graph-figure {
  margin: var(--space-8) 0;
  position: relative;
}
.graph-img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  display: block;
  cursor: zoom-in;
  transition: transform 0.35s ease, box-shadow 0.35s ease, filter 0.35s ease;
  box-shadow: var(--shadow-md);
}
.graph-img:hover {
  transform: scale(1.018);
  box-shadow: var(--shadow-lg);
  filter: brightness(1.05);
}

/* ── Graph Modal (appended to body by JS) ── */
.graph-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* Backdrop starts transparent */
  background: rgba(8, 8, 18, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  pointer-events: none;
  cursor: zoom-out;
  transition:
    background 0.38s ease,
    backdrop-filter 0.38s ease;
}
.graph-modal.is-open {
  background: rgba(8, 8, 18, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: all;
}
.graph-modal.is-closing {
  background: rgba(8, 8, 18, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  pointer-events: none;
}

/* Modal card — the image container */
.graph-modal__card {
  position: relative;
  max-width: min(1300px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Entry: start small, shifted down, invisible */
  transform: scale(0.78) translateY(32px);
  opacity: 0;
  transition:
    transform 0.45s cubic-bezier(0.34, 1.45, 0.64, 1),
    opacity 0.32s ease;
}
.graph-modal.is-open .graph-modal__card {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.graph-modal.is-closing .graph-modal__card {
  transform: scale(0.84) translateY(20px);
  opacity: 0;
  transition:
    transform 0.28s cubic-bezier(0.4, 0, 1, 1),
    opacity 0.22s ease;
}

/* The enlarged image inside the modal */
.graph-modal__img {
  max-width: 100%;
  max-height: calc(92vh - 60px);
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow:
    0 40px 120px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.07);
  display: block;
  cursor: default;
}

/* Close button — top-right of the card */
.graph-modal__close {
  position: absolute;
  top: -18px;
  right: -18px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.38);
  color: white;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1;
}
.graph-modal__close:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.15) rotate(90deg);
}

/* Hint text below image */
.graph-modal__hint {
  margin-top: 10px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.38);
  letter-spacing: 0.05em;
  user-select: none;
  pointer-events: none;
}
/* ── Copy Link Feedback Toast ── */
.copy-feedback {
  position: fixed;
  bottom: var(--space-8);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-text-primary);
  color: white;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 9999;
  white-space: nowrap;
}
.copy-feedback.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Ripple Effect ── */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0);
  animation: ripple-anim 0.6s linear;
  pointer-events: none;
}
@keyframes ripple-anim {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ── Fade-in-up Animation ── */
.fade-in-up {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.fade-in-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Search Page ── */
.search-page {
  background: var(--color-bg);
  min-height: 100vh;
}
.search-hero {
  background: white;
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--space-10) var(--space-6);
  text-align: center;
}
.search-hero-title {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--color-text-primary);
  margin-bottom: var(--space-5);
}
.search-form {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  gap: var(--space-3);
}
.search-input {
  flex: 1;
  padding: var(--space-4) var(--space-5);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: white;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(108, 62, 244, 0.12);
}
.search-btn {
  padding: var(--space-4) var(--space-6);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--font-size-base);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}
.search-btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}
.search-results-section {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}
.search-results-header {
  margin-bottom: var(--space-6);
}
.search-results-count {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
}
.search-results-count strong {
  color: var(--color-text-primary);
  font-weight: 700;
}
.search-no-results {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--color-text-muted);
}
.search-no-results h2 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-3);
}
.search-back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  font-size: var(--font-size-base);
  margin-top: var(--space-5);
  transition: gap 0.2s ease;
}
.search-back-link:hover {
  gap: var(--space-3);
}

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}
.breadcrumb a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}
.breadcrumb-sep {
  color: var(--color-border);
  font-size: 0.7rem;
}

/* ── Badge Colors ── */
.badge-orange {
  background: #FFF3E0;
  color: #E65100;
  border: 1px solid #FFCC80;
}
.badge-blue {
  background: #E3F2FD;
  color: #1565C0;
  border: 1px solid #90CAF9;
}
.badge-green {
  background: #E8F5E9;
  color: #2E7D32;
  border: 1px solid #A5D6A7;
}

/* ── Section Divider ── */
.section-divider {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-8) 0;
}
.divider-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-border);
  flex-shrink: 0;
}

/* ── Sticky CTA ── */
.sticky-cta {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 999;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.sticky-cta.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
/* Card-style sticky CTA matching original design: white bg, amber border, orange icon */
.sticky-cta-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  color: #1A1A2E;
  padding: 10px 16px 10px 10px;
  border-radius: 14px;
  border: 2px solid #F59E0B;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  font-size: var(--font-size-sm);
  min-width: 220px;
}
.sticky-cta-btn:hover {
  color: #1A1A2E; /* override global a:hover */
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.18);
  transform: translateY(-2px);
}
.sticky-cta-icon {
  width: 44px;
  height: 44px;
  background: #F59E0B;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sticky-cta-icon svg {
  width: 20px;
  height: 20px;
}
.sticky-cta-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.sticky-cta-text strong {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1A1A2E;
  line-height: 1.25;
}
.sticky-cta-text span {
  font-size: var(--font-size-xs);
  color: #8888A4;
  margin-top: 1px;
}
.sticky-cta-arrow {
  font-size: 1rem;
  color: #F59E0B;
  font-weight: 700;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .sticky-cta {
    right: var(--space-4);
    bottom: var(--space-4);
  }
  .sticky-cta-text span {
    display: none;
  }
}

/* ── Tooltip ── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text-primary);
  color: white;
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}
[data-tooltip]:hover::after {
  opacity: 1;
}

/* ── Responsive Utilities ── */
@media (max-width: 768px) {
  .search-form {
    flex-direction: column;
  }
  .search-btn {
    width: 100%;
  }
}

/* ── Article Hero Image ── */
.article-hero-image-wrap {
  width: 100%;
  border-radius: var(--radius-xl, 16px);
  overflow: hidden;
  margin-bottom: var(--space-6);
  background: var(--color-bg-secondary);
  /* Preserve original image dimensions: 1536 × 1026 ≈ 3:2 ratio */
  aspect-ratio: 1536 / 1026;
}
.article-hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Breadcrumb Bar ── */
.breadcrumb-bar {
  background: white;
  border-bottom: 1px solid var(--color-border-light, #f0f0f0);
  padding: var(--space-3) 0;
}
.breadcrumb-inner {
  max-width: var(--content-max-width, 1200px);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ── Search Form (search page) ── */
.search-input-wrap {
  position: relative;
  max-width: 560px;
  margin: var(--space-6) auto 0;
}
.search-input-wrap input[type="search"] {
  width: 100%;
  padding: var(--space-4) 52px var(--space-4) var(--space-5);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: white;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}
.search-input-wrap input[type="search"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(108, 62, 244, 0.12);
}
.search-submit-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.search-submit-btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-50%) scale(1.08);
}
.search-error {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--color-text-muted);
}
.search-no-results-icon {
  margin-bottom: var(--space-5);
  color: var(--color-border);
}

/* ── Blog Post Page Responsive ── */
@media (max-width: 768px) {
  .article-hero-image-wrap {
    border-radius: 0;
    margin-left: calc(-1 * var(--space-4));
    margin-right: calc(-1 * var(--space-4));
    aspect-ratio: 16 / 9;
  }
}
