/* The tree page borrows the story's tokens, rings, card and name tag from story.css; this lays out the one screen */
body { min-block-size: 100svh; }
.tree-bar {
  position: fixed;
  z-index: 6;
  inset: max(14px, env(safe-area-inset-top)) 16px auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.tree-bar .to-tree { position: static; }
.tree-bar form { flex: 1 1 14rem; display: flex; justify-content: flex-end; }
.tree-bar search { position: relative; inline-size: min(100%, 20rem); }
.tree-bar search svg { position: absolute; inset: 50% auto auto 14px; translate: 0 -50%; inline-size: 16px; block-size: 16px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.tree-bar input[type="search"] {
  inline-size: 100%;
  min-block-size: 40px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--hair);
  border-radius: 99px;
  background: rgb(12 18 15 / .9);
  color: var(--ink);
  font: 400 .9375rem var(--display);
}
.tree-bar input[type="search"]:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.tree-bar .ict {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-block-size: 40px;
  padding: 0 14px;
  border: 1px solid var(--hair);
  border-radius: 99px;
  background: rgb(12 18 15 / .9);
  color: var(--ink-2);
  font: 500 .8125rem/1 var(--data);
  cursor: pointer;
}
.tree-bar .ict input { accent-color: var(--teal); margin: 0; }
.tree-bar .ict:has(input:focus-visible) { outline: 3px solid var(--teal); outline-offset: 2px; }

.tree-stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 72px 12px 100px;
}
.tree-stage .rings {
  position: static;
  translate: none;
  inline-size: min(100%, calc(100svh - 172px));
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
@media (max-width: 40em) {
  .tree-stage { padding-top: 120px; }
  .tree-stage .rings { inline-size: min(100%, calc(100svh - 132px)); }
}

/* On a phone the card docks along the bottom, so the rings and the lit line stay in view above it */
@media (max-width: 40em) {
  .tree-bar form { flex-basis: 100%; }
  .tree-bar search { inline-size: 100%; }
  .pcard { inset: auto 12px max(12px, env(safe-area-inset-bottom)) !important; inline-size: auto; max-block-size: 46svh; }
  .tree-stage { place-items: start center; }
}

/* The stage takes pinches and drags; zoomed in, the rings run past their square to the screen's edges */
.tree-stage { touch-action: none; user-select: none; -webkit-user-select: none; }
.tree-stage .rings { overflow: visible; }

.tree-tools {
  position: fixed;
  z-index: 6;
  inset: auto auto max(16px, env(safe-area-inset-bottom)) 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}
.lenses { display: flex; flex-wrap: wrap; gap: 8px; }
.lenses button, .zoom button, .pc-actions button {
  min-block-size: 40px;
  padding: 0 14px;
  border: 1px solid var(--hair);
  border-radius: 99px;
  background: rgb(12 18 15 / .9);
  color: var(--ink-2);
  font: 500 .8125rem/1 var(--data);
  cursor: pointer;
}
.lenses button:hover, .zoom button:hover, .pc-actions button:hover { color: var(--ink); border-color: var(--ink-3); }
.lenses button[aria-pressed="true"] { color: var(--ink); border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
:is(.lenses, .zoom, .pc-actions) button:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.when { display: flex; align-items: center; gap: 12px; }
.when input { inline-size: min(14rem, 40vw); accent-color: var(--teal); }
.when output { font: italic 600 1.5rem/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; min-inline-size: 3.2ch; }

.zoom { position: fixed; z-index: 6; inset: auto 16px max(16px, env(safe-area-inset-bottom)) auto; display: flex; gap: 8px; }
.zoom button { display: inline-grid; place-items: center; min-inline-size: 40px; }
.zoom button[hidden] { display: none; }
.zoom svg { inline-size: 18px; block-size: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* The card's own actions, and the path between two people */
.pc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pc-actions button[data-act="share"] { background: var(--teal); border-color: var(--teal); color: #0C120F; }
.pc-actions button[data-act="share"]:hover { color: #0C120F; filter: brightness(1.08); }
.pc-actions button:disabled { opacity: .6; cursor: progress; }
.pc-connect { margin-top: 14px; }
.pc-connect input { inline-size: 100%; min-block-size: 40px; padding: 0 14px; border: 1px solid var(--hair); border-radius: 99px; background: rgb(12 18 15 / .9); color: var(--ink); font: 400 .9375rem var(--display); }
.pc-connect input:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.pc-path { display: grid; gap: 6px; margin: 14px 0 0; padding: 0 0 0 14px; list-style: none; border-left: 1px solid color-mix(in srgb, var(--cc, var(--teal)) 45%, var(--hair)); }
.pc-path li { font-size: .9375rem; line-height: 1.4; color: var(--ink-2); }

@media (max-width: 40em) {
  .tree-tools { inset: auto 16px max(16px, env(safe-area-inset-bottom)) 16px; }
  .lenses { flex-wrap: nowrap; gap: 6px; }
  .lenses button { padding: 0 11px; font-size: .75rem; }
  .when { flex: 1 1 100%; }
  .when input { flex: 1; inline-size: auto; }
  .zoom { inset-block-end: calc(max(16px, env(safe-area-inset-bottom)) + 136px); }
  .tree-stage { padding-bottom: 150px; }
  /* With a card open the controls step back, so the card can take the bottom of the screen with its buttons in reach */
  body:has(.pcard:not([hidden])) :is(.tree-tools, .zoom) { display: none; }
  .pcard { max-block-size: 60svh; }
}

.lenses button { display: inline-flex; align-items: center; gap: 7px; }
.lenses svg { inline-size: 16px; block-size: 16px; overflow: visible; }
.lenses .mark { stroke: none; }
@media (max-width: 40em) {
  .lenses { overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
  .lenses button { flex: none; }
}
.tree-stage .rings .dot { r: 7.5; fill-opacity: 1; }
.tree-stage .rings .ring { stroke-opacity: .5; }
.tree-stage .rings.focusing .dot { fill-opacity: .18; }
.tree-stage .rings.focusing .dot.lit { fill-opacity: 1; }

@media (min-width: 64em) {
  .pcard { inset: 50% auto auto 16px; translate: 0 -50%; max-block-size: calc(100dvh - 190px); }
}
/* The key takes its own row above the buttons, and the row stops short of the zoom buttons on the right */
.tree-tools { inset-inline-end: 180px; }
.tree-tools .line-key { position: static; inset: auto; order: -1; flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; border: 0; background: none; }
.tree-tools .line-key li { white-space: nowrap; }
@media (max-width: 40em) { .tree-tools { inset-inline-end: 16px; } }
.tree-bar .about-open { position: static; }

/* A phone's header takes three rows (about 154px) and its tools and zoom buttons about 190px at the bottom. The rings
   size to the space between and sit centred in it; with a card docked along the bottom they move up above it */
@media (max-width: 40em) {
  .tree-stage { padding: calc(max(14px, env(safe-area-inset-top)) + 160px) 12px 200px; place-items: center; }
  .tree-stage .rings { inline-size: min(100%, calc(100svh - max(14px, env(safe-area-inset-top)) - 360px)); }
  body:has(.pcard:not([hidden])) .tree-stage { place-items: start center; }
  /* The group buttons scroll sideways; the fade at the edge shows there is more past it */
  .lenses { mask-image: linear-gradient(to right, #000 calc(100% - 72px), transparent); }
}
/* The tools take about 170px on a tablet in portrait, where the group buttons wrap, and about 110px on a wider screen;
   the rings stop above them */
@media (min-width: 40.01em) and (max-width: 63.99em) {
  .tree-stage { padding-bottom: 190px; }
  .tree-stage .rings { inline-size: min(100%, calc(100svh - 262px)); }
}
@media (min-width: 64em) {
  .tree-stage { padding-bottom: 130px; }
  .tree-stage .rings { inline-size: min(100%, calc(100svh - 202px)); }
}
/* A phone on its side is too short to stack the rings over the tools, so the tools take a column on the left */
@media (orientation: landscape) and (max-height: 30em) {
  .tree-stage { padding: calc(max(12px, env(safe-area-inset-top)) + 52px) 16px 12px 336px; place-items: center; }
  .tree-stage .rings { inline-size: min(100%, calc(100svh - 76px)); }
  .tree-tools { inset: auto auto max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); inline-size: 304px; }
  .zoom { inset-block-end: max(12px, env(safe-area-inset-bottom)); }
}
