/* ==========================================================================
   HOMEPAGE SPECIFIC STYLES (Figma Replication)
   ========================================================================== */

/* ==========================================================================
   1. LOADING SCREEN ANIMATION ("HI" Vector Drop & Zoom)
   ========================================================================== */
.loader-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
  background-color: var(--loader-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none !important; /* Critical: Never block user interaction */
  animation: screenFadeOut 0.5s cubic-bezier(0.4, 0, 0.2, 1) 1.85s forwards;
}

html.no-loader .loader-screen {
  display: none !important;
}

.loader-svg {
  width: 720px;
  height: 480px;
  max-width: 90vw;
  overflow: visible;
  animation: zoomIntoWebsite 0.55s cubic-bezier(0.65, 0, 0.35, 1) 1.25s forwards;
}

/* 7 SVG Strokes Dropping in Staggered Order */
.loader-step {
  opacity: 0;
  transform: translateY(-90px);
  animation: vectorDropIn 0.32s cubic-bezier(0.18, 0.89, 0.32, 1.25) forwards;
}

#step1 { animation-delay: 0.0s; }
#step2 { animation-delay: 0.1s; }
#step3 { animation-delay: 0.2s; }
#step4 { animation-delay: 0.3s; }
#step7 { animation-delay: 0.35s; }
#step5 { animation-delay: 0.4s; }
#step6 { animation-delay: 0.5s; }

@keyframes vectorDropIn {
  0% {
    opacity: 0;
    transform: translateY(-90px);
  }
  70% {
    opacity: 1;
    transform: translateY(6px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes zoomIntoWebsite {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  70% {
    transform: scale(2.8);
    opacity: 0.8;
  }
  100% {
    transform: scale(4.2);
    opacity: 0;
  }
}

@keyframes screenFadeOut {
  0% {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
    display: none;
  }
}

/* ==========================================================================
   2. HOMEPAGE MAIN LAYOUT GRID
   ========================================================================== */
.home-layout {
  width: 100%;
  max-width: 1180px;
  height: calc(100vh - 100px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 10px 24px;
}

/* ==========================================================================
   3. CENTER JSON AREA CARD
   ========================================================================== */
.json-area-card {
  flex: 1;
  max-width: 820px;
  height: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 32px;
}

/* Card Header */
.json-card-header {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid var(--sub-panel-border);
  transition: border-color 0.25s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.card-title {
  font-family: var(--font-sans);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--text-primary);
  transition: color 0.3s ease;
}

/* Dual Mode Tabs [ MANUAL ] vs [ <> CHAIN ] */
.mode-switch-tabs {
  display: flex;
  background: var(--tab-track-bg);
  padding: 3px;
  border-radius: 9999px;
  border: 1px solid var(--tab-track-border);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.tab-btn {
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.8px;
  padding: 6px 14px;
  border-radius: 9999px;
  color: var(--tab-btn-text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: #0A6563;
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Scrollable Inner Body */
#jsonAreaScrollable {
  flex: 1;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   4. MANUAL JSON EDITOR VIEW
   ========================================================================== */
.manual-editor-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 10px;
}

.manual-textarea {
  flex: 1;
  width: 100%;
  background: var(--dark-glass-bg);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 16px 20px;
  color: #78C2E9;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  resize: none;
  outline: none;
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  user-select: text !important;
  cursor: text;
}

.manual-textarea:focus {
  border-color: #0A6563;
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.5), 0 0 16px rgba(10, 101, 99, 0.4);
}

.editor-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.syntax-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-weight: 700;
}

.syntax-badge.valid {
  background: rgba(55, 109, 51, 0.2);
  color: #2E7D32;
  border: 1px solid rgba(46, 125, 50, 0.35);
}

.syntax-badge.invalid {
  background: rgba(229, 9, 20, 0.18);
  color: #E50914;
  border: 1px solid rgba(229, 9, 20, 0.35);
}

/* ==========================================================================
   5. CHAIN BRANCH EDITOR VIEW (<> CHAIN)
   ========================================================================== */
.chain-editor-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chain-bracket-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-mono);
}

.chain-head-bracket, .chain-foot-bracket {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 900;
  color: var(--chain-bracket-color);
  transition: color 0.3s ease;
}

.chain-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 20px;
  margin: 6px 0;
}

/* Key-Value Row */
.kv-row {
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.25s ease;
}

/* Bracket Button <> */
.btn-bracket-icon {
  background: #376D33;
  color: #FFFFFF;
  border: none;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 13px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.btn-bracket-icon:hover {
  transform: scale(1.1);
  filter: brightness(1.25);
}

/* Black Stadium Capsule Pills (Figma Exact) */
.pill-input-key, .pill-input-value {
  background: #000000;
  color: #FFFFFF;
  border-radius: 9999px;
  border: 1.5px solid #222222;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 13px;
  padding: 10px 20px;
  outline: none;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.pill-input-key {
  width: 170px;
}

.pill-input-value {
  flex: 1;
  max-width: 440px;
}

.pill-input-key:focus, .pill-input-value:focus {
  border-color: #0A6563;
  box-shadow: 0 0 12px rgba(10, 101, 99, 0.6);
}

.row-colon {
  font-weight: 900;
  color: var(--chain-colon-color);
  font-size: 16px;
  transition: color 0.3s ease;
}

/* Remove Row Button × */
.btn-remove-row {
  background: none;
  border: none;
  color: #7E3B27;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  transition: transform 0.2s ease, color 0.2s ease;
}

.btn-remove-row:hover {
  color: #E50914;
  transform: scale(1.25);
}

/* Row-level Branch Reduction (Folded) */
.kv-row.row-reduced .pill-input-value {
  display: none;
}

.folded-badge {
  display: none;
  background: rgba(0, 0, 0, 0.4);
  color: #78C2E9;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.kv-row.row-reduced .folded-badge {
  display: inline-block;
}

/* Chain Controls Bar */
.chain-controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding-left: 20px;
}

.btn-chain-action {
  background: var(--btn-chain-bg);
  border: 1.5px solid var(--btn-chain-border);
  color: var(--btn-chain-text);
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-chain-action:hover {
  background: var(--item-card-bg);
  border-color: #0A6563;
  transform: translateY(-1px);
}

/* ==========================================================================
   NESTED BRANCH STYLING IN <> CHAIN VIEW
   ========================================================================== */
.branch-node {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--branch-node-bg);
  border-radius: 18px;
  padding: 8px 12px;
  border: 1px solid var(--branch-node-border);
  transition: all 0.2s ease;
}

.branch-node:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(10, 101, 99, 0.35);
}

.branch-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.branch-type-pill {
  background: #111B38;
  color: #78C2E9;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 9999px;
  border: 1px solid #1E293B;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.branch-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 20px;
  margin-left: 17px;
  border-left: 2.5px solid rgba(10, 101, 99, 0.45);
  margin-top: 4px;
  margin-bottom: 4px;
}

.branch-node.branch-folded .branch-inner {
  display: none;
}

.branch-fold-summary {
  display: none;
  background: rgba(0, 0, 0, 0.35);
  color: #A5F3FC;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.branch-node.branch-folded .branch-fold-summary {
  display: inline-block;
}

.branch-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.btn-branch-add {
  background: var(--btn-chain-bg);
  border: 1px solid var(--btn-chain-border);
  color: var(--btn-chain-text);
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 10.5px;
  padding: 4px 12px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-branch-add:hover {
  background: var(--item-card-bg);
  border-color: #0A6563;
  color: #0A6563;
  transform: translateY(-1px);
}

.btn-add-subbranch {
  background: rgba(55, 109, 51, 0.15);
  border: 1px solid rgba(55, 109, 51, 0.4);
  color: #2E7D32;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-add-subbranch:hover {
  background: #376D33;
  color: #FFFFFF;
}

/* ==========================================================================
   6. CARD FOOTER
   ========================================================================== */
.json-card-footer {
  height: 60px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1.5px solid rgba(255, 255, 255, 0.22);
}

.target-endpoint-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--endpoint-badge-text);
  font-weight: 700;
  transition: color 0.3s ease;
}

.endpoint-pill {
  background: var(--endpoint-pill-bg);
  padding: 4px 10px;
  border-radius: 8px;
  color: var(--endpoint-pill-color);
  border: 1px solid var(--endpoint-pill-border);
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ==========================================================================
   7. RIGHT COLUMN ACTION BUTTONS
   ========================================================================== */
.right-action-column {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
  justify-content: center;
}
