/* Infinite Script UI — the components every Infinite Script site builds its
   pages from: panels, buttons, the segmented control, inputs, chips, badges
   and floating tips. Page layout stays in each site's own stylesheet.

   Source of truth: infinite-services/src/assets/ui.css. Infinite Servers,
   Infinite Gateway and Infinite Visitors keep verbatim copies; edit this one
   and run scripts/sync-shared-css.sh (--check to only compare). Needs
   theme.css. Load it after theme.css and site-chrome.css and before the
   site's own stylesheet, which may extend these (never redefine them).

   Shapes carry meaning: what you act on (buttons, inputs, segmented controls)
   is a rounded rectangle, --r-control, or --r-small inside a group; what
   labels or filters (badges, chips) is a pill. Panels take --r. */

/* ---------- Focus ---------- */
:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Panel ---------- */
/* A surface of the page: a section, a card. .panel-pad for the standard
   padding; a site sets its own where a panel's content needs other. */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.panel-pad {
  padding: 22px 24px;
}

/* ---------- Buttons ---------- */
/* .btn is the everyday button; .btn-primary the one main action of a view;
   .btn-sm the compact size for tables and toolbars. Works on <a> too. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-control);
  background: var(--glass-control);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 0.16s,
    background 0.16s,
    border-color 0.16s,
    filter 0.16s;
}
.btn:hover:not(:disabled, [aria-disabled="true"]) {
  background: var(--surface-2);
}
.btn:is(:disabled, [aria-disabled="true"]) {
  opacity: 0.55;
  cursor: default;
}
.btn-primary {
  border-color: transparent;
  background: var(--accent-fill);
  color: #fff;
}
.btn-primary:hover:not(:disabled, [aria-disabled="true"]) {
  background: var(--accent-fill);
  filter: brightness(1.1);
}
.btn-sm {
  padding: 6px 12px;
  border-radius: var(--r-small);
  font-size: 12.5px;
}

/* A square button holding one 17px icon, the height of the header's
   controls. Give it an aria-label. */
.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  background: var(--glass-control);
  color: var(--dim);
  cursor: pointer;
  transition:
    color 0.18s,
    border-color 0.18s,
    background 0.18s;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-2);
  background: var(--surface-2);
}

/* ---------- Segmented control ---------- */
/* One choice out of a few, shown side by side: buttons in an inset well, the
   chosen one raised (.on or aria-pressed="true"). With more options than the
   row has room for, it scrolls under its own edge instead of widening the
   page. */
.seg {
  display: flex;
  gap: 3px;
  max-width: 100%;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--inset);
}
.seg::-webkit-scrollbar {
  display: none;
}
.seg button {
  flex: none;
  padding: 6px 11px;
  border: 0;
  border-radius: var(--r-small);
  background: transparent;
  color: var(--dim);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 0.16s,
    background 0.16s;
}
.seg button:hover {
  color: var(--text);
}
/* The well scrolls, so it clips: the ring goes inside the button. */
.seg button:focus-visible {
  outline-offset: -2px;
}
.seg button:is(.on, [aria-pressed="true"]) {
  background: var(--surface);
  color: var(--text);
  box-shadow:
    0 0 0 1px var(--border-2),
    var(--shadow-sm);
}

/* ---------- Inputs ---------- */
/* Text fields and selects. A <select class="input"> gets a chevron. */
.input {
  appearance: none;
  width: 100%;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  background: var(--inset);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  transition:
    border-color 0.16s,
    box-shadow 0.16s;
}
.input::placeholder {
  color: var(--faint);
}
.input:focus {
  border-color: color-mix(in oklch, var(--accent), transparent 45%);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent), transparent 86%);
}
select.input {
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position:
    right 17px center,
    right 12px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* ---------- Chips and badges (pills) ---------- */
/* A chip filters: a toggle, selected with .on or aria-pressed="true". */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--dim);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 0.16s,
    border-color 0.16s,
    background 0.16s;
}
.chip:hover {
  color: var(--text);
  border-color: var(--border-2);
}
.chip:is(.on, [aria-pressed="true"]) {
  border-color: transparent;
  background: var(--accent-fill);
  color: #fff;
}

/* A badge labels: a count, a role, a tag. .badge-accent for the red one. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--track);
  color: var(--dim);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-accent {
  border-color: color-mix(in oklch, var(--accent), transparent 78%);
  background: color-mix(in oklch, var(--accent), transparent 90%);
  color: var(--accent-text);
}

/* ---------- Floating tip ---------- */
/* Glass that floats over content: chart tooltips, hover details. Position it
   in the site's stylesheet; .tip-at keeps a tip over a point inside its box:
   set --at to the point's position across the box (0 to 1) and the tip puts
   the same fraction of its own width there, centred mid-way and flush with
   the box at either end. */
.tip {
  padding: 8px 11px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: var(--glass-float);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-float);
  pointer-events: none;
}
.tip-at {
  position: absolute;
  left: calc(var(--at) * 100%);
  transform: translateX(calc(var(--at) * -100%));
  max-width: 100%;
}

/* ---------- Error page ---------- */
/* What a site shows where there is no page: the code, an icon, a heading, a
   line and the way back, on one panel centred in the space between the header
   and the footer. The same in an app's own not-found view and in the static
   404.html and 50x.html the servers send (scripts/error-pages.mjs):

     <main class="error-page">
       <section class="panel error-card">
         <p class="error-code">404</p>
         <div class="error-glyph"><svg aria-hidden="true">…</svg></div>
         <h1>Page not found</h1>
         <p>…</p>
         <div class="error-actions"><a class="btn btn-primary">…</a></div>
       </section>
     </main> */
.error-page {
  flex: 1 0 auto;
  display: grid;
  place-items: center;
  padding: clamp(40px, 8vh, 80px) var(--page-gutter);
}
.error-card {
  width: 100%;
  max-width: 560px;
  padding: clamp(36px, 5vw, 52px);
  text-align: center;
}
.error-card .error-code {
  margin: 0 0 18px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  /* The tracking trails the last letter too: indent as much, so the code
     centres. */
  text-indent: 0.18em;
  color: var(--accent-text);
}
.error-glyph {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 0 auto 22px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--accent);
}
.error-glyph svg {
  width: 56px;
  height: 56px;
}
.error-card h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 3.4vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.error-card p {
  max-width: 420px;
  margin: 0 auto 26px;
  color: var(--dim);
  font-size: 15px;
  line-height: 1.6;
  text-wrap: pretty;
}
.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* ---------- Touch and narrow screens ---------- */
/* At under 16px, phones zoom the page into a field when it takes focus. */
@media (pointer: coarse) {
  .input {
    font-size: 16px;
  }
}
@media (max-width: 720px) {
  .panel-pad {
    padding: 18px 16px;
  }
}
