/**
 * Аварско-русский словарь — Стили
 * Дизайн-система согласована с index.avar.me
 */

/* ============================================================================
   CSS VARIABLES (взяты из index.avar.me)
   ============================================================================ */

:root {
  --bg-deep:        #f4f1ea;
  --bg-card:        #ffffff;
  --bg-card-hover:  #faf8f4;
  --bg-secondary:   #f0ece2;

  --text:           #1c2229;
  --text-muted:     #5a6570;
  --text-light:     #8a9099;

  --accent:         #9a7b1a;
  --accent-glow:    rgba(154, 123, 26, 0.25);
  --accent-light:   rgba(154, 123, 26, 0.12);

  --link:           #1a5f8a;
  --link-hover:     #0d4a6e;

  --border:         rgba(28, 34, 41, 0.1);
  --border-strong:  rgba(28, 34, 41, 0.18);

  --radius-sm:      6px;
  --radius:         12px;
  --radius-lg:      18px;

  --shadow-sm:      0 1px 3px rgba(28, 34, 41, 0.06);
  --shadow-md:      0 4px 12px rgba(28, 34, 41, 0.08);
  --shadow-lg:      0 10px 30px rgba(28, 34, 41, 0.12);

  --font-sans:      "Onest", system-ui, sans-serif;
  --font-serif:     "Literata", Georgia, serif;
  --font-mono:      ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   RESET & BASE
   ============================================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-deep);
  min-height: 100vh;
}

/* Фоновый паттерн (из index.avar.me) */
.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(201, 162, 39, 0.14), transparent),
    radial-gradient(ellipse 60% 40% at 100% 80%, rgba(94, 140, 180, 0.08), transparent),
    linear-gradient(180deg, #faf8f4 0%, var(--bg-deep) 50%);
  pointer-events: none;
}

.bg-pattern::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ============================================================================
   HEADER / HERO
   ============================================================================ */

.header {
  padding: 2.5rem 1.5rem 1.25rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.header-tag {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
}

.title .dot {
  color: var(--accent);
}

.results-section {
  display: block;
}

/* ============================================================================
   SEARCH SECTION
   ============================================================================ */

.search-section {
  margin-bottom: 2rem;
}

.search-container {
  position: relative;
  max-width: 560px;
  margin: 0 auto 0.75rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.875rem 3rem 0.875rem 3rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.search-input::placeholder {
  color: var(--text-light);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-sm);
}

.clear-btn {
  position: absolute;
  right: 0.875rem;
  display: none;
  padding: 0.25rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.clear-btn:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

/* ============================================================================
   SUGGESTIONS
   ============================================================================ */

.suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 380px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.suggestion-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
  font-size: 0.9375rem;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: var(--bg-card-hover);
}

/* ============================================================================
   SEARCH STATS
   ============================================================================ */

.search-stats {
  text-align: center;
  font-size: 0.84rem;
  color: var(--text-muted);
  min-height: 1.4rem;
}

/* ============================================================================
   HOME SAMPLES & PREFIX WORD LIST (как avar.me)
   ============================================================================ */

.home-samples-section {
  display: block;
  margin-bottom: 2.5rem;
}

.word-list-caption {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.word-list-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.word-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.word-list thead th {
  padding: 0.65rem 0.85rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.word-list tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.word-list tbody tr:hover,
.word-list tbody tr:focus {
  background: var(--bg-card-hover);
  outline: none;
}

.word-list td {
  padding: 0.6rem 0.85rem;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.word-list tbody tr:last-child td {
  border-bottom: none;
}

.word-list-word {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.word-list-forms {
  font-size: 0.84rem;
  color: var(--text-muted);
  min-width: 6rem;
}

.word-list-gloss {
  font-family: var(--font-serif);
  color: var(--text);
  line-height: 1.45;
}

/* ============================================================================
   WORD CARD
   ============================================================================ */

.word-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base);
}

.word-card:hover {
  box-shadow: var(--shadow-md);
}

.word-header {
  margin-bottom: 1.25rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--border);
}

/* Title row: word + exclamation form side by side */
.word-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.word-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.stress-vowel {
  color: var(--accent);
  font-weight: 650;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(154, 123, 26, 0.55);
}

/* Exclamation form badge (e.g. "бу!") */
.word-excl {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: default;
}

/* Stress + stem metadata row */
.word-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.word-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius-sm);
  cursor: default;
  user-select: none;
}

.word-meta-item b {
  font-weight: 700;
}

.word-gender-forms {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.word-gender-forms .forms-label {
  font-weight: 600;
  color: var(--text-muted);
}

.gender-form-chip {
  cursor: pointer;
}

/* ============================================================================
   RESULT BLOCKS
   ============================================================================ */

.result-block {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.result-block:last-child {
  margin-bottom: 0;
}

/* Labels (части речи) */
.result-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.label {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Precomment (пометка перед переводом) */
.result-precomment {
  font-size: 0.875rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.45;
}

/* Translation + подстрочная помета (comment, labels примера) */
.result-translation {
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.gloss-main {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
}

.gloss-sub {
  display: block;
  margin-top: 0.2em;
  padding-top: 0.05em;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 400;
  color: var(--text-light);
  line-height: 1.4;
}

/* Forms */
.result-forms {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.forms-label {
  font-weight: 600;
  color: var(--text-muted);
}

.form-chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-right: 0.3rem;
  margin-bottom: 0.3rem;
}

.form-chip .form-stem {
  color: var(--text-muted);
  font-weight: 400;
}

.form-chip .form-suffix {
  color: var(--text);
  font-weight: 600;
}

/* Relations (масдар от, род. пад. от, …) */
.result-relations {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.relation-item {
  display: inline;
  margin-right: 0.75rem;
}

.relation-item:last-child {
  margin-right: 0;
}

.relation-kind {
  font-weight: 600;
  color: var(--text-muted);
}

/* Lookup */
.result-lookup {
  margin-top: 0.75rem;
  font-size: 0.9375rem;
}

.lookup-label {
  font-weight: 600;
  color: var(--text-muted);
}

.lookup-link {
  color: var(--link);
  cursor: pointer;
  text-decoration: none;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  display: inline-block;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.lookup-link:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* Examples */
.result-examples {
  margin-top: 0.75rem;
}

.example-item {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 0.4rem;
}

.example-item:last-child {
  margin-bottom: 0;
}

.example-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 1rem;
  align-items: start;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
}

.example-grid:last-of-type {
  border-bottom: none;
}

.example-av {
  font-weight: 600;
  color: var(--text);
}

.example-ru {
  color: var(--text-muted);
}

.example-ru .gloss-main {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-muted);
}

.example-ru .gloss-sub {
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  .example-grid {
    grid-template-columns: 1fr;
    gap: 0.15rem;
    padding: 0.45rem 0;
  }

  .example-av::after {
    content: " —";
    color: var(--border-strong);
  }

  .example-ru {
    font-size: 0.82rem;
  }
}

/* ============================================================================
   NO RESULTS
   ============================================================================ */

.no-results {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.no-results svg {
  margin-bottom: 1rem;
  opacity: 0.4;
}

.no-results p {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.no-results-hint {
  font-size: 0.875rem;
  color: var(--text-light);
}

/* ============================================================================
   LOADING & ERROR
   ============================================================================ */

.loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-message {
  display: none;
  padding: 1rem 1.25rem;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid rgba(153, 27, 27, 0.15);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  text-align: center;
  font-size: 0.9375rem;
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.84rem;
}

.footer p {
  margin: 0.3rem 0;
}

.footer a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 600px) {
  .container {
    padding: 0 1rem 3rem;
  }

  .header {
    padding: 2rem 1rem 1rem;
  }

  .title {
    font-size: 1.75rem;
  }

  .word-card {
    padding: 1.25rem;
  }

  .word-title {
    font-size: 1.5rem;
  }

  .word-list-word {
    white-space: normal;
  }
}

@media (max-width: 400px) {
  .title {
    font-size: 1.5rem;
  }

  .word-title {
    font-size: 1.25rem;
  }
}

/* ============================================================================
   PRINT
   ============================================================================ */

@media print {
  .bg-pattern,
  .header,
  .search-section,
  .footer {
    display: none;
  }

  .word-card {
    box-shadow: none;
    border: 1px solid var(--border);
    page-break-inside: avoid;
  }
}
