/*
 * RJ Park Frontend - FAQ Component
 * Ported from rjdev-faq v1.2.0 (Navy Edge Style).
 * Uses shared design tokens from shared.css.
 */

/* ─────────────────────────────────────────
   CONTAINER
───────────────────────────────────────── */

.rjdev-faq-container {
  font-family: inherit;
  color: var(--rj-text);
  width: 100%;
  border: 1px solid var(--rj-border-medium);
  border-radius: var(--rj-radius-sm);
  overflow: hidden;
  background: var(--rj-bg-white);
}

/* Error and Notice States */
.rjdev-faq-error,
.rjdev-faq-notice {
  text-align: center;
  padding: 2rem;
  border-radius: var(--rj-radius-sm);
  margin: 1rem 0;
}

.rjdev-faq-error {
  color: var(--rj-color-error);
  background: var(--rj-color-error-bg);
  border: 1px solid var(--rj-color-error-border);
}

.rjdev-faq-notice {
  color: var(--rj-text-light);
  background: var(--rj-bg-alt);
  border: 1px solid var(--rj-border-light);
}

/* ─────────────────────────────────────────
   HEADER (search + pills)
───────────────────────────────────────── */

.faq-header {
  padding: var(--rj-space-md) var(--rj-space-md) 0;
}

/* ─────────────────────────────────────────
   SEARCH BAR
───────────────────────────────────────── */

.faq-search-wrapper {
  position: relative;
  margin-bottom: var(--rj-space-sm-md);
}

.faq-search-wrapper .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  pointer-events: none;
  color: var(--rj-text-muted);
}

.faq-search-input {
  width: 100%;
  font-family: inherit;
  font-size: var(--rj-font-size-base);
  font-weight: 400;
  color: var(--rj-text);
  background: var(--rj-bg-white);
  padding: 10px 36px 10px 38px;
  border: 1.5px solid var(--rj-input-border);
  border-radius: var(--rj-radius-sm);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-appearance: none;
}

.faq-search-input::placeholder {
  color: var(--rj-text-muted);
}

.faq-search-input:focus {
  border-color: var(--rj-primary);
  box-shadow: var(--rj-focus-ring);
}

.faq-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: var(--rj-space-xs);
  cursor: pointer;
  color: var(--rj-text-muted);
  font-size: var(--rj-font-size-sm);
  line-height: 1;
  display: none;
  transition: color 0.15s;
}

.faq-search-clear:hover {
  color: var(--rj-text-light);
}

.faq-search-clear.visible {
  display: block;
}

/* ─────────────────────────────────────────
   CATEGORY PILLS
───────────────────────────────────────── */

.faq-category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 14px;
  border: none;
}

.faq-filter-btn {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: var(--rj-font-weight-medium);
  padding: var(--rj-space-xs) var(--rj-space-sm-md);
  border-radius: var(--rj-radius-pill);
  cursor: pointer;
  transition: all 0.16s;
  white-space: nowrap;
  user-select: none;
  background: var(--rj-bg-muted);
  border: 1.5px solid transparent;
  color: var(--rj-text-light);
  outline: none;
}

.faq-filter-btn:hover {
  background: var(--rj-bg-muted-hover);
  color: var(--rj-text);
}

.faq-filter-btn.active {
  background: var(--rj-primary);
  border-color: var(--rj-primary);
  color: var(--rj-bg-white);
}

.faq-count {
  opacity: 0.5;
  font-size: 0.9em;
  margin-left: 2px;
}

/* ─────────────────────────────────────────
   FAQ LIST
───────────────────────────────────────── */

.faq-content-wrapper {
  position: relative;
  border-top: 1px solid var(--rj-border-subtle);
}

.faq-items {
  position: relative;
}

/* Category group labels */
.faq-category-group.cat-hidden {
  display: none;
}

.faq-category-label {
  font-size: 10.5px;
  font-weight: var(--rj-font-weight-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rj-text-light);
  padding: var(--rj-space-md) var(--rj-space-md) var(--rj-space-sm);
  display: block;
}

.faq-category-group:first-child .faq-category-label {
  padding-top: var(--rj-space-sm-md);
}

/* ─────────────────────────────────────────
   FAQ ITEMS -- ACCORDION VIA <details>
───────────────────────────────────────── */

.faq-item {
  border-bottom: 1px solid var(--rj-border-subtle);
  border-left: 3px solid transparent;
  transition: border-color 0.2s, background 0.15s, opacity var(--rj-transition);
}

.faq-item:last-of-type {
  border-bottom: none;
}

/* Gold left-border + subtle bg on open */
/* Note: #fafaf8 is a warm near-white that complements the gold border;
   --rj-bg-alt (#f8fafc) has a cool blue cast that conflicts with it. */
.faq-item:has(details[open]) {
  border-left-color: var(--rj-secondary);
  background: #fafaf8;
}

.faq-item.faq-hidden-more {
  display: none;
}

.faq-item.faq-revealing {
  opacity: 0;
  animation: faqReveal 0.3s ease forwards;
}

@keyframes faqReveal {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Remove native <details> marker */
.faq-item details summary {
  list-style: none;
}

.faq-item details summary::-webkit-details-marker {
  display: none;
}

.faq-question {
  width: 100%;
  background: none;
  border: none;
  padding: var(--rj-space-sm-md) var(--rj-space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  gap: 10px;
  text-align: left;
  font-family: inherit;
  transition: background 0.12s;
}

.faq-question:hover {
  background: rgba(37, 49, 75, 0.02);
}

.faq-question-text {
  font-size: var(--rj-font-size-base);
  font-weight: var(--rj-font-weight-semibold);
  color: var(--rj-text-dark);
  line-height: 1.4;
  flex: 1;
}

.faq-toggle-icon {
  width: var(--rj-space-lg);
  height: var(--rj-space-lg);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--rj-text-muted);
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s;
}

.faq-toggle-icon svg {
  width: var(--rj-space-md);
  height: var(--rj-space-md);
  display: block;
}

.faq-item details[open] .faq-toggle-icon {
  transform: rotate(180deg);
  color: var(--rj-primary);
}

.faq-answer-wrap {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.34s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-item details[open] .faq-answer-wrap {
  max-height: 300px;
}

.faq-answer-content {
  padding: 0 var(--rj-space-md) 14px var(--rj-space-md);
  font-size: 15px;
  line-height: 1.65;
  color: var(--rj-text-light);
  font-weight: 400;
}

.faq-answer-content p {
  margin: 0 0 0.75rem;
}

.faq-answer-content p:last-child {
  margin-bottom: 0;
}

/* ─────────────────────────────────────────
   FOOTER (contact + show all)
───────────────────────────────────────── */

.faq-footer {
  padding: 14px var(--rj-space-md);
  border-top: 1px solid var(--rj-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rj-space-sm-md);
  font-size: var(--rj-font-size-xs);
  color: var(--rj-text-light);
  font-weight: 400;
}

.faq-footer a {
  color: var(--rj-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.faq-footer a:hover {
  color: var(--rj-text);
}

.faq-show-more-wrap {
  flex-shrink: 0;
}

.faq-show-more-wrap.hidden {
  display: none;
}

.btn-show-all {
  font-family: inherit;
  font-size: var(--rj-font-size-xs);
  font-weight: var(--rj-font-weight-semibold);
  padding: 7px var(--rj-space-md);
  background: var(--rj-primary);
  color: var(--rj-bg-white);
  border: none;
  border-radius: var(--rj-radius-xs);
  cursor: pointer;
  transition: opacity 0.18s;
  white-space: nowrap;
}

.btn-show-all:hover {
  opacity: 0.85;
}

/* ─────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────── */

.faq-empty {
  display: none;
  font-size: 13px;
  color: var(--rj-text-light);
  font-weight: 400;
  padding: var(--rj-space-md-lg) var(--rj-space-md);
}

/* ─────────────────────────────────────────
   SEARCH HIGHLIGHT
───────────────────────────────────────── */

.faq-highlight {
  background-color: var(--rj-color-highlight-bg);
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
  font-weight: var(--rj-font-weight-medium);
  color: var(--rj-text);
}

/* ─────────────────────────────────────────
   MOBILE RESPONSIVE
───────────────────────────────────────── */

@media (max-width: 768px) {
  .rjdev-faq-container {
    border-radius: var(--rj-radius-sm);
  }

  .faq-header {
    padding: 14px 14px 0;
  }

  .faq-search-input {
    font-size: var(--rj-font-size-base);
    padding: 9px 34px 9px 36px;
  }

  .faq-category-filters {
    gap: 5px;
    padding-bottom: var(--rj-space-sm-md);
  }

  .faq-filter-btn {
    font-size: 11px;
    padding: var(--rj-space-xs) 10px;
  }

  .faq-question {
    padding: 11px 14px;
  }

  .faq-question-text {
    font-size: var(--rj-font-size-base);
  }

  .faq-answer-content {
    padding: 0 14px var(--rj-space-sm-md) 14px;
    font-size: 15px;
  }

  .faq-category-label {
    padding: 14px 14px 6px;
    font-size: 11px;
  }

  .faq-footer {
    padding: var(--rj-space-sm-md) 14px;
    font-size: 11.5px;
  }

  .btn-show-all {
    font-size: 11.5px;
    padding: 6px 14px;
  }
}

/* ─────────────────────────────────────────
   "SHOW ALL" MODAL (Variant B -- Flat List)
───────────────────────────────────────── */

.rj-faq-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--rj-overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.rj-faq-modal-overlay.rj-faq-modal-open {
  opacity: 1;
  visibility: visible;
}

.rj-faq-modal {
  background: var(--rj-bg-white);
  border-radius: var(--rj-radius-md);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--rj-transition-spring);
  box-shadow: var(--rj-shadow-lg);
}

.rj-faq-modal-overlay.rj-faq-modal-open .rj-faq-modal {
  transform: translateY(0) scale(1);
}

/* Header */
.rj-faq-modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: var(--rj-space-md-lg) var(--rj-space-lg);
  border-bottom: 1px solid var(--rj-border-light);
  flex-shrink: 0;
}

.rj-faq-modal-header-title {
  font-size: 1rem;
  font-weight: var(--rj-font-weight-bold);
  color: var(--rj-text-dark);
}

.rj-faq-modal-close {
  position: absolute;
  left: var(--rj-space-md);
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--rj-text-dark);
  transition: background 0.15s;
  padding: 0;
}

.rj-faq-modal-close:hover {
  background: var(--rj-bg-muted);
}

/* Body */
.rj-faq-modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 0 var(--rj-space-lg) var(--rj-space-xl);
  -webkit-overflow-scrolling: touch;
}

/* Category groups */
.rj-faq-modal-cat {
  padding-top: var(--rj-space-md-lg);
}

.rj-faq-modal-cat:first-child {
  padding-top: var(--rj-space-md);
}

.rj-faq-modal-cat-label {
  font-size: 10.5px;
  font-weight: var(--rj-font-weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rj-text-light);
  margin-bottom: var(--rj-space-sm-md);
  padding-bottom: var(--rj-space-sm);
  border-bottom: 1px solid var(--rj-border-light);
}

/* Q&A items */
.rj-faq-modal-item {
  margin-bottom: var(--rj-space-md-lg);
  opacity: 0;
  transform: translateY(8px);
  animation: rjFaqModalFade 0.3s ease forwards;
}

.rj-faq-modal-item:last-child {
  margin-bottom: 0;
}

@keyframes rjFaqModalFade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rj-faq-modal-q {
  font-size: 15px;
  font-weight: var(--rj-font-weight-semibold);
  color: var(--rj-text-dark);
  margin-bottom: var(--rj-space-xs);
  line-height: 1.4;
}

.rj-faq-modal-a {
  font-size: var(--rj-font-size-sm);
  color: var(--rj-text-light);
  line-height: 1.65;
}

.rj-faq-modal-a p {
  margin: 0 0 0.5rem;
}

.rj-faq-modal-a p:last-child {
  margin-bottom: 0;
}

/* Drag handle */
.rj-faq-modal-drag-handle {
  display: none;
  justify-content: center;
  padding: var(--rj-space-sm-md) 0 var(--rj-space-xs);
}

.rj-faq-modal-drag-handle span {
  width: 36px;
  height: var(--rj-space-xs);
  background: var(--rj-color-muted-gray);
  border-radius: 2px;
}

/* Body scroll lock */
body.rj-faq-body-locked {
  overflow: hidden;
}

/* Mobile bottom sheet */
@media (max-width: 767px) {
  .rj-faq-modal-overlay {
    align-items: flex-end;
  }

  .rj-faq-modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--rj-radius-lg) var(--rj-radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform var(--rj-transition-spring);
  }

  .rj-faq-modal-overlay.rj-faq-modal-open .rj-faq-modal {
    transform: translateY(0);
  }

  .rj-faq-modal-drag-handle {
    display: flex;
  }

  .rj-faq-modal-body {
    padding-bottom: calc(var(--rj-space-xl) + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .rj-faq-modal-overlay,
  .rj-faq-modal {
    transition-duration: 0.01ms !important;
  }
  .rj-faq-modal-item {
    animation-duration: 0.01ms !important;
  }
}

/* ─────────────────────────────────────────
   PRINT STYLES
───────────────────────────────────────── */

@media print {
  .faq-header,
  .faq-footer {
    display: none;
  }

  .rjdev-faq-container {
    border: none;
  }

  .faq-answer-wrap {
    max-height: none !important;
  }

  .faq-toggle-icon {
    display: none;
  }

  .faq-item {
    border-left: none;
  }
}

/* ─────────────────────────────────────────
   ACCESSIBILITY
───────────────────────────────────────── */

.faq-question:focus-visible {
  outline: 2px solid var(--rj-primary);
  outline-offset: -2px;
}

.faq-filter-btn:focus-visible {
  outline: 2px solid var(--rj-primary);
  outline-offset: 2px;
}

.faq-search-input:focus-visible {
  outline: none;
  border-color: var(--rj-primary);
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .faq-item {
    border-bottom-width: 2px;
  }

  .faq-filter-btn {
    border-width: 2px;
  }

  .faq-search-input {
    border-width: 2px;
  }
}
