/* ============================================================
   OpenSafety — App CSS
   Dark/Light mode via Bootstrap 5.3 data-bs-theme="auto"
   ============================================================ */

/* ---- Layout ---- */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

main.flex-grow-1 { flex: 1; }

/* ---- Navbar ---- */
.navbar-main {
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  z-index: 1030;
}

/* ---- Footer ---- */
.footer-main {
  background: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
}
.footer-link {
  color: var(--bs-secondary-color);
  text-decoration: none;
  transition: color .15s;
}
.footer-link:hover { color: var(--bs-primary); }

/* ---- Hero Carousel ---- */
.hero-carousel {
  position: relative;
  margin-bottom: 0;
  background: #0a0a0a;
}

/* Full-slide clickable wrapper */
.hero-slide-link {
  display: block;
  position: relative;
  text-decoration: none;
  cursor: pointer;
}
.hero-slide-link:hover .hero-read-btn {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  padding-right: 1.2rem;
}

/* Image */
.hero-img {
  display: block;
  width: 100%;
  height: 520px;
  object-fit: cover;
  object-position: center;
  transition: transform .6s ease;
}
.carousel-item.active .hero-img { transform: scale(1.01); }

.hero-placeholder {
  width: 100%;
  height: 520px;
  background: linear-gradient(135deg, #0d3480 0%, #1976d2 100%);
}

/* Gradient overlay (bottom-heavy) */
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,.05) 0%,
    rgba(0,0,0,.15) 35%,
    rgba(0,0,0,.75) 75%,
    rgba(0,0,0,.90) 100%
  );
}

/* Caption */
.hero-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem 2.5rem;
  z-index: 2;
}
.hero-title {
  font-size: clamp(1.3rem, 3.2vw, 2.1rem);
  line-height: 1.25;
  text-shadow: 0 2px 12px rgba(0,0,0,.5);
  margin: 0;
}
.hero-meta { text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.hero-trending-badge {
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.25);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.hero-read-btn {
  transition: padding-right .2s;
}

/* Prev/Next controls — move above the nav strip */
.hero-ctrl { bottom: 130px; top: auto; width: 44px; height: 44px; }
@media (max-width: 991.98px) { .hero-ctrl { bottom: 50px; } }

/* Dot indicators (mobile) */
.hero-dots { bottom: 12px; }

/* ---- Thumbnail nav strip (desktop) ---- */
.hero-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255,255,255,.08);
  overflow-x: auto;
  scrollbar-width: none;
}
.hero-nav::-webkit-scrollbar { display: none; }

.hero-nav-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .8rem;
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255,255,255,.07);
  border-top: 3px solid transparent;
  color: rgba(255,255,255,.55);
  text-align: left;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
}
.hero-nav-item:last-child { border-right: none; }
.hero-nav-item:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.9);
}
.hero-nav-item.active {
  border-top-color: var(--bs-primary);
  color: #fff;
  background: rgba(255,255,255,.06);
}

.hero-nav-item img,
.hero-nav-placeholder {
  width: 44px;
  height: 36px;
  object-fit: cover;
  border-radius: .3rem;
  flex-shrink: 0;
}
.hero-nav-placeholder {
  background: rgba(255,255,255,.1);
}
.hero-nav-title {
  font-size: .72rem;
  line-height: 1.3;
  font-weight: 500;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Push caption up so it sits above the nav strip */
.hero-caption { padding-bottom: calc(2rem + 62px); }
@media (max-width: 991.98px) { .hero-caption { padding-bottom: 2rem; } }

/* ---- Responsive ---- */
@media (max-width: 576px) {
  .hero-img, .hero-placeholder { height: 260px; }
  .hero-caption { padding: 1rem 1.25rem 1.5rem; }
}

/* ---- Emoji Reactions ---- */
.reactions-bar { user-select: none; }

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border-radius: 2rem !important;
  padding: .25rem .65rem;
  font-size: .82rem;
  transition: transform .15s, background .15s, border-color .15s, box-shadow .15s;
  line-height: 1;
}
.reaction-btn:hover:not(:disabled) {
  transform: scale(1.12);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.reaction-btn:active:not(:disabled) { transform: scale(.95); }

.reaction-active {
  background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
  border-color: var(--bs-primary) !important;
  color: var(--bs-primary) !important;
}

.reaction-emoji {
  font-size: 1.1rem;
  display: inline-block;
  line-height: 1;
}

.reaction-count {
  font-weight: 600;
  min-width: .8rem;
  text-align: center;
}

/* Pop keyframe on react */
@keyframes reactionPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.45); }
  70%  { transform: scale(.9); }
  100% { transform: scale(1); }
}
.reaction-pop { animation: reactionPop .4s ease; }

/* ---- Article Cards ---- */
.article-card {
  transition: transform .2s, box-shadow .2s;
  border-radius: .75rem !important;
  overflow: hidden;
}
.article-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.12) !important;
}
.article-thumb {
  height: 180px;
  object-fit: cover;
  width: 100%;
}
.article-thumb-placeholder {
  height: 180px;
  width: 100%;
}
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Article content media containment ---- */
.article-content {
  overflow: hidden;
  min-width: 0;
  width: 100%;
}
.article-content video,
.article-content iframe {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  border-radius: .5rem;
  box-sizing: border-box;
}
.article-content figure {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 1rem 0 !important;
  padding: 0 !important;
  overflow: hidden;
  box-sizing: border-box;
}

/* ---- Dark mode auto ---- */
@media (prefers-color-scheme: dark) {
  [data-bs-theme="auto"] {
    color-scheme: dark;
  }
  [data-bs-theme="auto"] .hero-img { filter: brightness(0.6); }
  [data-bs-theme="auto"] .article-thumb-placeholder { background: var(--bs-secondary-bg) !important; }
}

/* ---- CKEditor container ---- */
.ck-editor__editable_inline {
  min-height: 400px;
  border-radius: 0 0 .375rem .375rem !important;
}
.ck.ck-toolbar { border-radius: .375rem .375rem 0 0 !important; }

/* Sticky toolbar — sits just below the Bootstrap sticky navbar */
.ck.ck-sticky-panel__content_sticky {
  z-index: 1020 !important;
  top: 62px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.12) !important;
}
[data-bs-theme="dark"] .ck.ck-editor__main > .ck-editor__editable,
[data-bs-theme="dark"] .ck.ck-toolbar {
  background: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
  border-color: var(--bs-border-color) !important;
}

/* CKEditor media containment — mirrors .article-content rules */
.ck-content figure,
.ck-editor__editable figure {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 1rem 0 !important;
  padding: 0 !important;
  overflow: hidden;
  box-sizing: border-box;
}
.ck-content video,
.ck-editor__editable video {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  border-radius: .375rem;
}

/* ---- Form controls ---- */
.form-control, .form-select {
  border-radius: .5rem;
}

/* ---- Badges ---- */
.badge { font-weight: 500; }

/* ---- Recommended sidebar items ---- */
.rec-item { transition: background .15s; }
.rec-item:hover { background: var(--bs-secondary-bg); }
.rec-item:last-child { border-bottom: none !important; }

/* ---- Comment thread ---- */
.comment-thread + .comment-thread { border-top: 1px solid var(--bs-border-color); padding-top: .75rem; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bs-secondary-bg); border-radius: 3px; }

/* ---- PWA install banner ---- */
#pwaInstallBanner {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 9999;
  max-width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  border-radius: .75rem;
}

/* ---- Responsive ---- */
@media (max-width: 576px) {
  .hero-carousel { max-height: 260px; }
  .hero-img { height: 260px; }
  .hero-placeholder { height: 260px; }
  .carousel-caption-custom { display: none; }
  .carousel-caption-custom h2 { font-size: 1rem; }
}

/* ---- Sticky sidebar support ---- */
@media (min-width: 992px) {
  .sticky-sidebar { position: sticky; top: 80px; }
}
