/* =========================================================================
   SyllaZip — Component-level styles
   Buttons, cards, tabs, badges, inputs, textarea, progress, console.
   ========================================================================= */

/* ----------------------- Cards ----------------------- */
.card {
  position: relative;
  background: var(--bg-aged-oak);
  border: 1px solid var(--border-wood);
  border-radius: var(--radius-default);
  padding: 1.1rem 1.25rem;
  transition: border-color 300ms ease-out, box-shadow 300ms ease-out;
}
.card--hover:hover {
  border-color: rgba(201, 169, 98, 0.5);
  box-shadow: var(--shadow-card-hover);
}
.card--hover:hover::before,
.card--hover:hover::after {
  opacity: 1;
}
.card--padded { padding: 1.35rem 1.6rem; }
.card--tight  { padding: 0.75rem 1rem; }

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border-wood-50);
  margin-bottom: 0.75rem;
}
.card__title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg-parchment);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: 0.01em;
}
.card__title .icon { color: var(--brass); width: 18px; height: 18px; flex-shrink: 0; }
.card__subtitle {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--muted-ink);
  font-style: italic;
  margin: 0.35rem 0 0 0;
  line-height: 1.45;
}

/* ----------------------- Buttons ----------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-default);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-parchment);
  transition: all 200ms ease-out;
  user-select: none;
  white-space: nowrap;
  min-height: 40px;
}
.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-mahogany), 0 0 0 4px var(--brass);
}
.btn .icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

/* Primary — polished brass gradient */
.btn--primary {
  background: var(--gradient-brass);
  color: var(--bg-mahogany);
  box-shadow: var(--shadow-emboss);
  text-shadow:
    1px 1px 1px rgba(0, 0, 0, 0.40),
    -1px -1px 1px rgba(255, 255, 255, 0.10);
}
.btn--primary:hover {
  filter: brightness(1.10);
  box-shadow: var(--shadow-emboss-hover);
}
.btn--primary:active {
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.40),
    inset 0 -1px 1px rgba(255, 255, 255, 0.10);
}

/* Secondary — outlined brass, transforms to crimson on hover */
.btn--secondary {
  background: transparent;
  border: 2px solid var(--brass);
  color: var(--brass);
}
.btn--secondary:hover {
  border-color: var(--crimson);
  background: var(--crimson);
  color: var(--crimson-fg);
}
.btn--secondary:active {
  background: var(--crimson-deep);
  border-color: var(--crimson-deep);
}

/* Ghost — minimal, brass text + underline on hover */
.btn--ghost {
  background: transparent;
  color: var(--brass);
  padding: 0.32rem 0.55rem;
  letter-spacing: 0.11em;
  min-height: 32px;
}
.btn--ghost:hover {
  color: var(--brass-hi);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Size variants */
.btn--sm { padding: 0.3rem 0.65rem; font-size: 0.6rem; min-height: 32px; }
.btn--lg { padding: 0.6rem 1.3rem; font-size: 0.76rem; min-height: 44px; }
.btn--block { width: 100%; }

/* ----------------------- Badges ----------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-default);
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.35;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; }

/* Outline (wood grain) — default state badge */
.badge--outline {
  border-color: var(--border-wood);
  color: var(--fg-parchment);
  background: rgba(201, 169, 98, 0.04);
}
/* Brass — emphasis badge */
.badge--brass {
  border-color: var(--brass);
  color: var(--brass);
  background: rgba(201, 169, 98, 0.08);
}
/* Crimson — error / destructive badge */
.badge--crimson {
  border-color: var(--crimson);
  color: var(--crimson-fg);
  background: rgba(139, 38, 53, 0.20);
}
/* Amber — literal / "missing" indicator */
.badge--amber {
  border-color: #B8953F;
  color: #D4B872;
  background: rgba(184, 149, 63, 0.12);
}
/* Status: ready (brass filled) */
.badge--ready {
  background: var(--brass);
  color: var(--bg-mahogany);
  border-color: var(--brass);
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.30);
}
/* Status: loading (brass outline, spinner inside) */
.badge--loading {
  border-color: var(--brass);
  color: var(--brass);
  background: rgba(201, 169, 98, 0.06);
}
.badge--loading .spinner-mini {
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border-wood);
  border-top-color: var(--brass);
  border-radius: 50%;
  animation: academia-spin 1.1s linear infinite;
  display: inline-block;
}
@keyframes academia-spin { to { transform: rotate(360deg); } }

/* ----------------------- Status badge (header) ----------------------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-radius: var(--radius-default);
  border: 1px solid var(--border-wood);
  background: rgba(74, 63, 53, 0.20);
  color: var(--muted-ink);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-badge--ready {
  background: var(--brass);
  color: var(--bg-mahogany);
  border-color: var(--brass);
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.30);
}
.status-badge--loading {
  border-color: var(--brass);
  color: var(--brass);
  background: rgba(201, 169, 98, 0.06);
}
.status-badge--error {
  border-color: var(--crimson);
  color: var(--crimson-fg);
  background: rgba(139, 38, 53, 0.20);
}
.status-badge .icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.status-badge__spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--border-wood);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: academia-spin 1.1s linear infinite;
  display: inline-block;
}

/* ----------------------- Form controls ----------------------- */
.input,
.textarea,
.select-trigger {
  width: 100%;
  background: var(--bg-aged-oak);
  border: 1px solid var(--border-wood);
  border-radius: var(--radius-default);
  color: var(--fg-parchment);
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 0.4rem 0.65rem;
  transition: border-color 200ms ease-out, box-shadow 200ms ease-out;
  outline: none;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--muted-ink);
  font-style: italic;
}
.input:focus,
.textarea:focus,
.select-trigger:focus {
  border-color: var(--brass);
  box-shadow: 0 0 0 2px var(--bg-mahogany), 0 0 0 4px rgba(201, 169, 98, 0.30);
}
.textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.5;
}
.textarea--mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
}
.input:disabled,
.textarea:disabled,
.select-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Sample select dropdown (native) — themed wrapper */
.field-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted-ink);
  margin-bottom: 0.3rem;
}

/* Inline meta — character count, byte count */
.field-meta {
  font-family: var(--font-body);
  font-size: 0.76rem;
  color: var(--muted-ink);
  font-style: italic;
}

/* ----------------------- Stats panel ----------------------- */
.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  margin: 0.18rem 0;
}
.stat-row .label {
  color: var(--muted-ink);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.stat-row .label .icon { width: 12px; height: 12px; color: var(--brass); }
.stat-row .value {
  color: var(--fg-parchment);
  font-weight: 500;
}
.stat-row .value--accent { color: var(--brass); font-family: var(--font-heading); font-size: 1rem; }
.stat-row .value--crimson { color: var(--crimson); }

/* Big number block */
.stat-block {
  text-align: center;
  padding: 0.4rem 0.35rem;
  background: rgba(201, 169, 98, 0.04);
  border: 1px solid var(--border-wood-50);
  border-radius: var(--radius-default);
}
.stat-block__num {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--brass);
  line-height: 1.05;
}
.stat-block__num--crimson { color: var(--crimson); }
.stat-block__label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--muted-ink);
  font-style: italic;
  margin-top: 0.15rem;
}

/* Stats grid (2-col) */
.stats-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* Section separator within a card */
.stat-sep {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--border-wood) 20%, var(--border-wood) 80%, transparent 100%);
  border: none;
  margin: 0.55rem 0;
}

/* Progress bar — brass fill on wood-grain track */
.progress {
  position: relative;
  width: 100%;
  height: 8px;
  background: rgba(74, 63, 53, 0.45);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-wood-50);
}
.progress__bar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: var(--gradient-brass);
  border-radius: 999px;
  transition: width 500ms ease-out;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.progress__bar--crimson {
  background: linear-gradient(180deg, #A33D4E 0%, var(--crimson) 50%, var(--crimson-deep) 100%);
}

/* ----------------------- Tabs ----------------------- */
.tabs__list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-aged-oak);
  border: 1px solid var(--border-wood);
  border-radius: var(--radius-default);
  padding: 3px;
  gap: 3px;
}
@media (max-width: 640px) {
  .tabs__list { grid-template-columns: 1fr 1fr; }
}
.tabs__trigger {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  transition: color 200ms ease-out, border-color 200ms ease-out, background 200ms ease-out;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.tabs__trigger .icon { width: 12px; height: 12px; }
.tabs__trigger:hover {
  color: var(--brass);
}
.tabs__trigger.is-active {
  color: var(--brass);
  border-bottom: 2px solid var(--brass);
  background: rgba(201, 169, 98, 0.08);
  box-shadow: inset 0 -1px 0 rgba(201, 169, 98, 0.20);
}
.tabs__panel {
  display: none;
  margin-top: 0.55rem;
}
.tabs__panel.is-active {
  display: block;
}

/* ----------------------- Result panels (hex / base64 / pre) ----------------------- */
.code-block {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.5;
  background: rgba(28, 23, 20, 0.55);
  border: 1px solid var(--border-wood-50);
  border-radius: var(--radius-default);
  padding: 0.6rem 0.8rem;
  color: var(--fg-parchment);
  overflow: auto;
  max-height: 320px;
  white-space: pre;
  word-break: break-all;
}
.code-block--break {
  white-space: pre-wrap;
  word-break: break-all;
}

/* ----------------------- Word table ----------------------- */
.word-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 320px;
  overflow: auto;
}
.word-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  background: rgba(28, 23, 20, 0.35);
  border-radius: var(--radius-default);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  border-left: 2px solid var(--border-wood);
}
.word-row--morph { border-left-color: var(--brass); }
.word-row--literal { border-left-color: var(--brass-lo); }
.word-row__idx {
  color: var(--muted-ink);
  width: 32px;
  flex-shrink: 0;
}
.word-row__text { color: var(--fg-parchment); }
.word-row__text--morph { color: var(--brass); }
.word-row__text--literal { color: #D4B872; }

/* ----------------------- Lean map lemmas ----------------------- */
.lemma-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-height: 180px;
  overflow: auto;
  padding: 0.25rem;
}
.lemma-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.45rem;
  border: 1px solid var(--brass);
  border-radius: var(--radius-default);
  font-family: var(--font-body);
  font-size: 0.74rem;
  color: var(--fg-parchment);
  background: rgba(201, 169, 98, 0.06);
  letter-spacing: 0.02em;
  transition: background 200ms ease-out;
}
.lemma-chip:hover {
  background: rgba(201, 169, 98, 0.18);
}
.lemma-chip__id {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--brass);
  margin-right: 0.3rem;
}

/* ----------------------- Console log ----------------------- */
.console {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.5;
  background: rgba(28, 23, 20, 0.65);
  border: 1px solid var(--border-wood-50);
  border-radius: var(--radius-default);
  padding: 0.6rem 0.8rem;
  color: var(--fg-parchment);
  min-height: 80px;
  max-height: 240px;
  overflow: auto;
}
.console__line {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 0.25rem 0;
}
.console__time {
  color: var(--brass);
  margin-right: 0.5rem;
}
.console__msg--ok { color: var(--brass); }
.console__msg--err { color: var(--crimson); }
.console__msg--warn { color: #D4B872; }
.console__msg--muted { color: var(--muted-ink); }

/* ----------------------- Candidate sizes comparison ----------------------- */
.candidates {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
.candidate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.15rem 0;
}
.candidate__label { color: var(--muted-ink); }
.candidate__value { color: var(--fg-parchment); }
.candidate.is-chosen {
  color: var(--brass);
  font-weight: 600;
}
.candidate.is-chosen .candidate__label,
.candidate.is-chosen .candidate__value {
  color: var(--brass);
}
.candidate.is-chosen .candidate__value::after {
  content: " ← выбран";
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-left: 0.5rem;
  opacity: 0.9;
}

/* ----------------------- Verification banner ----------------------- */
.verification {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-default);
  font-family: var(--font-body);
  font-size: 0.82rem;
}
.verification--ok {
  background: rgba(201, 169, 98, 0.10);
  border: 1px solid var(--brass);
  color: var(--brass);
}
.verification--err {
  background: rgba(139, 38, 53, 0.18);
  border: 1px solid var(--crimson);
  color: var(--crimson-fg);
}
.verification .icon { width: 16px; height: 16px; flex-shrink: 0; }

/* ----------------------- Empty state ----------------------- */
.empty-state {
  text-align: center;
  padding: 1.5rem 0.75rem;
  color: var(--muted-ink);
}
.empty-state__icon {
  width: 28px;
  height: 28px;
  color: var(--border-wood);
  margin: 0 auto 0.55rem;
  opacity: 0.6;
}
.empty-state__text {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-style: italic;
}

/* ----------------------- Sample select (native <select>) ----------------------- */
/* NOTE: native <select> uses the body font (Cormorant Garamond), NOT Cinzel —
   Cinzel lacks Cyrillic diacritics and clips letter "й". The uppercase + tracking
   look is preserved by the body serif font, which has full Cyrillic coverage. */
.sample-select {
  display: inline-block;
  position: relative;
  min-width: 200px;
}
.sample-select select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  background: var(--bg-aged-oak);
  border: 1px solid var(--border-wood);
  border-radius: var(--radius-default);
  color: var(--fg-parchment);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 0.4rem 2rem 0.4rem 0.65rem;
  cursor: pointer;
  transition: border-color 200ms ease-out;
  min-height: 40px;
}
.sample-select select:focus {
  border-color: var(--brass);
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-mahogany), 0 0 0 4px rgba(201, 169, 98, 0.30);
}
.sample-select::after {
  content: "▾";
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--brass);
  pointer-events: none;
  font-size: 0.7rem;
}
.sample-select option {
  background: var(--bg-aged-oak);
  color: var(--fg-parchment);
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
}

/* ----------------------- Decoder panel (dropzone + pills + output) ----------------------- */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.1rem 1rem;
  border: 1px dashed var(--border-wood);
  border-radius: var(--radius-default);
  background: rgba(28, 23, 20, 0.35);
  cursor: pointer;
  transition: border-color 200ms ease-out, background 200ms ease-out, box-shadow 200ms ease-out;
  min-height: 96px;
}
.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--brass);
  background: rgba(201, 169, 98, 0.05);
  box-shadow: inset 0 0 0 1px rgba(201, 169, 98, 0.15);
}
.dropzone__icon {
  width: 28px;
  height: 28px;
  color: var(--brass);
  opacity: 0.8;
  margin-bottom: 0.4rem;
}
.dropzone__text {
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--fg-parchment);
  font-style: italic;
  line-height: 1.4;
}
.dropzone__text--muted { color: var(--muted-ink); }
.dropzone__text--filename {
  color: var(--brass);
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

/* Decoder mode-toggle pills (Base64 / Файл) */
.pill-group {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.18rem;
  border: 1px solid var(--border-wood);
  border-radius: var(--radius-default);
  background: rgba(28, 23, 20, 0.45);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.7rem;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  transition: color 200ms ease-out, background 200ms ease-out, border-color 200ms ease-out;
  min-height: 30px;
}
.pill:hover { color: var(--brass); }
.pill.is-active {
  color: var(--bg-mahogany);
  background: var(--gradient-brass);
  border-color: var(--brass);
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.30);
  box-shadow: var(--shadow-emboss);
}

/* Decoder output wrapper */
.decoder-output__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-wood-50);
  margin-bottom: 0.5rem;
}

/* Hidden helper (display:none, not just visibility) */
.is-hidden { display: none !important; }

/* ----------------------- Inline helpers ----------------------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.flex-wrap { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.gap-1 { gap: 0.35rem; }
.gap-2 { gap: 0.5rem; }
.mt-1 { margin-top: 0.35rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.35rem; }
.mb-2 { margin-bottom: 0.5rem; }
.text-brass { color: var(--brass); }
.text-crimson { color: var(--crimson); }
.text-muted { color: var(--muted-ink); }
.font-display { font-family: var(--font-display); }
.font-heading { font-family: var(--font-heading); }
.font-body { font-family: var(--font-body); }
.font-mono { font-family: var(--font-mono); }
.uppercase { text-transform: uppercase; }
.italic { font-style: italic; }
.text-center { text-align: center; }
.hidden { display: none; }
