/**
 * Design builder (catnip-design-builder.html) — Ocean Calm layer.
 *
 * Loads after the page's own inline <style>, so it only states what it changes.
 * Scope: the header and intro band, the Add a piece sidebar's own scrollbar,
 * and the active button's hover state. The rest of the page's colour and
 * spacing is still the old palette and is a separate pass.
 */

/* === HEADER ===
   Was a two-column bar: a left stack holding the back link, the "catnip /
   Design your space" text wordmark and the lead line, with the prototype chip
   pushed to the right. The wordmark is now the real logo and the back link is
   opposite it, so the header carries only those two and everything else moves
   into the intro column below. The page's own rule already makes this a
   space-between flex row; only the padding changes, to share one gutter with
   the intro band. */
header {
  padding: var(--space-s);
}

.builder-home {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

/* 40px matches the store header exactly (theme components.css, a.wordmark img). */
.builder-home img {
  display: block;
  height: 40px;
  width: auto;
}

.builder-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  padding: var(--space-3xs) var(--space-2xs);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--deep-ocean);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out);
}

.builder-back:hover {
  background: var(--pebble);
  text-decoration: underline;
}

/* === INTRO ===
   A band under the header: the page title and lead line on the left, the
   prototype chip opposite. It wraps at narrow widths so the chip drops under
   the lead rather than squeezing it. The planner mode toggle stays at the top
   of the workspace column, beside the canvas it acts on. */
.builder-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-s);
  padding-inline: var(--space-s);
  padding-block: var(--space-xs);
  border-bottom: 1px solid var(--hairline);
}

.builder-intro__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2xs);
}

/* The workspace columns share the header's gutter, so the intro, the logo and
   the parts panel all line up on the same left edge. */
aside,
main {
  padding: var(--space-s);
}

/* === ADD A PIECE SIDEBAR ===
   The whole sidebar scrolls, not just the piece list, so the selected piece's
   properties come with it.

   It needs an explicit cap. The grid row is as tall as its tallest item, and
   that item is this sidebar, so left to stretch it simply defines the row and
   never overflows. 80vh is the figure the page already uses for
   .layout { min-height }, so the workspace and its sidebar agree rather than
   this being a new magic number.

   Capped and align-self: start, the sidebar no longer reaches the bottom of the
   row, so its dividing border would stop halfway down. The border moves to
   main's left edge, which does stretch. Scoped away from .quote, the other
   <aside>. */
@media (min-width: 1001px) {
  aside:not(.quote) {
    align-self: start;
    max-height: 80vh;
    overflow-y: auto;
    border-right: 0;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--coastal-blue) transparent;
  }

  main {
    border-left: 1px solid var(--hairline);
  }

  /* Was the scroller before the sidebar took the job. */
  .parts {
    max-height: none;
    overflow-y: visible;
  }
}

/* === ACTIVE BUTTON ===
   `button:hover` is (0,1,1) and `.primary` is (0,1,0), so hovering the active
   view or mode button replaced its dark fill with the pale hover tint while
   the label stayed white: about 1.2:1, unreadable. The active button now
   darkens on hover instead. White on --deep-ocean is 7.17:1 and 9.20:1 on the
   hover shade.

   The JS toggles .primary on both the view buttons and the mode buttons, and
   sets aria-pressed on the mode pair, so .primary alone covers every case. */
button.primary,
button.primary:hover,
button.primary:focus-visible {
  color: var(--white);
  border-color: var(--deep-ocean);
}

button.primary {
  background: var(--deep-ocean);
}

button.primary:hover {
  background: var(--deep-ocean-hover);
  border-color: var(--deep-ocean-hover);
}

/* The page ships no focus styles at all. Controls get one here; select is
   already covered in controls.css. */
button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 2px solid var(--deep-ocean);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .builder-back {
    transition: none;
  }
}

/* The send-to-store group: the GST line, the button and its status message.
   They are one unit, so the space between them is this group's gap. None of
   them carries a margin, and the quote panel's own flow still places the
   group as a whole exactly where the GST line used to sit. */
.send {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.send__go {
  font-family: var(--font-heading);
  font-size: var(--text-body);
  font-weight: 700;
  padding: var(--space-xs) var(--space-s);
  border-radius: var(--radius-md);
}

.send__go[disabled] {
  cursor: progress;
  opacity: 0.65;
}

/* Kept in the DOM even when empty, because a live region that is removed or
   display:none is not reliably announced when it later fills. Empty with no
   margin it takes no height, so it costs the layout nothing. */
.send__status {
  margin: 0;
}

.send__status[data-state="error"] {
  color: var(--terracotta-hover);
}

/* The quote details, revealed only when the store says a design has to be
   priced by hand. Its own flex group, so the space between the fields is
   this group's gap and no field carries a margin. */
.send__contact {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.send__contact label {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  font-size: var(--text-small);
}

.send__contact input,
.send__contact textarea {
  width: 100%;
  font: inherit;
  font-size: var(--text-small);
}

.send__contact textarea {
  resize: vertical;
}

.send__contact p {
  margin: 0;
}
