/**
 * Card Stack Section CSS - Horizontal Scrolling Cards
 * Cards slide left from right to left while all visible at bottom
 */

.card-stack-section,
.card-stack-section * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.card-stack-section {
  position: relative;
  width: 100%;
  background: #faf9ef;
  padding: 60px 0 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.card-stack-section__container {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 0 18px;
}

.card-stack-section__header {
  text-align: center;
  margin-bottom: 34px;
  padding: 0 20px;
}

.card-stack-section__badge {
  display: inline-block;
  background: rgba(0, 0, 0, 0.04);
  color: #1f1f1f;
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 18px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.card-stack-section__title {
  font-size: clamp(28px, 5vw, 60px);
  font-weight: 500;
  color: #1a1a1a;
  margin-bottom: 12px;
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.card-stack-section__subtitle {
  font-size: clamp(14px, 2vw, 16px);
  color: #666;
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ============================================================
   WRAPPER - PINNED SECTION
   ============================================================ */

.card-stack-section__wrapper {
  position: relative;
  height: 716px;
  overflow: hidden;
  background: #faf9ef;
  display: block;
}

@media (min-width: 991px) {
  .card-stack-section__container {
    max-width: none;
    padding-right: 18px;
    padding-left: 18px;
  }

  .card-stack-section__wrapper {
    margin-right: 0;
    margin-left: 0;
  }

  .stack-card-item__footer {
    position: absolute;
    right: 20px;
    bottom: 24px;
    left: 20px;
    margin: 0;
    min-height: 162px;
  }

  .stack-card-item__image-container {
    position: absolute;
    bottom: 0;
    left: 0;
  }

  .stack-card-item__description {
    margin-left: 256px;
  }
}

/* ============================================================
   CARDS CONTAINER - VISIBLE ROW
   ============================================================ */

.card-stack-section__cards {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  height: 100%;
  padding: 0;
}

/* ============================================================
   INDIVIDUAL CARD
   ============================================================ */

.stack-card-item {
  position: relative;
  flex: 0 0 25%;
  flex-shrink: 0;
  width: 25%;
  height: 100%;
  min-height: 420px;
  background: #faf9ef;
  border: 1px solid #e8e3d8;
  
  padding: 20px;
  display: flex;
  flex-direction: column;
  will-change: transform, opacity;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.3s ease;
}

.stack-card-item:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Cards that have already been passed stay visible as compact pinned panels. */
.stack-card-item.is-card-past {
  padding: 20px;
}

.stack-card-item.is-card-past .stack-card-item__header {
  margin-bottom: 0;
}

.stack-card-item.is-card-past .stack-card-item__icon {
  width: 76px;
  height: 76px;
  margin-bottom: 12px;
}

.stack-card-item.is-card-past .stack-card-item__icon svg {
  width: 26px;
  height: 26px;
}

.stack-card-item.is-card-past .stack-card-item__title,
.stack-card-item.is-card-past .stack-card-item__tags,
.stack-card-item.is-card-past .stack-card-item__description {
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-10px);
  transition: max-height 0.45s ease, margin 0.45s ease, opacity 0.35s ease,
    transform 0.45s ease;
}

.stack-card-item.is-card-past .stack-card-item__footer {
  position: absolute;
  right: 20px;
  bottom: 20px;
  left: 20px;
  margin: 0;
  display: block;
  overflow: hidden;
}

.stack-card-item.is-card-past .stack-card-item__description {
  width: 0;
  max-width: 0;
  max-height: 0;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
}

.stack-card-item__title,
.stack-card-item__tags,
.stack-card-item__description {
  max-height: 500px;
  opacity: 1;
  transform: translateY(0);
  transition: max-height 0.45s ease, margin 0.45s ease, opacity 0.35s ease,
    transform 0.45s ease;
}

.stack-card-item__title {
  overflow: hidden;
}

.stack-card-item__description {
  overflow: hidden;
}

.stack-card-item.is-card-past .stack-card-item__description {
  flex: 0 0 0;
}

.stack-card-item__header {
  margin-bottom: 16px;
  flex-shrink: 0;
}

.stack-card-item__icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a1a;
  border-radius: 50%;
  background-image: radial-gradient(rgba(116, 93, 44, 0.55) 1.4px, transparent 1.7px);
  background-size: 7px 7px;
  mask-image: radial-gradient(circle, #000 60%, transparent 100%);
  -webkit-mask-image: radial-gradient(circle, #000 60%, transparent 100%);
  transition: width 0.45s ease, height 0.45s ease, margin 0.45s ease;
}

.stack-card-item__icon svg {
  width: 22px;
  height: 22px;
  display: block;
  color: currentColor;
  transition: width 0.45s ease, height 0.45s ease;
}

.stack-card-item__title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(30px, 3vw, 46px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #1a1a1a;
  margin-bottom: 12px;
}

.stack-card-item__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.stack-card-item__tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 1px solid rgba(17, 20, 25, 0.3);
  border-radius: 999px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1a1a1a;
  white-space: nowrap;
}

.stack-card-item__footer {
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-shrink: 0;
}

.stack-card-item__image-container {
  flex: 0 0 auto;
  width: 240px;
  height: 162px;
  border-radius: 10px;
  overflow: hidden;
  background: #2a2a2a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.stack-card-item__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stack-card-item__description {
  flex: 1;
  font-size: 18px;
  line-height: 1.28;
  color: #202020;
}

.stack-card-item--cta {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #4820d4;
  border-color: #4820d4;
  color: #ffffff;
}

.stack-card-item--cta .stack-card-item__cta-content {
  display: flex;
  width: min(820px, 100%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stack-card-item--cta .stack-card-item__icon {
  width: 76px;
  height: 76px;
  margin-bottom: 28px;
  color: rgba(255, 255, 255, 0.7);
  background-image: radial-gradient(rgba(255, 255, 255, 0.7) 1.4px, transparent 1.7px);
}

.stack-card-item--cta .stack-card-item__icon svg {
  width: 38px;
  height: 38px;
}

.stack-card-item--cta .stack-card-item__title {
  max-width: 900px;
  margin-bottom: 18px;
  color: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(34px, 4.5vw, 60px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0;
}

.stack-card-item--cta .stack-card-item__title-accent {
  display: inline-block;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.05em;
  font-style: italic;
  font-weight: 400;
}

.stack-card-item--cta .stack-card-item__description {
  flex: 0 1 auto;
  width: 100%;
  max-width: 520px;
  margin-right: auto;
  margin-left: auto;
  margin-bottom: 26px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  line-height: 1.35;
  text-align: center;
}

.stack-card-item__cta-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  border-radius: 999px;
  background: #ffffff;
  color: #202020;
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
}

.stack-card-item__cta-button span {
  font-size: 20px;
  line-height: 0.7;
}

/* ============================================================
   PROGRESS INDICATOR
   ============================================================ */

.card-stack-section__progress {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 20;
  pointer-events: auto;
}

.card-stack-section__progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.15);
  cursor: pointer;
  padding: 0;
  transition: transform 0.3s ease, background 0.3s ease;
}

.card-stack-section__progress-dot.is-active {
  background: #1a1a1a;
  transform: scale(1.4);
}

/* ============================================================
   SPACER FOR SCROLL PIN
   ============================================================ */

.card-stack-section__spacer {
  height: 30vh;
  background: #ffffff;
}

/* ============================================================
   TABLET (768px to 990px)
   ============================================================ */

@media (max-width: 990px) {
  .card-stack-section__wrapper {
    height: auto;
    overflow: visible;
    align-items: flex-start;
  }

  .card-stack-section__cards {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    width: 100%;
    height: auto;
    padding: 0;
  }

  .stack-card-item {
    position: static;
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    min-height: 400px;
    transform: none !important;
    opacity: 1 !important;
  }

  .stack-card-item__title {
    font-size: 28px;
  }

  .stack-card-item__footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .stack-card-item__image-container {
    width: 100%;
    height: 200px;
  }

  .card-stack-section__progress {
    display: none;
  }

  .card-stack-section__spacer {
    display: none;
  }
}

/* ============================================================
   MOBILE (640px to 767px)
   ============================================================ */

@media (max-width: 767px) {
  .card-stack-section {
    padding: 40px 0 0;
    background: #383838;
  }

  .card-stack-section__container {
    padding: 0 24px;
  }

  .card-stack-section__header {
    margin-bottom: 28px;
  }

  .card-stack-section__title {
    font-size: clamp(24px, 4vw, 40px);
  }

  .stack-card-item {
    padding: 20px;
    min-height: 350px;
    border-radius: 12px;
  }

  .stack-card-item__title {
    font-size: 24px;
  }

  .stack-card-item__icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
    margin-bottom: 12px;
  }

  .stack-card-item__footer {
    gap: 12px;
    margin-top: 0;
  }

  .stack-card-item__image-container {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }

  .stack-card-item__description {
    font-size: 12px;
    line-height: 1.4;
  }
}

/* ============================================================
   SMALL MOBILE (max 639px)
   ============================================================ */

@media (max-width: 639px) {
  .card-stack-section {
    padding: 32px 0 0;
    background: #383838;
  }

  .card-stack-section__container {
    padding: 0 24px;
  }

  .card-stack-section__header {
    margin-bottom: 24px;
    padding: 0;
  }

  .card-stack-section__badge {
    font-size: 10px;
    padding: 8px 14px;
  }

  .card-stack-section__title {
    font-size: clamp(20px, 3.5vw, 32px);
    margin-bottom: 8px;
  }

  .card-stack-section__subtitle {
    font-size: 13px;
  }

  .stack-card-item {
    padding: 20px;
    min-height: 0;
    border-radius: 0;
    border: 1px solid #ddd;
    margin-bottom: 16px;
  }

  .stack-card-item__title {
    font-size: 20px;
    margin-bottom: 8px;
  }

  .stack-card-item__icon {
    width: 36px;
    height: 36px;
    font-size: 18px;
    margin-bottom: 10px;
  }

  .stack-card-item__tags {
    gap: 6px;
    margin-bottom: 16px;
  }

  .stack-card-item__tag {
    padding: 5px 10px;
    font-size: 8px;
  }

  .stack-card-item__footer {
    gap: 10px;
    margin-top: 0;
  }

  .stack-card-item__image-container {
    order: 2;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
  }

  .stack-card-item__description {
    order: 1;
    flex: 0 0 auto;
    width: 100%;
    font-size: 11px;
    line-height: 1.3;
  }

  .stack-card-item__footer {
    align-items: stretch;
  }

  .stack-card-item--cta {
    min-height: 500px;
  }
}

/* ============================================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .stack-card-item,
  .stack-card-item__image,
  .card-stack-section__progress-dot {
    transition: none !important;
    animation: none !important;
    will-change: auto !important;
  }

  .stack-card-item__image {
    transform: scale(1) !important;
  }

  .stack-card-item:hover .stack-card-item__image {
    transform: scale(1) !important;
  }

  .card-stack-section__wrapper {
    position: static;
    height: auto;
    align-items: flex-start;
  }

  .card-stack-section__cards {
    flex-direction: column;
    transform: none !important;
  }

  .stack-card-item {
    position: static;
    transform: none !important;
    opacity: 1 !important;
    z-index: auto !important;
    width: 100%;
  }

  .card-stack-section__progress {
    display: none;
  }

  .card-stack-section__spacer {
    display: none;
  }
}

/* ============================================================
   ACCESSIBILITY - KEYBOARD FOCUS
   ============================================================ */

.stack-card-item:focus-visible {
  outline: 2px solid #1f1f1f;
  outline-offset: 2px;
}

.card-stack-section__progress-dot:focus-visible {
  outline: 2px solid #1f1f1f;
  outline-offset: 3px;
}

.stack-card-item {
  cursor: pointer;
}

/* ============================================================
   DARK MODE SUPPORT
   ============================================================ */

@media (prefers-color-scheme: dark) {
  .card-stack-section {
    background: #ffffff;
  }

  .card-stack-section__wrapper {
    background: #ffffff;
  }

  .card-stack-section__title,
  .card-stack-section__subtitle {
    color: #1a1a1a;
  }

  .card-stack-section__badge {
    background: rgba(0, 0, 0, 0.04);
    color: #1f1f1f;
    border-color: rgba(0, 0, 0, 0.08);
  }

  .stack-card-item:not(.stack-card-item--cta) {
    background: #ffffff;
    border-color: #e8e3d8;
  }

  .stack-card-item:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  }

  .stack-card-item:not(.stack-card-item--cta) .stack-card-item__title {
    color: #1a1a1a;
  }

  .stack-card-item:not(.stack-card-item--cta) .stack-card-item__description {
    color: #555;
  }

  .stack-card-item__tag {
    color: #1a1a1a;
    border-color: rgba(17, 20, 25, 0.3);
  }

  .stack-card-item:not(.stack-card-item--cta) .stack-card-item__icon {
    background: rgba(0, 0, 0, 0.04);
  }

  .card-stack-section__progress-dot {
    background: rgba(0, 0, 0, 0.15);
  }

  .card-stack-section__progress-dot.is-active {
    background: #1a1a1a;
  }

  .card-stack-section__spacer {
    background: #ffffff;
  }
}

/* ============================================================
   TOUCH DEVICE OPTIMIZATION
   ============================================================ */

@media (hover: none) and (pointer: coarse) {
  .stack-card-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  }

  .stack-card-item__image {
    transform: scale(1);
  }

  .stack-card-item:active .stack-card-item__image {
    transform: scale(1.02);
  }

  .card-stack-section__progress-dot:hover {
    transform: scale(1.2);
  }
}

/* ============================================================
   HIGH CONTRAST MODE
   ============================================================ */

@media (prefers-contrast: more) {
  .stack-card-item {
    border: 2px solid #1f1f1f;
  }

  .stack-card-item__tag {
    border: 1.5px solid #1f1f1f;
  }

  .stack-card-item__icon {
    border: 1px solid #1f1f1f;
  }
}
