/* ============================================================
   DNAViewer 8.0 — Native Vector Embed (Stable)
============================================================ */

/* ROOT TOKENS */
:root {
  --left-w: 260px;
  --right-w: 360px;
  --gap: 12px;
  --bg: #ffffff;
  --muted: #6b6b6b;
}

/* RESET */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color: #111;
  overflow: hidden; /* Desktop uses full viewport layout */
}

/* ============================================================
   DESKTOP GRID LAYOUT
============================================================ */
.container {
  display: grid;
  grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
  gap: var(--gap);
  height: 100vh;
  padding: 12px;
}

/* PANEL GENERIC */
.panel {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  min-height: 0;
}

.panel-header {
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid #eee;
  color: var(--muted);
}

/* ============================================================
   TREE PANEL
============================================================ */
.tree {
  overflow-y: auto;
  padding: 8px;
  font-size: 13px;
}

.branch {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
}
.branch:hover {
  background: #f5f7fb;
}
.branch.active {
  background: rgba(0, 116, 68, 0.12);
}

.branch-header {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.arrow {
  width: 10px;
  flex: 0 0 10px;
  font-size: 11px;
  text-align: center;
}

.children {
  display: none;
  margin-left: 6px;
  padding-left: 6px;
  border-left: 1px solid #ddd;
}
.branch.open > .children {
  display: block;
}

/* ============================================================
   VIEWER PANEL
============================================================ */
.viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  border-radius: 8px;
  overflow: hidden;
}

#pdfWrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

#placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #777;
  text-align: center;
  padding: 16px;
}

/* NATIVE PDF VIEWER */
#pdfEmbed {
  display: none;
  width: 100%;
  height: 100%;
  border: none;
}

/* ============================================================
   MEANING PANEL
============================================================ */
.meaning {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.m-title {
  font-size: 20px;
  font-weight: 700;
  color: #005533;
  margin-bottom: 14px;
}

.m-section {
  margin-bottom: 20px;
}

.m-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #005533;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ddd;
}

.m-label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  margin-bottom: 2px;
}

.m-value {
  background: #fafafa;
  border: 1px solid #e5e5e5;
  padding: 10px 12px;
  border-radius: 6px;
  white-space: pre-wrap;
}

/* ============================================================
   MOBILE LAYOUT 8.0 — STABLE NATIVE VIEWER
============================================================ */
@media (max-width: 900px) {

  html, body {
    overflow: auto; /* Allow natural scrolling on mobile */
  }

  .container {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    padding: 8px;
  }

  #left {
    order: 1;
    width: 100%;
    margin-bottom: 14px;
  }

  #right {
    order: 2;
    width: 100%;
    margin-bottom: 14px;
  }

  #center {
    order: 3;
    width: 100%;
    margin-bottom: 14px;
  }

  /* Make viewer tall enough for native PDF scrolling */
  .viewer {
    height: 80vh;
    min-height: 70vh;
  }

  #pdfEmbed {
    height: 100%;
    display: none; /* viewer.js toggles this */
  }
}
/* ============================================================
   INTRO OVERLAY POPUP
============================================================ */
#introOverlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

#introBox {
  width: min(720px, 90%);
  background: #ffffff;
  border-radius: 12px;
  padding: 28px 32px;
  box-shadow: 0 12px 38px rgba(0,0,0,0.12);
  font-size: 15px;
  line-height: 1.6;
}

#introBox p { margin-bottom: 14px; }

.intro-title {
  font-size: 24px;
  font-weight: 700;
  color: #005533;
  margin-bottom: 18px;
}

#introBtn {
  margin-top: 12px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background: #005533;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
#introBtn:hover { background: #003f26; }

@media (max-width: 900px) {
  #introBox {
    padding: 20px 18px;
  }
  .intro-title {
    font-size: 20px;
  }
}

/* ============================================================
   GLOBAL FIX — Intro Overlay must stay above all layouts
============================================================ */
#introOverlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 999999 !important;
  pointer-events: auto !important;
}
/* --------------------------
   Mobile PDF Overlay & Hint
   -------------------------- */

.initial-hint {
  background: #fffefc;
  border: 1px solid #efe9e1;
  padding: 8px 12px;
  border-radius: 8px;
  margin: 6px 12px;
  display: block;
}

/* Mobile overlay */
#mobilePdfOverlay {
  position: fixed;
  inset: 0;
  z-index: 999998;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.mobilePdfTop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
  flex: 0 0 auto;
}

.mobileBackBtn {
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: #005533;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.mobileBackBtn:hover { background: #004328; }

#mobilePdfIframe {
  flex: 1 1 auto;
  width: 100%;
  border: none;
}

/* make sure overlay sits above intro too */
#introOverlay { z-index: 999999; }
#mobilePdfOverlay { z-index: 1000000; }

/* small responsive tweak */
@media (max-width:900px) {
  .initial-hint { font-size:14px; margin:8px 10px; }
  .mobileBackBtn { padding:10px 14px; }
}
