/* ============================================================
   ROOTS — styles.css
   ============================================================ */

/* ─── TOKENS ─── */
:root {
  --bg:          #0c0c0c;
  --surface:     #141414;
  --surface-2:   #1a1a1a;
  --border:      #242424;
  --border-hi:   #333;
  --text:        #ede8de;
  --text-mid:    #999;
  --text-dim:    #555;
  --accent:      #d6f536;
  --accent-dim:  rgba(214,245,54,.08);
  --accent-glow: rgba(214,245,54,.25);
  --general:     #a78bfa;
  --fuego:       #ff6b35;
  --heart:       #f87171;
  --inter:       #38bdf8;
  --neutral:     #94a3b8;
  --muerto:      #555;
  --radius:      4px;
  --font-head:   'Bebas Neue', sans-serif;
  --font-body:   'DM Mono', monospace;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 13px; line-height: 1.65; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

/* ─── DEMO BANNER ─── */
#demoBanner { display: none; padding: 7px 20px; background: rgba(214,245,54,.06); border-bottom: 1px solid rgba(214,245,54,.15); font-size: 11px; color: var(--text-dim); text-align: center; }
#demoBanner.visible { display: block; }
#demoBanner strong { color: var(--accent); }

/* ─── HEADER ─── */
header { position: sticky; top: 0; z-index: 100; height: 52px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; background: rgba(12,12,12,.95); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
.logo { font-family: var(--font-head); font-size: 26px; letter-spacing: 4px; color: var(--accent); cursor: pointer; user-select: none; transition: opacity .15s; }
.logo:hover { opacity: .8; }
.header-right { display: flex; align-items: center; gap: 10px; }

/* Session pill */
.session-pill { display: flex; align-items: center; gap: 5px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 20px; font-size: 11px; color: var(--text-dim); cursor: pointer; transition: all .15s; user-select: none; }
.session-pill:hover { border-color: var(--accent-glow); color: var(--text-mid); }
.session-pill strong { color: var(--text-mid); }
.session-pill:hover strong { color: var(--accent); }
.nick-edit-hint { font-size: 10px; opacity: 0; transition: opacity .15s; }
.session-pill:hover .nick-edit-hint { opacity: 1; }

/* ─── MODAL ─── */
.modal-overlay { position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border-hi); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 360px; }
.modal-title { font-family: var(--font-head); font-size: 24px; letter-spacing: 1px; margin-bottom: 6px; }
.modal-desc { font-size: 11px; color: var(--text-dim); margin-bottom: 16px; line-height: 1.6; }
.nick-input { width: 100%; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-family: var(--font-body); font-size: 13px; outline: none; transition: border-color .15s; margin-bottom: 14px; }
.nick-input:focus { border-color: var(--accent-glow); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ─── BUTTONS ─── */
.btn { font-family: var(--font-body); font-size: 12px; padding: 6px 14px; border: none; border-radius: var(--radius); cursor: pointer; letter-spacing: .3px; transition: all .15s; }
.btn-primary { background: var(--accent); color: #0c0c0c; font-weight: 500; }
.btn-primary:hover { background: #c5e020; transform: translateY(-1px); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-hi); }
.btn-back { background: transparent; border: none; color: var(--text-dim); font-family: var(--font-body); font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 5px; padding: 6px 0; transition: color .15s; }
.btn-back:hover { color: var(--text); }

/* ─── LAYOUT ─── */
main { max-width: 880px; margin: 0 auto; padding: 28px 20px 80px; }

/* ─── HOME HERO ─── */
.home-hero { padding: 28px 0 24px; margin-bottom: 26px; border-bottom: 1px solid var(--border); }
.home-hero h1 { font-family: var(--font-head); font-size: clamp(36px, 9vw, 68px); letter-spacing: 2px; line-height: 1; margin-bottom: 10px; }
.home-hero h1 em { color: var(--accent); font-style: normal; }
.home-hero p { font-size: 12px; color: var(--text-dim); max-width: 380px; }
.section-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 12px; }

/* ─── ROOTS GRID ─── */
.roots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }

.root-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: all .15s; }
.root-card:hover { background: var(--surface-2); border-color: var(--border-hi); transform: translateY(-2px); }

.root-card.general { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-color: rgba(167,139,250,.4); }
.root-card.general:hover { background: rgba(167,139,250,.05); border-color: var(--general); }
.root-card.general .lang-badge { border-color: rgba(167,139,250,.3); color: var(--general); }
.card-left { flex: 1; min-width: 0; }
.card-right { flex-shrink: 0; }

.root-card.new-root { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 108px; border-style: dashed; border-color: var(--border-hi); color: var(--text-dim); text-align: center; }
.root-card.new-root:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); transform: translateY(-2px); }
.new-root .card-plus { font-size: 28px; line-height: 1; margin-bottom: 5px; }
.new-root .card-label { font-size: 11px; letter-spacing: .5px; }

.card-dot { width: 8px; height: 8px; border-radius: 50%; margin-bottom: 10px; flex-shrink: 0; }
.card-title { font-family: var(--font-head); font-size: 20px; letter-spacing: 1px; margin-bottom: 4px; }
.root-card.general .card-title { font-size: 26px; }
.card-desc { font-size: 11px; color: var(--text-dim); margin-bottom: 10px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.root-card.general .card-desc { margin-bottom: 0; }
.card-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 10px; color: var(--text-dim); }
.card-meta span { display: flex; align-items: center; gap: 3px; }
.lang-badge { font-size: 10px; padding: 2px 7px; border: 1px solid var(--border-hi); border-radius: 20px; color: var(--text-dim); }

/* ─── ROOT VIEW ─── */
.root-header { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.root-title { font-family: var(--font-head); font-size: clamp(28px, 8vw, 54px); letter-spacing: 2px; line-height: 1; margin-bottom: 8px; }
.root-desc { font-size: 13px; color: var(--text-mid); margin-bottom: 14px; }
.bases-box { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 10px 14px; font-size: 12px; color: var(--text-mid); border-radius: var(--radius); margin-bottom: 12px; }
.bases-label { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 3px; }
.root-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 11px; color: var(--text-dim); }

/* ─── POST FORM ─── */
.post-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 22px; }
.post-form-header { font-size: 11px; color: var(--text-dim); margin-bottom: 9px; }
.post-form-header strong { color: var(--accent); }

textarea { width: 100%; min-height: 80px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-family: var(--font-body); font-size: 13px; line-height: 1.6; resize: vertical; outline: none; transition: border-color .15s; }
textarea:focus { border-color: var(--accent-glow); }
textarea::placeholder { color: var(--text-dim); }

/* Image attach area */
.attach-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.attach-btn { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; background: transparent; border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font-body); font-size: 11px; color: var(--text-dim); cursor: pointer; transition: all .15s; }
.attach-btn:hover { border-color: var(--border-hi); color: var(--text-mid); }
.attach-btn.has-image { border-color: var(--accent-glow); color: var(--accent); }
.image-preview-wrap { position: relative; display: inline-block; margin-top: 8px; }
.image-preview { display: block; max-height: 160px; max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); object-fit: cover; }
.image-remove { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; background: rgba(0,0,0,.7); border: none; border-radius: 50%; color: var(--text); font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; transition: background .15s; }
.image-remove:hover { background: rgba(255,60,60,.7); }

.form-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.char-count { font-size: 11px; color: var(--text-dim); }
.char-count.over { color: var(--fuego); }

/* ─── POSTS LIST ─── */
.posts-list { display: flex; flex-direction: column; gap: 10px; }

.post-block { display: flex; flex-direction: column; }

/* Post card */
.post { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; transition: border-color .15s; }
.post:hover { border-color: var(--border-hi); }

/* Reply variant — indented */
.post.reply { background: transparent; border: 1px solid var(--border); border-left: 2px solid var(--border-hi); border-radius: 0 var(--radius) var(--radius) 0; margin-left: 20px; margin-top: 6px; padding: 10px 14px; }
.post.reply:hover { border-left-color: var(--accent-glow); }

.post-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.post-nick { font-size: 12px; color: var(--text-mid); }
.post-nick.is-me { color: var(--accent); }
.you-tag { padding: 1px 5px; background: var(--accent-dim); border: 1px solid var(--accent-glow); border-radius: 2px; font-size: 9px; letter-spacing: .5px; color: var(--accent); }
.post-time { font-size: 10px; color: var(--text-dim); }

.post-content { font-size: 13px; line-height: 1.7; margin-bottom: 10px; white-space: pre-wrap; word-break: break-word; }
.post-content .mention { color: var(--accent); font-weight: 500; }

/* Post image */
.post-image { display: block; max-width: 100%; max-height: 320px; border-radius: var(--radius); border: 1px solid var(--border); object-fit: cover; margin-bottom: 10px; cursor: zoom-in; }

.post-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }

/* Reaction buttons */
.rxn-btn { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; font-family: var(--font-body); font-size: 11px; color: var(--text-dim); cursor: pointer; transition: all .15s; }
.rxn-btn:hover { border-color: var(--border-hi); color: var(--text-mid); }
.rxn-btn.active-fuego      { background: rgba(255,107,53,.10); border-color: rgba(255,107,53,.4); color: var(--fuego); }
.rxn-btn.active-heart      { background: rgba(248,113,113,.10); border-color: rgba(248,113,113,.4); color: var(--heart); }
.rxn-btn.active-interesante{ background: rgba(56,189,248,.10);  border-color: rgba(56,189,248,.4);  color: var(--inter); }
.rxn-btn.active-neutral    { background: rgba(148,163,184,.10); border-color: rgba(148,163,184,.4); color: var(--neutral); }
.rxn-btn.active-muerto     { background: rgba(85,85,85,.15);    border-color: rgba(85,85,85,.4);    color: #888; }

/* Reply button — visible, accented */
.reply-btn { margin-left: auto; padding: 3px 11px; background: var(--accent-dim); border: 1px solid var(--accent-glow); border-radius: 20px; font-family: var(--font-body); font-size: 11px; color: var(--accent); cursor: pointer; transition: all .15s; }
.reply-btn:hover { background: rgba(214,245,54,.15); border-color: var(--accent); }
.reply-btn.active { background: rgba(214,245,54,.12); border-color: var(--accent); }

/* Replies thread */
.thread { display: flex; flex-direction: column; }

/* Collapsed state — hidden by default, toggled via JS */
.thread-collapsed { display: none; }

.thread-toggle { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; margin-left: 20px; padding: 3px 0; background: transparent; border: none; font-family: var(--font-body); font-size: 11px; color: var(--text-dim); cursor: pointer; transition: color .15s; }
.thread-toggle:hover { color: var(--text-mid); }

/* Custom reaction images */
.rxn-icon { width: 14px; height: 14px; object-fit: contain; vertical-align: middle; display: inline-block; }

/* Inline reply form */
.reply-form { margin-top: 8px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.reply-form.indented { margin-left: 20px; }
.reply-form textarea { min-height: 60px; font-size: 12px; }

/* ─── IMAGE LIGHTBOX ─── */
.lightbox { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox.hidden { display: none; }
.lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: var(--radius); }

/* ─── CREATE ROOT FORM ─── */
.create-wrapper { max-width: 520px; }
.create-header { margin-bottom: 26px; }
.create-header h1 { font-family: var(--font-head); font-size: 42px; letter-spacing: 2px; margin-bottom: 6px; }
.create-header h1 em { color: var(--accent); font-style: normal; }
.create-header p { font-size: 12px; color: var(--text-dim); line-height: 1.6; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px; }
input[type="text"], select { width: 100%; padding: 9px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-family: var(--font-body); font-size: 13px; outline: none; transition: border-color .15s; -webkit-appearance: none; }
input[type="text"]:focus, select:focus { border-color: var(--accent-glow); }
input::placeholder { color: var(--text-dim); }
select option { background: #1a1a1a; }
.form-hint { font-size: 11px; color: var(--text-dim); margin-top: 5px; }
.create-footer { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.create-note { font-size: 11px; color: var(--text-dim); }

/* ─── UTILITY ─── */
.empty-state { padding: 48px 20px; text-align: center; color: var(--text-dim); }
.empty-state p { font-size: 13px; line-height: 1.8; margin-bottom: 14px; }
.loading { padding: 36px; text-align: center; font-size: 12px; letter-spacing: 1px; color: var(--text-dim); }

/* ─── TOAST ─── */
.toast { position: fixed; bottom: 24px; right: 24px; z-index: 9999; padding: 10px 16px; background: var(--surface-2); border: 1px solid var(--border-hi); border-radius: var(--radius); font-size: 12px; color: var(--text); pointer-events: none; animation: toastIn .18s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ─── PINNED POSTS ─── */
/* Pinned posts get a subtle accent border and float to the top */
.post.pinned {
  border-color: rgba(214, 245, 54, 0.35);
  background: rgba(214, 245, 54, 0.03);
}

.post.pinned:hover {
  border-color: rgba(214, 245, 54, 0.55);
}

/* The pin badge shown inside pinned cards */
.pin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  padding: 2px 8px;
  background: rgba(214, 245, 54, 0.08);
  border: 1px solid rgba(214, 245, 54, 0.25);
  border-radius: 20px;
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--accent);
}

/* ─── ALGO INFO CHIP ─── */
/* Small chip shown in root footer explaining the community algorithm */
.algo-chip {
  font-size: 10px;
  color: var(--text-dim);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: help;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 480px) {
  main { padding: 16px 12px 60px; }
  .pill-label { display: none; }
  .root-card.general { flex-direction: column; align-items: flex-start; }
  .post-actions { gap: 4px; }
  .rxn-btn { padding: 3px 7px; font-size: 10px; }
}