/* ============================================================
   Mycelial - Components
   Drop-in CSS for every UI surface specified in the design doc.
   Depends on tokens.css, typography.css, animations.css.
   ============================================================ */

/* ---------- Glyph chip (source mark container) ---------- */
.glyph-chip {
  width: var(--chip-size);
  height: var(--chip-size);
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.glyph-chip svg { width: 1rem; height: 1rem; color: rgba(255,255,255,0.92); }

/* ---------- Sticky header ---------- */
.m-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(20, 20, 22, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 1rem 0.7rem;
  display: flex; flex-direction: column; gap: 0.7rem;
}
.m-header .top-row {
  display: flex; align-items: center; gap: 0.85rem;
}
.m-header .title {
  font-family: var(--serif); font-size: 1.05rem; color: var(--fg);
  flex: 1; letter-spacing: 0.02em;
}
.m-header .title em {
  font-style: italic; color: var(--fg-muted); font-size: 0.85rem;
  margin-left: 0.5rem;
}
.m-header .mushroom-toggle {
  width: 24px; height: 24px; color: var(--fg-muted); cursor: pointer;
}
.m-header .mushroom-toggle:hover { color: var(--fg); }

/* ---------- Window mode selector (Today / Recent / Unread / All) ---------- */
.window-modes {
  display: flex; gap: 0.15rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--rule); border-radius: 0.4rem;
  padding: 0.15rem;
}
.window-modes .mode {
  display: flex; align-items: center; gap: 0.35rem;
  font-family: var(--mono); font-size: var(--fs-system); letter-spacing: 0.12em;
  color: var(--fg-muted); text-transform: uppercase;
  padding: 0.35rem 0.55rem; border-radius: 0.3rem;
  cursor: pointer;
  transition: background var(--dur-micro), color var(--dur-micro);
}
.window-modes .mode svg { width: 12px; height: 12px; }
.window-modes .mode:hover { color: var(--fg); }
.window-modes .mode.active {
  background: rgba(142,255,176,0.10);
  color: var(--fg);
}
.window-modes .mode.active::before {
  content: ""; width: 4px; height: 4px; border-radius: 50%;
  background: var(--spore);
  box-shadow: 0 0 5px 1px rgba(142,255,176,0.6);
  margin-right: 0.1rem;
}

/* ---------- Spectrum slider ---------- */
.slider-bar {
  position: relative; height: 18px;
  border-radius: 9px;
  background: linear-gradient(90deg,
    var(--temp-coolest) 0%, var(--temp-cool) 16.6%, var(--temp-mid-cool) 33.3%,
    var(--temp-mid) 50%, var(--temp-mid-warm) 66.6%, var(--temp-warm) 83.3%,
    var(--temp-warmest) 100%);
  cursor: pointer;
  transition: filter var(--dur-settle) ease, box-shadow var(--dur-settle) ease;
}
.slider-bar.shuffle {
  /* Disengaged - shuffle on, no thumb, full luminance */
  box-shadow: 0 0 16px 1px rgba(142,255,176,0.18),
              inset 0 0 0 1px rgba(255,255,255,0.05);
  filter: saturate(1.05) brightness(1.05);
}
.slider-bar.engaged {
  /* User has touched it - bar dims so thumb takes priority */
  filter: saturate(0.85) brightness(0.85);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}
.slider-bar .slider-thumb {
  position: absolute; top: 50%;
  transform: translate(-50%, -50%);
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(20,20,22,0.95);
  border: 1.5px solid var(--spore);
  box-shadow: 0 0 12px 1px rgba(142,255,176,0.5),
              inset 0 0 0 2px rgba(20,20,22,0.95);
  display: flex; align-items: center; justify-content: center;
  transition: opacity var(--dur-settle) ease,
              transform var(--dur-micro) ease,
              box-shadow var(--dur-micro) ease;
}
.slider-bar .slider-thumb::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--spore); box-shadow: 0 0 8px 1px var(--spore);
  animation: spore-pulse var(--dur-pulse) ease-in-out infinite;
}
.slider-bar.shuffle .slider-thumb { opacity: 0; pointer-events: none; }
.slider-bar.dragging .slider-thumb {
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: 0 0 22px 3px rgba(142,255,176,0.7),
              inset 0 0 0 2px rgba(20,20,22,0.95);
}

/* ---------- Item card ---------- */
.item {
  border: 1px solid var(--rule); border-radius: 0.5rem;
  background: var(--bg-deep);
  padding: 1rem;
  position: relative;
}
.item .row {
  display: grid;
  grid-template-columns: var(--chip-size) minmax(0, 1fr);
  column-gap: 0.85rem;
  align-items: flex-start;
}
.item .ttl {
  font-family: var(--serif);
  font-size: var(--fs-title); line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--fg);
}
.item .meta-line {
  font-family: var(--mono); font-size: var(--fs-meta);
  letter-spacing: 0.06em; color: var(--fg-faint);
  margin-top: 0.25rem;
}
.item .body-text {
  font-family: var(--serif);
  font-size: var(--fs-body); line-height: 1.65; color: var(--fg);
  margin-top: 0.7rem;
}

/* --- Item states --- */
.item.is-open .ttl { position: relative; }
.item.is-open .ttl::before {
  /* open marker: dot in left margin */
  content: ""; position: absolute; left: -0.55rem; top: 0.4rem;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--spore);
  box-shadow: 0 0 6px 1px rgba(142,255,176,0.55);
}
.item.is-done .ttl,
.item.is-done .glyph-chip,
.item.is-done .meta-line { opacity: 0.32; }
.item.is-done .ttl {
  text-decoration: line-through;
  text-decoration-color: rgba(255,255,255,0.3);
}
.item.is-resonated .row { padding-left: 0.65rem; position: relative; }
.item.is-resonated .row::before {
  /* spore-line in the gutter */
  content: ""; position: absolute; left: -0.2rem; top: 0.3rem; bottom: 0.3rem;
  width: 1.5px; border-radius: 1px;
  background: linear-gradient(180deg, transparent, var(--spore), transparent);
  opacity: 0.7;
}
.item.is-tempered .ttl       { color: rgba(217,183,135,0.4); }
.item.is-tempered .glyph-chip { opacity: 0.4; filter: saturate(0.5); }
.item.is-tempered .meta-line  { color: rgba(217,183,135,0.3); }
.item.is-arrival { animation: state-spore var(--dur-bloom) ease-out; }

/* ---------- Action bar (desktop hover cluster) ---------- */
.action-bar {
  position: absolute; top: 0.6rem; right: 0.7rem;
  display: flex; gap: 0.3rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.item:hover .action-bar { opacity: 1; }
.action-bar button {
  background: rgba(20,20,22,0.85);
  border: 1px solid var(--rule); border-radius: 0.3rem;
  padding: 0.35rem; cursor: pointer;
  color: var(--fg-muted); display: flex;
  transition: color var(--dur-micro), border-color var(--dur-micro), background var(--dur-micro);
}
.action-bar button svg { width: 16px; height: 16px; }
.action-bar button:hover { color: var(--fg); border-color: rgba(255,255,255,0.18); }
.action-bar button.act-resonate:hover { color: var(--spore); border-color: rgba(142,255,176,0.3); }
.action-bar button.act-temper:hover   { color: var(--amber); border-color: rgba(217,183,135,0.3); }

/* ---------- Action bar (mobile - long-press, 44px hit targets) ---------- */
.action-bar.is-mobile {
  position: static; gap: 0.3rem; opacity: 1;
}
.action-bar.is-mobile button {
  width: 44px; height: 44px; padding: 0; border-radius: 0.4rem;
  align-items: center; justify-content: center;
}
.action-bar.is-mobile button svg { width: 20px; height: 20px; }

/* ---------- Source footer (view original) ---------- */
.source-footer {
  margin-top: 1rem; padding-top: 0.7rem;
  border-top: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
}
.source-footer .src-name {
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.1em;
  color: var(--fg-muted); text-transform: uppercase;
  display: flex; align-items: center; gap: 0.5rem;
}
.source-footer .open-link {
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.14em;
  color: var(--amber); text-transform: uppercase;
  display: flex; align-items: center; gap: 0.4rem;
  border-bottom: 1px solid rgba(217,183,135,0.3);
  padding-bottom: 1px; cursor: pointer;
  transition: color var(--dur-micro), border-color var(--dur-micro);
}
.source-footer .open-link:hover { color: #f0d29c; border-color: rgba(217,183,135,0.6); }
.source-footer .open-link svg { width: 12px; height: 12px; }

/* ---------- Recent Actions panel ---------- */
.recent-panel {
  border: 1px solid var(--rule); border-radius: 0.6rem;
  background: rgba(20,20,22,0.92);
  overflow: hidden;
  width: 100%; max-width: var(--col-panel);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.recent-panel .panel-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
}
.recent-panel .panel-head .ttl {
  font-family: var(--mono); font-size: 0.65rem; letter-spacing: 0.14em;
  color: var(--fg); text-transform: uppercase;
}
.recent-panel .row {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; column-gap: 0.7rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.recent-panel .row:last-child { border-bottom: none; }
.recent-panel .row .icon-cell { width: 1.2rem; height: 1.2rem; color: var(--fg-muted); }
.recent-panel .row .body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.recent-panel .row .body .item-ttl {
  font-family: var(--serif); font-size: 0.82rem; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-panel .row .body .meta-line {
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.08em;
  color: var(--fg-faint); text-transform: uppercase;
}
.recent-panel .row .undo-btn {
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.14em;
  color: var(--fg-muted); text-transform: uppercase;
  border: 1px solid var(--rule); border-radius: 0.25rem;
  padding: 0.25rem 0.5rem; cursor: pointer; background: transparent;
  transition: color var(--dur-micro), border-color var(--dur-micro);
}
.recent-panel .row .undo-btn:hover {
  color: var(--spore); border-color: rgba(142,255,176,0.4);
}
.recent-panel .empty {
  padding: 2.5rem 1rem; text-align: center;
  font-family: var(--serif); font-style: italic;
  color: var(--fg-muted); font-size: 0.95rem;
}
.recent-panel .empty svg {
  width: 32px; height: 32px; color: var(--fg-faint);
  display: block; margin: 0 auto 0.6rem; opacity: 0.6;
}

/* ---------- Toast (action confirmations + system messages) ---------- */
.toast {
  display: flex; align-items: center; gap: 0.7rem;
  background: rgba(20,20,22,0.95);
  border: 1px solid var(--rule); border-radius: 0.4rem;
  padding: 0.6rem 0.85rem;
  font-family: var(--serif); font-size: 0.9rem; color: var(--fg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast .icon { color: var(--fg-muted); flex-shrink: 0; }
.toast .undo {
  margin-left: auto;
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.14em;
  color: var(--spore); text-transform: uppercase; cursor: pointer;
}
.toast.system .undo { color: var(--amber); }

/* ---------- Offline (spinning void) state ---------- */
.offline-state {
  background: var(--bg-deep-quiet, #08080a);
  padding: 4rem 2rem;
  display: flex; flex-direction: column; align-items: center; gap: 1.4rem;
  position: relative; overflow: hidden;
}
.offline-state::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 35%, rgba(142,255,176,0.04) 0%, transparent 70%);
  animation: breathe var(--dur-page) ease-in-out infinite;
}
.offline-state .void-svg {
  width: 48px; height: 48px;
  color: rgba(142,255,176,0.55);
  z-index: 1;
}
.offline-state .void-svg .ring-rot     { animation: spin-slow 6s linear infinite; transform-origin: 12px 12px; }
.offline-state .void-svg .ring-rot-rev { animation: spin-slow 9s linear infinite reverse; transform-origin: 12px 12px; }
.offline-state .lbl {
  font-family: var(--mono); font-size: 0.65rem; letter-spacing: 0.18em;
  color: rgba(255,255,255,0.4); text-transform: uppercase;
}
.offline-state .sub {
  font-family: var(--serif); font-style: italic; color: var(--fg-faint);
  font-size: 0.85rem;
}

/* ---------- Empty state ---------- */
.empty-state {
  padding: 4rem 2rem;
  display: flex; flex-direction: column; align-items: center; gap: 1.2rem;
}
.empty-state .empty-svg {
  width: 40px; height: 40px;
  color: var(--fg-faint); opacity: 0.7;
  animation: breathe-soft var(--dur-breath) ease-in-out infinite;
}
.empty-state .lbl {
  font-family: var(--serif); font-style: italic;
  font-size: 1.1rem; letter-spacing: 0.06em;
  color: var(--fg-muted);
}
