/*
 * AP Drive Comic Gallery — Student Story Comic Page
 *
 * ALL colors come from CSS custom properties set by PHP via wp_head.
 * To change colors: WP Admin → AP Comic Gallery → Colors tab.
 *
 * Variables reference (set in :root by PHP):
 *   --apdg-primary           Main brand color (default: #F47B20)
 *   --apdg-primary-dark      Hover/darker shade  (default: #D96A10)
 *   --apdg-secondary         Secondary color     (default: #1E40AF)
 *   --apdg-secondary-text    Text on secondary   (default: #FFFFFF)
 *   --apdg-hero-bg           Hero banner bg      (default: #F47B20)
 *   --apdg-hero-text         Hero title          (default: #FFFFFF)
 *   --apdg-hero-back         Back link color     (default: rgba(255,255,255,0.85))
 *   --apdg-content-bg        Content background  (default: #FFFFFF)
 *   --apdg-navbar-bg         Bottom nav bg       (default: #FFF5EC)
 *   --apdg-navbar-border     Bottom nav border   (default: #F9CBAA)
 *   --apdg-text-heading      Heading text        (default: #1A2340)
 *   --apdg-text-body         Body text           (default: #1A2340)
 *   --apdg-text-muted        Secondary text      (default: #6B7280)
 *   --apdg-border            Border color        (default: #E5E7EB)
 */

/* ── Outer wrap ──────────────────────────────────────────────────────────── */
.apdg-ss-wrap {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--apdg-text-body, #1A2340);
}

/* ── Container ───────────────────────────────────────────────────────────── */
.apdg-ss-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ══ Hero banner ════════════════════════════════════════════════════════════ */
.apdg-ss-hero {
  background: var(--apdg-hero-bg, #F47B20);
  padding: 28px 0 36px;
  position: relative;
  overflow: hidden;
}

/* Decorative circle */
.apdg-ss-hero::after {
  content: '';
  position: absolute;
  right: -60px;
  top: -60px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}

.apdg-ss-hero .apdg-ss-container { position: relative; z-index: 1; }

/* Back link */
.apdg-ss-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--apdg-hero-back, rgba(255,255,255,0.85));
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 20px;
  transition: color 0.15s;
  letter-spacing: 0.02em;
}
.apdg-ss-back:hover { color: var(--apdg-hero-text, #FFFFFF); }
.apdg-ss-back svg   { width: 16px; height: 16px; flex-shrink: 0; }

/* Hero body */
.apdg-ss-hero-body { display: flex; flex-direction: column; gap: 6px; }

.apdg-ss-eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--apdg-hero-back, rgba(255,255,255,0.7));
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.apdg-ss-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--apdg-hero-text, #FFFFFF);
  line-height: 1.2;
  margin: 0;
}

.apdg-ss-counter {
  font-size: 13px;
  color: var(--apdg-hero-back, rgba(255,255,255,0.65));
  margin: 0;
}

/* ══ Content area ═══════════════════════════════════════════════════════════ */
.apdg-ss-content {
  background: var(--apdg-content-bg, #FFFFFF);
  padding: 36px 0 28px;
}

/* ── Comic image ──────────────────────────────────────────────────────────── */
.apdg-ss-comic-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.apdg-ss-img-btn {
  position: relative;
  display: inline-block;
  border: none;
  background: none;
  padding: 0;
  cursor: zoom-in;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10),
              0 0 0 3px color-mix(in srgb, var(--apdg-primary, #F47B20) 20%, transparent);
  transition: box-shadow 0.2s, transform 0.2s;
  max-width: 100%;
}

.apdg-ss-img-btn:hover,
.apdg-ss-img-btn:focus-visible {
  box-shadow: 0 12px 40px rgba(0,0,0,0.15),
              0 0 0 3px color-mix(in srgb, var(--apdg-primary, #F47B20) 50%, transparent);
  transform: translateY(-2px);
}

/* Fallback for browsers without color-mix */
@supports not (color: color-mix(in srgb, red 10%, white)) {
  .apdg-ss-img-btn       { box-shadow: 0 4px 24px rgba(0,0,0,0.10), 0 0 0 3px rgba(244,123,32,0.15); }
  .apdg-ss-img-btn:hover { box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 0 0 3px rgba(244,123,32,0.4); }
}

.apdg-ss-img-btn:focus-visible {
  outline: 3px solid var(--apdg-primary, #F47B20);
  outline-offset: 3px;
}

.apdg-ss-img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
}

/* Zoom badge */
.apdg-ss-zoom-badge {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--apdg-primary, #F47B20);
  color: var(--apdg-hero-text, #FFFFFF);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.apdg-ss-zoom-badge svg { width: 12px; height: 12px; }
.apdg-ss-img-btn:hover       .apdg-ss-zoom-badge,
.apdg-ss-img-btn:focus-visible .apdg-ss-zoom-badge { opacity: 1; }

/* No image fallback */
.apdg-ss-no-img {
  text-align: center;
  padding: 40px 20px;
  background: #F8FAFC;
  border: 2px dashed var(--apdg-border, #E5E7EB);
  border-radius: 12px;
  color: var(--apdg-text-muted, #6B7280);
  font-size: 14px;
}

/* ── Description ──────────────────────────────────────────────────────────── */
.apdg-ss-desc {
  max-width: 640px;
  margin: 0 auto 24px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--apdg-text-muted, #6B7280);
  border-left: 4px solid var(--apdg-primary, #F47B20);
  padding-left: 16px;
}
.apdg-ss-desc p:first-child { margin-top: 0; }
.apdg-ss-desc p:last-child  { margin-bottom: 0; }

/* ── Actions (Share button) ───────────────────────────────────────────────── */
.apdg-ss-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding-top: 8px;
}

.apdg-ss-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  background: var(--apdg-secondary, #1E40AF);
  color: var(--apdg-secondary-text, #FFFFFF);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
}
.apdg-ss-share-btn:hover  { filter: brightness(0.88); transform: translateY(-1px); }
.apdg-ss-share-btn:active { transform: none; }
.apdg-ss-share-btn svg    { width: 16px; height: 16px; }

/* ══ Navigation bar ═════════════════════════════════════════════════════════ */
.apdg-ss-nav-bar {
  background: var(--apdg-navbar-bg, #FFF5EC);
  border-top: 2px solid var(--apdg-navbar-border, #F9CBAA);
  padding: 20px 0;
}

.apdg-ss-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

/* Nav prev/next buttons */
.apdg-ss-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--apdg-content-bg, #FFFFFF);
  border: 2px solid var(--apdg-border, #E5E7EB);
  border-radius: 12px;
  text-decoration: none;
  color: var(--apdg-text-body, #1A2340);
  transition: all 0.15s;
  min-width: 0;
  overflow: hidden;
}
.apdg-ss-nav-btn:hover {
  border-color: var(--apdg-primary, #F47B20);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.apdg-ss-nav-disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}
.apdg-ss-nav-btn svg { flex-shrink: 0; width: 20px; height: 20px; color: var(--apdg-primary, #F47B20); }

.apdg-ss-nav-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }

.apdg-ss-nav-dir {
  font-size: 10px;
  font-weight: 700;
  color: var(--apdg-primary, #F47B20);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.apdg-ss-nav-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--apdg-text-heading, #1A2340);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apdg-ss-nav-thumb {
  width: 40px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  opacity: 0.85;
  border: 1px solid var(--apdg-border, #E5E7EB);
}

.apdg-ss-nav-prev                            { justify-content: flex-start; }
.apdg-ss-nav-next                            { justify-content: flex-end; flex-direction: row-reverse; }
.apdg-ss-nav-next .apdg-ss-nav-meta         { text-align: right; }

/* All stories button (centre) */
.apdg-ss-all-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--apdg-primary, #F47B20);
  color: var(--apdg-hero-text, #FFFFFF);
  border-radius: 10px;
  text-decoration: none;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: filter 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.apdg-ss-all-btn:hover { filter: brightness(0.88); transform: translateY(-1px); }
.apdg-ss-all-btn svg   { width: 18px; height: 18px; }

/* ══ Share popup ════════════════════════════════════════════════════════════ */
.apdg-share-popup {
  position: fixed;
  z-index: 999999;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--apdg-content-bg, #FFFFFF);
  border: 1px solid var(--apdg-border, #E5E7EB);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
  padding: 18px 20px;
  min-width: 270px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.apdg-share-popup.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: all;
}

.apdg-share-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.apdg-share-popup-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--apdg-text-heading, #1A2340);
}
.apdg-share-popup-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--apdg-text-muted, #6B7280);
  padding: 2px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color 0.15s;
}
.apdg-share-popup-close:hover { color: var(--apdg-text-heading, #1A2340); }
.apdg-share-popup-close svg { width: 16px; height: 16px; }

.apdg-share-popup-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.apdg-share-popup-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--apdg-border, #E5E7EB);
  border-radius: 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--apdg-text-body, #1A2340);
  background: #F8FAFC;
  transition: all 0.15s;
  cursor: pointer;
}
.apdg-share-popup-link:hover {
  background: var(--apdg-navbar-bg, #FFF5EC);
  border-color: var(--apdg-primary, #F47B20);
  color: var(--apdg-primary-dark, #D96A10);
}
.apdg-share-popup-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.apdg-share-copy-success {
  background: #F0FDF4 !important;
  border-color: #22C55E !important;
  color: #15803D !important;
}

/* Lightbox z-index */
#apdg-cp-lb { z-index: 999000 !important; }

/* ══ Mobile ═════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .apdg-ss-title   { font-size: 24px; }
  .apdg-ss-hero    { padding: 20px 0 28px; }
  .apdg-ss-content { padding: 24px 0 20px; }
  .apdg-ss-nav {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .apdg-ss-all-btn  { grid-column: 1 / -1; flex-direction: row; justify-content: center; }
  .apdg-ss-nav-prev { grid-row: 2; }
  .apdg-ss-nav-next { grid-row: 2; }
  .apdg-ss-nav-thumb { display: none; }
  .apdg-ss-img        { max-height: 65vw; }
  .apdg-share-popup   { left: 12px; right: 12px; bottom: 16px; min-width: 0; transform: translateY(10px); }
  .apdg-share-popup.visible { transform: translateY(0); }
}
