/* tree.css
   Tree canvas + SVG styling + tree tools
*/

/* -----------------------------
   CANVAS + SVG
----------------------------- */

#canvas{
  position: relative;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 14px;

  /* parchment-glass backdrop */
  background:
    radial-gradient(900px 560px at 15% 10%, rgba(255,255,255,0.70), rgba(255,255,255,0.00)),
    radial-gradient(700px 520px at 80% 20%, rgba(176,204,196,0.22), rgba(255,255,255,0.00)),
    linear-gradient(180deg, rgba(255,255,255,0.25), rgba(255,255,255,0.10));

  overflow: hidden;

  /* IMPORTANT:
     Avoid height:auto for an interactive SVG surface.
     Use a stable, responsive height that feels app-like on all screens.
  */
  height: clamp(320px, 62vh, 720px);
  min-height: 340px;

  box-shadow: 0 14px 34px rgba(40,32,24,0.08);
}

#treeSvg{
  width: 100%;
  height: 100%;
  min-height:600px;
  display: block;
  /* helps prevent tiny overflow artifacts in some browsers */
  overflow: visible;
}

/* -----------------------------
   NODE SHADOWS
----------------------------- */

/* SVG card shadow */
.tree-nodes rect{
  filter:
    drop-shadow(0 14px 26px rgba(0,0,0,0.20))
    drop-shadow(0 4px 10px rgba(0,0,0,0.12));
}

/* -----------------------------
   TOOLS
----------------------------- */

.treeToolbar{
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
}

.treeToolbar .treeToolbarBtn{
  user-select: none;
  touch-action: manipulation;
  border: 1px solid rgba(92,70,50,0.24);
  background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(248,244,238,0.72));
  color: rgba(60,40,28,0.92);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.75), 0 10px 20px rgba(40,32,24,0.10);
  backdrop-filter: blur(6px);
  cursor: pointer;
}

.treeToolbar .treeToolbarBtn:hover{ filter: brightness(1.02); }
.treeToolbar .treeToolbarBtn:active{ transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.65), 0 7px 16px rgba(40,32,24,0.10); }

@media (max-width: 520px){
  .treeToolbar{
    justify-content: space-between;
    gap: 8px;
  }
  .treeToolbar .treeToolbarBtn{
    flex: 1;
  }
}

/* If you still have a single legacy .fit-btn in templates somewhere,
   keep it working, but prefer using .treeTools wrapper going forward. */
.fit-btn{
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(40,32,24,0.10);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  user-select: none;
  touch-action: manipulation;
}

/* -----------------------------
   RESPONSIVE
----------------------------- */

/* large desktop: tree becomes app-height */
@media (min-width: 1024px){
  #canvas{
    height: calc(100vh - 110px);
    min-height: 520px;
    border-radius: 16px;
  }
}

/* slightly wider phones */
@media (min-width: 480px){
  #canvas{
    min-height: 380px;
  }
}

/* ultra small */
@media (max-width: 360px){
  #canvas{
    height: clamp(280px, 58vh, 520px);
    min-height: 280px;
  }

  .treeTools{
    top: 8px;
    right: 8px;
    gap: 8px;
  }

  .treeTools .fit-btn,
  .fit-btn{
    padding: 8px 10px;
    border-radius: 11px;
    font-size: 12.5px;
  }
}
/* Embed-only: keep the tree tight inside landing cards */
.isEmbed #canvas{
  height: 100% !important;
  min-height: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
