/* ------------------------------------------------------------------
   schneehage.dev — index page
   Built on the SnowDev design system (assets/ds-bundle.css).
   Tokens come from :root[data-snowdev-theme="dark"] in the bundle;
   nothing here redefines them.
   ------------------------------------------------------------------ */

:root {
  /* Page gutter used by every full-bleed row. */
  --gutter: clamp(20px, 4vw, 56px);
}

html, body { margin: 0; }
body { min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }

input { font-family: var(--font-mono); }

mark { background: color-mix(in oklab, var(--accent) 28%, transparent); color: inherit; }

*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Visually hidden but exposed to assistive tech. */
.vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ico { display: block; flex: none; }

.wrap { display: flex; flex-direction: column; min-height: 100vh; }

/* Standalone-page layout — used only by login/index.html to center its
   .gate card on an otherwise empty page (the other pages use .gate inside
   a fixed-position .overlay, layered over page content; this page has no
   content behind it to layer over). */
.standalone {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ── Section labels ────────────────────────────────────────────────── */

.section-label {
  margin: 0;
  padding: 34px var(--gutter) 12px;
  font: 400 10.5px/1 var(--font-mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.section-label--accent { padding-top: 26px; color: var(--accent); }

/* ── Card grids ────────────────────────────────────────────────────────
   The source design separates cells with `border-right`, which leaves no
   divider at all between stacked cells on narrow screens — fixed below by
   also drawing `border-bottom` on every item.

   An earlier version of this drew those dividers a different way: a 1px
   grid `gap` over a `--border`-colored container background, with each
   item painted `--bg` on top so only the gaps showed through. That reads
   as thin hairlines only when every row is completely full. The app list
   is no longer a fixed count (apps get added, and visibility toggles move
   them between grids), so a short trailing row is now routine — and CSS
   grid still paints the *whole* row's height across the container,
   occupied columns or not, so an incomplete row exposed a solid block of
   the container's --border color rather than a thin line. Per-item
   borders don't have that failure mode: there's nothing to paint where
   there's no item. */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  border-top: 1px solid var(--border);
}
.grid--public { border-bottom: 1px solid var(--border); }
.grid > * {
  background: var(--bg);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* ── App card ────────────────────────────────────────────────────────
   Not an <a> wrapping everything: the admin toggle below needs to be its
   own interactive control, and a <button> can't nest inside an <a>. This
   uses the "stretched link" pattern instead — .app-card__link is an
   absolutely-positioned link filling the card, the visible content sits
   on top of it with pointer-events:none so clicks fall through to the
   link, and the admin button opts back into pointer-events so it still
   gets its own clicks. */

.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 28px;
  min-height: 220px;
  color: var(--text);
  transition: background var(--dur-fast) var(--ease-out);
}
.app-card:hover { background: var(--surface-2); }

.app-card__link {
  position: absolute;
  inset: 0;
  z-index: 0;
}
/* Default focus-visible offset pushes outward from the element's own box;
   on a card-filling link that lands on the neighbouring card. Pull it back
   inside so the ring stays within this card. */
.app-card__link:focus-visible { outline-offset: -2px; }

.app-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.app-card__mono {
  display: grid;
  place-items: center;
  width: 72px; height: 72px;
  border-radius: var(--r-sharp);
  color: var(--on-gradient);
  font: 700 26px/1 var(--font-display);
  flex-shrink: 0;
}

/* An uploaded icon occupies the same tile as the monogram it replaces —
   same box, same radius, same gradient behind it. `contain` because an
   uploaded logo has whatever aspect ratio it has and cropping someone's
   mark is worse than letting the gradient show; the inset keeps it off
   the rounded corners. The gradient staying visible is also why the
   colour swatch remains useful for apps that have uploaded an icon.

   No inset: an uploaded icon fills the tile edge to edge, and the tile's
   own border-radius clips it to the same rounded square as a monogram.
   `contain` still means a non-square image is letterboxed onto the
   gradient rather than cropped — losing part of someone's logo is worse
   than showing a little colour beside it. Switch to `cover` if you would
   rather it always bleed to the edges and accept the crop. */
.app-card__mono--img,
.palette__mono--img {
  box-sizing: border-box;
  object-fit: contain;
  /* Overrides the `display: grid` above — an <img> is a replaced element
     and grid layout does nothing useful for its contents. */
  display: block;
}

.app-card__admin {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-sharp);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  pointer-events: auto;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.app-card__admin:hover { color: var(--text); border-color: var(--border); background: var(--bg); }
.app-card__admin[aria-expanded="true"] { color: var(--accent); border-color: var(--border); background: var(--bg); }

.app-card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.app-card__name {
  font: 700 30px/1 var(--font-display);
  text-transform: uppercase;
}
.app-card__host {
  font: 400 11.5px/1.3 var(--font-mono);
  color: var(--text-muted);
}

/* Tabular figures so a ticking label ("9MIN AGO" -> "10MIN AGO") does
   not nudge the chip beside it sideways as the digits change width. */
.ago { font-variant-numeric: tabular-nums; }

.app-card__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font: 400 11px/1 var(--font-mono);
  text-transform: uppercase;
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Per-app admin panel ───────────────────────────────────────────────
   Bleeds to the card's own edges via negative margin matching its
   28px padding, reading as a drawer rather than a nested box. */

.app-card__admin-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: -6px -28px -28px;
  padding: 22px 28px 26px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.app-card__admin-panel[hidden] { display: none; }

.admin-panel__section { display: flex; flex-direction: column; gap: 10px; }
.admin-panel__label {
  font: 400 10px/1 var(--font-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.admin-panel__icon-editor {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-panel__preview { width: 40px; height: 40px; font-size: 15px; }

.admin-panel__icon-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.admin-panel__icon-btn { font-size: 11px; }

/* Same treatment as .add-app__error — one failure style for the panel and
   the add-app form, so a rejected upload reads the same as a rejected
   subdomain. Empty until something goes wrong, and taking no space then. */
.admin-panel__error {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--c-blocked);
  border-radius: var(--r-sharp);
  background: color-mix(in oklab, var(--c-blocked) 14%, transparent);
  font: 400 12px/1.4 var(--font-mono);
  color: var(--text);
}
.admin-panel__error:empty { display: none; }

.admin-panel__mono-input {
  width: 56px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sharp);
  background: var(--surface);
  color: var(--text);
  font: 700 13px/1 var(--font-mono);
  text-align: center;
  text-transform: uppercase;
}

.admin-panel__swatches { display: flex; gap: 8px; }
.swatch {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--r-sharp);
  color: var(--on-gradient);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.swatch:hover { transform: translateY(-1px); }
.swatch[aria-pressed="true"] { border-color: var(--text); }

/* The status picker renders the actual chips, so the choice is made by
   looking at what the card will show rather than reading a list of
   words. .chip sets `cursor: default` for its display use — these are
   buttons, so that is undone here.

   Wraps rather than scrolling: five chips do not fit across a 300px card
   at the narrow end of the grid, and a second row is a better answer
   than a hidden one. */
.admin-panel__statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.status-opt {
  cursor: pointer;
  color: var(--text-muted);
  background: transparent;
}
.status-opt:hover { color: var(--text); }
/* The dot is the tone; the border is the selection. Keeping those two
   signals separate is what lets the unselected chips still show their
   own colour instead of all going grey. */
.status-opt[aria-pressed="true"] {
  border-color: var(--text);
  background: var(--surface-2);
  color: var(--text);
}

.admin-panel__segmented {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: var(--r-sharp);
  overflow: hidden;
}
.seg {
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: 600 11px/1 var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.seg + .seg { border-left: 1px solid var(--border); }
.seg:hover { color: var(--text); }
.seg[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }

/* Two-class selector, not .admin-panel__rows alone: needs to outweigh
   .rows's own margin further down the sheet regardless of source order. */
.app-card__admin-panel .rows { margin: 0; }

/* ── Remove app ────────────────────────────────────────────────────── */

/* Set apart from the editing controls above it by a rule, so the one
   irreversible action in the panel does not sit flush against the
   reversible ones. */
.admin-panel__section--danger {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.remove-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.remove-row__warn {
  font: 400 11px/1.4 var(--font-mono);
  text-transform: uppercase;
  color: var(--text);
  text-wrap: pretty;
}

.remove-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sharp);
  background: transparent;
  font: 600 11px/1 var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.remove-btn:hover { color: var(--c-blocked); border-color: var(--c-blocked); }

/* Only the confirming press is filled — the first click still reads as a
   neutral control, so the destructive colour appears exactly once, at the
   point where it is actually about to happen. */
.remove-btn--confirm {
  border-color: var(--c-blocked);
  background: var(--c-blocked);
  color: oklch(16% 0.006 320);
}
.remove-btn--confirm:hover {
  color: oklch(16% 0.006 320);
  filter: brightness(1.08);
}

/* ── Status chip (compact variant of the DS `.chip`) ───────────────── */

.chip--sm {
  gap: .45rem;
  padding: .3rem .7rem;
  font-size: .6875rem;
}
.chip--sm .dot { width: 7px; height: 7px; }

.chip[data-tone="progress"]   .dot { background: var(--c-progress); }
.chip[data-tone="todo"]       .dot { background: var(--c-todo); }
.chip[data-tone="review"]     .dot { background: var(--c-review); }
.chip[data-tone="blocked"]    .dot { background: var(--c-blocked); }
.chip[data-tone="done"]       .dot { background: var(--c-done); }
.chip[data-tone="notstarted"] .dot { background: var(--c-notstarted); }
.chip[data-tone="onhold"]     .dot { background: var(--c-onhold); }
.chip[data-tone="archived"]   .dot { background: var(--c-archived); }

/* ── System & server details ───────────────────────────────────────── */

.sys { border-top: 1px solid var(--border); }

.sys__toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px var(--gutter);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}
.sys__toggle:hover { color: var(--text); }

.sys__chev { display: flex; transition: transform var(--dur-fast) var(--ease-out); }
.sys__toggle[aria-expanded="true"] .sys__chev { transform: rotate(90deg); }

.sys__label,
.sys__state {
  font: 400 10.5px/1 var(--font-mono);
  text-transform: uppercase;
}
.sys__label { letter-spacing: .18em; }
.sys__rule { flex: 1; height: 1px; background: var(--border); }

/* Per-item borders, not the gap/container-background trick — see the note
   above .grid. Three fixed columns still hit the same failure mode: at a
   viewport wide enough for exactly 2 columns, the 3rd item wraps alone and
   leaves an empty trailing cell for the container background to fill. */
.sys__body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  border-top: 1px solid var(--border);
}
.sys__body[hidden] { display: none; }

.sys__col {
  padding: 24px var(--gutter) 28px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.sys__title {
  font: 400 10px/1 var(--font-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}

.rows {
  display: flex;
  flex-direction: column;
  margin: 14px 0 0;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font: 400 10.5px/1.4 var(--font-mono);
  text-transform: uppercase;
}
.row dt { color: var(--text-muted); }
.row dd { margin: 0; text-align: right; }

/* ── Footer ────────────────────────────────────────────────────────── */

.site-footer {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding: 18px var(--gutter) 40px;
  border-top: 1px solid var(--border);
  font: 400 10.5px/1.6 var(--font-mono);
  text-transform: uppercase;
  color: var(--text-muted);
}

.account { display: flex; align-items: center; gap: 10px; }

/* Save state, admin page footer. Empty until the first edit, so it takes
   up no room on a page nobody has changed yet. */
.save-status:empty { display: none; }
.save-status {
  font: 400 10.5px/1.6 var(--font-mono);
  text-transform: uppercase;
  color: var(--text-muted);
}
.save-status[data-tone="error"] { color: var(--c-blocked); }

/* Placeholder shown while the app list loads, replaced by the real
   content (or an error) once the request settles. */
.load-state {
  margin: 0;
  padding: 34px var(--gutter);
  font: 400 11px/1.5 var(--font-mono);
  text-transform: uppercase;
  color: var(--text-muted);
}
.load-state[hidden] { display: none; }
.load-state[data-tone="error"] { color: var(--c-blocked); }
/* Sign-out is a real form (POST /api/logout, not a JS handler) — display:
   contents keeps the <form> itself out of the flex layout so its button
   still sits inline with the other footer links. */
.account__form { display: contents; }

.linkbtn {
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font: 400 10.5px/1.6 var(--font-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.linkbtn:hover { color: var(--text); border-color: var(--text); }

/* ── Overlays ──────────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
}
.overlay[hidden] { display: none; }

.overlay--palette {
  z-index: 20;
  align-items: flex-start;
  padding: 12vh 20px;
  background: color-mix(in oklab, var(--bg) 72%, transparent);
}
.overlay--gate {
  z-index: 25;
  align-items: center;
  padding: 24px;
  background: color-mix(in oklab, var(--bg) 80%, transparent);
}

/* ── Command palette ───────────────────────────────────────────────── */

.palette {
  width: 100%;
  max-width: 600px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-sharp);
  background: var(--surface);
  box-shadow: var(--glow);
  overflow: hidden;
}

.palette__search {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.palette__icon { display: flex; color: var(--text-muted); }

.palette__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 400 15px/1 var(--font-body);
  outline: none;
}
.palette__input::placeholder { color: var(--text-muted); }

.palette__esc {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-sharp);
  background: transparent;
  font: 400 10px/1 var(--font-mono);
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
}
.palette__esc:hover { color: var(--text); border-color: var(--text-muted); }

.palette__results { overflow-y: auto; }

.palette__row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.palette__row:hover,
.palette__row[aria-selected="true"] {
  background: var(--surface-2);
  color: var(--text);
}
.palette__row[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--accent); }

.palette__mono {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--r-sharp);
  color: var(--on-gradient);
  font: 700 12px/1 var(--font-display);
}
.palette__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.palette__name { font: 600 14.5px/1 var(--font-body); }
.palette__host { font: 400 10.5px/1 var(--font-mono); color: var(--text-muted); }
.palette__tag  { font: 400 10px/1 var(--font-mono); text-transform: uppercase; color: var(--text-muted); }

.palette__empty {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  font: 400 10.5px/1 var(--font-mono);
  text-transform: uppercase;
  color: var(--text-muted);
}

.palette__foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  background: var(--bg);
  font: 400 10px/1 var(--font-mono);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Sign-in gate ──────────────────────────────────────────────────── */

.gate {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  padding: 36px 32px 30px;
  border: 1px solid var(--border);
  border-radius: var(--r-sharp);
  background: var(--surface);
  box-shadow: var(--glow);
  overflow-y: auto;
}

.gate__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.gate__eyebrow {
  font: 400 10.5px/1 var(--font-mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
}
.gate__close {
  display: flex;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.gate__close:hover { color: var(--text); }

.gate__title {
  margin: 14px 0 12px;
  font: 700 clamp(38px, 6vw, 52px)/.92 var(--font-display);
  letter-spacing: -.01em;
  text-transform: uppercase;
}
.gate__copy {
  margin: 0 0 24px;
  font: 400 13.5px/1.6 var(--font-body);
  color: var(--text-muted);
  text-wrap: pretty;
}

.gate__input {
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--r-sharp);
  background: var(--bg);
  font: 400 12.5px/1 var(--font-mono);
  color: var(--text);
}
.gate__input::placeholder { color: var(--text-muted); }

/* ── Add app ───────────────────────────────────────────────────────────
   .gate/.gate__* above started as the sign-in modal's styling; that modal
   is gone (Caddy basic_auth on /private/* replaced it — see README.md),
   but the shell and field styles are still exactly what this form needs,
   so add-app reuses them rather than duplicating a second modal look. */

/* The DS button is pill-shaped by default; this form uses the sharp
   radius shared by every other surface on this page. */
.add-app__form .btn { justify-content: center; border-radius: var(--r-sharp); }

.add-app__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 4px;
}

.add-app__host-row { display: flex; align-items: center; gap: 8px; }
.add-app__host-input { flex: 1; min-width: 0; }
.add-app__host-suffix {
  font: 400 12.5px/1 var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
}

.add-app__error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--c-blocked);
  border-radius: var(--r-sharp);
  background: color-mix(in oklab, var(--c-blocked) 14%, transparent);
  font: 400 12px/1.4 var(--font-mono);
  color: var(--text);
}

/* ── Narrow screens ────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .app-card { min-height: 0; }
  .gate { padding: 28px 22px 24px; }
  .overlay--palette { padding: 8vh 12px; }
}
