/* ==========================================================================
   UAVs Meet Embodied Intelligence - Level 2 & 3 Research Gallery & Detail
   Directly adapted from Flying Intelligence Recent Research geometry,
   3D stage perspective, origin-captured detail expansion, and 3D card flip.
   ========================================================================== */

/* Level 2 Paper Gallery View Container */
html { scrollbar-gutter: stable; }
.paper-gallery-view {
  position: relative;
  z-index: 10;
  width: 100%;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 2rem 3rem;
  box-sizing: border-box;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.paper-gallery-view.is-hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

/* Gallery Top Bar */
.gallery-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1420px;
  margin: 0 auto 0.6rem;
  padding: 0.4rem 1.5rem 0;
  box-sizing: border-box;
}

.btn-back-categories {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 1.15rem;
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, rgba(16, 38, 57, 0.18));
  border-radius: 999px;
  color: var(--color-navy, #102639);
  font-family: var(--font-mono, monospace);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(16, 38, 57, 0.04);
  transition: all 0.2s ease;
}

.btn-back-categories:hover {
  background: #ffffff;
  border-color: #102639;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(16, 38, 57, 0.08);
}

.gallery-counter-badge {
  font-family: var(--font-mono, monospace);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-navy, #102639);
  background: var(--color-surface, #ffffff);
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--color-border, rgba(16, 38, 57, 0.14));
}

.gallery-counter-current {
  color: var(--color-orange, #df6f3f);
}

/* Gallery Header Title */
.gallery-header {
  text-align: center;
  margin: 0.2rem auto 1.4rem;
  max-width: 900px;
}

.gallery-title {
  font-size: clamp(2.2rem, 3.2vw, 2.75rem);
  font-weight: 850;
  letter-spacing: -0.035em;
  color: var(--color-navy, #102639);
  line-height: 1.1;
}

/* Flying Intelligence Stage & Record Layout */
.research-airspace-stage {
  position: relative;
  width: 100%;
  max-width: 1440px;
  min-height: 560px;
  margin: 0 auto;
  perspective: 1400px;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  touch-action: pan-y;
  cursor: grab;
}

.research-airspace-stage:active {
  cursor: grabbing;
}

/* Individual Paper Record */
.research-record {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(520px, 86vw);
  margin: 0;
  opacity: var(--record-opacity, 1);
  z-index: var(--record-layer, 10);
  transform:
    translate(-50%, -50%)
    translate3d(var(--record-x, 0px), var(--record-y, 0px), var(--record-z, 0px))
    rotate(var(--record-rotate, 0deg))
    scale(var(--record-scale, 1));
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.45s ease;
  will-change: transform, opacity;
}

.research-record[aria-hidden="true"] {
  pointer-events: none;
}

.research-record__cover {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  cursor: pointer;
  outline: none;
}

/* Paper Figure Frame - Direct Image Focus */
.research-media-frame {
  position: relative;
  width: 100%;
  height: 310px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(16, 38, 57, 0.12);
  box-shadow: 0 16px 45px rgba(16, 38, 57, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem;
  overflow: hidden;
  box-sizing: border-box;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.research-record.is-active .research-media-frame:hover {
  box-shadow: 0 24px 65px rgba(16, 38, 57, 0.18);
  border-color: rgba(223, 111, 63, 0.4);
}

.research-media-img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* STRICTLY contain to preserve figures */
  border-radius: 8px;
}

/* =========================================================================
   Typography Below Figure: Clear Hierarchy
   ========================================================================= */

.research-record__meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: center;
  max-width: 860px;
  margin-inline: auto;
  transition: opacity 0.3s ease;
}

/* Center Active Paper Typography */
.research-record.is-active .research-record__method {
  font-size: clamp(28px, 2vw, 36px);
  font-weight: 800;
  line-height: 1.1;
  color: var(--color-navy, #102639);
  letter-spacing: -0.02em;
}

.research-record.is-active .research-record__title {
  font-size: clamp(20px, 1.45vw, 26px);
  font-weight: 600;
  color: var(--color-navy, #102639);
  line-height: 1.25;
  max-width: 820px;
  margin-inline: auto;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.research-record.is-active .research-record__venue {
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-orange, #df6f3f);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.15rem;
}

/* Side Preview Papers Typography (Inactive) */
.research-record:not(.is-active) .research-record__meta {
  opacity: 0.6;
  gap: 0.2rem;
}

.research-record:not(.is-active) .research-record__method {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-navy, #102639);
}

.research-record:not(.is-active) .research-record__title {
  font-size: 0.85rem;
  color: var(--color-muted, #586976);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.research-record:not(.is-active) .research-record__venue {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-orange, #df6f3f);
  text-transform: uppercase;
}

/* Stage Navigation Arrows */
.research-stage-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(16, 38, 57, 0.14);
  color: var(--color-navy, #102639);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(16, 38, 57, 0.12);
  transition: all 0.2s ease;
}

.research-stage-nav:hover {
  background: var(--color-navy, #102639);
  color: #ffffff;
  transform: translateY(-50%) scale(1.08);
}

.research-stage-prev {
  left: 1rem;
}

.research-stage-next {
  right: 1rem;
}

.research-stage-nav svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Keyboard hint */
.gallery-keyboard-hint {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.74rem;
  color: var(--color-muted, #586976);
}

.key-pill {
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid rgba(16, 38, 57, 0.18);
  background: #ffffff;
  font-weight: 700;
}

/* Pending Category State */
.pending-category-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  text-align: center;
  gap: 1rem;
}

.pending-category-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--color-navy, #102639);
}

.pending-category-msg {
  font-family: var(--font-mono, monospace);
  font-size: 0.9rem;
  color: var(--color-muted, #586976);
  background: rgba(16, 38, 57, 0.05);
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
}

/* ==========================================================================
   Level 3: Full-Screen 3D Flip Paper Detail View
   ========================================================================== */

.research-detail {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 38, 57, 0.48);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding: 1.5rem;
  box-sizing: border-box;
}

.research-detail.is-open {
  opacity: 1;
  pointer-events: auto;
}

.research-detail__backdrop {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

/* 3D Flipper Stage */
.research-detail__stage {
  position: relative;
  z-index: 2;
  width: min(1050px, 88vw);
  height: min(760px, 84dvh);
  perspective: 2200px;
}

.research-detail__flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.88s cubic-bezier(0.22, 1, 0.36, 1);
}

.research-detail.is-flipped .research-detail__flipper {
  transform: rotateY(180deg);
}

/* Flipper Front and Back Faces */
.research-detail__face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 30px 90px rgba(16, 38, 57, 0.3);
  border: 1px solid rgba(112, 149, 164, 0.25);
  transition: box-shadow 0.88s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Front Face: Magnified Paper Figure */
.research-detail__front {
  transform: rotateY(0deg);
  padding: 2rem;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
}

.research-detail__front img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Back Face: Structured Academic Detail */
.research-detail__back {
  transform: rotateY(180deg);
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
  scrollbar-width: thin;
}

.research-detail.is-flipped .research-detail__face {
  box-shadow: 0 22px 65px rgba(16, 38, 57, 0.22);
}
.detail-figure {
  flex: 0 0 36%;
  min-height: 0;
  padding: 1rem;
  background: linear-gradient(120deg, #edf2f1, #fff 50%, #edf2f1);
  border-bottom: 1px solid rgba(16, 38, 57, 0.1);
}
.detail-figure img { width: 100%; height: 100%; object-fit: contain; }
.detail-copy { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 1.5rem 2.25rem; overscroll-behavior: contain; scrollbar-width: thin; }
.detail-meta-content { min-width: 0; overflow-wrap: anywhere; }
.research-record__cover:focus-visible .research-media-frame { outline: 2px solid var(--color-orange); outline-offset: 4px; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(16, 38, 57, 0.1);
}

.detail-counter {
  font-family: var(--font-mono, monospace);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-orange, #df6f3f);
}

.btn-detail-close {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  background: rgba(16, 38, 57, 0.06);
  border: 1px solid rgba(16, 38, 57, 0.12);
  border-radius: 999px;
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-navy, #102639);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-detail-close:hover {
  background: var(--color-navy, #102639);
  color: #ffffff;
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex-grow: 1;
}

.detail-method-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-navy, #102639);
  letter-spacing: -0.02em;
}

.detail-paper-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-muted, #586976);
  line-height: 1.4;
}

/* One Sentence Summary */
.detail-summary-box {
  background: rgba(223, 111, 63, 0.06);
  border-left: 3px solid var(--color-orange, #df6f3f);
  padding: 0.75rem 1rem;
  border-radius: 0 10px 10px 0;
}

.summary-tag {
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-orange, #df6f3f);
  margin-bottom: 0.25rem;
}

.summary-content {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--color-navy, #102639);
  font-style: italic;
}

/* Meta Rows */
.detail-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.84rem;
}

.detail-meta-label {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-muted, #586976);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  min-width: 72px;
  padding-top: 0.15rem;
}

.detail-meta-content {
  flex-grow: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-navy, #102639);
}

/* Tag Chips */
.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  background: rgba(16, 38, 57, 0.05);
  border: 1px solid rgba(16, 38, 57, 0.12);
  color: var(--color-navy, #102639);
}

.tag-chip.task-tag {
  background: rgba(53, 108, 154, 0.08);
  border-color: rgba(53, 108, 154, 0.25);
  color: #29577d;
}

.tag-chip.method-tag {
  background: rgba(223, 111, 63, 0.08);
  border-color: rgba(223, 111, 63, 0.25);
  color: #a63b0e;
}

/* ★ FIRST Badge and Tooltip */
.first-badge-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.first-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.75rem;
  background: linear-gradient(135deg, #df6f3f 0%, #c85023 100%);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(223, 111, 63, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: none;
}

.first-badge:hover,
.first-badge:focus {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(223, 111, 63, 0.5);
}

.first-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 290px;
  max-width: 320px;
  background: #102639;
  color: #ffffff;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.45;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 60;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.first-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #102639;
}

.first-badge-container:hover .first-tooltip,
.first-badge-container:focus-within .first-tooltip,
.first-badge-container.is-active .first-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* Detail Action Buttons */
.detail-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(16, 38, 57, 0.1);
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.15rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: all 0.2s ease;
  cursor: pointer;
}

.btn-paper {
  background: var(--color-navy, #102639);
  color: #ffffff;
  border: 1px solid var(--color-navy, #102639);
}

.btn-paper:hover {
  background: #1d3e5c;
  box-shadow: 0 4px 14px rgba(16, 38, 57, 0.2);
}

.btn-code {
  background: #ffffff;
  color: var(--color-orange, #df6f3f);
  border: 1px solid rgba(223, 111, 63, 0.4);
}

.btn-code:hover {
  background: rgba(223, 111, 63, 0.08);
  border-color: var(--color-orange, #df6f3f);
}

/* Detail Navigation Prev/Next Arrows */
.detail-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(16, 38, 57, 0.15);
  color: var(--color-navy, #102639);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(16, 38, 57, 0.16);
  transition: all 0.2s ease;
}

.detail-nav-btn:hover {
  background: var(--color-navy, #102639);
  color: #ffffff;
  transform: translateY(-50%) scale(1.08);
}

.detail-nav-prev {
  left: -22px;
}

.detail-nav-next {
  right: -22px;
}

.detail-nav-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Responsive Rules */
@media (max-width: 768px) {
  .paper-gallery-view {
    padding: 1rem 1rem 2rem;
  }
  .research-airspace-stage {
    min-height: 480px;
  }
  .research-media-frame {
    height: 240px;
  }
  .research-stage-prev {
    left: 0;
  }
  .research-stage-next {
    right: 0;
  }
  .research-detail__stage {
    width: 100%;
    height: 88dvh;
  }
  .research-detail { padding: 1rem; }
  .research-record { width: min(520px, 82vw); }
  .detail-figure { flex-basis: 29%; }
  .detail-copy { padding: 1rem 1.15rem; }
  .detail-meta-label { min-width: 58px; }
  .detail-nav-prev {
    left: 0;
  }
  .detail-nav-next {
    right: 0;
  }
  .detail-nav-btn { top: 0; transform: translateY(-105%); }
  .detail-nav-btn:hover { transform: translateY(-105%); }
  .first-tooltip {
    width: min(240px, calc(100vw - 185px));
    left: 0;
    transform: translateY(4px);
  }
  .first-tooltip::after {
    left: 20px;
  }
  .first-badge-container:hover .first-tooltip,
  .first-badge-container:focus-within .first-tooltip,
  .first-badge-container.is-active .first-tooltip { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .research-detail, .research-detail__flipper, .research-detail__face,
  .research-record, .research-media-frame { transition-duration: 0.02s; }
}
