/* ==========================================================================
   Waidrn — funding.css (v1.3 Phase 0 project page / funding UI)
   Proposal 04 + review fixes 05 §2.2–2.11. Uses the app design tokens so light
   and dark themes both work. All interactive targets are >= 44px.
   ========================================================================== */

/* ------------------------------------------------------------------ hero */
.fund-hero {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 1.15rem;
  padding: 1.1rem 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 1rem;
}

.fund-hero-cover {
  width: 120px;
  height: 180px;
  border-radius: 10px;
  border: 1px solid var(--gold-line);
  background:
    linear-gradient(155deg, var(--gold-ghost), transparent 55%),
    radial-gradient(120px 60px at 30% 10%, var(--gold-ghost), transparent 70%),
    var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fund-hero-initial {
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--gold);
  opacity: 0.85;
}

.fund-hero-main { min-width: 0; }
.fund-hero h1 { margin: 0.2rem 0 0.35rem; line-height: 1.15; }
.fund-hero-badges { margin: 0.2rem 0 0.45rem; }

.fund-pitch {
  margin: 0.35rem 0 0.5rem;
  font-size: var(--fs-base);
  color: var(--ink-2);
  max-width: 72ch;
}

.fund-hero-meta { margin: 0.25rem 0 0.5rem; }

.fund-tagbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.4rem 0 0.65rem;
}

.fund-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0 0.85rem;
}

.fund-hero-actions .btn,
.fund-hero-actions a.btn { min-height: 44px; display: inline-flex; align-items: center; }

/* funding state strip */
.fund-strip {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
}

.fund-strip-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.4rem;
  font-size: var(--fs-lg);
  color: var(--ink);
}

.fund-strip-phase { font-weight: 600; color: var(--gold); }
.fund-strip-clock { color: var(--ink-2); }

.fund-strip-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin-top: 0.3rem;
}

.fund-seal { color: var(--info); }
.fund-draft-terms { color: var(--warn); }

/* lock story above the fold */
.fund-lock-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 0.9rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-inset);
}

.fund-lock-step {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.fund-lock-step-n {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--gold-line);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
}

.fund-lock-step strong { color: var(--ink); }

.fund-lock-steps-compact {
  grid-template-columns: 1fr;
  margin-top: 0.75rem;
}

/* ---------------------------------------------------------- main 3 columns */
.fund-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 380px;
  gap: 1rem;
  align-items: start;
}

.fund-col-ladder { position: sticky; top: 84px; min-width: 0; }
.fund-col-pool { position: sticky; top: 84px; min-width: 0; }
.fund-col-content { min-width: 0; }

/* --------------------------------------------------------------- the ladder */
.fund-ladder { padding: 0.9rem; }
.fund-rungs {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.fund-rung {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 0.35rem;
  padding: 0.55rem 0 0.75rem;
  border-left: 2px solid var(--line);
  margin-left: 15px;
  border-radius: 0;
}

.fund-rung:last-child { border-left-color: transparent; }
.fund-rung-body { min-width: 0; padding-right: 0.25rem; }

.fund-rung-rail {
  position: relative;
  left: -18px;
  width: 34px;
  display: flex;
  justify-content: center;
}

.fund-rung-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink-3);
  font-size: 14px;
}

.fund-rung-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem;
}

.fund-rung-pos {
  font-family: var(--font-display);
  color: var(--gold);
  font-weight: 600;
}

.fund-rung-head h3 {
  margin: 0;
  font-size: var(--fs-md);
  flex: 1 1 100%;
  order: 3;
}

.fund-rung-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  margin: 0.3rem 0;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.fund-rung-share {
  height: 6px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
  margin: 0.25rem 0 0.35rem;
}

.fund-share-bar {
  height: 100%;
  min-width: 2px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
}

.fund-rung-threads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.chip-thread {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.chip-review { border-color: var(--warn); color: var(--warn); }

.fund-rung-evidence {
  border-left: 2px solid var(--ok);
  padding-left: 0.5rem;
  margin: 0.35rem 0 0.25rem;
}

.fund-rung-evidence a { word-break: break-all; }

/* states */
.fund-rung-passed .fund-rung-glyph { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }
.fund-rung-building .fund-rung-glyph { color: var(--gold); border-color: var(--gold); background: var(--gold-ghost); }
.fund-rung-funding .fund-rung-glyph { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
.fund-rung-vote { border-left-color: var(--gold); }
.fund-rung-vote .fund-rung-glyph { color: var(--gold-bright); border-color: var(--gold-bright); background: var(--gold-ghost); }
.fund-rung-failed .fund-rung-glyph { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }
.fund-rung-failed .fund-rung-head h3 { color: var(--ink-3); text-decoration: line-through; }
.fund-rung-live {
  background: var(--surface-2);
  border: 1px solid var(--gold-line);
  border-left: 2px solid var(--gold);
  border-radius: 10px;
  margin-left: 15px;
  padding-right: 0.5rem;
}

/* active boundary decision block (proposal 04 §3.5 / review 2.4) */
.fund-decision {
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  padding: 0.7rem;
  margin-top: 0.55rem;
  background: var(--surface-inset);
}
.fund-decision h4 { margin: 0 0 0.35rem; font-size: var(--fs-md); }
.fund-default { color: var(--ink-2); margin: 0.15rem 0 0.35rem; }
.fund-leave-form { margin: 0.35rem 0; }
.fund-leave-form .btn-lg,
.fund-decision .btn-lg { min-height: 44px; }

.tone-danger { color: var(--danger); }
.tone-ok { color: var(--ok); }
.tone-warn { color: var(--warn); }
.tone-muted { color: var(--ink-3); }
.tone-active { color: var(--gold); }
.tone-vote { color: var(--gold-bright); }

/* share timeline */
.fund-share-timeline {
  border-top: 1px solid var(--line);
  margin-top: 0.8rem;
  padding-top: 0.7rem;
}
.fund-subtitle { font-size: var(--fs-md); margin: 0.4rem 0 0.5rem; }
.fund-share-bars { display: flex; flex-direction: column; gap: 0.25rem; }
.fund-share-row {
  display: grid;
  grid-template-columns: 2rem 3rem minmax(0, 1fr);
  gap: 0.4rem;
  align-items: center;
}
.fund-share-label { color: var(--gold); font-size: var(--fs-sm); }
.fund-share-value { color: var(--ink-2); font-size: var(--fs-sm); text-align: right; }
.fund-share-track {
  height: 10px;
  background: var(--surface-3);
  border-radius: 6px;
  overflow: hidden;
}
.fund-share-fill { height: 100%; background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright)); }
.fund-share-sentence { margin: 0.5rem 0 0; font-size: var(--fs-sm); }

/* ------------------------------------------------------------ pool panel */
.fund-pool { padding: 0.9rem; }

.fund-waterfall {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: var(--surface-inset);
  margin-bottom: 0.55rem;
}
.fund-waterfall-line {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.12rem 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
}
.fund-waterfall-line strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.fund-waterfall-locked { border-top: 1px dashed var(--line-strong); margin-top: 0.25rem; padding-top: 0.35rem; }
.fund-waterfall-locked strong { color: var(--gold); }

.fund-invariant { font-size: var(--fs-xs); line-height: 1.45; }

.fund-target { margin: 0.5rem 0; }
.fund-target-head { display: flex; justify-content: space-between; gap: 0.5rem; font-size: var(--fs-sm); }
.fund-target-head strong { color: var(--gold); font-variant-numeric: tabular-nums; }

.fund-progress {
  height: 12px;
  border-radius: 7px;
  background: var(--surface-3);
  overflow: hidden;
  margin: 0.3rem 0;
}
.fund-progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright)); }

.fund-rails { font-size: var(--fs-sm); }
.fund-census { color: var(--ink-2); }
.fund-patrons summary { min-height: 36px; display: flex; align-items: center; cursor: pointer; }

/* MY PLEDGE panel */
.fund-mypledge {
  border: 1px solid var(--gold-line);
  border-radius: 10px;
  padding: 0.75rem;
  margin-top: 0.8rem;
  background: var(--surface-2);
}
.fund-mypledges { display: flex; flex-direction: column; gap: 0.7rem; }
.fund-mypledge-row {
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.55rem;
}
.fund-mypledge-row:last-child { border-bottom: 0; }
.fund-mypledge-closed { opacity: 0.75; }

.fund-pledge-form { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.4rem; }
.fund-quick-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.fund-quick-chips .chip { min-height: 44px; min-width: 44px; justify-content: center; }

.fund-visibility {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin: 0;
}
.fund-visibility legend { color: var(--gold); font-size: var(--fs-sm); padding: 0 0.3rem; }
.fund-visibility label { min-height: 44px; display: flex; align-items: center; gap: 0.45rem; }
.fund-visibility-form { margin: 0.35rem 0; }
.fund-visibility-form .field { max-width: 320px; }

.fund-leave-calc {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  margin-top: 0.4rem;
  background: var(--surface-inset);
}
.fund-leave-calc h4 { margin: 0 0 0.3rem; font-size: var(--fs-sm); color: var(--gold); }
.fund-calc-rows { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.15rem 0.6rem; margin: 0.2rem 0; }
.fund-calc-rows dt { color: var(--ink-2); font-size: var(--fs-sm); }
.fund-calc-rows dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* disclosure */
.fund-disclosure {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  margin-top: 0.8rem;
  background: var(--surface-inset);
}
.fund-disclosure summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--gold); }
.fund-disclosure-body { padding-bottom: 0.4rem; }
.fund-disclosure-body li { margin: 0.2rem 0; }

/* ---------------------------------------------------------- content column */
.fund-col-content .card { margin-bottom: 0.9rem; }
.fund-evidence { display: flex; flex-direction: column; gap: 0.6rem; }
.fund-evidence-row { border-left: 2px solid var(--ok); padding-left: 0.55rem; }
.fund-evidence-row header { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; }
.fund-evidence-row .badges { margin-left: auto; }

.fund-discussion-split {
  display: grid;
  grid-template-columns: minmax(0, 0.62fr) minmax(0, 1fr);
  gap: 0.9rem;
}
.fund-thread-nav ul { display: flex; flex-direction: column; gap: 0.2rem; }
.fund-thread-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}
.fund-thread-link:hover { background: var(--gold-ghost); }
.fund-thread-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fund-thread-preview {
  border-left: 1px solid var(--line);
  padding-left: 0.85rem;
}

.fund-project-actions { display: flex; flex-wrap: wrap; gap: 0.15rem 0.4rem; margin-top: 0.4rem; }

.fund-stalled-banner { border: 1px solid var(--danger); background: var(--danger-bg); }
.fund-stalled-banner .card-title { color: var(--danger); }

/* --------------------------------------------------------------- mobile bar */
.fund-mobile-bar { display: none; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1279px) {
  .fund-layout { grid-template-columns: 270px minmax(0, 1fr); }
  .fund-col-pool { grid-column: 1 / -1; position: static; }
  .fund-col-ladder { top: 72px; }
}

@media (max-width: 899px) {
  .fund-hero { grid-template-columns: 84px minmax(0, 1fr); }
  .fund-hero-cover { width: 84px; height: 126px; }
  .fund-lock-steps { grid-template-columns: 1fr; }
  .fund-discussion-split { grid-template-columns: 1fr; }
  .fund-thread-preview { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 0.6rem; }
}

@media (max-width: 767px) {
  .fund-layout { display: flex; flex-direction: column; }
  .fund-col-ladder, .fund-col-pool { position: static; width: 100%; }

  /* the ladder becomes a horizontal stepper (proposal 03 §7.2) */
  .fund-rungs {
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.35rem;
    gap: 0.5rem;
  }
  .fund-rung {
    flex: 0 0 82%;
    scroll-snap-align: start;
    border-left: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin: 0;
    grid-template-columns: 28px minmax(0, 1fr);
  }
  .fund-rung-live { margin: 0; border-color: var(--gold-line); }
  .fund-rung:last-child { border-left: 1px solid var(--line); }
  .fund-rung-rail { left: -6px; }

  .fund-hero { padding: 0.8rem; }
  .fund-hero-actions .btn { flex: 1 1 auto; justify-content: center; }

  /* sticky fund bar on phones */
  .fund-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 0.55rem max(0.75rem, env(safe-area-inset-left)) calc(0.55rem + env(safe-area-inset-bottom));
    background: var(--header-bg);
    border-top: 1px solid var(--line-strong);
    backdrop-filter: blur(8px);
    font-size: var(--fs-sm);
  }
  .fund-mobile-bar .btn { min-height: 44px; }
  body { padding-bottom: 74px; }
}

@media (max-width: 420px) {
  .fund-hero { grid-template-columns: 1fr; }
  .fund-hero-cover { width: 100%; height: 96px; }
  .fund-hero-initial { font-size: 2.2rem; }
}

/* motion-safe + focus */
.fund-layout a:focus-visible,
.fund-layout button:focus-visible,
.fund-hero a:focus-visible,
.fund-hero button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

@media print {
  .fund-col-ladder, .fund-col-pool, .fund-mobile-bar { position: static; }
  .fund-mobile-bar { display: none; }
}

/* follow-ups: claim vote, share, top-up, rung links */
.fund-claim-vote { border: 1px solid var(--gold-line); background: var(--surface-2); }
.fund-claim-vote .inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.fund-claim-vote .inline-form label { min-height: 44px; display: inline-flex; align-items: center; gap: 0.35rem; }

.fund-share summary {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  color: var(--gold);
}
.fund-share input {
  min-height: 44px;
  width: min(100%, 320px);
}

.fund-rung-links { margin: 0.25rem 0 0; }
.fund-rung-links a { min-height: 36px; display: inline-flex; align-items: center; }

.fund-topup-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: end;
  margin: 0.4rem 0;
}
.fund-topup-form .field { min-width: 140px; margin: 0; }
.fund-topup-form select { min-height: 44px; }
.fund-topup-form .btn { min-height: 44px; }

/* live milestone badge/state (never the bare token "active") */
.badge-live { border-color: var(--gold); color: var(--gold); background: var(--gold-ghost); }
.tone-live { color: var(--gold); }
