/* ==========================================================================
   TES-WEB · PUBLIC ANNOUNCEMENT VIEWER  (assets/css/announcement-viewer.css)
   --------------------------------------------------------------------------
   The pop-up the landing-page carousel opens: the SAME two-pane photo viewer
   the portal uses (markup: includes/render_announcement_detail.php,
   behaviour: assets/js/announcement-detail.js). These rules are copied from
   the viewer section of portal.css so the landing page doesn't have to load
   the whole portal stylesheet; if the portal viewer's look changes, mirror
   it here. Public-only extras (sign-in box, page scroll lock, button resets
   the landing page lacks) are at the bottom.
   Loaded after index.css, which brings in tokens.css (colours, dark mode).
   ========================================================================== */

/* ------------------------------ Modal shell ----------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(36, 21, 18, 0.5);
  align-items: flex-start;
  justify-content: center;
  padding: 30px 16px;
  overflow-y: auto;
  z-index: 1000;            /* above the landing page's sticky header (100) */
}
.modal-overlay.is-open { display: flex; animation: modalOverlayFade 0.16s var(--ease); }
@keyframes modalOverlayFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-overlay.is-open .modal-card { animation: modalPop 0.2s var(--ease); }

.modal-card {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 560px;
  padding: 28px;
  color: var(--ink);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.3rem;
  color: var(--ink-faint);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.modal-close:hover { background: var(--cream); color: var(--maroon); }
.modal-loading { text-align: center; color: var(--ink-faint); padding: 40px 0; }
.detail-error  { color: var(--maroon); text-align: center; padding: 20px 0; }

/* ------------------------------ Post text ------------------------------- */
.pinned-tag   { color: var(--gold); font-weight: 600; }
.audience-tag { color: var(--ink-soft); }
.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-bottom: 10px;
}
.detail-title { font-size: 1.25rem; margin: 0 0 10px; }
.detail-content {
  font-size: 0.92rem;
  color: var(--ink);
  line-height: 1.6;
  margin-bottom: 14px;
  white-space: pre-line;
}
.detail-stats {
  display: flex;
  gap: 18px;
  font-size: 0.82rem;
  color: var(--ink-faint);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* -------------------- Two-pane layout (post has photos) ----------------- */
.modal-card:has(.detail-box.has-stage) {
  max-width: none;
  width: 98vw;
  padding: 0;
  overflow: hidden;
}
.modal-card:has(.detail-box.has-stage) .modal-body { padding: 0; }
.modal-card:has(.detail-box.has-stage) .modal-close {
  top: 14px;
  left: 14px;
  right: auto;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  z-index: 6;
}
.modal-card:has(.detail-box.has-stage) .modal-close:hover { background: rgba(0, 0, 0, 0.7); }
.detail-box.has-stage { display: flex; align-items: stretch; height: 95vh; }

/* -------------------------------- Stage -------------------------------- */
.detail-stage {
  position: relative;
  flex: 1 1 60%;
  min-width: 0;
  background: #0c0c0e;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.detail-stage-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.detail-stage-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.12s var(--ease);
  user-select: none;
  -webkit-user-drag: none;
}
.detail-stage.is-zoomed .detail-stage-img { cursor: grab; }
.detail-stage.is-zoomed .detail-stage-img:active { cursor: grabbing; }
.detail-stage.is-maximized {
  position: fixed;
  inset: 0;
  z-index: 1100;
  height: auto;
  background: rgba(10, 10, 12, 0.98);
}
.detail-stage.is-maximized .detail-stage-img { max-height: 92vh; max-width: 96vw; }
.detail-stage.is-maximized .detail-stage-nav.prev { left: 24px; }
.detail-stage.is-maximized .detail-stage-nav.next { right: 24px; }
.stage-tool .ic-min { display: none; }
.detail-stage.is-maximized .stage-tool-max .ic-max { display: none; }
.detail-stage.is-maximized .stage-tool-max .ic-min { display: inline; }
.stage-tool svg { width: 18px; height: 18px; }
.detail-stage-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: #241512;
  font-size: 1.7rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  transition: background 0.15s var(--ease);
}
.detail-stage-nav:hover { background: #fff; }
.detail-stage-nav.prev { left: 14px; }
.detail-stage-nav.next { right: 14px; }
.detail-stage-counter {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
}
.detail-stage-tools { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; }
.stage-tool {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1.15rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s var(--ease);
}
.stage-tool:hover { background: rgba(0, 0, 0, 0.78); }

/* ----------------------------- Right pane ------------------------------ */
.detail-box.has-stage .detail-pane {
  flex: 0 0 400px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--paper);
}
.detail-pane-scroll { flex: 1 1 auto; overflow-y: auto; padding: 44px 24px 14px; }
.detail-content-wrap { max-height: 8.4em; overflow: hidden; transition: max-height 0.2s var(--ease); }
.detail-content-wrap.is-expanded { max-height: 340px; overflow-y: auto; }
.detail-see-more {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  margin: 6px 0 12px;
  cursor: pointer;
}
.detail-see-more:hover { text-decoration: underline; }

/* No-picture posts keep a single-column reading layout. */
.detail-box.no-stage .detail-pane { display: block; }
.detail-box.no-stage .detail-pane-scroll { padding: 4px 2px 0; overflow: visible; }

/* -------------------------- Mobile: stack (portrait) ------------------- */
@media (max-width: 820px) {
  .modal-card:has(.detail-box.has-stage) { max-width: 96vw; }
  .detail-box.has-stage { flex-direction: column; max-height: 90vh; }
  .detail-stage { flex: 0 0 auto; height: 44vh; }
  .detail-stage-img { max-height: 44vh; }
  .detail-box.has-stage .detail-pane {
    flex: 1 1 auto;
    max-width: none;
    max-height: none;
    min-height: 0;
  }
  .detail-pane-scroll { padding: 20px 16px 12px; }
}

/* ============================ PUBLIC EXTRAS ============================ */

/* The landing page has no global button reset (portal.css does). */
.modal-overlay button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}
.modal-overlay .detail-stage-nav { background: rgba(255, 255, 255, 0.85); }
.modal-overlay .detail-stage-nav:hover { background: #fff; }
.modal-overlay .stage-tool { background: rgba(0, 0, 0, 0.5); }
.modal-overlay .stage-tool:hover { background: rgba(0, 0, 0, 0.78); }
.modal-overlay .modal-close:focus-visible,
.modal-overlay .detail-stage-nav:focus-visible,
.modal-overlay .stage-tool:focus-visible,
.detail-public-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Keep the page behind the pop-up from scrolling. */
body.ann-viewer-open { overflow: hidden; }

/* Where the dashboards have Like / Comment and the thread: a sign-in box. */
.detail-public-cta {
  margin-top: 16px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--maroon);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
.detail-public-cta p { margin: 0; font-size: 0.92rem; line-height: 1.5; }
.detail-public-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--maroon);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.detail-public-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2); }
[data-theme="dark"] .detail-public-btn { color: #7A1B2E; }

@media (prefers-reduced-motion: reduce) {
  .modal-overlay.is-open,
  .modal-overlay.is-open .modal-card { animation: none; }
}
