/**
 * SwiftGigs component + spacing primitives.
 * Colors come from qg-tokens.css — never hardcode a hex in this file.
 * Load AFTER qg-tokens.css and after page CSS.
 *
 * Naming: .sg-* so these never collide with existing .qg-* rules.
 */

:root {
  /* Spacing scale from the mockup */
  --sg-page-x: 20px;
  --sg-gap-sm: 8px;
  --sg-gap-md: 10px;
  --sg-gap-section: 20px;
  --sg-radius-card: 15px;
  --sg-radius-btn: 14px;
  --sg-radius-square: 10px;
}

/* ── Layout ───────────────────────────────────────────────────────────── */

.sg-page {
  padding-left: var(--sg-page-x);
  padding-right: var(--sg-page-x);
}

.sg-header {
  padding: 20px var(--sg-page-x) 12px;
}

.sg-section + .sg-section {
  margin-top: var(--sg-gap-section);
}

/* Sticky bottom action bar (not the tab bar — see note at end of file) */
.sg-actionbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: 14px var(--sg-page-x) 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ── Typography ───────────────────────────────────────────────────────── */

.sg-h1 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.sg-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sg-body {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text);
}

.sg-body--muted {
  color: var(--text-muted);
}

/* Money is always green, always 700. Size varies by context. */
.sg-money {
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.sg-money--sm { font-size: 14px; }
.sg-money--md { font-size: 17px; }
.sg-money--lg { font-size: 22px; }

/* ── Cards ────────────────────────────────────────────────────────────── */

.sg-card {
  display: block;
  width: 100%;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--sg-radius-card);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

/* Selected "choice card" = teal outline + tint.
 * The inset shadow fakes the extra 0.5px of border so selecting a card
 * never reflows the layout. */
.sg-card.is-selected {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 0.5px var(--teal);
  background: var(--teal-tint);
}

.sg-card--compact { padding: 13px 14px; }
.sg-card--roomy   { padding: 18px 16px; }

/* ── Rows ─────────────────────────────────────────────────────────────── */

.sg-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.sg-row + .sg-row {
  border-top: 1px solid var(--border);
}

/* ── Icon in rounded square ───────────────────────────────────────────── */

.sg-isq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--sg-radius-square);
  background: var(--surface-alt);
  color: var(--text);
}

.sg-isq svg { width: 19px; height: 19px; }

/* Smaller variant used inside the urgency selector cards */
.sg-isq--sm { width: 30px; height: 30px; }
.sg-isq--sm svg { width: 16px; height: 16px; }

.sg-isq--primary { color: var(--primary); }
.sg-isq--teal    { color: var(--teal); }

/* ── Pills / chips ────────────────────────────────────────────────────── */

.sg-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sg-gap-sm);
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

/* Pills are ~34px tall by design but must stay a 44px tap target.
 * The pseudo-element extends the hit area without changing the visual. */
.sg-pill::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 44px;
}

/* Selected pill = solid purple fill (distinct from the teal-tint card state) */
.sg-pill.is-selected {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.sg-pill--teal.is-selected {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--teal-text);
}

.sg-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sg-gap-md);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.sg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sg-gap-md);
  width: 100%;
  min-height: 48px;
  padding: 15px;
  border: none;
  border-radius: var(--sg-radius-btn);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: filter 0.15s;
}

.sg-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.sg-btn:not(:disabled):active { filter: brightness(0.93); }

/* Posting flow */
.sg-btn--primary {
  background: var(--primary);
  color: var(--primary-text);
}

/* Earning flow */
/* --teal-text, not --primary-text: white on teal is 1.9:1 in dark mode. */
.sg-btn--teal {
  background: var(--teal);
  color: var(--teal-text);
}

.sg-btn--quiet {
  background: var(--surface-alt);
  color: var(--text);
}

.sg-btn--auto { width: auto; }

/* ── Wordmark ─────────────────────────────────────────────────────────── */
/* Requires Playfair Display to be loaded on the page. */

.sg-wordmark {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: var(--grad-wordmark);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

/* Fallback for engines without background-clip:text support */
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .sg-wordmark {
    background: none;
    color: var(--primary);
    -webkit-text-fill-color: var(--primary);
  }
}

/* ── Focus ────────────────────────────────────────────────────────────── */

.sg-card:focus-visible,
.sg-pill:focus-visible,
.sg-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Motion ───────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .sg-card,
  .sg-pill,
  .sg-btn { transition: none; }
}

/* ── App bar ──────────────────────────────────────────────────────────── */
/* Home shows the wordmark + city and one person button. Every inner screen
   shows a back square on the left and at most ONE contextual control on the
   right. The page title lives in the body, not here. */

.sg-appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px var(--sg-page-x);
  background: var(--bg);
  border-bottom: none;
}

.sg-appbar__brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sg-appbar__brand .sg-wordmark { font-size: 23px; line-height: 1.15; }

.sg-appbar__city {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 36px square for back / filter / search / overflow. Round variant is the
   person button on Home. */
.sg-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--sg-radius-square);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sg-iconbtn svg { width: 18px; height: 18px; }
.sg-iconbtn:active { background: var(--surface-alt); }

/* The 36px visual is under the 44px minimum tap target, so extend the hit
   area with a pseudo-element rather than growing the button. */
.sg-iconbtn::after {
  content: "";
  position: absolute;
  width: 44px;
  height: 44px;
}
.sg-iconbtn { position: relative; }

.sg-iconbtn--round {
  border-radius: 50%;
  border-color: transparent;
  background: var(--surface-alt);
  color: var(--primary);
}

.sg-iconbtn--teal { color: var(--teal); background: var(--surface-alt); border-color: transparent; }

/* Count badge on the filter control */
.sg-iconbtn__badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 100px;
  background: var(--teal);
  color: var(--teal-text);
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

/* The beta strip is deliberately not styled here: it appears on Home only, so
   it lives in dashboard.html's own <style> block rather than a shared sheet. */

/* ── Segmented control ────────────────────────────────────────────────── */

.sg-seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 100px;
  background: var(--surface-alt);
}

.sg-seg__opt {
  flex: 1;
  min-height: 38px;
  padding: 8px 10px;
  border: none;
  border-radius: 100px;
  background: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

/* Active segment is solid teal — this is a view switcher, not a flow action,
   so it does not follow --accent. */
.sg-seg__opt.is-active {
  background: var(--teal);
  color: var(--teal-text);
}

/* ── Step progress (Post a Task wizard) ───────────────────────────────── */

.sg-steps {
  display: flex;
  gap: 6px;
}

.sg-steps__seg {
  flex: 1;
  height: 4px;
  border-radius: 100px;
  background: var(--border);
}

.sg-steps__seg.is-done { background: var(--primary); }

/* ── Progress dots (Active Gig) ───────────────────────────────────────── */

.sg-prog {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sg-prog__step {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.sg-prog__step.is-done { color: var(--text); }

.sg-prog__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
}

.sg-prog__step.is-done .sg-prog__dot {
  border-color: var(--teal);
  background: var(--teal);
}

.sg-prog__line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Initials avatar ──────────────────────────────────────────────────── */

.sg-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-on-soft);
  font-size: 13.5px;
  font-weight: 700;
  overflow: hidden;
}

.sg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sg-avatar--lg { width: 52px; height: 52px; font-size: 17px; }
.sg-avatar--sm { width: 32px; height: 32px; font-size: 11.5px; }

/* ── Bottom tab bar ───────────────────────────────────────────────────── */
/* Exactly four items: Home / Gigs / Messages / Profile. Active is purple in
   both flows — the tab bar says where you are, not which flow you are in. */

.sg-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
}

.sg-tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 48px;
  padding: 2px 0;
  color: var(--text-muted);
  text-decoration: none;
  position: relative;
}

.sg-tabbar__item svg { width: 22px; height: 22px; }
.sg-tabbar__lbl { font-size: 11px; font-weight: 500; }
.sg-tabbar__item.is-active { color: var(--primary); }
.sg-tabbar__item.is-active .sg-tabbar__lbl { font-weight: 600; }

/* Unread count on Messages */
.sg-tabbar__badge {
  position: absolute;
  top: 0;
  left: 50%;
  margin-left: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 100px;
  background: var(--danger);
  color: var(--danger-text);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.sg-tabbar__badge:empty { display: none; }

/* Pages with the tab bar need room to scroll past it. */
body.sg-has-tabbar {
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}
