/* ==========================================================================
   Buddy OS Wave1 — 守夜安頓寮 · 前簷點燈安頓 + 落印封存
   Scope: blissfulife-buddy only. Tokens: --fleet-* only (0 new hex).
   ========================================================================== */

/* Dock clearance only. Five tabs stay. Toast position stays in the page. */
body[data-realm="buddy"] {
  padding-bottom: calc(var(--tab-h, 68px) + 56px + env(safe-area-inset-bottom));
}

/* ---- 前簷 layout: one centred porch, roster moves to the second layer ---- */
@media (min-width: 1024px) {
  body[data-realm="buddy"] .buddy-cinema {
    display: block;
    max-width: 980px;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
  }

  body[data-realm="buddy"] #buddy-main-app {
    max-width: 760px;
    margin: 0 auto;
    padding: 0;
  }

  body[data-realm="buddy"] #buddy-guest-start {
    max-width: 680px;
    margin: 2.5rem auto 1rem;
  }

  /* Wave0 inline base CSS pinned the tabbar to left:0; centre it on desktop. */
  body[data-realm="buddy"] .buddy-tabbar {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: min(640px, calc(100% - 2rem)) !important;
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
  }
}

body[data-realm="buddy"] #buddy-stage-left {
  display: none !important;
}

/* The old "tonight's circle" promo competed with the porch's single CTA.
   Keep its DOM/hook; circle entry remains in the feed and the 同行 tab. */
body[data-realm="buddy"] #buddy-view-explore #buddy-tonight {
  display: none !important;
}

@media (max-width: 1023px) {
  body[data-realm="buddy"] #buddy-guest-start {
    margin: 1.25rem 0 1rem;
    padding: 1.15rem 1.1rem 1.25rem;
  }
}

/* ---- Porch card ---- */
#buddy-guest-start {
  border-top: 2px solid var(--fleet-amber) !important;
  padding: 1.25rem 1.15rem 1.3rem;
}

.buddy-porch-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.55rem;
}

.buddy-lamp {
  display: inline-flex;
  color: var(--fleet-amber-soft);
  flex: none;
}

.buddy-porch-kicker {
  font-family: var(--fleet-ui);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fleet-muted-strong);
}

#buddy-guest-start h1 {
  font-family: var(--fleet-ui);
  font-size: clamp(1.65rem, 4.4vw, 2.15rem);
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -0.01em;
  color: var(--fleet-text);
  margin: 0.15rem 0 0.25rem;
}

.buddy-porch-sub {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--fleet-muted-strong);
  letter-spacing: 0.01em;
}

.buddy-porch-note {
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--fleet-muted);
}

#buddy-guest-start label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fleet-muted);
}

#buddy-one-step {
  min-height: 50px;
  border-radius: var(--fleet-r-control);
  font-size: 16px;
}

#buddy-today-step {
  min-height: 52px;
  border-radius: var(--fleet-r-control);
  font-size: 1rem;
  letter-spacing: 0.03em;
}

#buddy-one-step-done {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--fleet-jade-text);
}

#buddy-one-step-done::before {
  content: "安";
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: 0.4rem;
  border: 1px solid var(--fleet-jade);
  border-radius: var(--fleet-r-chip);
  color: var(--fleet-jade-text);
  font-size: 0.62rem;
  font-weight: 800;
  vertical-align: middle;
}

/* ---- 8-state copy lines ---- */
.buddy-porch-status {
  min-height: 1.2em;
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--fleet-muted);
}

.buddy-porch-status[data-kind="error"] {
  padding-left: 0.55rem;
  border-left: 2px solid var(--fleet-muted);
  color: var(--fleet-body);
}

.buddy-porch-member,
.buddy-porch-minor {
  position: relative;
  margin: 0.35rem 0 0;
  padding-left: 0.85rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--fleet-muted-strong);
}

.buddy-porch-member::before,
.buddy-porch-minor::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--fleet-amber);
}

/* ---- 落印封存匣 ---- */
.buddy-seal-box {
  margin: 1rem 0 0.35rem;
  padding: 0.9rem;
  border: 1px solid var(--fleet-line);
  border-left: 2px solid var(--fleet-amber);
  border-radius: var(--fleet-r-card);
  background: var(--fleet-bg);
}

.buddy-seal-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.buddy-seal-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid var(--fleet-amber);
  border-radius: var(--fleet-r-chip);
  color: var(--fleet-amber-soft);
  font-family: var(--fleet-ui);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  background: transparent;
}

.buddy-seal-mark--small {
  width: 20px;
  height: 20px;
  font-size: 0.62rem;
}

.buddy-seal-kicker {
  margin: 0;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fleet-muted);
}

.buddy-seal-title {
  margin: 0.15rem 0 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--fleet-text);
}

.buddy-seal-list {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.buddy-seal-entry {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--fleet-line-soft);
  border-radius: var(--fleet-r-control);
  background: var(--fleet-surface);
}

.buddy-seal-entry-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.buddy-seal-entry-text {
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--fleet-text);
  word-break: break-word;
}

.buddy-seal-entry-time {
  font-size: 0.65rem;
  line-height: 1.2;
  color: var(--fleet-muted);
  font-variant-numeric: tabular-nums;
}

.buddy-seal-note {
  margin: 0.6rem 0 0;
  font-size: 0.7rem;
  line-height: 1.45;
  color: var(--fleet-muted);
}

.buddy-seal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.buddy-seal-btn {
  flex: 1;
  min-width: 132px;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--fleet-line-cool);
  border-radius: var(--fleet-r-control);
  background: transparent;
  color: var(--fleet-text);
  font-family: var(--fleet-ui);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.buddy-seal-btn--ghost {
  border-color: var(--fleet-line);
  color: var(--fleet-amber-soft);
}

.buddy-seal-btn:hover,
.buddy-seal-btn:focus-visible {
  border-color: var(--fleet-focus);
}

.buddy-seal-btn:focus-visible,
.buddy-porch-actions:focus-visible {
  outline: 2px solid var(--fleet-focus);
  outline-offset: 2px;
}

/* ---- Wave0 compliance lines stay readable under the porch ---- */
#buddy-guest-start .buddy-guest-safety {
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--fleet-muted);
}

#buddy-guest-start .buddy-guest-safety--second {
  margin-top: 0.1rem;
}

@media (max-width: 420px) {
  #buddy-guest-start {
    padding: 1.1rem 1rem 1.2rem;
  }

  .buddy-seal-actions {
    flex-direction: column;
  }

  .buddy-seal-btn {
    width: 100%;
    min-width: 0;
  }
}

/* Sealed porch: keep #buddy-seal-box fully above the fixed tab bar at scrollTop 0.
   The lead may scroll inside the card. Body padding-bottom is unchanged (page-end clearance).
   Does not apply while the seal box stays hidden. */
body[data-realm="buddy"] #buddy-guest-start:has(#buddy-seal-box:not([hidden])) {
  margin-top: 0.35rem;
}
body[data-realm="buddy"] #buddy-guest-start:has(#buddy-seal-box:not([hidden])) .buddy-porch-fit {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
  padding-bottom: 16px;
}
body[data-realm="buddy"] #buddy-guest-start:has(#buddy-seal-box:not([hidden])) .buddy-porch-lead {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
body[data-realm="buddy"] #buddy-guest-start:has(#buddy-seal-box:not([hidden])) #buddy-seal-box {
  flex: 0 0 auto;
  margin-top: 0.45rem;
}

/* ---- 守約同行 · 次層說明（唔入隊、唔自動配對） ---- */
#buddy-companion-sheet .buddy-sheet-panel {
  background: var(--fleet-surface);
  border: 1px solid var(--fleet-line);
  color: var(--fleet-text);
}

.buddy-covenant-lead {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--fleet-body);
}

.buddy-covenant-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.buddy-covenant-list li {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--fleet-line-soft);
  border-radius: var(--fleet-r-control);
  background: var(--fleet-bg);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--fleet-muted-strong);
}

.buddy-covenant-list strong {
  display: block;
  margin-bottom: 0.1rem;
  color: var(--fleet-text);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.buddy-covenant-note {
  margin: 0.7rem 0 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--fleet-muted);
}

.buddy-covenant-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

/* Secondary companion layer: no second solid gold CTA while matching is offline. */
#buddy-view-companions .buddy-primary {
  background: transparent !important;
  border: 1px solid var(--fleet-line-cool) !important;
  color: var(--fleet-text) !important;
  box-shadow: none !important;
}
