/* The mispache-ui base components: the shared structural styles.

   Reset, typography, the shell (body / container / main / footer), the topbar
   and its menus, the card, buttons, form inputs, toasts, and the modal/dialog.
   Colors are only ever the CSS custom properties declared in themes.css, never
   a literal. This is the canonical copy; each app vendors it and serves it
   itself, before its own app-specific stylesheet.

   Extracted from mispache-core's style.css; the app-specific rules stay there.
   A consuming app loads this before its own sheet, which may still carry a
   duplicate of these rules until it has finished migrating off them. */
* { box-sizing: border-box; }
/* The `hidden` attribute must always win — otherwise display rules on the
   same element (e.g. .btn's display:inline-block) would show hidden things. */
[hidden] { display: none !important; }

/* Harabara — the display face behind the logo (titles / large text). */
@font-face {
  font-family: "Harabara";
  src: url("fonts/Harabara.ttf") format("truetype");
  font-display: swap;
}
h1, h2, .hero-title { font-family: "Harabara", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* The footer sits at the foot of the window on every page, however short the
   content is: the body is a column and <main> takes up whatever height is left
   over, so its background panel reaches the footer instead of leaving a gap of
   bare page above it. `dvh` after `vh` so a mobile browser's disappearing
   toolbar cannot leave the footer floating mid-screen. */
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
}

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

/* width: 100% is load-bearing. <main> is a flex item of <body> (see below), and
   a flex item with `margin: 0 auto` is *not* stretched -- it is sized to fit its
   content and then centred. Without this, a page whose content is narrow (an
   empty admin queue, a profile) collapses to a sliver in the middle of the
   screen instead of filling the width the topbar and footer already use. */
.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }
/* flex: 1 1 auto — grow into whatever height the body has left, so the page's
   background panel runs all the way down to the footer (see `body` above). */
.main { flex: 1 1 auto; padding: 24px 16px 64px; background: var(--bg-soft); box-shadow: 0 0 500px 50px var(--border); }

/* ---- top bar ---- */
.topbar {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 56px; }
/* Logo — square tile, rounded top-left + bottom-right, palette-aware glyph.
   Filled with the accent, like .btn-primary: it is a link, and it should read
   as one. The glyph is --card rather than the white .btn-primary uses, because
   four of the eight palettes have a bright accent at night (spring-night is
   #63d98b), where white on the accent is nearly invisible -- 1.8:1 against
   --card's 8.5:1. Every theme is above 3:1 this way. */
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 11px 0 11px 0;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.22);
  color: var(--card);
  text-decoration: none;
}
.logo:hover { text-decoration: none; filter: brightness(1.15); }
.logo-mark {
  display: block; width: 24px; height: 24px;
  background: currentColor;
  -webkit-mask: url("logo.svg") center / contain no-repeat;
  mask: url("logo.svg") center / contain no-repeat;
}
.logo-lg { display: flex; width: 76px; height: 76px; border-radius: 22px 0 22px 0; margin: 0 auto 20px; }
.logo-lg .logo-mark { width: 52px; height: 52px; }
.topnav { display: flex; align-items: center; gap: 14px; font-size: 0.92rem; flex-wrap: wrap; }
.nav-user { color: var(--accent); font-weight: 600; }
.nav-badge {
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: 0.68rem; padding: 1px 6px; margin-left: 3px; vertical-align: top;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: transparent; border: none; color: var(--text); cursor: pointer;
  font-size: 1.25rem; line-height: 1; padding: 6px 8px; border-radius: 6px;
}
.icon-btn:hover { background: var(--card-2); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28); padding: 6px; z-index: 50;
  display: flex; flex-direction: column; gap: 2px;
}
.menu[hidden] { display: none; }
.menu-left { left: 0; right: auto; }
/* The top-right context menu opens inward, or it runs off the screen. */
.menu-right { left: auto; right: 0; }
.menu-item {
  display: block; width: 100%; padding: 8px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: 0.92rem; text-align: left;
  background: transparent; border: none;
}
.menu-item:hover { background: var(--card-2); text-decoration: none; }
.menu-item-btn { cursor: pointer; font: inherit; }
.menu-item-muted { color: var(--muted); }
.page-context { display: flex; align-items: center; gap: 8px; }
.handle { color: var(--text); font-weight: 600; }

/* ---- cards & layout ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-head { border-bottom: 1px solid var(--border); margin-bottom: 14px; padding-bottom: 10px; }

/* ---- buttons ---- */
.btn {
  display: inline-block; border: 1px solid var(--border); background: var(--card-2);
  color: var(--text); padding: 8px 16px; border-radius: 8px; cursor: pointer;
  font-size: 0.9rem; font-weight: 600; text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.15); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
/* The "go ahead, delete it" button, in the same red the error toasts use. Only
   ever worn by a control that destroys something (static/dialog.js sets it from
   its `danger` option). */
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.inline-form { display: inline; }
.link-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 0.82rem; padding: 0; text-decoration: underline;
}
.link-btn:hover { color: var(--danger); }

/* ---- toast notifications ---- */
.toasts {
  position: fixed; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toasts-top-left { top: 64px; left: 16px; align-items: flex-start; }
.toasts-top-right { top: 64px; right: 16px; align-items: flex-end; }
.toasts-bottom-left { bottom: 16px; left: 16px; align-items: flex-start; }
.toasts-bottom-right { bottom: 16px; right: 16px; align-items: flex-end; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 14px 0 14px 0; /* rounded TL + BR, pointy TR + BL — the logo corner language */
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
  font-size: 0.9rem; font-weight: 600;
  max-width: 360px;
  opacity: 1; transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast--leaving { opacity: 0; transform: translateY(-6px); }
.toast-success {
  background: #e3f6e8; color: #14522b;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24),
              inset 0 0 0 1px rgba(20, 82, 43, 0.35),
              inset 0 3px 8px rgba(20, 82, 43, 0.20);
}
.toast-error {
  background: #fdecea; color: #7f1d14;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24),
              inset 0 0 0 1px rgba(127, 29, 20, 0.35),
              inset 0 3px 8px rgba(127, 29, 20, 0.20);
}
.toast-info, .toast-message {
  background: #e6f2fb; color: #14466e;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24),
              inset 0 0 0 1px rgba(20, 70, 110, 0.35),
              inset 0 3px 8px rgba(20, 70, 110, 0.20);
}
.toast-close {
  background: none; border: none; color: inherit; cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 2px 4px; opacity: 0.85; flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }

.field-error { display: block; color: var(--danger); font-size: 0.82rem; margin-top: 2px; }
input[type="file"].is-too-big { color: var(--danger); }

.stack-form { display: flex; flex-direction: column; gap: 14px; }
.stack-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.stack-form input, .stack-form textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; font: inherit; font-weight: 400;
}
.stack-form input:focus, .stack-form textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.stack-form select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; }
/* A format hint that belongs to the field above it: pulled up out of the form's
   14px gap so it reads as part of that field, not as a break before the next. */
.stack-form .field-hint { margin: -10px 0 0; font-weight: 400; }

.form-actions { display: flex; gap: 10px; }

.auth-card { max-width: 420px; margin: 40px auto; }
/* A form page with substance to it -- a group's name, description, picture and
   interests. Wider than a login box, still a comfortable measure rather than a
   full-width field. */
.form-card { max-width: 640px; margin: 40px auto; }

.footer { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: 0.85rem; text-align: center; background: var(--bg); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 936px; height: min(88vh, 760px); max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-hint { margin: 0; padding: 12px 18px; font-size: 0.85rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.modal-hint code { background: var(--card-2); border-radius: 4px; padding: 1px 5px; }

.modal-actions { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--border); }
.modal-actions .muted.small { margin-left: auto; }

.modal-confirm { max-width: 440px; height: auto; }
.dialog-message { margin: 0; line-height: 1.5; }
.dialog-actions { justify-content: flex-end; border-top: none; padding-top: 4px; }

.dialog-actions { justify-content: flex-end; border-top: none; padding-top: 4px; position: relative; }
.dialog-ring {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s ease-out;
  /* A whisper of depth, so the track is a thing sitting above the card rather
     than a line drawn on it. */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}
/* The full circle: the track the progress fills in. `card-2` is the site's
   second surface colour, so on a light palette it is a soft grey and on a dark
   one a raised slate, which keeps a quiet circle visible either way. The border
   is the same `--border` hairline every card uses, because that is the edge the
   rest of the site draws. */
.dialog-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--card-2);
  border: 1px solid var(--border);
  box-sizing: border-box;
  /* The track is a ring, not a disc: it must not cover the button sitting in
     the middle of it. The inner half is masked away, leaving the band. */
  -webkit-mask: linear-gradient(#000 0 0) content-box exclude,
                linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box exclude,
        linear-gradient(#000 0 0);
  padding: 5px;
}
/* The progress arc: the danger colour, growing clockwise from the top over the
   track, masked to the same 5px band so the two are the same circle. The top of
   a conic gradient is 12 o'clock, which is where a progress arc is expected to
   start. */
.dialog-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    var(--danger) calc(var(--hold, 0) * 360deg),
    transparent 0
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box exclude,
                linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box exclude,
        linear-gradient(#000 0 0);
  padding: 5px;
  box-sizing: border-box;
}
.dialog-ring.is-holding { opacity: 1; }
/* The circle hangs outside the actions row and off the bottom of the dialog, so
   the modal must not clip it. */
.modal-confirm { overflow: visible; }
.dialog-hold-note { margin-right: auto; }
.dialog-actions .btn.needs-hold { cursor: pointer; }

.modal-sm { max-width: 520px; height: auto; max-height: 92vh; }
.modal-body { padding: 16px 18px; overflow-y: auto; }

