/* Kibbutznik — product theme.
 *
 * Aligned with the marketing brand palette (warm cream + pulse red).
 * Was previously a green/cream variant; the green is preserved as
 * --sage for "deliberation / agreement" states only. Ships no-build
 * via <link> tag.
 */

:root {
  /* Brand tokens — match landing/welcome.html exactly. */
  --bg: #fdf8f0;            /* warm cream */
  --bg-alt: #f4ead8;        /* slightly darker cream for alt sections */
  --bg-card: #fffdf9;
  --text: #2a2520;          /* near-black, slightly warm (welcome --ink) */
  --text-dim: #5a5249;      /* welcome --ink-soft */
  --text-muted: #8a8076;    /* welcome --ink-muted */
  --border: #e8dec9;        /* welcome --line */

  --accent: #e94560;        /* pulse red — same across all surfaces */
  --accent-hover: #d9304a;
  --accent-soft: #fdebee;
  --sage: #6fa885;          /* deliberation / agreement (was the old --accent) */
  --sage-soft: #e5f1ed;
  --gold: #d9a441;          /* AI presence */

  --warn: #d97746;
  --danger: #c14b57;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(20, 24, 38, 0.08);
  --shadow-hover: 0 4px 20px rgba(20, 24, 38, 0.12);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Default <a> in body copy is the brand accent without an underline at rest;
 * underline only on hover for affordance. Chrome elements (.btn, .brand, etc.)
 * suppress the underline entirely — see .btn rules below. */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

header.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: 0.02em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  width: 22px;
  height: 22px;
  display: inline-block;
  flex-shrink: 0;
}

.btn {
  font: inherit;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none; /* anchors styled as buttons must NOT inherit the global underline */
  display: inline-block;
  text-align: center;
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover, a.btn:hover { border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn.primary:hover, a.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: white; box-shadow: var(--shadow-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover, a.btn.ghost:hover { color: var(--text); background: rgba(0,0,0,0.04); }
/* Disabled styling is distinct enough that users don't mistake the "type your
 * email to enable" state for a hard-disabled control. */
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--bg);
  color: var(--text-muted);
  border-color: var(--border);
}
.btn.primary[disabled] { background: #f0d9dd; color: #9a8487; border-color: #f0d9dd; }

.input {
  font: inherit;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: white;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.hero {
  padding: 4rem 1.5rem 3rem;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  margin: 0 0 0.5rem;
}
.hero p {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin: 0 auto 1.5rem;
  max-width: 620px;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.feature {
  padding: 1rem 1.1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.feature-title {
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text);
}
.feature { border-left: 3px solid var(--accent-soft); }

.muted { color: var(--text-dim); font-size: 0.9rem; }
.bold { font-weight: 600; }
.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--accent-soft);
  color: var(--accent);
}

.stack { display: flex; flex-direction: column; gap: 0.8rem; }
.row { display: flex; align-items: center; gap: 0.75rem; }
.row.right { justify-content: flex-end; }

footer.app-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Highlight flash for a freshly-created proposal.
 * Pulses the accent color as a ring + soft background tint for
 * ~3 seconds, then settles back to a plain card. */
@keyframes proposal-new-kf {
    0% {
        background: var(--accent-soft);
        box-shadow: 0 0 0 0 rgba(233, 69, 96, 0.45);
        transform: translateY(-4px);
    }
    40% {
        background: var(--accent-soft);
        box-shadow: 0 0 0 12px rgba(233, 69, 96, 0);
        transform: translateY(0);
    }
    100% {
        background: var(--bg-card);
        box-shadow: none;
        transform: translateY(0);
    }
}
.proposal-new-pulse {
    animation: proposal-new-kf 3s ease-out forwards;
}

/* ── Proposal card (redesigned) ─────────────────────────
 * Matches the landing page mock aesthetic, translated to the app's
 * cream/light theme. Structure: type chip top-left, status badge
 * top-right, author row, title, body, support progress bar with a
 * threshold tick, optional outcome/meta footer.
 */
.proposal-card {
    padding: 1.25rem 1.35rem;
    transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
    cursor: pointer;
    position: relative;
}
.proposal-card:hover { box-shadow: var(--shadow-hover); border-color: var(--accent); }

.proposal-card .pc-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.65rem;
}
.proposal-card .pc-type {
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
    color: var(--accent); text-transform: uppercase;
    display: inline-flex; align-items: center; gap: 0.3rem;
}
.proposal-card .pc-status {
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em;
    padding: 0.22em 0.6em; border-radius: 999px; white-space: nowrap;
    text-transform: uppercase;
}
.pc-status.outthere { color: var(--warn); background: rgba(217,119,70,.12); border:1px solid rgba(217,119,70,.35); }
.pc-status.ontheair { color: var(--accent); background: var(--accent-soft); border:1px solid rgba(59,128,112,.35); }
.pc-status.accepted { color: var(--accent); background: var(--accent-soft); border:1px solid rgba(59,128,112,.45); }
.pc-status.rejected { color: var(--danger); background: rgba(193,75,87,.1); border:1px solid rgba(193,75,87,.3); }
.pc-status.draft,
.pc-status.canceled { color: var(--text-dim); background: rgba(0,0,0,.04); border:1px solid var(--border); }

.proposal-card .pc-author {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.45rem;
}
.pc-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6fb09b);
    color: white; font-size: 0.82rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.pc-author-name { color: var(--text); font-weight: 600; font-size: 0.9rem; }
.pc-author-meta { color: var(--text-dim); font-size: 0.78rem; }

/* Clickable avatars / author names open a member profile modal. */
.pc-avatar.clickable,
.pc-author-name.clickable { cursor: pointer; }
.pc-author-name.clickable:hover { text-decoration: underline; color: var(--accent); }
.pc-avatar.clickable:hover { box-shadow: 0 0 0 2px var(--accent-soft); }
.card.clickable { cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.card.clickable:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); }

.proposal-card .pc-title {
    color: var(--text); font-size: 1.05rem; font-weight: 700;
    margin: 0.4rem 0 0.5rem; line-height: 1.35;
}
.proposal-card .pc-body {
    color: var(--text-dim); font-size: 0.92rem; line-height: 1.5;
    margin-bottom: 1rem;
}

.pc-support { margin: 0.8rem 0 0.2rem; }
.pc-support-labels {
    display: flex; justify-content: space-between;
    font-size: 0.8rem; color: var(--text-dim);
    margin-bottom: 0.35rem;
}
.pc-support-labels strong { color: var(--accent); font-weight: 700; }
.pc-support-track {
    position: relative; height: 7px; border-radius: 4px;
    background: rgba(0,0,0,0.06); overflow: visible;
}
.pc-support-fill {
    height: 100%; border-radius: 4px;
    background: linear-gradient(90deg, var(--accent), #6fb09b);
    box-shadow: 0 0 8px rgba(59,128,112,.4);
    transition: width 0.9s cubic-bezier(.2,.7,.3,1);
}
.pc-threshold-tick {
    position: absolute; top: -4px;
    width: 2px; height: 15px;
    background: var(--text); opacity: 0.35;
}
.pc-threshold-tick::after {
    content: attr(data-label);
    position: absolute; top: 17px; left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem; color: var(--text-dim);
    white-space: nowrap;
}

.pc-footer {
    margin-top: 0.9rem; padding-top: 0.8rem;
    border-top: 1px dashed var(--border);
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.75rem; flex-wrap: wrap;
}
.pc-footer .pc-meta {
    font-size: 0.78rem; color: var(--text-dim);
}
.pc-support-btn {
    font-weight: 600;
}
.pc-support-btn.supported {
    background: var(--accent-soft); color: var(--accent);
    border-color: var(--accent);
}

/* Breadcrumb trail for action-communities: root › action › sub-action.
 * Lives right above the community header. Last crumb is the current
 * action (styled like plain text, not a link). */
.action-breadcrumb {
    display: flex; align-items: center; flex-wrap: wrap;
    font-size: 0.85rem; color: var(--text-dim);
    margin: 0.25rem 0 0.75rem;
    gap: 0.25rem;
}
.action-breadcrumb-item {
    color: var(--accent); cursor: pointer;
    text-decoration: none;
}
.action-breadcrumb-item:hover { text-decoration: underline; }
.action-breadcrumb-item.current {
    color: var(--text); cursor: default; font-weight: 600;
}
.action-breadcrumb-item.current:hover { text-decoration: none; }
.action-breadcrumb-sep { color: var(--text-dim); opacity: 0.6; }

/* Pitch block in the proposal detail modal — the proposer's "why".
 * Accented left border + soft fill so it reads as editorial copy, not
 * metadata. Keeps the modal scannable: title on top, then pitch, then
 * the usual age/support footer. */
.pitch-block {
    margin: 0.6rem 0 0.9rem;
    padding: 0.7rem 0.9rem;
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
}
.pitch-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}
.pitch-text {
    color: var(--text);
    font-size: 0.94rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ── Mobile (<= 640px) ─────────────────────────────────────────
   The proposal-detail modal (and other large card content) was
   pushing past the screen edge on phones — padding stacked from
   overlay + card was eating ~80px on each side, and long unbroken
   strings (UUIDs in val_text, raw JSON for CommitArtifact, URLs
   in pitches) broke layout because nothing had overflow-wrap. */
@media (max-width: 640px) {
    .card {
        padding: 1rem 0.9rem;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    /* Modal overlay was padding:1rem in inline style. Honor that
       still, but make the .card child willing to take FULL width
       inside it. The maxWidth:640 inline style stays a safe cap. */
    .row {
        flex-wrap: wrap;
        gap: 0.5rem;
        min-width: 0;       /* let flex children shrink below content */
    }
    .pill {
        max-width: 100%;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    .pitch-block {
        padding: 0.6rem 0.7rem;
    }
    /* Headings inside cards should hyphenate / wrap rather than
       cause horizontal scroll. */
    .card h1, .card h2, .card h3 {
        overflow-wrap: break-word;
        word-break: break-word;
        hyphens: auto;
    }
}

/* The same break-word treatment is useful at all sizes for code-
   shaped content that bots / agents emit — UUIDs, JSON arrays,
   long compound titles. Costs nothing on desktop (only kicks in
   when a string would actually overflow). */
.card { overflow-wrap: break-word; }
.card h1, .card h2, .card h3, .card p { overflow-wrap: break-word; }

/* ── Modal helpers ─────────────────────────────────────────────
   Three places in app.js render a click-to-dismiss overlay with a
   .card child as the dialog. They were using inline padding:1.4rem
   which beat the .card mobile rule (CSS specificity: inline wins),
   so on phones they overflowed. Move padding into a class so the
   mobile @media block can adjust it. */
.modal-overlay {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(0, 0, 0, 0.55);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-card {
    width: 100%;
    max-height: 92vh;
    overflow: auto;
    padding: 1.4rem;
}
@media (max-width: 640px) {
    .modal-overlay { padding: 0.5rem; }
    .modal-card { padding: 1rem 0.9rem; max-height: 96vh; }
}

/* ── Mobile header collapse ──
 * The desktop header packs "← Home / Kibbutznik / Skills / Sign in" into a
 * justify-between flex row. On a 375px screen the four items wrap to two
 * rows with one orphan label floating. Mobile rules: tighter padding, hide
 * the "← Home" text (keep arrow as icon), and drop the "Skills" link for
 * logged-out visitors (it lives in the menu / Browse for signed-in ones). */
@media (max-width: 640px) {
    header.app-header { padding: 0.55rem 0.85rem; }
    header.app-header .brand { font-size: 1.05rem; }
    header.app-header .home-link-label { display: none; }
    header.app-header .row { gap: 0.5rem; }
}

/* ── Tab strip overflow on community detail ──
 * 7-8 tabs in a single row overflow silently below ~700px. Let them scroll
 * horizontally with no scrollbar chrome; right-edge fade hints there's more. */
.tab-strip {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    position: relative;
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
}
.tab-strip::-webkit-scrollbar { display: none; }
.tab-strip > * { flex-shrink: 0; }

/* ── Activity-feed flash on new event arrival ──
 * Mirror the viewer's "new event" treatment so freshly-streamed proposals
 * pop briefly. Re-uses the same accent-soft tone for cross-surface unity. */
@keyframes new-row-flash {
    0%   { background: var(--accent-soft); }
    100% { background: transparent; }
}
.new-row-flash { animation: new-row-flash 1.6s ease-out forwards; }
