/* Features Section - Consolidated Styles
 * Refactored to remove !important by using @layer cascade
 * Layer order defined in main.css: base, components, sections, utilities, responsive
 */

/* ==========================================================================
   CSS CUSTOM PROPERTIES FOR FEATURES
   ========================================================================== */

:root {
  /* Feature grid proportions */
  --feature-cols-sm: 1.1fr 1.4fr 2fr;
  --feature-cols-md: 1.15fr 1.45fr 2.1fr;
  --feature-cols-lg: 1.2fr 1.5fr 2.2fr;
  --feature-cols-xl: 1.25fr 1.55fr 2.3fr;
  --feature-cols-2xl: 1.3fr 1.6fr 2.4fr;
  --feature-cols-3xl: 1.35fr 1.65fr 2.5fr;

  /* Feature spacing - minimal vertical padding */
  --feature-padding-sm: 0.75rem 20px 3.5rem;
  --feature-padding-md: 0.75rem 40px 3.5rem;
  --feature-padding-lg: 0.75rem 80px 3.5rem;
  --feature-padding-xl: 0.75rem 160px 3.5rem;

  /* Feature heights */
  --feature-min-height-sm: 200px;
  --feature-min-height-md: 230px;
  --feature-min-height-lg: 260px;
  --feature-min-height-xl: 300px;

  /* Video container heights */
  --video-height-sm: 180px;
  --video-height-md: 200px;
  --video-height-lg: 220px;
  --video-height-xl: 240px;

  /* Title sizes using clamp for smooth scaling */
  --feature-title-size: clamp(8rem, 12vw + 6rem, 22rem);
  --feature-desc-size: clamp(1rem, 0.5vw + 0.8rem, 1.4rem);
}

/* ==========================================================================
   BASE DESKTOP STYLES (768px+)
   ========================================================================== */

@media screen and (min-width: 768px) {
  /* Container - Full width */
  .interactive-features {
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background-color: #ffffff;
    position: relative;
    z-index: 1;
  }

  .interactive-features .container {
    max-width: 100%;
    width: 100%;
    padding: 0;
    margin: 0;
    overflow: visible;
  }

  /* Feature list - Grid container */
  .feature-list {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: max-content;
    gap: 0;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  /* Feature item - Grid layout */
  a.feature-item,
  .feature-item {
    display: grid;
    grid-template-columns: var(--feature-cols-md);
    width: 100%;
    height: auto;
    max-height: none;
    min-height: var(--feature-min-height-xl);
    padding: 0 160px;
    gap: 0;
    align-items: stretch;
    align-content: stretch;
    overflow: visible;
    border-bottom: 1px solid var(--color-border, #e0e0e0);
    margin: 0;
    box-sizing: border-box;
    position: relative;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.3s ease;
  }

  /* Hover background */
  a.feature-item:hover,
  .feature-item:hover {
    background-color: #e8e8e8;
  }

  a.feature-item:hover .feature-video-container,
  .feature-item:hover .feature-video-container {
    background-color: #e8e8e8;
  }

  /* Column order: Description (1) | Video (2) | Title (3) */
  .feature-description {
    order: 1;
    grid-column: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    position: relative;
    height: 100%;
    min-height: auto;
    max-height: none;
    overflow: visible;
    margin: 0;
    padding: 0;
    color: #333;
  }

  .feature-description p {
    margin: 0 0 1rem 0;
    padding-top: 0;
    overflow: visible;
    text-overflow: initial;
    -webkit-line-clamp: unset;
    display: block;
    max-height: none;
    word-wrap: normal;
    overflow-wrap: normal;
    word-break: keep-all;
    hyphens: none;
    letter-spacing: 0.01em;
    font-size: var(--feature-desc-size);
    font-weight: 585;
    line-height: 1.35;
  }

  .feature-number {
    margin-top: auto;
    padding-top: 1rem;
    opacity: 0.6;
    font-family: monospace;
    font-size: 0.85rem;
  }

  /* Video container - visible by default with symbol */
  .feature-video-container {
    order: 2;
    grid-column: 2;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100%;
    max-height: none;
    overflow: hidden;
    border-radius: 0;
    background: #f0f0f0;
    z-index: 1;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: box-shadow 0.3s ease;
    pointer-events: auto;
    box-shadow: none;
    margin: 0;
    padding: 0;
  }

  /* Video element - hidden by default */
  .feature-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    object-fit: cover;
    object-position: center center;
    transform: none;
    margin: 0;
    padding: 0;
    display: block;
    transition: transform 0.3s ease, opacity 0.3s ease;
    clip-path: none;
    opacity: 0;
    z-index: 1;
  }

  /* Symbol placeholder image - visible by default */
  .feature-symbol {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: left top;
    z-index: 2;
    opacity: 1;
    transition: opacity 0.3s ease;
    transform: scale(1.3);
    transform-origin: left top;
  }

  /* Hover: show video, hide symbol */
  a.feature-item:hover .feature-video,
  .feature-item:hover .feature-video {
    opacity: 1;
    transform: scale(1.02);
  }

  a.feature-item:hover .feature-symbol,
  .feature-item:hover .feature-symbol {
    opacity: 0;
  }

  /* Title column */
  .feature-title {
    order: 3;
    grid-column: 3;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    position: relative;
    height: auto;
    min-height: auto;
    max-height: none;
    overflow: visible;
    margin-top: 0;
    padding-top: 0;
    padding-left: 0.5rem;
    z-index: 10;
  }

  .feature-title h3 {
    font-size: var(--feature-title-size);
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 0.8;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    word-wrap: break-word;
    overflow: visible;
    display: block;
    transition: transform 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
  }

  /* Title shift on hover */
  a.feature-item:hover .feature-title h3,
  .feature-item:hover .feature-title h3 {
    transform: translateX(16px);
  }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* Tablets (768px - 1023px) */
@media screen and (min-width: 768px) and (max-width: 1023px) {
  a.feature-item,
  .feature-item {
    grid-template-columns: var(--feature-cols-sm);
    padding: var(--feature-padding-sm);
    gap: 0;
    min-height: var(--feature-min-height-sm);
  }

  .feature-description {
    padding-right: 0.5rem;
  }

  .feature-description p {
    font-size: 1.23rem;
    line-height: 1.3;
  }

  .feature-number {
    font-size: 0.7rem;
  }

  .feature-video-container {
    height: 100%;
    min-height: 100%;
    max-height: none;
  }

  .feature-title {
    padding-left: 0.25rem;
  }

  .feature-title h3 {
    font-size: 6.2rem;
  }
}

/* Small desktops (1024px - 1279px) */
@media screen and (min-width: 1024px) and (max-width: 1279px) {
  .interactive-features .container {
    padding: 0 40px;
  }

  .feature-list {
    margin: 0 -40px;
  }

  a.feature-item,
  .feature-item {
    grid-template-columns: var(--feature-cols-lg);
    padding: var(--feature-padding-md);
    gap: 0;
    min-height: var(--feature-min-height-md);
  }

  .feature-description {
    padding-right: 1rem;
  }

  .feature-description p {
    font-size: 1.3rem;
    line-height: 1.3;
  }

  .feature-number {
    font-size: 0.75rem;
  }

  .feature-video-container {
    height: 100%;
    min-height: 100%;
    max-height: none;
  }

  .feature-title {
    padding-left: 0.5rem;
  }

  .feature-title h3 {
    font-size: 7.7rem;
  }
}

/* Large desktops (1280px - 1439px) */
@media screen and (min-width: 1280px) and (max-width: 1439px) {
  a.feature-item,
  .feature-item {
    grid-template-columns: var(--feature-cols-xl);
    padding: var(--feature-padding-lg);
    gap: 0;
    min-height: var(--feature-min-height-lg);
  }

  .feature-description {
    padding-right: 1.5rem;
  }

  .feature-description p {
    font-size: 1.37rem;
  }

  .feature-number {
    font-size: 0.8rem;
  }

  .feature-video-container {
    height: 100%;
    min-height: 100%;
    max-height: none;
  }

  .feature-title {
    padding-left: 0.5rem;
  }

  .feature-title h3 {
    font-size: 9.2rem;
  }
}

/* XL screens (1440px - 1919px) */
@media screen and (min-width: 1440px) and (max-width: 1919px) {
  a.feature-item,
  .feature-item {
    grid-template-columns: var(--feature-cols-2xl);
    padding: var(--feature-padding-xl);
    gap: 0;
    min-height: var(--feature-min-height-xl);
  }

  .feature-description {
    padding-right: 2rem;
  }

  .feature-description p {
    font-size: 1.4rem;
  }

  .feature-video-container {
    height: 100%;
    min-height: 100%;
    max-height: none;
  }

  .feature-title h3 {
    font-size: 10rem;
  }
}

/* XXL screens (1920px+) */
@media screen and (min-width: 1920px) {
  a.feature-item,
  .feature-item {
    grid-template-columns: var(--feature-cols-3xl);
  }

  .feature-description p {
    font-size: 1.47rem;
  }

  .feature-title h3 {
    font-size: 11.6rem;
  }
}

/* ==========================================================================
   TOUCH DEVICE SUPPORT
   ========================================================================== */

@media (hover: none) and (pointer: coarse) and (min-width: 768px) {
  /* Show video on tap/focus for touch devices */
  a.feature-item:active .feature-video,
  .feature-item:active .feature-video,
  a.feature-item:focus .feature-video,
  .feature-item:focus .feature-video {
    opacity: 1;
  }

  a.feature-item:active .feature-symbol,
  .feature-item:active .feature-symbol,
  a.feature-item:focus .feature-symbol,
  .feature-item:focus .feature-symbol {
    opacity: 0;
  }
}

/* ==========================================================================
   MOBILE (below 768px) - Videos always visible
   ========================================================================== */

@media screen and (max-width: 767.98px) {
  .feature-video-container {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
  }

  /* On mobile: show video, hide symbol (no hover) */
  .feature-video {
    opacity: 1;
  }

  .feature-symbol {
    opacity: 0;
  }

  .feature-title h3 {
    font-size: 2.25rem;
    font-weight: 400;
    line-height: 0.8;
  }

  .feature-description p {
    font-size: 0.83rem;
    font-weight: 500;
    line-height: 1.2;
  }
}

/* Small screens (640px - 767px) */
@media screen and (min-width: 640px) and (max-width: 767.98px) {
  .feature-title h3 {
    font-size: 3rem;
  }

  .feature-description p {
    font-size: 0.882rem;
    line-height: 1.25;
  }
}

/* ==========================================================================
   UNIFORM HEIGHTS (JS-controlled)
   ========================================================================== */

@media screen and (min-width: 768px) {
  .features-uniform .feature-item {
    min-height: var(--features-height, 300px);
  }

  .features-video-synced .feature-video-container {
    height: var(--video-height, 220px);
    min-height: var(--video-height, 220px);
    max-height: var(--video-height, 220px);
  }
}

/* ==========================================================================
   FALLBACK FOR BROWSERS WITHOUT GRID
   ========================================================================== */

@supports not (display: grid) {
  @media screen and (min-width: 768px) {
    a.feature-item,
    .feature-item {
      display: flex;
      min-height: 300px;
    }
  }
}
