/* ============================================================================
   Suggestions — the community's own backlog.

   One board panel, hairline-ruled rows under sunken section bands, exactly the
   rhythm the notifications feed and the transactions ledger already keep: a
   suggestion is a line in a shared record, not a floating card. Each row leads
   with its vote rail — the score is the community's ranking, so it sits first
   and is set in mono like every other machine value.

   "Implementadas" is a settled section of the same ledger, not an archive:
   rows keep full ink (fading read rows takes copy under 4.5:1) and carry the
   solved-green chip with its word.
   ========================================================================= */

/* ---------------------------------------------------------------------------
   Page
   ------------------------------------------------------------------------ */

.sg {
  padding-block: var(--sp-8) var(--sp-16);
}

/* Same single reading column as the other account-shaped feeds. */
.sg__col {
  max-width: 780px;
  margin-inline: auto;
}

.sg__head {
  margin-block-end: var(--sp-6);
}

.sg__title {
  font-size: var(--fs-3xl);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-display);
  color: var(--ink-050);
  margin: 0 0 var(--sp-2);
}

.sg__subtitle {
  color: var(--ink-300);
  max-width: 58ch;
  margin: 0;
}

/* ---------------------------------------------------------------------------
   Composer — the panel a signed-in visitor writes into. Fields come from the
   base .field primitives; this only arranges them.
   ------------------------------------------------------------------------ */

.sg-composer {
  margin-block-end: var(--sp-6);
}

.sg-composer .panel__title {
  margin: 0;
}

.sg-composer__body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.sg-composer__body .field-errors {
  margin: 0;
}

.sg-composer__actions {
  display: flex;
  justify-content: flex-end;
}

/* Signed-out note in the composer's slot, so the page keeps one shape. */
.sg-login {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  margin-block-end: var(--sp-6);
  color: var(--ink-200);
}

.sg-login .icon {
  color: var(--ink-400);
}

.sg-login__text {
  margin: 0;
}

.sg-login__text a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.sg-login__text a:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------------------------
   The board
   ------------------------------------------------------------------------ */

.sg-board {
  overflow: hidden;
}

/* Section band — the same sunken strip the ledger uses for a day heading.
   The count is a machine value: mono, next to its word. */
.sg-band {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  padding: var(--sp-2) var(--sp-5);
  background: var(--ink-900);
  border-block: 1px solid var(--line);
}

.sg-board > .sg-band:first-child {
  border-block-start: 0;
}

.sg-band__name {
  color: var(--ink-300);
}

/* State colour next to its word: the section heading is the word. */
.sg-band--done .sg-band__name {
  color: var(--solved);
}

.sg-band__count {
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--ink-400);
}

.sg-board__none {
  margin: 0;
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--ink-400);
}

/* ---------------------------------------------------------------------------
   Rows — each row is its own turbo-frame, so the separator is drawn above
   the row and cancelled where a band already rules the seam.
   ------------------------------------------------------------------------ */

.sg-row {
  display: block;
  border-block-start: 1px solid var(--line);
}

.sg-board > .sg-row:first-child,
.sg-band + .sg-row,
.sg-board__none + .sg-row {
  border-block-start: 0;
}

.sg-row__grid {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  column-gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
}

/* ---------------------------------------------------------------------------
   Vote rail — up, score, down in a reserved first column. The score is the
   row's ranking: mono, tabular, signed, so the signal survives greyscale.
   ------------------------------------------------------------------------ */

.sg-vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.sg-vote__form {
  margin: 0;
  line-height: 0;
}

.sg-vote__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--ink-400);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}

.sg-vote__btn:hover {
  background: var(--ink-800);
  color: var(--ink-100);
}

.sg-vote__btn--up.is-active {
  background: var(--solved-wash);
  color: var(--solved);
}

.sg-vote__btn--down.is-active {
  background: var(--danger-wash);
  color: var(--danger);
}

.sg-vote__score {
  min-width: 2ch;
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--ink-200);
  text-align: center;
  /* A signed figure: without isolation the bidi algorithm moves the sign to
     the other side of the digits under dir="rtl" ("+12" renders as "12+"). */
  direction: ltr;
  unicode-bidi: isolate;
}

.sg-vote__score.is-up {
  color: var(--solved);
}

.sg-vote__score.is-down {
  color: var(--danger);
}

/* ---------------------------------------------------------------------------
   Row body
   ------------------------------------------------------------------------ */

.sg-row__titleline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  /* Optically align the first text line with the up-vote button beside it. */
  padding-block-start: 2px;
}

.sg-row__title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: var(--lh-snug);
  color: var(--ink-050);
  overflow-wrap: anywhere;
}

.sg-row__desc {
  margin-block-start: var(--sp-1);
  max-width: 60ch;
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--ink-200);
  overflow-wrap: anywhere;
}

.sg-row__desc p {
  margin: 0 0 var(--sp-2);
}

.sg-row__desc p:last-child {
  margin-block-end: 0;
}

.sg-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-block-start: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--ink-400);
}

.sg-author {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--ink-200);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--dur-1) var(--ease);
}

.sg-author:hover {
  color: var(--ink-050);
}

.sg-meta-dot {
  color: var(--ink-500);
}

/* Owner and admin controls sit at the row's inline end. button_to wraps each
   button in its own form; the forms are flex items like any other. */
.sg-row__tools {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-inline-start: auto;
}

.sg-row__tools form {
  margin: 0;
  line-height: 0;
}

/* ---------------------------------------------------------------------------
   Comments — a disclosure under the row, with the thread in a sunken well.
   ------------------------------------------------------------------------ */

.sg-comments {
  margin-block-start: var(--sp-3);
  border-block-start: 1px solid var(--line);
  padding-block-start: var(--sp-3);
}

.sg-comments__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  list-style: none;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-400);
  user-select: none;
  transition: color var(--dur-1) var(--ease);
}

.sg-comments__toggle::-webkit-details-marker {
  display: none;
}

.sg-comments__toggle:hover {
  color: var(--ink-100);
}

.sg-comments__list {
  margin-block-start: var(--sp-3);
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.sg-comments__list:empty {
  display: none;
}

.sg-comment {
  padding: var(--sp-3) var(--sp-4);
}

.sg-comment + .sg-comment {
  border-block-start: 1px solid var(--line);
}

.sg-comment__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--ink-400);
}

.sg-comment__content {
  margin-block-start: var(--sp-1);
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
  color: var(--ink-200);
  overflow-wrap: anywhere;
}

.sg-comment__content p {
  margin: 0 0 var(--sp-1);
}

.sg-comment__content p:last-child {
  margin-block-end: 0;
}

.sg-comment-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sp-2);
  margin-block-start: var(--sp-3);
}

.sg-comment-form .field__error {
  flex-basis: 100%;
}

.sg-comment-form__input {
  flex: 1;
  min-width: 200px;
  font-size: var(--fs-sm);
  resize: vertical;
}

.sg-comments__login {
  margin: var(--sp-3) 0 0;
  font-size: var(--fs-sm);
  color: var(--ink-400);
}

.sg-comments__login a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.sg-comments__login a:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------------------------
   Inline edit — replaces the row's content inside its own frame.
   ------------------------------------------------------------------------ */

.sg-edit {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
}

.sg-edit .field-errors {
  margin: 0;
}

.sg-edit__title {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--ink-200);
}

.sg-edit__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
}

/* ---------------------------------------------------------------------------
   Phones — tighter gutters; the tools cluster drops to its own line.
   ------------------------------------------------------------------------ */

@media (max-width: 767px) {
  .sg {
    padding-block: var(--sp-6) var(--sp-12);
  }

  .sg__title {
    font-size: var(--fs-2xl);
  }

  .sg-band,
  .sg-board__none {
    padding-inline: var(--sp-4);
  }

  .sg-row__grid {
    grid-template-columns: 36px minmax(0, 1fr);
    column-gap: var(--sp-3);
    padding: var(--sp-4);
  }

  .sg-vote__btn {
    width: 32px;
  }

  .sg-edit {
    padding: var(--sp-4);
  }
}
