/**
 * CMS Component Styles
 *
 * Matches dealer-template.css aesthetic for consistent branding.
 * These styles are used in statically generated dealer pages.
 *
 * Browser Requirements:
 * - Tabs component uses CSS :has() selector (Chrome 105+, Safari 15.4+, Firefox 121+)
 * - Users on older browsers will see tab content but without active tab highlighting
 */

/* ==================== CSS VARIABLES ==================== */
:root {
  --cms-primary: #093b66;
  --cms-accent: #f8981d;
  --cms-text: #000000;
  --cms-text-muted: #757575;
  --cms-bg-light: #f0f0f0;
  --cms-bg-white: #ffffff;
  --cms-border: #c6c6c6;
  --cms-radius: 8px;
  --cms-radius-lg: 12px;
}

/* ==================== MAIN CONTENT AREA ==================== */
.site-main {
  min-height: 60vh;
  padding: 2rem 0;
  background-color: #ffffff;
}

.site-main .container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* .page-content {
  max-width: 900px;
} */

/* ==================== RICH TEXT ==================== */
.cms-rich-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--cms-text);
}

.cms-rich-text p {
  margin-bottom: 1rem;
}

.cms-rich-text a {
  color: var(--cms-primary);
  text-decoration: underline;
}

.cms-rich-text a:hover {
  color: var(--cms-accent);
}

.cms-rich-text strong {
  font-weight: 600;
}

.cms-rich-text ul,
.cms-rich-text ol {
  margin: 1rem 0;
  padding-left: 2rem;
}

.cms-rich-text li {
  margin-bottom: 0.5rem;
}

.cms-rich-text blockquote {
  border-left: 4px solid var(--cms-primary);
  padding-left: 1rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--cms-text-muted);
}

/* ==================== HEADINGS ==================== */
.container > h1 {
  color: var(--cms-primary);
  font-weight: 600;
  margin-bottom: 1rem;
  line-height: 1.2;
  font-size: 3rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--cms-border);
}
.cms-heading,
.lexical-heading-h2,
.lexical-heading-h3,
.lexical-heading-h4 {
  color: var(--cms-primary);
  font-weight: 600;
  margin-bottom: 1rem;
  line-height: 1.2;
}

h2.cms-heading,
.lexical-heading-h2 {
  font-size: 2rem;
}

h3.cms-heading,
.lexical-heading-h3 {
  font-size: 1.5rem;
}

h4.cms-heading,
.lexical-heading-h4 {
  font-size: 1.25rem;
}

/* ==================== ACCORDION ==================== */
.cms-accordion {
  margin: 1.5rem 0;
}

.cms-accordion-item {
  border: 1px solid var(--cms-border);
  border-radius: var(--cms-radius);
  margin-bottom: 0.5rem;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.cms-accordion-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cms-accordion-item summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  background-color: var(--cms-bg-white);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.cms-accordion-item summary:hover {
  background-color: var(--cms-bg-light);
  color: var(--cms-primary);
}

.cms-accordion-item summary:focus-visible {
  outline: 2px solid var(--cms-primary);
  outline-offset: -2px;
}

.cms-accordion-item summary::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--cms-primary);
}

.cms-accordion-item[open] summary {
  background-color: var(--cms-bg-light);
  border-bottom: 1px solid var(--cms-border);
  color: var(--cms-primary);
}

.cms-accordion-item[open] summary::after {
  content: '−';
}

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

.cms-accordion-content {
  padding: 1.25rem;
  background-color: var(--cms-bg-white);
  animation: accordion-open 0.15s ease-out;
}

/* Opacity-only animation to avoid Cumulative Layout Shift (CLS) */
@keyframes accordion-open {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ==================== TABS ==================== */
.cms-tabs {
  margin: 1.5rem 0;
}

.cms-tabs-list {
  display: flex;
  border-bottom: 2px solid var(--cms-border);
  gap: 0;
}

.cms-tab-radio {
  display: none;
}

.cms-tab-label {
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--cms-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s ease;
  border-radius: var(--cms-radius) var(--cms-radius) 0 0;
}

.cms-tab-label:hover {
  color: var(--cms-primary);
  background-color: rgba(9, 59, 102, 0.05);
}

.cms-tab-label:focus-visible {
  outline: 2px solid var(--cms-primary);
  outline-offset: -2px;
}

/* FIX: Use :has() selector since labels are not adjacent to radios */
/* The labels are nested inside .cms-tabs-list, so we use :has() to check parent state */
/* Support up to 10 tabs */
.cms-tabs:has(.cms-tab-radio:nth-of-type(1):checked) .cms-tab-label:nth-of-type(1),
.cms-tabs:has(.cms-tab-radio:nth-of-type(2):checked) .cms-tab-label:nth-of-type(2),
.cms-tabs:has(.cms-tab-radio:nth-of-type(3):checked) .cms-tab-label:nth-of-type(3),
.cms-tabs:has(.cms-tab-radio:nth-of-type(4):checked) .cms-tab-label:nth-of-type(4),
.cms-tabs:has(.cms-tab-radio:nth-of-type(5):checked) .cms-tab-label:nth-of-type(5),
.cms-tabs:has(.cms-tab-radio:nth-of-type(6):checked) .cms-tab-label:nth-of-type(6),
.cms-tabs:has(.cms-tab-radio:nth-of-type(7):checked) .cms-tab-label:nth-of-type(7),
.cms-tabs:has(.cms-tab-radio:nth-of-type(8):checked) .cms-tab-label:nth-of-type(8),
.cms-tabs:has(.cms-tab-radio:nth-of-type(9):checked) .cms-tab-label:nth-of-type(9),
.cms-tabs:has(.cms-tab-radio:nth-of-type(10):checked) .cms-tab-label:nth-of-type(10) {
  color: var(--cms-primary);
  border-bottom-color: var(--cms-primary);
  font-weight: 600;
  background-color: rgba(9, 59, 102, 0.03);
}

.cms-tabs-content {
  padding: 1rem 0;
}

.cms-tab-panel {
  display: none;
  animation: tab-fade-in 0.2s ease-out;
}

@keyframes tab-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Show active tab panel based on radio selection - support up to 10 tabs */
.cms-tab-radio:nth-of-type(1):checked ~ .cms-tabs-content .cms-tab-panel:nth-of-type(1),
.cms-tab-radio:nth-of-type(2):checked ~ .cms-tabs-content .cms-tab-panel:nth-of-type(2),
.cms-tab-radio:nth-of-type(3):checked ~ .cms-tabs-content .cms-tab-panel:nth-of-type(3),
.cms-tab-radio:nth-of-type(4):checked ~ .cms-tabs-content .cms-tab-panel:nth-of-type(4),
.cms-tab-radio:nth-of-type(5):checked ~ .cms-tabs-content .cms-tab-panel:nth-of-type(5),
.cms-tab-radio:nth-of-type(6):checked ~ .cms-tabs-content .cms-tab-panel:nth-of-type(6),
.cms-tab-radio:nth-of-type(7):checked ~ .cms-tabs-content .cms-tab-panel:nth-of-type(7),
.cms-tab-radio:nth-of-type(8):checked ~ .cms-tabs-content .cms-tab-panel:nth-of-type(8),
.cms-tab-radio:nth-of-type(9):checked ~ .cms-tabs-content .cms-tab-panel:nth-of-type(9),
.cms-tab-radio:nth-of-type(10):checked ~ .cms-tabs-content .cms-tab-panel:nth-of-type(10) {
  display: block;
}

/* ==================== SPACER ==================== */
.cms-spacer {
  display: block;
}

/* ==================== DIVIDER ==================== */
.cms-divider {
  border: none;
  border-top: 1px solid var(--cms-border);
  margin: 2rem 0;
}

/* ==================== HERO ==================== */
.cms-hero {
  position: relative;
  padding: 5rem 2rem;
  text-align: center;
  color: #ffffff;
  margin: 0 -2rem; /* Full-width bleed */
}

.cms-hero-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
}

.cms-hero-content {
  position: relative;
  z-index: 10;
  max-width: 800px;
  margin: 0 auto;
}

.cms-hero-headline {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #ffffff;
}

.cms-hero-subheadline {
  font-size: 1.25rem;
  margin-bottom: 2rem;
  opacity: 0.9;
}

.cms-hero-button {
  display: inline-block;
  background-color: var(--cms-accent);
  color: var(--cms-text);
  font-weight: 600;
  padding: 0.75rem 2rem;
  border-radius: 32.5px;
  text-decoration: none;
  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}

.cms-hero-button:hover {
  background-color: #e88a17;
  transform: translateY(-2px);
}

/* ==================== IMAGE ==================== */
.cms-image {
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
}

.cms-image img {
  max-width: 100%;
  height: auto;
  border-radius: var(--cms-radius);
}

.cms-image--full {
  width: 100%;
}

.cms-image--full img {
  width: 100%;
}

.cms-image--half {
  width: 50%;
}

.cms-image--left {
  align-items: flex-start;
}

.cms-image--center {
  align-items: center;
}

.cms-image--right {
  align-items: flex-end;
}

.cms-image figcaption {
  font-size: 0.9rem;
  color: #555555; /* Darker than --cms-text-muted for better readability */
  margin-top: 0.75rem;
  text-align: inherit;
  font-style: italic;
  line-height: 1.4;
}

/* ==================== TWO COLUMN LAYOUT ==================== */
.cms-two-column {
  display: grid;
  margin: 1.5rem 0;
}

.cms-two-column--50-50 {
  grid-template-columns: 1fr 1fr;
}

.cms-two-column--33-67 {
  grid-template-columns: 1fr 2fr;
}

.cms-two-column--67-33 {
  grid-template-columns: 2fr 1fr;
}

.cms-two-column--gap-small {
  gap: 1rem;
}

.cms-two-column--gap-medium {
  gap: 2rem;
}

.cms-two-column--gap-large {
  gap: 3rem;
}

.cms-column-left,
.cms-column-right {
  min-width: 0; /* Prevent grid blowout */
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .cms-two-column {
    grid-template-columns: 1fr !important;
  }

  .cms-two-column--gap-small,
  .cms-two-column--gap-medium,
  .cms-two-column--gap-large {
    gap: 1.5rem;
  }

  .cms-image--half {
    width: 100%;
  }

  .cms-hero {
    padding: 3rem 1.5rem;
  }

  .cms-hero-headline {
    font-size: 2rem;
  }

  .cms-hero-subheadline {
    font-size: 1rem;
  }

  h2.cms-heading {
    font-size: 1.75rem;
  }

  h3.cms-heading {
    font-size: 1.25rem;
  }

  .cms-tabs-list {
    flex-wrap: wrap;
  }

  .cms-tab-label {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}

/* ==================== BLOG STYLES ==================== */
.blog-post-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--cms-border);
}

.blog-post-header h1 {
  color: var(--cms-primary);
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.blog-meta {
  color: var(--cms-text-muted);
  font-size: 0.875rem;
  display: flex;
  gap: 1rem;
}

.blog-post-preview {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--cms-border);
}

.blog-post-preview h2 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.blog-post-preview h2 a {
  color: var(--cms-primary);
  text-decoration: none;
}

.blog-post-preview h2 a:hover {
  text-decoration: underline;
}

.blog-post-preview .excerpt {
  color: var(--cms-text-muted);
  margin: 0.75rem 0;
}

.blog-post-preview .read-more {
  color: var(--cms-accent);
  font-weight: 600;
  text-decoration: none;
}

.blog-post-preview .read-more:hover {
  text-decoration: underline;
}
