/* ============================================================================
   Services panel container — the box the second app slides into.
   Layout and gesture only; the app's own chrome lives in services.css.
   Flat and 2D: the panel is a surface step above the feed with a hairline
   edge, not a floating card with a shadow.
   ============================================================================ */

.panel {
  position: absolute;
  inset: 0;
  z-index: var(--z-panel);

  background: var(--c-ground);
  border-left: var(--border-hairline);

  display: grid;
  grid-template-rows: auto 1fr;

  transform: translate3d(100%, 0, 0);
  will-change: transform;

  /* Off by default for the whole subtree, so nothing behind is tabbable. */
  visibility: hidden;
}

.panel.is-open {
  transform: translate3d(0, 0, 0);
  visibility: visible;
}

/* Only animate when the finger is not driving it — during a drag the transform
   is set directly each frame and a transition would fight it. */
.panel.is-animating {
  /* Closing: hold visibility until the slide-out has finished, otherwise the
     panel disappears on frame one and the animation is never seen. */
  transition: transform var(--dur-base) var(--ease-out),
              visibility 0s linear var(--dur-base);
}

.panel.is-animating.is-open {
  /* Opening: become visible immediately so the slide-in is visible. */
  transition: transform var(--dur-base) var(--ease-out),
              visibility 0s;
}

.panel.is-dragging { visibility: visible; }

/* --- shared form + result primitives (used by services views) --- */

.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field + .field { margin-top: var(--s-3); }

.field label {
  font-size: var(--t-caption);
  font-weight: var(--fw-semibold);
  color: var(--c-text-muted);
}

.input,
.select {
  height: var(--tap-min);
  padding: 0 var(--s-3);
  background: var(--c-raised);
  border: var(--border-hairline);
  border-radius: var(--r-md);
  color: var(--c-text);
  font-size: var(--t-callout);
  width: 100%;
}

.input::placeholder { color: var(--c-text-faint); }
.input:focus-visible,
.select:focus-visible { border-color: var(--c-line-strong); }

.grade-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: var(--s-2);
  align-items: center;
}
.grade-row + .grade-row { margin-top: var(--s-2); }

.btn-row { display: flex; gap: var(--s-2); }

.btn {
  flex: 1;
  height: var(--tap-min);
  border-radius: var(--r-md);
  font-size: var(--t-callout);
  font-weight: var(--fw-semibold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--border-hairline);
  background: var(--c-raised);
  color: var(--c-text);
}

.btn:active { opacity: 0.6; }

.btn-primary {
  background: var(--c-gold);
  border-color: var(--c-gold);
  color: var(--c-text-on-gold);
  font-weight: var(--fw-bold);
}

.btn-ghost { background: transparent; color: var(--c-text-muted); }

.result {
  padding: var(--s-4);
  border: var(--border-hairline);
  border-radius: var(--r-md);
  background: var(--c-raised);
}

.result-value {
  font-family: var(--font-num);
  font-size: var(--t-large-title);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-title);
  line-height: 1;
  color: var(--c-gold);
}

.result-label {
  margin-top: var(--s-2);
  font-size: var(--t-subhead);
  font-weight: var(--fw-semibold);
}

.result-break {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: var(--border-faint);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.result-break div {
  display: flex;
  justify-content: space-between;
  font-size: var(--t-footnote);
  color: var(--c-text-muted);
}

.result-break span:last-child { color: var(--c-text); }

.note {
  font-size: var(--t-caption);
  line-height: 1.45;
  color: var(--c-text-muted);
  border-left: 2px solid var(--c-line-strong);
  padding-left: var(--s-3);
}

.note-warn { border-left-color: var(--c-warning); color: var(--c-warning); }

/* ============================================================================
   Edge tab — how the services app is reached on small screens.

   Replaces swipe-left, which fought tap-to-open on a card: the same horizontal
   finger movement had to mean two different things. A visible control that
   never competes with another interaction beats a gesture users must be taught.

   Right edge over the marketplace; left edge once the services app is showing.
   ============================================================================ */

.edge-tab {
  position: absolute;
  top: 50%;
  z-index: var(--z-panel);
  transform: translateY(-50%);

  width: 38px; /* Increased from 26px for better grip */
  min-width: 0;
  padding: var(--s-6) 0; /* Increased vertical padding to make it taller */

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);

  background: var(--c-surface);
  border: var(--border-hairline);
  color: var(--c-text);

  transition: transform var(--dur-base) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
}

.edge-tab:active { opacity: 0.7; }

/* Closed: clings to the right edge, rounded on the inboard side only. */
.edge-tab {
  right: 0;
  left: auto;
  border-right: none;
  border-radius: var(--r-md) 0 0 var(--r-md);
}

/* Open: the same tab, now on the left, pointing back. */
.edge-tab.is-open {
  right: auto;
  left: 0;
  border-right: var(--border-hairline);
  border-left: none;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}

.edge-tab-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: var(--t-caption-2);
  font-weight: var(--fw-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-gold);
}

.edge-tab svg {
  width: 13px;
  height: 13px;
  color: var(--c-text-muted);
  transition: transform var(--dur-base) var(--ease-out);
}

.edge-tab.is-open svg { transform: rotate(180deg); }

/* Docked side by side, there is nothing to slide to. */
.edge-tab.is-docked { display: none; }

/* ============================================================================
   The demand board — "What students want".

   Opened from the Sell tab and stacked ON TOP of the studio, so a seller reads
   the campus's open requests and carries straight on into recording without
   losing their place.

   Flat surfaces and hairlines only, like everything else. Gold appears exactly
   twice — the count on a demand row, and the highest named budget — because
   those two numbers are the entire reason a seller is reading this screen.
   ============================================================================ */

.bd {
  position: absolute;
  inset: 0;
  z-index: var(--z-sheet);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  place-items: end center;
}

.bd[hidden] { display: none; }

.bd-scrim {
  position: absolute;
  inset: 0;
  background: var(--c-scrim-heavy);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}

.bd.is-open .bd-scrim { opacity: 1; }

.bd-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 88%;
  display: flex;
  flex-direction: column;

  background: var(--c-surface);
  border: var(--border-hairline);
  border-bottom: none;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;

  transform: translateY(12px);
  opacity: 0;
  transition: transform var(--dur-base) var(--ease-spring),
              opacity var(--dur-base) var(--ease-out);
}

.bd.is-open .bd-sheet { transform: none; opacity: 1; }

.bd-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-4) var(--s-3);
  border-bottom: var(--border-hairline);
}

.bd-title {
  font-size: var(--t-title-3);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-title);
  color: var(--c-text);
}

.bd-close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  border: var(--border-hairline);
  background: var(--c-raised);
  color: var(--c-text-muted);
}

.bd-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--s-4) var(--s-4) calc(var(--s-8) + var(--safe-bottom));
}

.bd-lede,
.bd-foot,
.bd-empty {
  font-size: var(--t-footnote);
  color: var(--c-text-muted);
  line-height: var(--lh-body);
}

.bd-lede { margin-bottom: var(--s-4); }
.bd-foot { margin-top: var(--s-4); text-align: center; }
.bd-empty { padding: var(--s-8) var(--s-2); text-align: center; }

/* --- the demand list --- */

.bd-rows {
  display: flex;
  flex-direction: column;
  border: var(--border-hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.bd-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--s-3) var(--s-4);
  background: var(--c-raised);
  border: none;
  border-bottom: var(--border-hairline);
  color: var(--c-text);
  text-align: left;
}

.bd-row:last-child { border-bottom: none; }
.bd-row:active { background: var(--c-raised-hi); }

.bd-term {
  font-size: var(--t-callout);
  font-weight: var(--fw-semibold);
  text-transform: capitalize;
}

/* The number is the message. Gold, and pushed to the right where the eye
   scanning a list of counts expects to find it. */
.bd-count {
  margin-left: auto;
  font-size: var(--t-caption);
  font-weight: var(--fw-bold);
  color: var(--c-gold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bd-budget {
  font-size: var(--t-caption-2);
  color: var(--c-gold-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bd-chev { width: 15px; height: 15px; color: var(--c-text-faint); flex: none; }

/* --- one term's requests --- */

.bd-back {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  min-height: 34px;
  margin-bottom: var(--s-3);
  padding: 0 var(--s-3) 0 var(--s-2);
  border-radius: var(--r-pill);
  border: var(--border-hairline);
  background: var(--c-raised);
  color: var(--c-text-muted);
  font-size: var(--t-caption);
  font-weight: var(--fw-semibold);
}

.bd-back svg { width: 14px; height: 14px; }

.bd-term-title {
  font-size: var(--t-title-3);
  font-weight: var(--fw-bold);
  text-transform: capitalize;
  color: var(--c-text);
  margin-bottom: var(--s-1);
}

.bd-reqs {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  list-style: none;
}

.bd-req {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  border: var(--border-hairline);
  background: var(--c-raised);
}

.bd-req-text {
  font-size: var(--t-subhead);
  color: var(--c-text);
  line-height: var(--lh-snug);
}

.bd-req-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-3);
  margin-top: var(--s-2);
  font-size: var(--t-caption-2);
  color: var(--c-text-faint);
}

.bd-req-budget { color: var(--c-gold-dim); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .bd-sheet, .bd-scrim { transition: none; }
}


/* --- the handle, over content -------------------------------------------
   When the panel is open the handle sits on top of the panel's own content.
   The first fix for that shifted the entire page right to clear it, which is
   a heavy price for a 38px grip — so instead the handle gets out of the way
   optically: mostly transparent at rest, solid the moment it is touched.

   `backdrop-filter` rather than a flat background, so whatever it covers stays
   legible through it instead of being hidden by it. */
.edge-tab.is-open {
  opacity: 0.4;
  background: var(--c-scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-color: transparent;
}

.edge-tab.is-open:hover,
.edge-tab.is-open:active,
.edge-tab.is-open.is-grabbed {
  opacity: 1;
  background: var(--c-surface);
  border-color: var(--c-line);
}

/* The handle is dragged, so the browser must not claim the gesture as a scroll.
   Without this, a touch drag fires pointerdown and then immediately
   pointercancel as the page takes over — which is exactly why dragging worked
   with a mouse and only tapping worked on a phone. */
.edge-tab {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
