/* =============================================================================
   Багер София — стилове
   Палитра, основана на материалите на изкопната площадка: бетон, асфалт,
   строителна жълта и предупредително оранжева, прясна пръст и стомана.
   ========================================================================== */

:root {
  --concrete-bg:      #EAE6DD;
  --asphalt-ink:       #211F1A;
  --asphalt-soft:      #3A362E;
  --excavator-yellow:  #F2B705;
  --safety-orange:     #E2571C;
  --soil-brown:        #6B4A33;
  --soil-light:        #B08A5E;
  --steel-teal:        #3F6B68;
  --grass-green:       #7C9A4E; /* само за илюстрацията в началото */

  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;

  --radius-sm: 3px;
  --radius-md: 6px;
  --content-width: 920px;
  --shadow-card: 0 1px 2px rgba(33, 31, 26, 0.06), 0 4px 14px rgba(33, 31, 26, 0.07);
}

/* ---------------------------------------------------------------------------
   Reset / основи
   ------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--concrete-bg);
  color: var(--asphalt-ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 0.5em;
  letter-spacing: 0.01em;
}

h1 { font-size: clamp(2rem, 4.5vw, 3rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); text-transform: uppercase; letter-spacing: 0.03em; }
h3 { font-size: 1.15rem; margin-bottom: 0.2em; }

p { margin: 0 0 1em; }

a { color: var(--steel-teal); text-decoration-thickness: 1.5px; }
a:hover { color: var(--safety-orange); }

img, svg { max-width: 100%; }

button, input { font-family: inherit; font-size: 1rem; }

/* Видимо клавиатурно focus състояние навсякъде по сайта */
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--steel-teal);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--excavator-yellow);
  color: var(--asphalt-ink);
  padding: 0.6em 1em;
  z-index: 100;
  font-weight: 600;
}
.skip-link:focus { left: 0.5em; top: 0.5em; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.wrap { max-width: var(--content-width); margin: 0 auto; padding: 0 1.25rem; }

/* ---------------------------------------------------------------------------
   Бутони
   ------------------------------------------------------------------------ */
.btn {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
  padding: 0.75em 1.5em;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-primary {
  background: var(--excavator-yellow);
  color: var(--asphalt-ink);
  border-color: var(--excavator-yellow);
}
.btn-primary:hover { background: var(--safety-orange); border-color: var(--safety-orange); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--concrete-bg);
  border-color: var(--concrete-bg);
}
.btn-ghost:hover { background: var(--concrete-bg); color: var(--asphalt-ink); }
.btn-secondary {
  background: var(--asphalt-ink);
  color: var(--concrete-bg);
  border-color: var(--asphalt-ink);
  font-size: 0.85rem;
  padding: 0.7em 1.2em;
}
.btn-secondary:hover { background: var(--steel-teal); border-color: var(--steel-teal); }

/* ---------------------------------------------------------------------------
   Основна навигация
   ------------------------------------------------------------------------ */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1rem 1.25rem;
}
.site-nav-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--asphalt-ink);
  text-decoration: none;
}
.site-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav-links a {
  color: var(--asphalt-soft);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
}
.site-nav-links a:hover { color: var(--safety-orange); }

/* ---------------------------------------------------------------------------
   Bageri
   ------------------------------------------------------------------------ */
.bageri { background: var(--asphalt-ink); color: var(--concrete-bg); }
.bageri-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4.5rem) 1.25rem clamp(2rem, 5vw, 3rem);
}
.eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.85rem;
  color: var(--excavator-yellow);
  margin-bottom: 0.75em;
}
.bageri h1 { color: var(--concrete-bg); max-width: 14ch; }
.bageri h1 .accent { color: var(--excavator-yellow); }
.bageri-lede { max-width: 48ch; color: var(--concrete-bg); opacity: 0.88; font-size: 1.05rem; }
.bageri-actions { display: flex; gap: 0.9rem; flex-wrap: wrap; margin-top: 1.5rem; }
.bageri-art { line-height: 0; }
.bageri-art svg { display: block; width: 100%; height: auto; }
.bageri-art-image {
  display: block;
  width: 100%;
  height: auto;
}
.bageri-art.has-custom-height { height: var(--hero-height); overflow: hidden; }
.bageri-art.has-custom-height svg,
.bageri-art.has-custom-height .bageri-art-image {
  height: 100%;
  object-fit: cover;
}

/* ---------------------------------------------------------------------------
   Търсене
   ------------------------------------------------------------------------ */
.search-bar {
  margin: 2.25rem 0 1.75rem;
  padding: 0;
}
.search-bar form { display: flex; gap: 0.6rem; max-width: 30rem; }
.search-bar input[type="search"] {
  flex: 1;
  padding: 0.7em 0.9em;
  border: 2px solid var(--asphalt-ink);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--asphalt-ink);
}
.search-meta { margin-top: 0.6rem; font-size: 0.92rem; color: var(--asphalt-soft); }

/* ---------------------------------------------------------------------------
   Съобщения
   ------------------------------------------------------------------------ */
.alert {
  max-width: var(--content-width);
  margin: 1.5rem auto 0;
  padding: 0 1.25rem;
}
.alert {
  display: block;
  margin: 1.5rem auto 0;
  max-width: calc(var(--content-width) - 2.5rem);
  padding: 0.9em 1.1em;
  border-radius: var(--radius-md);
  font-weight: 500;
}
.alert-success { background: #E5EEE0; border: 1px solid var(--grass-green); color: #3C5226; }
.alert-error { background: #F8E4DC; border: 1px solid var(--safety-orange); color: #8C2E12; }

/* ---------------------------------------------------------------------------
   Класация — списък с карти
   ------------------------------------------------------------------------ */
main { max-width: var(--content-width); margin: 0 auto; padding: 2.5rem 1.25rem 1rem; }

#listing { margin-bottom: 3rem; }

.empty-state {
  background: #fff;
  border: 1px dashed var(--soil-light);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  color: var(--asphalt-soft);
}

.company-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.company-card {
  display: flex;
  align-items: flex-start;
  gap: 1.1rem;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 1.1rem 1.3rem;
}

.rank-stamp {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 2px solid var(--soil-brown);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--soil-brown);
  transform: rotate(-7deg);
  position: relative;
  margin-top: 0.15rem;
}
.rank-stamp::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px dashed var(--soil-brown);
  border-radius: 50%;
  opacity: 0.55;
}

.company-main { flex: 1 1 auto; min-width: 0; }
.company-name {
  font-size: 1.15rem;
  text-transform: none;
  letter-spacing: 0.01em;
  margin-bottom: 0.15em;
}
.company-name a { color: var(--asphalt-ink); text-decoration: none; }
.company-name a:hover { color: var(--safety-orange); text-decoration: underline; }
.company-description { margin: 0 0 0.4em; color: var(--asphalt-soft); font-size: 0.92rem; line-height: 1.5; }
.company-phone { margin: 0; font-family: var(--font-mono); font-size: 1.05rem; font-weight: 700; }
.company-phone a { color: var(--asphalt-ink); text-decoration: none; }
.company-phone a:hover { color: var(--safety-orange); }

.company-rating {
  flex: 0 0 11.5rem;
  text-align: right;
}

/* --- Звезди: средна оценка (двуслоен CSS overlay, без JS) ----------------- */
.stars-display {
  position: relative;
  display: inline-block;
  font-size: 1.3rem;
  letter-spacing: 0.12em;
  line-height: 1;
}
.stars-base { color: var(--soil-light); }
.stars-fill {
  position: absolute;
  inset: 0;
  overflow: hidden;
  width: var(--rating-pct, 0%);
  color: var(--excavator-yellow);
  white-space: nowrap;
}
.rating-meta {
  margin: 0.25em 0 0.5em;
  font-size: 0.85rem;
  color: var(--asphalt-soft);
}
.rating-meta .rating-value,
.rating-meta .rating-count { font-family: var(--font-mono); font-weight: 600; }

.already-voted {
  margin: 0;
  font-size: 0.82rem;
  color: var(--steel-teal);
  font-weight: 600;
}

/* --- Звезди: интерактивно гласуване (reversed DOM + row-reverse trick) --- */
.vote-widget { border: 0; margin: 0; padding: 0; }
.stars-input {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 0.08em;
}
.stars-input input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.stars-input label {
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--soil-light);
  transition: color 0.12s ease, transform 0.12s ease;
}
.stars-input label:hover { transform: scale(1.12); }
.stars-input input:checked ~ label,
.stars-input label:hover ~ label,
.stars-input label:hover {
  color: var(--excavator-yellow);
}
.stars-input input:focus-visible + label {
  outline: 3px solid var(--steel-teal);
  outline-offset: 2px;
  border-radius: 2px;
}
.vote-widget.is-voting { opacity: 0.5; pointer-events: none; }
.vote-error {
  margin: 0.4em 0 0;
  font-size: 0.78rem;
  color: var(--safety-orange);
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Странициране
   ------------------------------------------------------------------------ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  margin-top: 2rem;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.9rem;
}
.page-link { color: var(--steel-teal); text-decoration: none; font-weight: 600; }
.page-link:hover { color: var(--safety-orange); }
.page-status { color: var(--asphalt-soft); }

/* ---------------------------------------------------------------------------
   Формуляр за нова фирма
   ------------------------------------------------------------------------ */
.add-company {
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  margin-bottom: 3rem;
}
.section-lede { color: var(--asphalt-soft); }

.company-form { display: grid; gap: 1.1rem; max-width: 32rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-weight: 600; font-size: 0.92rem; }
.field input {
  padding: 0.65em 0.8em;
  border: 1.5px solid var(--soil-light);
  border-radius: var(--radius-sm);
  background: var(--concrete-bg);
  color: var(--asphalt-ink);
}
.field input:focus { border-color: var(--steel-teal); }
.field-error { margin: 0; font-size: 0.82rem; color: var(--safety-orange); font-weight: 600; }
.field-captcha input { max-width: 8rem; font-family: var(--font-mono); }

/* Honeypot — невидимо за хора, но налично за ботове, които попълват всичко */
.field-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.company-form .btn-primary { justify-self: start; }

/* Правила за добавяне на фирма + чекбокс за съгласие */
.field-consent { gap: 0.6rem; }
.consent-rules {
  background: var(--concrete-bg);
  border-radius: var(--radius-sm);
  padding: 0.6em 0.9em;
}
.consent-rules summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--steel-teal);
}
.consent-rules p { margin: 0.6em 0 0; font-size: 0.85rem; color: var(--asphalt-soft); }
.consent-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}
.consent-checkbox input { margin-top: 0.2em; flex-shrink: 0; }

/* ---------------------------------------------------------------------------
   ЧЗВ
   ------------------------------------------------------------------------ */
.faq { margin-bottom: 3rem; }
.faq-item {
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 1rem 1.3rem;
  margin-bottom: 0.7rem;
}
.faq-item summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
}
.faq-item p { margin: 0.7em 0 0; color: var(--asphalt-soft); }

/* ---------------------------------------------------------------------------
   За нас / Контакти
   ------------------------------------------------------------------------ */
.static-section { margin-bottom: 3rem; }
.static-content p { color: var(--asphalt-soft); line-height: 1.6; margin: 0 0 1em; }
.contact-email-line { margin-top: 0.5em; }
.contact-email-line a {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--steel-teal);
  text-decoration: none;
}
.contact-email-line a:hover { color: var(--safety-orange); }

/* ---------------------------------------------------------------------------
   Футър
   ------------------------------------------------------------------------ */
.site-footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  font-size: 0.85rem;
  color: var(--asphalt-soft);
}
.footer-links { margin-top: 0.5em; }
.footer-links a { color: var(--steel-teal); }

/* ---------------------------------------------------------------------------
   Общи условия / Политика за поверителност
   ------------------------------------------------------------------------ */
.legal-page { max-width: 42rem; margin: 0 auto; padding: 2.5rem 1.25rem 3rem; }
.legal-back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-weight: 600;
  color: var(--steel-teal);
  text-decoration: none;
}
.legal-back-link:hover { text-decoration: underline; }
.legal-header-image {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 1.75rem;
}
.legal-page h1 { margin-bottom: 0.3em; }
.legal-page h2 { margin-top: 2rem; margin-bottom: 0.4em; font-size: 1.15rem; }
.legal-page p { color: var(--asphalt-soft); line-height: 1.65; margin: 0 0 1em; }
.legal-page .updated-note { font-size: 0.85rem; margin-bottom: 1.75rem; }
.legal-page a { color: var(--steel-teal); }

/* ---------------------------------------------------------------------------
   Бутон „Обратно в началото" — плъзга се отдясно при появяване/скриване
   ------------------------------------------------------------------------ */
.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 40;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: none;
  background: var(--excavator-yellow);
  color: var(--asphalt-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  opacity: 0;
  transform: translateX(2.5rem);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.15s ease;
}
.back-to-top.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.back-to-top:hover { background: var(--safety-orange); color: #fff; }
.back-to-top:focus-visible { outline: 3px solid var(--steel-teal); outline-offset: 2px; }

@media (max-width: 640px) {
  .back-to-top { right: 1rem; bottom: 1rem; width: 2.7rem; height: 2.7rem; }
}

/* ---------------------------------------------------------------------------
   Отзивчивост
   ------------------------------------------------------------------------ */
@media (max-width: 640px) {
  .company-card { flex-wrap: wrap; }
  .company-rating { flex-basis: 100%; text-align: left; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px dashed var(--soil-light); }
  .stars-input label { font-size: 1.7rem; }
  .search-bar form { max-width: none; }
  .bageri h1 { max-width: none; }
}
