/* The Activity runs in a small, dark, mobile-capable iframe (design §6a).
   The palette matches the website's so the two read as one product. */
:root {
  color-scheme: dark;

  --bg: #1e1f22;
  --surface: #2b2d31;
  --raised: #313338;
  --surface-hover: #35373c;
  --text: #f2f3f5;
  --soft: #dbdee1;
  --muted: #949ba4;
  --faint: #6d6f78;
  --accent: #5865f2;
  --accent-strong: #4752c4;
  --border: #3f4147;
  --border-soft: #35373c;
  --green: #23a55a;
  --green-text: #4ade80;
  --danger: #f23f43;

  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must beat every layout rule below it. A class that
   sets `display` (`.boot` is `grid`) otherwise keeps the element on screen
   after JS hides it, which leaves the boot overlay covering a working app. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Mobile safe areas: Discord renders the Activity full-bleed. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Keyboard focus has to be visible on every control, including the ones that
   are only styled as cards. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection { background: var(--accent); color: var(--text); }

/* Labels that exist for screen readers, where the placeholder carries the
   visible hint. A placeholder is not a label: it disappears as you type. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------- boot state */

.boot {
  display: grid; place-items: center; gap: 16px;
  min-height: 100vh; padding: 24px; text-align: center; color: var(--muted);
}
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------------- chrome */

/* The bar and the tabs stick as one block. Sticking them separately means
   guessing the bar's height for the tabs' `top`, and being a pixel or two out
   leaves a strip of scrolling content showing between them. */
.chrome { position: sticky; top: 0; z-index: 5; background: var(--bg); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.topbar strong { letter-spacing: -0.01em; }

/* Inside .chrome, so switching views never means scrolling back up a list. */
.tabs {
  display: flex; gap: 4px; padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1; padding: 8px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font: inherit; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.tab:hover { color: var(--soft); }
.tab.active { background: var(--surface); color: var(--text); font-weight: 600; }

.view { padding: 12px 16px 32px; }

/* ------------------------------------------------------------------- controls */

.filters { display: grid; gap: 8px; margin-bottom: 12px; }
.filters .row { display: flex; gap: 8px; }
.filters .row > * { flex: 1; min-width: 0; }

input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--raised);
  border: 1px solid var(--border); border-radius: 6px; padding: 9px 10px;
  transition: border-color 0.12s, background 0.12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--surface-hover); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input::placeholder, textarea::placeholder { color: var(--faint); }

.check { display: flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.check input { width: auto; accent-color: var(--accent); }

.picker { position: relative; }
.picker input { width: 100%; }
.options {
  position: absolute; z-index: 10; left: 0; right: 0; margin: 4px 0 0; padding: 0;
  list-style: none; max-height: 220px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / 0.4);
}
.options li button {
  display: flex; justify-content: space-between; gap: 12px; width: 100%;
  border: 0; border-radius: 0; background: transparent; text-align: left; cursor: pointer;
}
.options li button:hover { background: var(--surface-hover); }

/* ---------------------------------------------------------------------- cards */

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.card:hover { background: var(--surface-hover); border-color: var(--accent); }
/* Touch has no hover, so the press itself has to acknowledge the tap. */
.card:active { transform: scale(0.995); }
.card h3 { margin: 0 0 2px; font-size: 15px; line-height: 1.35; color: var(--text); }
.card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }

.badge {
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--border); color: var(--soft); white-space: nowrap;
}
.badge.green { background: rgb(35 165 90 / 0.2); color: var(--green-text); }
.badge.accent { background: rgb(88 101 242 / 0.25); color: #a5b4fc; }
.badge.amber { background: rgb(240 177 50 / 0.2); color: #f0b132; }
.badge.red { background: rgb(242 63 67 / 0.2); color: #ff9a9d; }

.muted { color: var(--muted); font-size: 13px; }
/* Money lines up column-wise when the digits are tabular. */
.salary { font-weight: 600; color: var(--green-text); font-variant-numeric: tabular-nums; }

/* The list is dimmed, not emptied, while the next answer is on its way: an
   in-place refresh should not make the screen jump. */
.cards.busy { opacity: 0.5; pointer-events: none; transition: opacity 0.12s; }

/* Skeletons stand in for the first load, where there is nothing to dim. */
.skeleton {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
}
.skeleton .line {
  height: 10px; border-radius: 999px; background: var(--raised);
  animation: pulse 1.4s ease-in-out infinite;
}
.skeleton .line + .line { margin-top: 8px; }
.skeleton .line.short { width: 45%; }
.skeleton .line.mid { width: 70%; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.more { width: 100%; margin-top: 12px; cursor: pointer; }
.more:disabled { opacity: 0.6; cursor: default; }

.empty {
  padding: 32px 8px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty strong { display: block; color: var(--soft); margin-bottom: 4px; }

/* ---------------------------------------------------------------- offer sheet */

.sheet {
  position: fixed; inset: 0; background: var(--bg); overflow-y: auto; z-index: 20;
  /* The fixed sheet leaves the body's flow, so it needs the insets itself or
     its header slides under a notch. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  animation: rise 0.18s ease-out;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

.sheet-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.back {
  background: transparent; border: 0; color: var(--muted); padding: 6px 8px;
  cursor: pointer; border-radius: 6px;
}
.back:hover { background: var(--surface); color: var(--text); }

.sheet-body { padding: 16px 16px 40px; }
.sheet-body h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.25; }
.sheet-body .description {
  white-space: pre-wrap; color: var(--soft); margin-top: 16px;
  padding-top: 16px; border-top: 1px solid var(--border-soft);
}

.apply { display: grid; gap: 8px; margin-top: 20px; }
.apply textarea { width: 100%; min-height: 90px; resize: vertical; }

.primary {
  background: var(--accent); border-color: var(--accent);
  font-weight: 600; cursor: pointer;
}
.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.primary:disabled { opacity: 0.5; cursor: default; }
.secondary { background: transparent; border-color: var(--border); cursor: pointer; }
.secondary:hover { background: var(--surface-hover); }
.secondary.on { border-color: var(--accent); color: #a5b4fc; }

a { color: #a5b4fc; }
a:hover { color: var(--text); }

/* --------------------------------------------------------------- account choice */

.choice-card {
  width: min(360px, 90vw);
  display: grid; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px; text-align: left;
}
.choice-card h2 { margin: 0; font-size: 18px; }

/* A labelled control in the completion form. The labels are visible here —
   three fields asked at once need saying which is which, and a placeholder
   disappears the moment someone starts typing. */
.field { display: grid; gap: 4px; }
.field > span, .field > label { font-size: 13px; font-weight: 600; color: var(--soft); }
.field input { width: 100%; }
.field small { font-size: 12px; }
.choice-card .muted { margin: 0 0 6px; }
.choice-error {
  margin: 0; padding: 8px 10px; border-radius: 6px;
  background: rgb(242 63 67 / 0.15); color: #ff9a9d; font-size: 13px;
}

/* ---------------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(90vw, 420px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / 0.45);
  padding: 10px 16px; z-index: 50; font-size: 14px;
  animation: toast-in 0.18s ease-out;
}
.toast.error { border-color: var(--danger); color: #ff9a9d; }
@keyframes toast-in {
  from { transform: translate(-50%, 8px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
