/*
 * The places tree: a control room for the place data. Every rule sits under
 * .v-places, so no other screen changes. Every colour is a house token or
 * mixed from one, so each palette carries through; the meanings are fixed:
 * accent is usage, amber is drift, green is clean; the level tags wear four
 * inks of their own, the settlement's a deeper green than clean's. The
 * faces are the house's, from application.css.
 */

/* The page: a tighter line for density. */
.v-places { line-height: 1.5; }

/* The drift ledger: one line per check, its count amber where it found
   something and green where it is clean, each line a way into the report. */
.v-places .p-ledger { inline-size: 62rem; max-inline-size: 100%; margin-block: 1.5rem; padding: 1rem 1.25rem; }
.v-places .p-ledger h2 { margin: 0 0 .5rem; font-size: 1.1875rem; }
.v-places .p-ledger ul {
  display: grid; grid-template-rows: repeat(3, auto); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); column-gap: 3rem;
  margin: 0; padding: 0; list-style: none;
}
.v-places .p-ledger h2 a { color: var(--v-accent); }
.v-places .p-ledger li a { display: flex; align-items: baseline; gap: .75rem; padding-block: .3rem; color: var(--v-ink); text-decoration: none; }
.v-places .p-ledger a:hover span:last-child { text-decoration: underline; }
.v-places .p-ledger-count { min-inline-size: 3.5ch; font-size: 1.125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.v-places [data-state="drift"] .p-ledger-count { color: var(--v-warn); }
.v-places [data-state="clean"] .p-ledger-count { color: var(--v-ok); }

/* The tree, as wide as the ledger: room for the names, yet each count close
   enough to read with its name. Each level indents from the start under a
   guide line, so every row's end edge is the same: the counts sit there in
   four fixed columns under one header row, which stays in view down the whole
   tree. A faint line under each row keeps its counts with it. */
.v-places .v-tree { inline-size: 62rem; max-inline-size: 100%; padding: 0 .75rem .5rem; }
.v-places .v-tree ul { margin: 0; padding: 0; list-style: none; }
.v-places .v-tree ul ul { margin-inline-start: .5rem; padding-inline-start: 1.25rem; border-inline-start: 1px solid var(--v-divider); }
.v-places .v-tree summary,
.v-places .v-tree-leaf,
.v-places .v-tree-head { display: flex; align-items: center; gap: .5rem; padding: .6rem .5rem; }
.v-places [data-level]:not([data-level="district"]) > details > summary,
.v-places .v-tree-leaf { border-block-end: 1px solid var(--v-divider); }
.v-places [data-level="district"] > details > summary { border-radius: var(--v-radius-small); }
.v-places .v-tree summary { list-style: none; cursor: pointer; }
.v-places .v-tree summary::-webkit-details-marker { display: none; }
.v-places .v-tree-leaf { padding-inline-start: 2rem; }
.v-places .v-tree-head {
  position: sticky; inset-block-start: 0; z-index: 1;
  margin-inline: -.75rem; margin-block-end: .25rem; padding: .75rem 1.25rem;
  background: var(--v-panel); border-block-end: 1px solid var(--v-divider);
  border-radius: var(--v-radius) var(--v-radius) 0 0;
}
.v-places .v-tree-head .v-tree-counts { color: var(--v-ink-muted); font-size: .8125rem; font-weight: 500; }
.v-places .p-tools { flex: 1; display: flex; gap: .5rem; }
.v-places .p-tools .v-btn { padding: .2rem .8rem; font-size: .875rem; }
/* The tray under the pointer carries the eye from a name across to its counts. */
.v-places [data-level] > details > summary:hover,
.v-places .v-tree-leaf:hover { background: var(--v-hover); }
.v-places .v-tree-name { flex: 1; min-inline-size: 0; margin-inline-end: 2rem; }
/* The tags beside a name, each saying its meaning in words: the level's word
   on every row, in its level's colour; amber where the report finds the place
   or something folded under it; grey where nothing uses it. */
.v-places .p-level,
.v-places .p-problem,
.v-places .p-inside,
.v-places .p-unused {
  margin-inline-start: .4rem; padding: .05rem .5rem; vertical-align: .1em;
  font-size: .75rem; font-weight: 500; white-space: nowrap;
  border-radius: 999px;
}
/* Each tag is a solid fill of its own hue, set wide apart so none is taken
   for another; only the unused tag is grey. */
.v-places .p-problem,
.v-places .p-inside {
  color: var(--v-tag-on-problem); background: var(--v-tag-problem);
}
.v-places .p-unused {
  color: var(--v-tag-on); background: var(--v-tag-unused);
}
/* Open, the branch shows its problems row by row, so the count steps aside. */
.v-places [data-level]:has(> details[open]) > .v-tree-name .p-inside { display: none; }
.v-places [data-tag="district"] {
  color: var(--v-tag-on); background: var(--v-tag-district);
}
.v-places [data-tag="subdistrict"] {
  color: var(--v-tag-on); background: var(--v-tag-subdistrict);
}
.v-places [data-tag="settlement"] {
  color: var(--v-tag-on); background: var(--v-tag-settlement);
}
.v-places [data-tag="neighborhood"] {
  color: var(--v-tag-on); background: var(--v-tag-neighborhood);
}
/* The lines under the headers that say what a dash, a zero and a tag's colour
   mean; the legend's level words wear their tags. */
.v-places .p-legend { margin: 0 0 .25rem; padding-inline: .5rem; color: var(--v-ink-muted); font-size: .8125rem; text-align: end; }
.v-places .p-legend [data-tag] { padding: 0 .45rem; font-weight: 500; border-radius: 999px; }

/* A count; a zero is muted, and a count the level does not keep is a muted dash. */
.v-places .v-tree-counts { display: grid; grid-template-columns: repeat(4, 8rem); flex: none; font-size: .9375rem; font-variant-numeric: tabular-nums; }
.v-places .v-tree-zero,
.v-places .v-tree-blank { color: var(--v-ink-muted); }

/* A closed branch's chevron points along the line, an open one down. */
.v-places .v-tree .v-chevron { transition: none; }
.v-places .v-tree details:not([open]) > summary .v-chevron { transform: rotate(90deg); }
.v-places .v-tree details:not([open]) > summary .v-chevron:dir(ltr) { transform: rotate(-90deg); }

/* Each level reads as its level, by weight and size: the district strongest
   on a band, the neighborhood quietest. */
.v-places [data-level="district"] > details > summary,
.v-places [data-level="district"] > .v-tree-name { font-size: 1.1875rem; font-weight: 600; }
.v-places [data-level="district"] > details > summary { background: var(--v-raised); }
.v-places [data-level="district"] + [data-level="district"] { margin-block-start: .5rem; }
.v-places [data-level="subdistrict"] > details > summary,
.v-places [data-level="subdistrict"] > .v-tree-name,
.v-places [data-level="subdistrict"] > .v-tree-leaf { font-size: 1.0625rem; font-weight: 500; }
.v-places [data-level="settlement"] > details > summary,
.v-places [data-level="settlement"] > .v-tree-name,
.v-places [data-level="settlement"] > .v-tree-leaf { font-size: 1rem; }
.v-places [data-level="neighborhood"] .v-tree-name { color: var(--v-ink-muted); font-size: .9375rem; }

/* The orphan groups are a problem to look at, not a district: apart, in the
   caution ink on the panel, a hairline caution edge round them (#461). */
.v-places .v-tree-orphans { margin-block-start: 1.5rem; }
.v-places .v-tree-orphans > details > summary {
  font-weight: 600; color: var(--v-warn);
  border: 1px solid var(--ic-caution, var(--v-warn)); border-radius: var(--v-radius-small);
}

/* A branch eases its height open and shut, where the browser can. */
.v-places .v-tree { interpolate-size: allow-keywords; }
.v-places .v-tree details::details-content { block-size: 0; overflow: hidden; transition: block-size .15s ease, content-visibility .15s allow-discrete; }
.v-places .v-tree details[open]::details-content { block-size: auto; }

@media (prefers-reduced-motion: reduce) {
  .v-places .v-tree details::details-content { transition: none; }
}

/* A row's one press is its name, to its edit screen, in the row's own ink.
   A branch's row is a grid of chevron, name and counts over its folded rows:
   the details spans both rows, its summary keeps the name's column empty,
   and the name, its sibling, sits in that column on top, so the rest of the
   row still folds and the name never does. */
.v-places .v-tree-name a { color: inherit; text-decoration: none; }
.v-places .v-tree-name a:hover { text-decoration: underline; }
.v-places [data-level]:has(> details) {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: .5rem;
}
.v-places [data-level] > details { grid-area: 1 / 1 / 3 / -1; display: grid; grid-template-columns: subgrid; grid-template-rows: subgrid; }
.v-places [data-level] > details > summary { grid-area: 1 / 1 / 2 / -1; display: grid; grid-template-columns: subgrid; }
.v-places [data-level] > details::details-content,
.v-places [data-level] > details > ul { grid-area: 2 / 1 / 3 / -1; }
.v-places [data-level] > details > summary > .v-tree-counts { grid-column: 3; }
.v-places [data-level] > .v-tree-name { position: relative; z-index: 1; grid-area: 1 / 2; align-self: center; }
.v-places [data-level]:has(> .v-tree-name:hover) > details > summary { background: var(--v-hover); }

/* The name search above the header, its count of places found beside it.
   A row the search leaves out is gone, though the tree's grid would show it. */
.v-places .p-find { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem 1rem; padding: 1rem .5rem .5rem; }
.v-places .p-find .v-field { flex: 0 1 24rem; min-inline-size: 0; }
.v-places .p-found { margin: 0; padding-block-end: .7rem; color: var(--v-ink-muted); font-size: .9375rem; }
.v-places .v-tree li[hidden] { display: none; }
/* While a search writes the tree, branches open at once, not eased one by
   one; a settlement or neighborhood off the screen is not laid out until it
   scrolls near. */
.v-places .v-tree.is-finding details::details-content { transition: none; }
.v-places [data-level="settlement"] { content-visibility: auto; contain-intrinsic-size: auto 2.75rem; }
.v-places [data-level="neighborhood"] { content-visibility: auto; contain-intrinsic-size: auto 2.5rem; }
/* content-visibility clips what a row draws outside it, so a fold button's ring sits inside. */
.v-places [data-level] > details > summary:focus-visible { outline-offset: -2px; }

/* The box's clear button, at its end inside it, shown while it holds text:
   a 32px round press, muted at rest, in ink on a tray when pointed at or
   focused. The browser's own is hidden, so every browser shows this one. */
.v-places .p-search-box { position: relative; }
.v-places .p-search-box .v-input { padding-inline-end: 2.75rem; }
.v-places .p-search-box .v-input::-webkit-search-cancel-button { appearance: none; display: none; }
.v-places .p-clear {
  position: absolute; inset-block-start: 50%; inset-inline-end: .25rem; translate: 0 -50%;
  display: grid; place-items: center; inline-size: 2rem; block-size: 2rem; min-block-size: 0; padding: 0;
  color: var(--v-ink-muted); background: transparent; border: 0; border-radius: 50%; cursor: pointer;
  transition: opacity .15s ease, visibility .15s, background-color .15s ease, color .15s ease;
}
.v-places .p-clear .v-icon { inline-size: 1.125rem; block-size: 1.125rem; }
/* A .v-btn, round and borderless in the box: the press's own hover step and ink ring. */
.v-places .p-clear:hover,
.v-places .p-clear:focus-visible { color: var(--v-ink); background: var(--v-hover); }
.v-places .p-clear:focus-visible { outline-offset: 1px; }
.v-places .v-input:placeholder-shown + .p-clear { opacity: 0; visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
  .v-places .p-clear { transition: none; }
}

/* The data's source, named at the foot of the tree, small and quiet. */
.v-places .p-source { margin-block: 1rem 0; font-size: .8125rem; }

/* The add and edit forms, the move's confirm and the delete: one column,
   each error under its field. */
.v-places .p-form,
.v-places .p-delete { max-inline-size: 32rem; margin-block: 1.5rem; }
.v-places .p-field { display: grid; gap: .25rem; }
.v-places .p-error { margin: 0; color: var(--v-danger); font-size: .875rem; }
.v-places .p-delete h2 { font-size: 1.1875rem; }
.v-places .p-confirm { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: 1.5rem 0; }

/* A row brought into view, by Tab or Shift+Tab or a link, lands below the
   sticky header, not under it. */
.v-places .v-tree summary,
.v-places .v-tree-leaf { scroll-margin-block-start: 4.5rem; }

/* On a phone the rows scroll sideways inside a box of their own, never the
   page, and the header sits outside that box so it keeps sticking; it wraps
   its buttons above the column names to fit. The box is positioned so the
   screen reader's hidden words stay inside it. */
@media (max-width: 40rem) {
  .v-places .v-tree { min-inline-size: 0; }
  .v-places .v-tree-head { flex-wrap: wrap; justify-content: flex-end; }
  .v-places .v-tree summary,
  .v-places .v-tree-leaf { scroll-margin-block-start: 8rem; }
  .v-places .p-tree-scroll { position: relative; overflow-x: auto; }
  .v-places .p-tree-scroll > * { inline-size: max-content; min-inline-size: 100%; }
  .v-places .v-tree-name { white-space: nowrap; margin-inline-end: 1rem; }
  .v-places .v-tree-counts { grid-template-columns: repeat(4, 4.5rem); }
  .v-places .p-ledger ul { grid-template-rows: none; grid-auto-flow: row; grid-auto-columns: minmax(0, 1fr); }
}
