/* ==========================================================================
   Buddy OS Wave2 — 六約守則閣 + 守約同行長廊
   Scope: blissfulife-buddy only. Tokens: --fleet-* only (0 new hex).
   ========================================================================== */

/* ---- porch ghost entry: 讀六約守則 ---- */
.buddy-porch-covenant-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 0.7rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fleet-amber-soft);
  font-family: var(--fleet-ui);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.buddy-porch-covenant-link:hover,
.buddy-porch-covenant-link:focus-visible {
  color: var(--fleet-focus);
}

/* ---- full hall ---- */
.w2-hall {
  position: fixed;
  inset: 0;
  z-index: 10020;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 88px;
  background: var(--fleet-bg);
  color: var(--fleet-text);
}

.w2-hall[hidden] {
  display: none !important;
}

body.w2-hall-open {
  overflow: hidden;
}

.w2-hall__inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 4rem;
}

.w2-hall__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0 0.9rem;
  border-bottom: 1px solid var(--fleet-line-soft);
  background: var(--fleet-bg);
}

.w2-hall__kicker {
  margin: 0;
  font-family: var(--fleet-ui);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fleet-amber-soft);
}

.w2-hall__title {
  margin: 0.25rem 0 0;
  font-family: var(--fleet-ui);
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--fleet-text);
}

.w2-hall__close {
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--fleet-line-cool);
  border-radius: var(--fleet-r-control);
  background: transparent;
  color: var(--fleet-text);
  font-size: 1rem;
  cursor: pointer;
}

.w2-hall__close:hover,
.w2-hall__close:focus-visible {
  border-color: var(--fleet-focus);
  color: var(--fleet-focus);
}

.w2-hall__lead {
  max-width: 74ch;
  margin: 0.9rem 0 1.2rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--fleet-body);
}

/* ---- six covenant plaques / accordion ---- */
.w2-covenants {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: start;
  margin: 0 0 2rem;
}

.w2-covenant {
  border: 1px solid var(--fleet-line-cool);
  border-radius: var(--fleet-r-card);
  background: var(--fleet-surface);
  overflow: hidden;
}

.w2-covenant[open] {
  border-color: var(--fleet-line);
}

.w2-covenant summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 48px;
  padding: 0.8rem 0.9rem;
  cursor: pointer;
  list-style: none;
  color: var(--fleet-text);
  font-family: var(--fleet-ui);
  font-size: 0.9rem;
  font-weight: 800;
}

.w2-covenant summary::-webkit-details-marker {
  display: none;
}

.w2-covenant summary::after {
  content: "+";
  margin-left: auto;
  color: var(--fleet-amber-soft);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.w2-covenant[open] summary::after {
  content: "−";
}

.w2-covenant__no {
  flex: none;
  min-width: 22px;
  color: var(--fleet-amber-soft);
  font-size: 9.5px;
  letter-spacing: 0.08em;
}

.w2-covenant__title {
  flex: 1;
  min-width: 0;
}

.w2-covenant__body {
  margin: 0 0.9rem;
  padding: 0.65rem 0 0.85rem;
  border-top: 1px solid var(--fleet-line-soft);
  color: var(--fleet-muted-strong);
  font-size: 0.84rem;
  line-height: 1.55;
}

/* ---- corridor / steps ---- */
.w2-corridor {
  margin-top: 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--fleet-line-cool);
}

.w2-corridor__title {
  margin: 0.2rem 0 0.8rem;
  font-family: var(--fleet-ui);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--fleet-text);
}

.w2-tier-note {
  margin: -0.35rem 0 0.8rem;
  color: var(--fleet-muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.w2-steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.w2-step {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.8rem;
  border: 1px solid var(--fleet-line-soft);
  border-radius: var(--fleet-r-control);
  background: var(--fleet-surface);
}

.w2-step__num {
  flex: none;
  color: var(--fleet-amber-soft);
  font-family: var(--fleet-ui);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.w2-step__body {
  min-width: 0;
}

.w2-badge {
  display: inline-block;
  margin-bottom: 0.25rem;
  padding: 0.14rem 0.45rem;
  border: 1px solid var(--fleet-line);
  border-radius: var(--fleet-r-pill);
  color: var(--fleet-amber-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.w2-step__title {
  margin: 0.1rem 0 0.15rem;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--fleet-text);
}

.w2-step__line {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--fleet-muted);
}

/* ---- cross-day context ---- */
.w2-context {
  margin-top: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--fleet-line-cool);
  border-radius: var(--fleet-r-card);
  background: var(--fleet-surface);
}

.w2-context__head h3 {
  margin: 0.15rem 0 0.5rem;
  font-size: 0.98rem;
  color: var(--fleet-text);
}

.w2-context__list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.w2-context__list li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--fleet-line-soft);
  border-radius: var(--fleet-r-control);
  background: var(--fleet-bg);
}

.w2-context__day {
  flex: none;
  color: var(--fleet-muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.w2-context__text {
  flex: 1;
  min-width: 0;
  color: var(--fleet-text);
  font-size: 0.8rem;
  line-height: 1.4;
  word-break: break-word;
}

.w2-context__time {
  flex: none;
  color: var(--fleet-muted);
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
}

.w2-context__empty {
  margin: 0.3rem 0 0;
  color: var(--fleet-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ---- L3 draft ---- */
.w2-l3 {
  margin-top: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--fleet-line-cool);
  border-radius: var(--fleet-r-card);
  background: var(--fleet-surface);
}

.w2-l3 label {
  display: block;
  margin: 0.3rem 0 0.35rem;
  color: var(--fleet-body);
  font-size: 0.8rem;
  font-weight: 700;
}

.w2-l3 textarea {
  width: 100%;
  min-height: 104px;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--fleet-line-cool);
  border-radius: var(--fleet-r-control);
  background: var(--fleet-bg);
  color: var(--fleet-text);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
}

.w2-l3 textarea:focus-visible {
  outline: 2px solid var(--fleet-focus);
  outline-offset: 2px;
}

.w2-l3__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.55rem;
}

/* ---- cloud seal status (local / syncing / synced / error) ---- */
.buddy-seal-sync {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
  color: var(--fleet-muted);
  font-family: var(--fleet-ui);
  font-size: 0.7rem;
  line-height: 1.4;
}

.buddy-seal-sync::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--fleet-muted);
}

.buddy-seal-sync[data-state="syncing"] {
  color: var(--fleet-body);
}

.buddy-seal-sync[data-state="syncing"]::before {
  background: var(--fleet-amber);
}

.buddy-seal-sync[data-state="synced"] {
  color: var(--fleet-jade-text);
}

.buddy-seal-sync[data-state="synced"]::before {
  background: var(--fleet-jade);
}

.buddy-seal-sync[data-state="error"] {
  color: var(--fleet-body);
}

.buddy-seal-sync[data-state="error"]::before {
  background: var(--fleet-muted-strong);
}

.w2-context-sync {
  margin: 0.35rem 0 0;
  padding-left: 0.1rem;
}

/* ---- L4 gate entry ---- */
#buddy-pro-gate {
  background: var(--fleet-scrim) !important;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.w2-l4 {
  margin-top: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--fleet-line);
  border-radius: var(--fleet-r-card);
  background: var(--fleet-surface);
}

.w2-l4__line {
  margin: 0.2rem 0 0.6rem;
  color: var(--fleet-body);
  font-size: 0.82rem;
  line-height: 1.5;
}

.w2-status {
  display: inline-block;
  margin: 0.45rem 0 0;
  color: var(--fleet-muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

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

.w2-status[data-kind="ok"] {
  color: var(--fleet-jade-text);
}

.w2-hall__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

/* ---- old companion layer containment ---- */
#buddy-view-companions::before {
  content: "舊同行入口 · 已收納。新路徑：由前簷「讀六約守則」或落印匣「了解守約同行」進入六約守則閣／守約同行長廊。";
  display: block;
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--fleet-line-soft);
  border-radius: var(--fleet-r-control);
  background: var(--fleet-surface);
  color: var(--fleet-muted-strong);
  font-size: 0.78rem;
  line-height: 1.5;
}

#buddy-view-companions .rpg-hud,
#buddy-view-companions .buddy-gamify-section {
  display: none !important;
}

/* ---- responsive ---- */
@media (max-width: 1000px) {
  .w2-covenants {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .w2-hall__inner {
    padding: 0.9rem 0.9rem 3rem;
  }

  .w2-hall__title {
    font-size: 1.6rem;
  }

  .w2-covenants {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
  }

  .w2-steps {
    grid-template-columns: 1fr;
  }

  .w2-step {
    padding: 0.7rem;
  }

  .w2-context__list li {
    flex-wrap: wrap;
  }

  .w2-context__time {
    margin-left: auto;
  }

  .w2-hall__actions {
    flex-direction: column;
  }

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

@media (prefers-reduced-motion: reduce) {
  .w2-hall {
    scroll-behavior: auto;
  }
}
