/*
 * controls.css: every button, link and form field, on every page that has any (they all load it).
 *
 * One family (2026-11-14, the owner: "Apple level ... clean and cohesive"; docs/DESIGN.md "Controls"):
 *   .control                  a quiet button: text on nothing, a soft wash under the pointer (toolbars, filter chips)
 *   .control--solid           a secondary button: a soft tint (--fill) in a panel or a card, a floating pill on the map
 *   .control--flag            the one primary button of a screen: filled pink (--accent)
 *   .control--warn            a button that deletes or ends something: red text
 *   .text-button              a small action in a sentence or at the end of a row ("Edit", "Show all", "Sign out");
 *                             older names that mean the same are listed with it below, so they all look alike
 *   .segmented                a few buttons where one is chosen (EN / RO, Model / Satellite / Plan): a tinted track
 *                             and a white thumb, like iOS
 *   round buttons             the compass, Recenter, 3D / 2D, back to the top, "+"
 * A button is "on" when it has aria-pressed="true" (the script sets it, so the look and the accessibility state agree).
 *
 * Links are ink, never the browser's blue: a soft wash under the pointer says they can be pressed, and inside a
 * sentence a faint line under them says it before the pointer gets there.
 *
 * The first block gives the bare elements (a, button, input, select, textarea) their look at zero specificity
 * (:where), so a page's own classes always win and nothing is ever left looking like the browser's default.
 */

/* ------------------------------------------------------------------ The bare elements */

:root { accent-color: var(--accent); } /* tick boxes, radio buttons and sliders */

:where(button) {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
:where(button:disabled) { cursor: not-allowed; }

:where(a) {
  color: inherit;
  text-decoration: none;
  border-radius: 0.3em;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), text-decoration-color var(--duration) var(--ease);
}
:where(a[href]:hover) { background-color: var(--hover); }
/* Inside a sentence a link keeps a faint line under it, so it can be found without the pointer. */
:where(p, dd, td, blockquote, figcaption, .fine-print, .legal__body li, .report li) > :where(a:not([class])) {
  text-decoration: underline;
  text-decoration-color: var(--link-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
:where(p, dd, td, blockquote, figcaption, .fine-print, .legal__body li, .report li) > :where(a:not([class])):hover { text-decoration-color: currentColor; }

/* Text boxes and selects: one height, one border, one focus ring. */
:where(input:not([type="checkbox"], [type="radio"], [type="color"], [type="range"], [type="file"], [type="hidden"],
  [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea) {
  box-sizing: border-box;
  min-height: var(--field-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background-color: var(--sheet-raised);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
:where(textarea) { padding: var(--space-2) var(--space-3); line-height: var(--leading-body); resize: vertical; }
:where(input, select, textarea)::placeholder { color: var(--ink-muted); opacity: 0.75; }
:where(input:not([type="checkbox"], [type="radio"], [type="color"], [type="range"], [type="file"]), select, textarea):focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--press);
}
:where(input, select, textarea):disabled { opacity: 0.55; cursor: not-allowed; }
/* A select draws our chevrons, the same on every browser (macOS's "up and down" one). Two :not()s so it wins over a
   page's "background: ..." on its select, which would otherwise take the chevrons away. */
select:not([multiple]):not([size]) {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2rem;
  background-image: var(--chevron-select);
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.625rem 0.875rem;
  cursor: pointer;
}
:where(input[type="checkbox"], input[type="radio"]) { width: 1rem; height: 1rem; margin: 0; flex: none; cursor: pointer; }
:where(label:has(> input[type="checkbox"], > input[type="radio"])) { cursor: pointer; }

/* A form's button stands a little apart from the last field above it (a page's own margin wins). */
:where(form) > :where(.control, .group-actions) { margin-top: var(--space-4); }

/* A fold's plain title ("Enter a plot by hand", "Security"): the app's chevron after it, not the browser's triangle. */
:where(summary:not([class])) {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: fit-content;
  max-width: 100%;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  border-radius: 0.35em;
  transition: background-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
:where(summary:not([class]))::-webkit-details-marker { display: none; }
:where(summary:not([class]))::after {
  content: "";
  flex: none;
  width: 0.4rem;
  height: 0.4rem;
  margin-top: -0.15rem;
  border-right: 1.6px solid var(--ink-muted);
  border-bottom: 1.6px solid var(--ink-muted);
  transform: rotate(45deg);
  transition: transform var(--duration) var(--ease);
}
:where(details[open]) > :where(summary:not([class]))::after { margin-top: 0.15rem; transform: rotate(-135deg); }
:where(summary:not([class])):hover { background-color: var(--hover); box-shadow: 0 0 0 0.25em var(--hover); }

/* ------------------------------------------------------------------ Buttons */

.control {
  display: inline-flex;          /* also makes <a class="control"> line up exactly like a <button> */
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  max-width: 100%;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.control:hover { background: var(--hover); }
.control:active { background: var(--press); }
.control[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
.control:disabled, .control[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.control:disabled:hover { background: transparent; }

/* Secondary: a soft tint in a panel or a card. No border, no shadow (those are for things floating on the map). */
.control--solid {
  padding: 0 var(--space-4);
  background: var(--fill);
}
.control--solid:hover { background: var(--fill-hover); }
.control--solid:active { background: var(--press); }
.control--solid:disabled:hover { background: var(--fill); }
.control--solid[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }

/* The one primary button of a screen ("Generate presentation", "Send"): filled pink. */
.control--flag, .control--flag:active { background: var(--accent); color: var(--accent-text); }
.control--flag:hover { background: var(--accent-hover); }
.control--flag:disabled:hover { background: var(--accent); }

/* Deletes or ends something: red words; asking "Sure?" it gets a red tint. */
.control--warn { color: var(--warn); }
.control--warn[data-confirming] { background: color-mix(in srgb, var(--warn) 12%, transparent); }

/* On the map the secondary buttons float: a light pill with a shadow (frosted where the page has class="glass"). */
.toolbar .control--solid,
.toolbar .layers-menu > summary {
  background: var(--sheet);
  box-shadow: var(--shadow-control);
}
.toolbar .control--solid:hover { background: var(--sheet-sunk); }
.toolbar .control--solid[aria-pressed="true"],
.glass .toolbar .layers-menu[open] > summary { background: var(--ink); color: var(--sheet); }

/* Text buttons: a small action in a sentence or at the end of a row. Muted words, a soft wash under the pointer,
   the same everywhere. The older class names below mean the same thing: new markup uses .text-button. */
.text-button,
.legend__edit,
.legend__delete,
.advice__refresh,
.sheet__sign-out,
.link-button,
.group-picker__all,
.finder-link {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0.35em;
  background: none;
  color: var(--ink-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: inherit;
  text-align: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), color var(--duration) var(--ease);
}
/* The wash reaches a little past the words (a shadow, so nothing moves). */
:is(.text-button, .legend__edit, .legend__delete, .advice__refresh, .sheet__sign-out, .link-button, .group-picker__all, .finder-link):hover,
:where(a:not([class]), .plot-owners__name, .client-plots__name, .legend__name--link):hover {
  background-color: var(--hover);
  box-shadow: 0 0 0 0.25em var(--hover);
  color: var(--ink);
}
:is(.text-button, .legend__edit, .legend__delete, .advice__refresh, .sheet__sign-out, .link-button, .group-picker__all, .finder-link):active {
  background-color: var(--press);
  box-shadow: 0 0 0 0.25em var(--press);
}
:is(.text-button, .legend__edit, .legend__delete, .advice__refresh, .sheet__sign-out, .link-button, .group-picker__all, .finder-link):disabled { opacity: 0.45; cursor: not-allowed; }
/* A text button that deletes or removes: red under the pointer, and while it asks "Sure?". */
:is(.text-button--warn, .legend__delete, .legend__edit.group-actions__delete):is(:hover, [data-confirming]) {
  color: var(--warn);
  background-color: color-mix(in srgb, var(--warn) 10%, transparent);
  box-shadow: 0 0 0 0.25em color-mix(in srgb, var(--warn) 10%, transparent);
}

/* ------------------------------------------------------------------ Segmented (one of a few) */

.segmented {
  display: inline-flex;
  gap: 2px;
  max-width: 100%;
  padding: var(--inset-segmented);
  background: var(--fill);
  border: 0;
  border-radius: var(--radius-pill);
}
.segmented .control { border-radius: var(--radius-pill); min-height: calc(var(--control-height) - 2 * var(--inset-segmented)); }
.segmented .control:hover { background: var(--hover); }
.segmented .control:is([aria-pressed="true"], [aria-selected="true"], [aria-checked="true"]) {
  background: var(--thumb);
  color: var(--ink);
  box-shadow: var(--shadow-thumb);
}
/* On the map the group floats like the buttons beside it. */
.toolbar .segmented { background: var(--sheet); box-shadow: var(--shadow-control); }
.toolbar .segmented .control:is([aria-pressed="true"], [aria-selected="true"], [aria-checked="true"]) { background: var(--ink); color: var(--sheet); box-shadow: none; }
/* A group that wraps onto several rows (a lot picker with many lots): round ends only as round as one row, else 44 lots
   made a circle (2026-11-10). On one row it looks the same as --radius-pill; the buttons' ends stay concentric. */
.segmented--wrap { flex-wrap: wrap; border-radius: calc(1.125rem + var(--inset-segmented)); }
.segmented--small .control { min-height: var(--control-height-sm); padding: 0 var(--space-2); font-size: var(--text-xs); }

/* Bigger touch targets on phones and tablets. */
@media (pointer: coarse) {
  .control { min-height: 2.75rem; }
  .segmented .control { min-height: calc(2.75rem - 2 * var(--inset-segmented)); }
  .segmented--small .control { min-height: 2.25rem; }
}

.toolbar {
  position: absolute;
  top: var(--edge);
  right: var(--edge);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  max-width: calc(100% - var(--sheet-width) - 3 * var(--edge));
}

/* On phones the panel is below the map, so the toolbar can use the full width. */
@media (max-width: 47.5rem) {
  .toolbar { left: var(--edge); max-width: none; justify-content: flex-start; }
}

/* ------------------------------------------------------------------ Round buttons: compass, back to the top */

.compass, .to-top, .dial-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow-control);
  cursor: pointer;
  transition: background var(--duration) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.compass:hover, .to-top:hover, .dial-button:hover { background: var(--sheet-sunk); }

/* The compass: bottom right of the map, clear of the credits. Its needle points north (the pink half) and turns
   with the map: src/map.js reports the heading, src/ui.js turnCompass sets --heading. */
.compass {
  position: absolute;
  right: var(--edge);
  bottom: calc(var(--edge) + 1.5rem);
  z-index: 1;
}
.compass__needle {
  width: 0.7rem;
  height: 1.75rem;
  background: linear-gradient(var(--flag) 50%, var(--ink-muted) 50%);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  transform: rotate(var(--heading, 0deg));
}
.app:not(.is-ready) .compass { visibility: hidden; }

/* Recenter (a pin), the 3D / 2D button and the compass, one above the other at the bottom right of the map. */
.map-dial {
  position: absolute;
  right: var(--edge);
  bottom: calc(var(--edge) + 1.5rem); /* clear of the credits */
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.map-dial .compass { position: static; }
/* A little larger than the other round buttons, easier to hit on a phone. */
.map-dial .compass, .map-dial .dial-button { width: 3.25rem; height: 3.25rem; }
.map-dial .compass__needle { width: 0.8rem; height: 2.05rem; }
.dial-button { font-size: var(--text-base); font-weight: 650; font-variant-numeric: tabular-nums; }
.dial-button__icon { width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }
.dial-button__icon circle { fill: var(--flag); stroke: none; }
.app:not(.is-ready) .map-dial { visibility: hidden; }

/* Back to the top: rides along the bottom of the panel's text once it is scrolled down (src/ui.js watchToTop). */
.to-top {
  position: sticky;
  bottom: var(--inset-sheet);
  z-index: 2;
  margin: var(--space-4) 0 0 auto;
  font-size: var(--text-base);
  font-weight: 650;
}
.to-top::before { content: "↑"; }

/* ------------------------------------------------------------------ Preview banner (unapproved plot) */

.preview-banner {
  position: absolute;
  top: var(--edge);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: var(--space-2) var(--space-4);
  background: var(--warn);
  color: var(--sheet);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-control);
  font-size: var(--text-sm);
  font-weight: 650;
  text-align: center;
  pointer-events: none;
}

/* ------------------------------------------------------------------ Loading and error messages */

.status {
  position: absolute;
  left: 50%;
  bottom: 3rem;
  transform: translateX(-50%);
  max-width: min(28rem, calc(100% - 2 * var(--edge)));
  padding: var(--space-2) var(--space-4);
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-control);
  font-size: var(--text-sm);
  font-weight: 550;
  text-align: center;
  pointer-events: none;
}

/* Errors need to be impossible to miss, so they move to the middle and get room to breathe. */
.status[data-kind="error"] {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-sheet);
  border-color: var(--warn);
  color: var(--warn);
  font-size: var(--text-base);
  pointer-events: auto;
}

/* "Layers" on /admin's toolbar: a button that opens a short list of ticks below it. */
.layers-menu { position: relative; display: flex; }
.layers-menu > summary { flex: 1; }
.layers-menu > summary { list-style: none; }
.layers-menu > summary::-webkit-details-marker { display: none; }
.layers-menu[open] > summary { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.layers-menu__list {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 2;
  display: grid;
  gap: var(--space-2);
  min-width: 14rem;
  padding: var(--space-3);
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius-sheet);
  box-shadow: var(--shadow-control);
  font-size: var(--text-sm);
}

/* An agency's "Share it on other sites" (account.html #share-kit, src/share-kit.js). */
.share-kit { display: grid; gap: var(--space-3); }
.share-kit__link { display: flex; gap: var(--space-2); }
.share-kit__link input { flex: 1; min-width: 0; font: inherit; }
.share-kit__qr { display: flex; gap: var(--space-3); align-items: center; }
.share-kit__qr canvas { width: 120px; height: 120px; flex: none; border-radius: var(--radius-small); }
