/* SPA-mode styles. Loaded after style.css to override the legacy
 * sandbox defaults. */

body.app-mode {
  overflow: auto;
  background: var(--bg);
}

/* ---------- header ---------- */

#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: rgba(20, 24, 28, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.brand-dot { color: var(--accent); margin: 0 6px; }
.brand-sub { color: var(--muted); font-weight: 400; font-size: 12px; }

.header-search {
  position: relative;
  display: flex;
  gap: 4px;
  width: 280px;
  max-width: 40vw;
}
.header-search input {
  flex: 1;
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}
.header-search input:focus { outline: none; border-color: var(--accent); }
.header-search button {
  font: inherit;
  font-size: 11px;
  padding: 0 10px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.header-search button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- page chrome ---------- */

#page {
  min-height: calc(100vh - 50px);
  padding: 0;
}
.page-narrow {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ---------- landing (search only) ---------- */

.landing-hero {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 24px 48px;
  text-align: center;
}
.landing-hero h1 {
  font-size: 36px;
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}
.landing-hero .tagline {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 28px;
}
.landing-hero .landing-search {
  position: relative;
  display: flex;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}
.landing-hero .landing-search input {
  flex: 1;
  font: inherit;
  font-size: 15px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}
.landing-hero .landing-search input:focus { outline: none; border-color: var(--accent); }
.landing-hero .landing-search button {
  font: inherit;
  background: var(--accent);
  color: #14181c;
  border: none;
  border-radius: 6px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}
.landing-hero .landing-search button:hover { filter: brightness(1.1); }
.landing-hint { margin-top: 14px; font-size: 12px; }

.landing-guide {
  margin: 32px 0 0;
  padding: 0 0 0 26px;
  text-align: left;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.landing-guide li { margin: 4px 0; }
.landing-guide li::marker { color: var(--accent); font-weight: 700; }
.landing-guide .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--accent);
}

.landing-example {
  margin: 14px 0 0;
  text-align: left;
}
.landing-example-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  padding-left: 4px;
}
.landing-example-post {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 10px 14px;
  white-space: nowrap;
  overflow-x: auto;
}

/* ---------- typeahead (shared) ---------- */

.typeahead-pop {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 10;
  text-align: left;
}
.typeahead-pop .row-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.typeahead-pop .row-result:hover { background: var(--panel-2); }
.typeahead-pop .avatar-img {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.typeahead-pop .avatar-blank {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--panel-2);
}
.typeahead-pop .text-col .name { font-size: 13px; color: var(--text); }
.typeahead-pop .text-col .handle { font-size: 11px; color: var(--muted); }

/* ---------- user profile page ---------- */

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 770px;
  align-items: start;
  gap: 28px;
  max-width: 1800px;
  margin: 0 auto;
  padding: 28px 36px;
}
@media (max-width: 1280px) {
  .profile-layout { grid-template-columns: minmax(0, 1fr) 400px; }
}
@media (max-width: 900px) {
  .profile-layout { grid-template-columns: 1fr; padding: 20px; }
}
.profile-left {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 70px;
}
.active-horse-badge {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  background: var(--accent);
  color: #14181c;
  padding: 3px 10px;
  border-radius: 3px;
}
.profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.profile-header img {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
}
.profile-header .blank-pfp {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--panel-2);
}
.profile-header .name { font-size: 18px; font-weight: 600; }
.profile-header .handle { color: var(--muted); font-size: 13px; }
.profile-horse-wrap {
  width: 100%;
  height: 520px;
  background: #0a0d10;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.profile-horse-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.profile-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.profile-right h2 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

#profile-stable {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 10px;
  align-content: start;
}
#profile-stable .stable-header { grid-column: 1 / -1; margin-bottom: 0; }
#profile-stable .stable-card { margin-bottom: 0; }
#profile-stable .empty-state { grid-column: 1 / -1; }

/* ACTIVE tag for the newest horse (replaces the old "LATEST"/"PINNED" pair) */
.card-tag.active { background: var(--accent); color: #14181c; }
.stable-card.active {
  border-left-color: var(--accent);
  background: linear-gradient(to right, rgba(196,211,106,0.10), var(--panel-2) 40%);
}

/* ---------- sim-values grid (sections: motor → LFO → body → cosmetic) */

.sim-values { font-size: 10px; }

.sim-section-label {
  margin: 6px 0 2px;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.sim-section-label:first-child { margin-top: 0; }

.sim-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 8px;
  font-variant-numeric: tabular-nums;
}
.sim-cell {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 1px 4px;
  border-radius: 2px;
  overflow: hidden;
  white-space: nowrap;
}
.sim-cell .sim-key {
  color: var(--muted);
  text-overflow: ellipsis;
  overflow: hidden;
}
.sim-cell .sim-val { color: var(--text); }
.sim-geometry .sim-val  { color: var(--accent); }
.sim-cosmetic .sim-val  { color: #d8c79a; }
.sim-modulator .sim-val { color: #9ac9d8; }

/* Per-card "view post" link + collapsed sim-values details */
.card-post-link {
  font-size: 10px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.card-post-link:hover { text-decoration: underline; }

.card-sim {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.card-sim summary {
  cursor: pointer;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 9px;
  padding: 2px 0 4px;
  list-style: none;
}
.card-sim summary::before { content: "▸ "; font-size: 9px; }
.card-sim[open] summary::before { content: "▾ "; }
.card-sim summary:hover { color: var(--text); }

/* ---------- active-horse sim table on the profile-left column ----- */

.profile-sim-values {
  background: var(--panel-2);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 11px;
}
.profile-sim-values:empty { display: none; }
.profile-sim-values .sim-values-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.profile-sim-values .sim-values-name {
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}
.profile-sim-values .sim-values-sub {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.profile-sim-values .sim-values { font-size: 11px; }
.profile-sim-values .sim-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- empty / loading states ---------- */

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state h2 { color: var(--text); margin: 0 0 8px; }
.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
