/* Panel + board + card grid, and the one breakpoint reflow. */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--board);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--leading-body);
}

:focus-visible {
  outline: var(--focus-ring) solid var(--pop);
  outline-offset: 2px;
}

/* ── User panel ─────────────────────────────────────────────────────────────
   Chrome. Sits outside the cards and takes no part in the pane reflow. */

.panel {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--panel-width);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-4);
  background: var(--paper);
  border-right: 1px solid var(--edge);
  z-index: var(--z-panel);
}

/* Pins settings to the bottom of the rail without knowing the rail's height. */
.panel__foot { margin-top: auto; }

/* ── Board ──────────────────────────────────────────────────────────────────
   Offset off the same token the panel is sized from — never a duplicate. */

.board {
  margin-left: var(--panel-width);
  padding: var(--space-6) var(--space-5);
}

.board__inner {
  max-width: var(--board-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.board__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.board__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ── Blabthread card ────────────────────────────────────────────────────────
   The pane arrangement is declarative via grid-template-areas so folding
   cannot scramble it: fold and reflow are independent state on this element. */

.card__body {
  display: grid;
  grid-template-areas: "blab media";
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
  padding: var(--space-4);
}

.pane--blab  { grid-area: blab; }
.pane--media { grid-area: media; }

.card[data-folded="true"] .card__body { display: none; }

/* ── Mobile ─────────────────────────────────────────────────────────────────
   Every rule below the breakpoint lives in this one block. */

@media (max-width: 768px) {
  .panel {
    inset: 0 0 auto 0;
    width: auto;
    height: var(--panel-height);
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 0 var(--space-3);
    border-right: 0;
    border-bottom: 1px solid var(--edge);
  }

  /* Nothing is pinned on mobile — the bar is the whole panel. */
  .panel__foot { margin-top: 0; }
  .panel__wordmark,
  .panel__info { display: none; }

  /* The bar is exactly --panel-height tall, so the claim form cannot open inside it. It
     drops below instead, as a sheet the bar's own border already frames. */
  .panel__claim:not([hidden]) {
    position: absolute;
    inset: var(--panel-height) 0 auto 0;
    background: var(--paper);
    border-bottom: 1px solid var(--edge);
    padding: var(--space-3);
  }

  /* The bar is only --panel-height tall, so there is nothing above it to rise into — the
     sheet drops below instead, over the board, the same way the claim form does. Anchored to
     the panel rather than to .panel__foot so it spans the bar's full width. */
  .sheet {
    inset: var(--panel-height) 0 auto auto;
    position: fixed;
    width: min(260px, 100vw);
    margin: 0;
    transform: translateY(calc(var(--space-3) * -1));
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }

  .sheet--open { transform: translateY(0); }

  .board {
    margin-left: 0;
    margin-top: var(--panel-height);
    padding: var(--space-4) var(--space-3);
  }

  /* The title is optional and this is the layout with no vertical room to spare, so the field
     collapses behind its own label. The disclosure becomes the visible control; the label and
     the input appear only once it is expanded, which JS signals with aria-expanded. */
  .composer__disclose {
    display: block;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--ink);
    text-align: left;
    background: transparent;
    border: 1px dashed var(--edge);
    border-radius: var(--radius-pill);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
  }

  .composer__disclose[aria-expanded="false"] ~ .composer__label,
  .composer__disclose[aria-expanded="false"] ~ .composer__input { display: none; }

  /* Stacked, so the preview can sit between Choose image and Send it — order rather than
     source order, because desktop wants it first and mobile wants it second. */
  .composer__field--image {
    flex-direction: column;
    align-items: stretch;
  }

  .composer__preview {
    order: 2;
    height: auto;
    max-width: 100%;
    max-height: calc(var(--space-6) * 4);
  }

  /* Panes reflow, they do not fold — and the order inverts: media on top. */
  .card__body {
    grid-template-areas:
      "media"
      "blab";
    grid-template-columns: 1fr;
  }

  /* On top and stacked, the media pane has no side-by-side pane to bound its height, so a
     full-width image would push the blab pane off the screen. Capped harder instead — the
     blab pane stays reachable.

     The token is re-declared rather than max-height: components.css loads after this file
     and would win the property. A custom property on .media-view beats the :root default
     on specificity regardless of file order. */
  .media-view {
    --media-single-max: var(--media-max-mobile);
  }
}
