/* =============================================================================
   Chess — panels.css
   Slide-out panel system + opening info bar
============================================================================= */

/* ── Opening info bar ─────────────────────────────────────────────────────── */

.opening-info-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: none;
  font-family: var(--mono);
  font-size: 0.72rem;
  min-height: 1.8rem;
  overflow: hidden;
}

.opening-eco {
  flex: 0 0 auto;
  padding: 0.12rem 0.4rem;
  border-radius: 0.25rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
}

.opening-name {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.opening-book-status {
  flex: 0 0 auto;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.opening-book-status.in-book {
  background: rgba(33, 101, 63, 0.25);
  color: var(--success);
  border: 1px solid rgba(145, 220, 173, 0.3);
}
.opening-book-status.out-of-book {
  background: rgba(112, 39, 34, 0.2);
  color: var(--danger);
  border: 1px solid rgba(243, 181, 176, 0.25);
}

.opening-book-move {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.65rem;
}
.opening-book-move strong {
  color: var(--accent);
}

/* ── Slide-out panel ──────────────────────────────────────────────────────── */

.slide-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}
.slide-panel-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.slide-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(15, 18, 24, 0.98), rgba(10, 12, 16, 0.99));
  border-left: 1px solid var(--line-strong);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
}
.slide-panel.open {
  transform: translateX(0);
}

.slide-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.slide-panel-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.slide-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.35rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.slide-panel-close:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.slide-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

/* ── Panel trigger buttons ────────────────────────────────────────────────── */

.panel-triggers {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.panel-trigger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  flex: 1;
  padding: 0.4rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.panel-trigger-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.panel-trigger-btn svg {
  width: 0.85rem;
  height: 0.85rem;
  flex: 0 0 auto;
}

/* ── Opening Book panel content ───────────────────────────────────────────── */

.ob-section {
  margin-bottom: 1rem;
}

.ob-heading {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.ob-opening-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.2rem;
}

.ob-eco-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 0.25rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 0.4rem;
}

.ob-theory-line {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.7;
  padding: 0.5rem 0.65rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0.35rem;
  border: 1px solid var(--line);
  word-wrap: break-word;
}
.ob-theory-line .played {
  color: var(--ink);
}
.ob-theory-line .book-next {
  color: var(--accent);
  font-weight: 700;
}
.ob-theory-line .future {
  color: var(--muted);
  opacity: 0.6;
}

.ob-plan {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.ob-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.ob-tag {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.ob-tag-beginner { border-color: rgba(52,211,153,.4); color: #6ee7b7; }
.ob-tag-intermediate { border-color: rgba(251,191,36,.4); color: #fcd34d; }
.ob-tag-advanced { border-color: rgba(251,113,133,.4); color: #fda4af; }

.ob-tag-style {
  border-color: rgba(199,210,254,.3);
  color: var(--accent);
}

.ob-key-idea {
  font-style: italic;
}

.ob-famous {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.3rem 0 0;
}

.ob-winrate {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  height: 1.4rem;
  border-radius: 0.25rem;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
}
.ob-winrate-bar {
  display: flex;
  height: 100%;
  width: 100%;
  border-radius: 0.25rem;
  overflow: hidden;
}
.ob-wr-white {
  background: #e8e0d0;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ob-wr-draw {
  background: #6b7280;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ob-wr-black {
  background: #2a2a2a;
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ob-deviation {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.6rem;
  background: rgba(243, 181, 176, 0.08);
  border: 1px solid rgba(243, 181, 176, 0.2);
  border-radius: 0.35rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--danger);
}

/* ── Deviation analysis ───────────────────────────────────────────────────── */

.ob-analysis-loading {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.5rem 0;
}

.ob-deviation-analysis {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ob-analysis-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 0.35rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.ob-analysis-label {
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 0 0 auto;
  min-width: 4.5rem;
}

.ob-analysis-move {
  font-weight: 700;
  font-size: 0.85rem;
  flex: 1;
}
.ob-move-played { color: var(--ink); }
.ob-move-best { color: var(--accent); }

.ob-analysis-eval {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 0.8rem;
}

.ob-analysis-loss {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.7rem;
}

.ob-loss-badge {
  padding: 0.12rem 0.4rem;
  border-radius: 0.25rem;
  font-weight: 700;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ob-loss-blunder {
  background: rgba(232, 64, 64, 0.2);
  color: #e84040;
  border: 1px solid rgba(232, 64, 64, 0.3);
}
.ob-loss-mistake {
  background: rgba(232, 128, 76, 0.2);
  color: #e8804c;
  border: 1px solid rgba(232, 128, 76, 0.3);
}
.ob-loss-inaccuracy {
  background: rgba(247, 201, 72, 0.15);
  color: #f7c948;
  border: 1px solid rgba(247, 201, 72, 0.25);
}
.ob-loss-minor {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid var(--line);
}

.ob-loss-cp {
  color: var(--muted);
  font-size: 0.65rem;
}

/* ── Shout panel content ──────────────────────────────────────────────────── */

.shout-preview {
  padding: 0.7rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  margin-bottom: 0.75rem;
}
.shout-preview-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}
.shout-preview-stat {
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
}

.shout-textarea {
  width: 100%;
  min-height: 5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.35rem;
  border: 1px solid var(--line-strong);
  background: var(--panel-soft);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  margin-bottom: 0.6rem;
}
.shout-textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.shout-char-count {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  text-align: right;
  margin-bottom: 0.5rem;
}
.shout-char-count.over { color: var(--danger); }

/* ── Library panel content ────────────────────────────────────────────────── */

.lib-search-bar {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.lib-search-input {
  flex: 1;
  padding: 0.45rem 0.65rem;
  border-radius: 0.35rem;
  border: 1px solid var(--line-strong);
  background: var(--panel-soft);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8rem;
}
.lib-search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.lib-search-btn {
  padding: 0.45rem 0.7rem;
  border-radius: 0.35rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #11141b;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.lib-results {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.lib-book-card {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem;
  border-radius: 0.35rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.14s, background 0.14s;
}
.lib-book-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.lib-book-cover {
  width: 50px;
  height: 70px;
  border-radius: 0.2rem;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
  flex: 0 0 auto;
}

.lib-book-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.lib-book-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-book-author {
  font-size: 0.72rem;
  color: var(--muted);
}
.lib-book-format {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lib-loading, .lib-empty {
  text-align: center;
  padding: 2rem 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Captured piece entrance animation ────────────────────────────────────── */

@keyframes captured-entrance {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.captured-new {
  animation: captured-entrance 0.2s ease-out;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .slide-panel {
    width: 100vw;
  }
  .opening-info-bar {
    font-size: 0.65rem;
    padding: 0.3rem 0.5rem;
  }
}

/* ── Alternative response cards ──────────────────────────────────────────── */

.ob-alt-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ob-alt-card {
  padding: 0.6rem 0.7rem;
  border-radius: 0.35rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.14s, background 0.14s;
}
.ob-alt-card:hover {
  border-color: var(--accent);
  background: rgba(199, 210, 254, 0.04);
}

.ob-alt-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.ob-alt-move {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.ob-alt-eco {
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.08rem 0.25rem;
  border-radius: 0.2rem;
  background: var(--accent-soft, rgba(199, 210, 254, 0.1));
  color: var(--accent);
  flex-shrink: 0;
}

.ob-alt-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ob-alt-winrate {
  height: 1rem;
  border-radius: 0.2rem;
  overflow: hidden;
  display: flex;
  margin: 0.25rem 0;
  font-family: var(--mono);
  font-size: 0.5rem;
  font-weight: 600;
}

.ob-alt-plan {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .slide-panel { transition: none; }
  .slide-panel-backdrop { transition: none; }
  .captured-new { animation: none; }
}
