/* ==========================================================================
   Shortcode Styles
   Extracted from inline styles in layouts/shortcodes/
   ========================================================================== */

/* ==========================================================================
   FAQ Shortcode - layouts/shortcodes/faq.html
   ========================================================================== */

.faq-section {
  max-width: 800px;
}

.faq-search-wrapper {
  display: none; /* Hidden by default, shown by JS */
}

.faq-search-wrapper.faq-search-active {
  display: block;
}

.faq-search-input:focus {
  box-shadow: none;
  border-color: #0d6efd;
}

.faq-item {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

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

.faq-item[open] {
  border-color: #0d6efd;
}

.faq-question {
  padding: 1rem 1.25rem;
  margin: 0;
  cursor: pointer;
  list-style: none;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.faq-icon {
  transition: transform 0.2s ease;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.faq-item[open] .faq-icon {
  transform: rotate(90deg);
}

.faq-item[open] .faq-question {
  background: #e7f1ff;
}

.faq-answer {
  padding: 0 1.25rem 1rem;
  line-height: 1.7;
}

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

/* Search highlight */
.faq-highlight {
  background-color: #fff3cd;
  padding: 0.1em 0.2em;
  border-radius: 2px;
}

/* Status text */
.faq-search-status:empty {
  display: none;
}

/* ==========================================================================
   Cost Reference Table - layouts/shortcodes/cost-reference-table.html
   ========================================================================== */

.cost-reference-table-wrapper {
  max-height: 600px;
  overflow-y: auto;
  overflow-x: auto; /* Enable horizontal scroll on mobile */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Visual scroll indicator for mobile */
.cost-reference-table-wrapper::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(to right, transparent, rgba(0,0,0,0.05));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.cost-reference-table-wrapper.has-overflow::after {
  opacity: 1;
}

.cost-reference-table {
  min-width: 500px; /* Prevent table from collapsing too much */
}

.cost-reference-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.cost-reference-table tbody tr:hover {
  background-color: rgba(13, 110, 253, 0.075) !important;
}

.cost-reference-table td a {
  color: inherit;
}

.cost-reference-table td a:hover {
  text-decoration: underline !important;
}

/* Mobile responsiveness */
@media (max-width: 576px) {
  .cost-reference-table-wrapper {
    position: relative;
    margin: 0 -0.5rem; /* Extend to edges on mobile */
    padding: 0 0.5rem;
  }

  .cost-reference-table {
    font-size: 0.8rem;
  }

  .cost-reference-table th,
  .cost-reference-table td {
    padding: 0.5rem 0.25rem;
    white-space: nowrap; /* Prevent text wrap in cells */
  }

  /* Allow state name column to wrap */
  .cost-reference-table td:first-child {
    white-space: normal;
    min-width: 100px;
  }
}

/* Very small screens */
@media (max-width: 380px) {
  .cost-reference-table {
    font-size: 0.75rem;
  }

  .cost-reference-table th,
  .cost-reference-table td {
    padding: 0.4rem 0.2rem;
  }
}

@media print {
  .cost-reference-table-wrapper {
    max-height: none;
    overflow: visible;
  }
  .cost-reference-table thead {
    position: static;
  }
}

/* ==========================================================================
   Coverage Quiz - layouts/shortcodes/coverage-quiz.html
   ========================================================================== */

/* Quiz container */
.coverage-quiz {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Question transitions */
.quiz-question {
  animation: quizFadeIn 0.3s ease-in-out;
}

@keyframes quizFadeIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Option buttons */
.quiz-option {
  padding: 0.875rem 1rem;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.quiz-option:hover {
  transform: translateX(4px);
}

.quiz-option:focus {
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

.quiz-option.selected {
  background-color: var(--bs-primary);
  color: white;
  border-color: var(--bs-primary);
}

/* Recommendation cards */
.recommendation-card {
  border-left: 4px solid var(--bs-primary);
  background: var(--bs-light);
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 0 0.375rem 0.375rem 0;
}

.recommendation-card.priority-high {
  border-left-color: var(--bs-danger);
}

.recommendation-card.priority-medium {
  border-left-color: var(--bs-warning);
}

.recommendation-card.priority-low {
  border-left-color: var(--bs-info);
}

.recommendation-card h4 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.recommendation-card p {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

/* Results animation */
.quiz-results {
  animation: quizFadeIn 0.4s ease-in-out;
}

/* Dark mode support */
[data-bs-theme="dark"] .recommendation-card {
  background: var(--bs-dark);
}

/* Print: hide quiz */
@media print {
  .coverage-quiz {
    display: none !important;
  }
}

/* ==========================================================================
   Life Insurance Calculator - layouts/shortcodes/life-insurance-calculator.html
   ========================================================================== */

#life-calc-container .form-label {
  font-weight: 500;
}

#life-calc-container .form-text {
  font-size: 0.8rem;
}

#life-calc-container fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

#life-calc-container legend {
  width: 100%;
}

#life-calc-container .display-4 {
  color: var(--bs-success);
}

@media print {
  #life-calc-container button {
    display: none;
  }

  #life-calc-container #calc-results {
    display: block !important;
  }
}

/* Dark mode support for life calculator */
[data-bs-theme="dark"] #life-calc-container {
  background: var(--bs-body-bg);
}

[data-bs-theme="dark"] #life-calc-container .card-header {
  background: var(--bs-primary) !important;
}

[data-bs-theme="dark"] #life-calc-container .form-control {
  background: var(--bs-body-bg);
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] #life-calc-container .input-group-text {
  background: var(--bs-secondary-bg);
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] #life-calc-container .form-text {
  color: var(--bs-secondary-color);
}

/* ==========================================================================
   Deductible vs Premium Calculator - layouts/shortcodes/deductible-premium-calculator.html
   ========================================================================== */

#deductible-calc-container .form-label {
  font-weight: 500;
}

#deductible-calc-container .form-text {
  font-size: 0.8rem;
}

#deductible-calc-container fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

#deductible-calc-container legend {
  width: 100%;
}

#deductible-calc-container .display-6 {
  font-size: 1.75rem;
}

@media print {
  #deductible-calc-container button {
    display: none;
  }

  #deductible-calc-container #deductible-calc-results {
    display: block !important;
  }
}

/* Dark mode support for deductible calculator */
[data-bs-theme="dark"] #deductible-calc-container {
  background: var(--bs-body-bg);
}

[data-bs-theme="dark"] #deductible-calc-container .card-header {
  background: var(--bs-primary) !important;
}

[data-bs-theme="dark"] #deductible-calc-container .form-control {
  background: var(--bs-body-bg);
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] #deductible-calc-container .input-group-text {
  background: var(--bs-secondary-bg);
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] #deductible-calc-container .form-text {
  color: var(--bs-secondary-color);
}

/* ==========================================================================
   Glossary Term Tooltip - layouts/shortcodes/glossary-term.html
   ========================================================================== */

.glossary-tooltip {
  /* Visual indicator that term has a definition */
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--bs-primary, #0d6efd);
  text-underline-offset: 3px;
  cursor: help;
  position: relative;
}

a.glossary-tooltip {
  color: var(--bs-primary, #0d6efd);
}

a.glossary-tooltip:hover {
  text-decoration-style: solid;
}

/* Tooltip popup using pure CSS */
.glossary-tooltip::after {
  content: attr(data-definition);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 0.75rem;
  background: #333;
  color: #fff;
  font-size: 0.875rem;
  font-weight: normal;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;

  /* Offset above the term */
  margin-bottom: 8px;
}

/* Arrow pointing down */
.glossary-tooltip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #333;
  z-index: 1001;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;

  /* Position arrow */
  margin-bottom: 2px;
}

/* Show tooltip on hover and focus */
.glossary-tooltip:hover::after,
.glossary-tooltip:hover::before,
.glossary-tooltip:focus::after,
.glossary-tooltip:focus::before {
  opacity: 1;
  visibility: visible;
}

/* Adjust position for terms near edges */
.glossary-tooltip.tooltip-left::after {
  left: 0;
  transform: translateX(0);
}

.glossary-tooltip.tooltip-right::after {
  left: auto;
  right: 0;
  transform: translateX(0);
}

/* Dark mode support */
[data-bs-theme="dark"] .glossary-tooltip::after {
  background: #f8f9fa;
  color: #212529;
}

[data-bs-theme="dark"] .glossary-tooltip::before {
  border-top-color: #f8f9fa;
}

/* Missing term indicator (for development) */
.glossary-term-missing {
  color: var(--bs-warning, #ffc107);
  text-decoration: wavy underline;
}

/* Mobile: show definitions inline since tooltips are harder to trigger */
@media (max-width: 768px) {
  .glossary-tooltip::after,
  .glossary-tooltip::before {
    display: none;
  }

  /* On mobile, tapping shows the definition via title attribute */
  .glossary-tooltip {
    cursor: pointer;
  }
}

/* Print: show term but remove interactive styling */
@media print {
  .glossary-tooltip {
    text-decoration: none;
    cursor: default;
  }

  .glossary-tooltip::after,
  .glossary-tooltip::before {
    display: none;
  }
}

/* ==========================================================================
   Breadcrumb Navigation - layouts/partials/breadcrumb.html
   ========================================================================== */

.breadcrumb-nav {
  font-size: 0.875rem;
}

.breadcrumb-nav .breadcrumb {
  background: transparent;
  padding: 0;
}

.breadcrumb-nav .breadcrumb-item a {
  color: var(--bs-secondary);
  text-decoration: none;
}

.breadcrumb-nav .breadcrumb-item a:hover {
  color: var(--bs-primary);
  text-decoration: underline;
}

.breadcrumb-nav .breadcrumb-item.active {
  color: var(--bs-body-color);
  font-weight: 500;
}

/* Home icon styling */
.breadcrumb-nav .breadcrumb-item:first-child a {
  color: var(--bs-primary);
}

/* Separator styling */
.breadcrumb-nav .breadcrumb-item + .breadcrumb-item::before {
  color: var(--bs-secondary);
}

/* Print: show full breadcrumb path */
@media print {
  .breadcrumb-nav {
    margin-bottom: 1rem;
  }

  .breadcrumb-nav .breadcrumb-item a {
    color: #000;
  }
}

/* ==========================================================================
   Newsletter Signup CTA - layouts/shortcodes/newsletter-signup.html
   ========================================================================== */

.newsletter-signup {
  transition: box-shadow 0.2s ease;
}

.newsletter-signup:hover {
  box-shadow: 0 4px 12px rgba(var(--bs-primary-rgb), 0.15);
}

.newsletter-form .form-control {
  border-color: var(--bs-primary);
}

.newsletter-form .form-control:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Dark mode adjustments */
[data-bs-theme="dark"] .newsletter-signup {
  background: rgba(var(--bs-primary-rgb), 0.15) !important;
  border-color: rgba(var(--bs-primary-rgb), 0.3) !important;
}

/* Mobile: stack form elements */
@media (max-width: 991px) {
  .newsletter-signup .row > [class*="col-"] {
    text-align: center;
  }

  .newsletter-form {
    max-width: 400px;
    margin: 1rem auto 0;
  }
}

/* Print: hide newsletter signup */
@media print {
  .newsletter-signup {
    display: none !important;
  }
}

/* ==========================================================================
   Disabled State Styling
   Visual feedback for disabled form elements
   ========================================================================== */

button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
.btn:disabled,
.btn.disabled {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: auto; /* Allow cursor change even when disabled */
}

/* Ensure disabled buttons don't respond to hover */
button:disabled:hover,
.btn:disabled:hover,
.btn.disabled:hover {
  transform: none;
  box-shadow: none;
}

/* ==========================================================================
   Reduced Motion Support
   Disables animations for users who prefer reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  /* FAQ accordion transitions */
  .faq-item,
  .faq-icon {
    transition: none;
  }

  /* Quiz animations */
  .quiz-question,
  .quiz-results {
    animation: none;
  }

  .quiz-option {
    transition: none;
  }

  .quiz-option:hover {
    transform: none;
  }

  /* Glossary tooltip transitions */
  .glossary-tooltip::after,
  .glossary-tooltip::before {
    transition: none;
  }

  /* Newsletter hover effect */
  .newsletter-signup {
    transition: none;
  }
}

/* ==========================================================================
   Touch Target Sizing - WCAG 2.5.5 Level AAA Compliance
   Ensures all interactive elements have minimum 44x44px touch targets
   ========================================================================== */

/* Base touch target improvements for all interactive elements */
.quiz-option,
.faq-question,
.btn,
#life-calc-container button,
#deductible-calc-container button {
  min-height: 44px;
  touch-action: manipulation; /* Prevents double-tap zoom delay */
}

/* Quiz option buttons - ensure adequate touch target */
.quiz-option {
  min-height: 48px;
  display: flex;
  align-items: center;
}

/* FAQ question summaries */
.faq-question {
  min-height: 48px;
}

/* Form inputs in calculators */
#life-calc-container .form-control,
#deductible-calc-container .form-control,
.coverage-quiz .form-control {
  min-height: 44px;
  touch-action: manipulation;
}

/* Newsletter form input */
.newsletter-form .form-control {
  min-height: 44px;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Increase padding on touch devices for easier tapping */
  .quiz-option {
    padding: 1rem 1.25rem;
    min-height: 52px;
  }

  .faq-question {
    padding: 1.25rem 1.5rem;
    min-height: 52px;
  }

  /* Larger buttons on touch devices */
  #life-calc-container .btn,
  #deductible-calc-container .btn,
  .coverage-quiz .btn {
    padding: 0.875rem 1.5rem;
    min-height: 48px;
  }

  /* Add spacing between interactive elements to prevent accidental taps */
  .quiz-option + .quiz-option {
    margin-top: 0.5rem;
  }

  .faq-item + .faq-item {
    margin-top: 0.75rem;
  }

  /* Ensure form controls have adequate spacing */
  #life-calc-container .form-control,
  #deductible-calc-container .form-control {
    min-height: 48px;
    font-size: 1rem; /* Prevent zoom on iOS */
  }

  /* Glossary terms need larger tap targets on mobile */
  .glossary-tooltip {
    padding: 0.25rem 0.125rem;
    margin: -0.25rem -0.125rem;
  }
}

/* Ensure links within content have adequate touch targets */
.faq-answer a,
.recommendation-card a,
.coverage-quiz a {
  display: inline-block;
  min-height: 44px;
  line-height: 44px;
  vertical-align: middle;
}

/* ==========================================================================
   Review Widget - layouts/shortcodes/review-widget.html
   ========================================================================== */

.review-widget {
  border-left: 4px solid var(--bs-warning, #ffc107);
}

.review-widget .rating-stars {
  font-size: 1.1rem;
  letter-spacing: 0.1em;
}

.review-widget .rating-stars .fa-star,
.review-widget .rating-stars .fa-star-half-alt {
  color: var(--bs-warning, #ffc107);
}

.review-widget .rating-stars .far.fa-star {
  color: var(--bs-secondary, #6c757d);
  opacity: 0.5;
}

.review-widget.aggregate-rating {
  background: linear-gradient(135deg, var(--bs-light) 0%, rgba(255, 193, 7, 0.05) 100%);
}

.review-widget.individual-review blockquote {
  border-left: 3px solid var(--bs-primary, #0d6efd);
  padding-left: 1rem;
  margin-left: 0;
  font-style: italic;
  color: var(--bs-body-color);
}

.review-widget .review-source {
  font-style: italic;
}

/* Dark mode support */
[data-bs-theme="dark"] .review-widget {
  border-left-color: var(--bs-warning, #ffc107);
}

[data-bs-theme="dark"] .review-widget.aggregate-rating {
  background: linear-gradient(135deg, var(--bs-dark) 0%, rgba(255, 193, 7, 0.1) 100%);
}

[data-bs-theme="dark"] .review-widget.individual-review blockquote {
  border-left-color: var(--bs-primary, #6ea8fe);
}

/* Print: show reviews clearly */
@media print {
  .review-widget {
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .review-widget .rating-stars {
    display: none;
  }

  .review-widget .rating-text::after {
    content: " stars";
  }
}

/* ==========================================================================
   Category Landing Pages - layouts/categories/term.html
   ========================================================================== */

.category-header {
  border-bottom: 1px solid var(--bs-border-color);
  padding-bottom: 1.5rem;
}

.category-header .display-5 {
  color: var(--bs-primary);
}

.category-intro {
  font-size: 1.05rem;
  line-height: 1.7;
}

.category-intro ul,
.category-intro ol {
  margin-top: 0.5rem;
}

/* Featured posts cards */
.featured-posts .featured-card {
  border-left: 4px solid var(--bs-warning);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.featured-posts .featured-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.featured-posts .card-title a {
  color: var(--bs-body-color);
}

.featured-posts .card-title a:hover {
  color: var(--bs-primary);
}

/* Related categories badges */
.related-categories .btn {
  transition: background-color 0.15s ease;
}

.related-categories .badge {
  font-weight: normal;
}

/* Dark mode adjustments */
[data-bs-theme="dark"] .category-header {
  border-bottom-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .featured-posts .featured-card {
  background: var(--bs-dark);
}

[data-bs-theme="dark"] .featured-posts .featured-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .featured-posts .featured-card {
    transition: none;
  }

  .featured-posts .featured-card:hover {
    transform: none;
  }
}

/* Print: clean category layout */
@media print {
  .category-header {
    border-bottom: none;
    padding-bottom: 0;
  }

  .featured-posts,
  .related-categories {
    display: none;
  }
}
