/* SpecialCoffee.ru Component Library
   Reusable BEM components: buttons, cards, forms, badges, accordion.
   Depends on css/variables.css and css/base.css (must be loaded first). */

/* =============================================================================
   Section 1: Buttons (COMP-01, COMP-02)
   ============================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--space-sm) var(--space-lg);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast);
}

/* Primary — red fill */
.btn-primary {
  background-color: var(--color-red);
  border-color: var(--color-red);
  color: var(--text-on-dark);
}

.btn-primary:hover {
  background-color: var(--color-chocolate);
  border-color: var(--color-chocolate);
  color: var(--text-on-dark);
}

.btn-primary:active {
  background-color: var(--color-chocolate);
  border-color: var(--color-chocolate);
  color: var(--text-on-dark);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Secondary — red outline */
.btn-secondary {
  background-color: transparent;
  border-color: var(--color-red);
  color: var(--color-red);
}

.btn-secondary:hover {
  background-color: var(--color-red);
  border-color: var(--color-red);
  color: var(--text-on-dark);
}

.btn-secondary:active {
  background-color: var(--color-red);
  border-color: var(--color-red);
  color: var(--text-on-dark);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Telegram — blue fill */
.btn-telegram {
  background-color: var(--color-telegram);
  border-color: var(--color-telegram);
  color: var(--text-on-dark);
}

.btn-telegram:hover {
  filter: brightness(0.85);
}

.btn-telegram:active {
  filter: brightness(0.8);
}

/* Gold — B2B accent */
.btn-gold {
  background-color: var(--color-gold);
  border-color: var(--color-gold);
  color: var(--color-chocolate);
}

.btn-gold:hover {
  background-color: var(--color-chocolate);
  border-color: var(--color-chocolate);
  color: var(--text-on-dark);
}

.btn-gold:active {
  background-color: var(--color-chocolate);
  border-color: var(--color-chocolate);
  color: var(--text-on-dark);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Small size — touch target maintained */
.btn-sm {
  min-height: 44px;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-small);
}

/* Large size */
.btn-lg {
  min-height: 52px;
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-subheading);
}

/* Block modifier — full width */
.btn-block {
  width: 100%;
}

/* =============================================================================
   Section 2: Cards (COMP-03, COMP-04)
   ============================================================================= */

/* Product Card */
.card-product {
  display: flex;
  flex-direction: column;
  background-color: var(--color-cream);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition-normal);
}

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

.card-product__image {
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.card-product__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: var(--bg-light);
}

.card-product__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  gap: var(--space-sm);
}

.card-product__title {
  font-family: 'Playfair Display', serif;
  font-size: var(--font-size-subheading);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.card-product__description {
  color: var(--text-secondary);
  font-size: var(--font-size-small);
}

.card-product__cta {
  margin-top: auto;
}

/* Segment Card */
.card-segment {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background-color: var(--color-cream);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow var(--transition-normal),
    transform var(--transition-normal);
}

.card-segment:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-segment__icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.card-segment__title {
  font-family: 'Playfair Display', serif;
  font-size: var(--font-size-subheading);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.card-segment__description {
  color: var(--text-secondary);
}

.card-segment__link {
  margin-top: auto;
  font-weight: var(--font-weight-semibold);
}

/* =============================================================================
   Section 3: Forms (COMP-05)
   ============================================================================= */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.form-label {
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  color: var(--text-primary);
  font-size: var(--font-size-body);
  transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-red);
  outline: none;
}

/* Select — custom arrow */
.form-select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-md) center;
  padding-right: var(--space-xl);
}

/* Textarea */
.form-textarea {
  resize: vertical;
  min-height: 120px;
}

/* Error state */
.form-group.has-error .form-input,
.form-group.has-error .form-select,
.form-group.has-error .form-textarea {
  border-color: var(--color-error);
}

.form-error {
  display: none;
  font-size: var(--font-size-small);
  color: var(--color-error);
}

.form-group.has-error .form-error {
  display: block;
}

.form-success {
  font-size: var(--font-size-small);
  color: var(--color-success);
}

/* =============================================================================
   Section 4: Badges (COMP-06)
   ============================================================================= */

.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  line-height: 1.4;
  white-space: nowrap;
}

.badge-new {
  background-color: var(--color-red);
  color: var(--text-on-dark);
}

.badge-premium {
  background-color: var(--color-gold);
  color: var(--color-chocolate);
}

.badge-sustainable {
  background-color: var(--color-success);
  color: var(--text-on-dark);
}

/* =============================================================================
   Section 5: Accordion (COMP-07)
   ============================================================================= */

/* Structural wrapper only */
.accordion {}

.accordion-item {
  border-bottom: 1px solid var(--color-border);
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  text-align: left;
  transition: color var(--transition-fast);
}

.accordion-trigger:hover {
  color: var(--color-red);
}

.accordion-trigger::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: var(--font-weight-regular);
  flex-shrink: 0;
  transition: transform var(--transition-normal);
}

.accordion-item.is-open .accordion-trigger::after {
  transform: rotate(45deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
}

.accordion-item.is-open .accordion-content {
  max-height: 600px;
}

.accordion-content__inner {
  padding-bottom: var(--space-md);
  color: var(--text-secondary);
}

/* ===== Phase 9: Product Page Components ===== */

/* Breadcrumbs (D-08 fix: removes default <ol> numbering, adds › pseudo separator) */
.breadcrumbs {
  padding: var(--space-md) 0;
  font-size: var(--font-size-small);
  color: var(--text-secondary);
}

.breadcrumbs__list {
  list-style: none;
  list-style-type: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  padding: 0;
  padding-left: 0;
  margin: 0;
  counter-reset: none;
}

/* Belt-and-braces: some browsers (older Safari, Firefox with certain
   a11y settings) don't inherit list-style-type: none from <ol> to <li>
   reliably. Apply directly to li, neutralize ::marker, and force
   display:block so <li> is no longer display:list-item (no marker box). */
.breadcrumbs__list > li {
  list-style: none;
  list-style-type: none;
  display: block;
  margin: 0;
}

.breadcrumbs__list > li::marker {
  content: '';
  display: none;
}

.breadcrumbs__list a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumbs__list a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.breadcrumbs__list li[aria-current="page"] {
  color: var(--text-primary);
}

.breadcrumbs__list li + li::before {
  content: '›';
  margin-right: var(--space-xs);
  color: var(--text-secondary);
}

/* Product hero (D-07: two-column layout at ≥768px) */
.product-hero {
  padding: var(--space-2xl) 0;
  background: var(--color-cream);
}

.product-hero__layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.product-hero__image-wrap {
  position: relative;
}

.product-hero__image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
}

.product-hero__badge {
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  background: var(--color-red);
  color: var(--text-on-dark);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  border-radius: var(--radius-sm);
}

.product-hero__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.product-hero__content h1 {
  margin: 0;
  font-size: var(--font-size-heading);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
}

.product-tagline {
  margin: 0;
  font-size: var(--font-size-subheading);
  line-height: var(--line-height-tight);
  color: var(--text-secondary);
  font-weight: var(--font-weight-regular);
}

.product-hero__meta {
  font-size: var(--font-size-small);
  color: var(--text-secondary);
}

@media (min-width: 768px) {
  .product-hero__layout {
    flex-direction: row;
    gap: var(--space-xl);
    align-items: flex-start;
  }

  .product-hero__image-wrap {
    flex: 0 0 45%;
  }

  .product-hero__content {
    flex: 1;
  }
}

/* Product description (D-02a: standalone prose section) */
.product-description {
  padding: var(--space-2xl) 0;
  max-width: 720px;
  margin: 0 auto;
  font-size: var(--font-size-body);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
}

/* Product specs grid (D-02) */
.product-specs {
  padding: var(--space-2xl) 0;
  background: var(--color-cream);
}

.product-specs h2 {
  margin: 0 0 var(--space-lg);
  font-size: var(--font-size-heading);
  color: var(--text-primary);
}

.product-specs__flavors {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.product-specs__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

.product-specs__card {
  background: var(--color-latte);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.product-specs__card-label {
  display: block;
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
}

.product-specs__card-value {
  display: block;
  font-size: var(--font-size-body);
  color: var(--text-primary);
}

@media (min-width: 768px) {
  .product-specs__grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Flavor chips (gold border accent per UI-SPEC color contract) */
.chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-latte);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-full);
  font-size: var(--font-size-small);
  color: var(--text-primary);
}

/* Intensity dots (D-03: CSS-only filled/empty dots) */
.intensity-dots {
  display: inline-flex;
  gap: var(--space-xs);
  align-items: center;
}

.intensity-dots__dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--text-secondary);
}

.intensity-dots__dot--filled {
  background: var(--color-red);
  border-color: var(--color-red);
}

/* Related products (D-06a: locks 1/2/4 responsive grid) */
.related-products {
  padding: var(--space-2xl) 0;
}

.related-products h2 {
  margin: 0 0 var(--space-lg);
  font-size: var(--font-size-heading);
  color: var(--text-primary);
}

.related-products__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

@media (min-width: 768px) {
  .related-products__grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
  }
}

@media (min-width: 1024px) {
  .related-products__grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Lead form prefill label (D-01: visible product context above duplicated form) */
.lead-form__product {
  margin: 0 0 var(--space-md);
  padding: var(--space-md);
  background: var(--color-latte);
  border-left: 3px solid var(--color-red);
  font-size: var(--font-size-body);
  color: var(--text-primary);
}

.lead-form__product strong {
  font-weight: var(--font-weight-semibold);
}

/* =============================================================================
   Phase 10 — Catalog Page
   Additive-only primitives for catalog.html: filter chips, filter rows,
   filter section, responsive catalog grid (CAT-07), empty state, reset
   control, product-card type label and corner badge positioning.
   No existing rule bodies are modified; the .card-product rule below is
   additive (browser merges position:relative with the rule at line 129).
   ============================================================================= */

/* Additive: make existing .card-product a positioning context for corner badge */
.card-product {
  position: relative;
}

/* Product card — type label (catalog-only element emitted by js/catalog.js) */
.card-product__type {
  display: block;
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-regular);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* Product card — corner badge wrapper (absolute over image area) */
.card-product__corner-badge {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  z-index: 2;
  pointer-events: none;
}

/* Catalog hero — tighter bottom spacing to bring filters closer */
.catalog-hero {
  padding-bottom: var(--space-lg);
}

/* Catalog results wrapper — reduce top padding so filters sit close to hero */
.catalog-results-section {
  padding-top: var(--space-md);
}

/* Filter section — outer wrapper for all facet rows + reset control */
.filter-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-sm);
  margin-bottom: var(--space-lg);
  background-color: var(--color-latte);
  border-radius: var(--radius-lg);
}

/* Filter row — single facet row; chips scroll horizontally on mobile */
.filter-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--space-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

/* Filter row label — static facet title */
.filter-row__label {
  flex-shrink: 0;
  margin-right: var(--space-xs);
  color: var(--text-secondary);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

/* Filter chip — toggleable pill button */
.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 44px;
  padding: var(--space-xs) var(--space-md);
  background-color: transparent;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.filter-chip:hover {
  border-color: var(--color-red);
  color: var(--color-red);
}

.filter-chip.is-active {
  background-color: var(--color-red);
  border-color: var(--color-red);
  color: var(--text-on-dark);
}

.filter-chip:focus-visible {
  outline: 2px solid var(--color-red);
  outline-offset: 2px;
}

/* Catalog reset — text-only "Сбросить фильтры" control */
.catalog-reset {
  display: none;
  align-self: flex-end;
  padding: var(--space-xs) var(--space-sm);
  background: none;
  border: none;
  color: var(--color-red);
  font-family: inherit;
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  text-decoration: underline;
  cursor: pointer;
}

.catalog-reset.is-visible {
  display: inline-block;
}

/* Catalog grid — responsive 1 / 2 / 3 column product layout (CAT-07) */
.catalog-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 768px) {
  .catalog-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xl);
  }
}

@media (min-width: 1024px) {
  .catalog-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Catalog empty state — shown when filters yield zero results */
.catalog-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-3xl) var(--space-md);
  text-align: center;
}

.catalog-empty__title {
  color: var(--text-primary);
  font-family: 'Playfair Display', serif;
  font-size: var(--font-size-heading);
  font-weight: var(--font-weight-semibold);
}

.catalog-empty__body {
  max-width: 480px;
  color: var(--text-secondary);
  font-size: var(--font-size-body);
}

/* === Phase 11: Business Page Components === */

/* Business Hero — dark header section for business.html */
.business-hero {
  background: var(--bg-dark);
  color: var(--text-on-dark);
  padding: var(--space-2xl) 0;
  text-align: center;
}

.business-hero h1 {
  font-size: var(--font-size-heading);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--text-on-dark);
  margin-bottom: var(--space-sm);
}

.business-hero p {
  font-size: var(--font-size-subheading);
  color: var(--text-on-dark);
  opacity: 0.9;
  line-height: var(--line-height-normal);
}

/* Segment Section — full-width section wrapper */
.segment-section {
  background: var(--bg-light);
  padding: var(--space-2xl) 0;
}

/* Alternating background for even segment sections */
.segment-section--alt {
  background: var(--color-latte);
}

/* Segment Section Inner — responsive two-column layout */
.segment-section__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

@media (min-width: 768px) {
  .segment-section__inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    align-items: start;
  }

  /* Reverse column order for alt sections (products col moves left) */
  .segment-section--alt .segment-section__products {
    order: -1;
  }
}

/* Segment Content Block — icon + headline + tagline + benefits + CTA */
.segment-section__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Segment Icon — SVG container */
.segment-section__icon {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.segment-section__icon svg {
  width: 100%;
  height: 100%;
  stroke: var(--text-primary);
}

@media (min-width: 768px) {
  .segment-section__icon {
    width: 80px;
    height: 80px;
  }
}

/* Segment Benefits — UL list of benefit bullets */
.segment-section__benefits {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Segment Benefit Item — single bullet with inline SVG checkmark */
.segment-section__benefit {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  font-size: var(--font-size-body);
  color: var(--text-secondary);
  line-height: var(--line-height-normal);
}

/* Segment Products Block — product cards stacked in the second column */
.segment-section__products {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.segment-section__products .card-product {
  width: 100%;
}

/* KP Form Section — centered form section with latte background */
.kp-form-section {
  background: var(--color-latte);
  padding: var(--space-3xl) 0;
}

/* KP Form Container — centered max-width wrapper */
.kp-form {
  max-width: 640px;
  margin: 0 auto;
}

/* KP Form Row — pairs short fields side by side at tablet+ */
.kp-form__row {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

@media (min-width: 768px) {
  .kp-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
  }
}
