/* AI Story Section — Grid, Cards, Line Art, Animations
 * Replaces old ai-bento-* classes
 */

/* ==========================================
   THEME TOKENS — LINE ART
   ========================================== */
:root {
  --line-art-dark: #78AF2E;
  --line-art-light: #025EC4;
  --line-art-color: var(--line-art-dark);
}

[data-theme="light"] {
  --line-art-color: var(--line-art-light);
}

/* ==========================================
   SECTION WRAPPER
   ========================================== */
.ai-story {
  position: relative;
  z-index: 1;
  background: #1B2F2B;
  overflow: hidden;
  padding: 0;
}

[data-theme="light"] .ai-story {
  background: #F0F5F2;
}

/* Light mode card overrides */
[data-theme="light"] .ai-story-card {
  border: 1px dashed rgba(2, 94, 196, 0.25);
  background: rgba(2, 94, 196, 0.04);
}

[data-theme="light"] .ai-story-plus {
  color: rgba(2, 94, 196, 0.35);
}

[data-theme="light"] .ai-story-inner {
  border-left-color: rgba(2, 94, 196, 0.08);
  border-right-color: rgba(2, 94, 196, 0.08);
}

.ai-story-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 80px 3rem 96px;
  position: relative;
  z-index: 1;
  border-left: 1px solid rgba(120, 175, 46, 0.08);
  border-right: 1px solid rgba(120, 175, 46, 0.08);
}

/* ==========================================
   20-COLUMN GRID
   ========================================== */
.ai-story-grid {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 16px;
  grid-auto-rows: auto;
}

/* Span utilities */
.ai-story-col-7 {
  grid-column: span 7;
}

/* 35% */
.ai-story-col-8 {
  grid-column: span 8;
}

/* 40% */
.ai-story-col-10 {
  grid-column: span 10;
}

/* 50% */
.ai-story-col-12 {
  grid-column: span 12;
}

/* 60% */
.ai-story-col-13 {
  grid-column: span 13;
}

/* 65% */
.ai-story-col-20 {
  grid-column: span 20;
}

/* 100% */

/* ==========================================
   CARD BASE
   ========================================== */
.ai-story-card {
  border: 1px dashed rgba(120, 175, 46, 0.25);
  border-radius: 8px;
  padding: 28px;
  background: rgba(0, 20, 20, 0.3);
  position: relative;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: visible;
  /* plus markers need to overflow */
}

/* Inner wrapper: heading row + body text */
.ai-story-card__inner {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Heading row: title on left, SVG on right */
.ai-story-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.ai-story-card__title {
  font-family: 'Geist', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}

.ai-story-card__body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* ==========================================
   CORNER PLUS MARKERS
   ========================================== */
.ai-story-plus {
  position: absolute;
  width: 24px;
  height: 24px;
  color: rgba(120, 175, 46, 0.5);
  pointer-events: none;
  z-index: 2;
}

.ai-story-plus--tl {
  top: -12px;
  left: -12px;
}

.ai-story-plus--tr {
  top: -12px;
  right: -12px;
}

.ai-story-plus--bl {
  bottom: -12px;
  left: -12px;
}

.ai-story-plus--br {
  bottom: -12px;
  right: -12px;
}

/* ==========================================
   STATEMENT CARD (Card 7)
   ========================================== */
.ai-story-card--statement {
  padding: 48px 40px;
  min-height: 240px;
}

.ai-story-card--statement .ai-story-card__inner {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 48px;
}

.ai-story-statement__graphic {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0;
  margin-right: 60px;
}

.ai-story-card--statement .line-art {
  width: 160px;
  height: 160px;
}

.ai-story-statement__text {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.ai-story-card--statement h2 {
  font-family: 'Geist', sans-serif;
  font-size: clamp(32px, 5vw, 60px);
  font-weight: 800;
  color: var(--text-bright);
  line-height: 1.1;
  letter-spacing: -1px;
}

.ai-story-card--statement .ai-story-card__body {
  color: var(--text-secondary);
  font-size: 16px;
  margin-top: 12px;
  line-height: 1.55;
  max-width: 560px;
  margin-left: 0;
}

/* "Designed for sovereignty." accent color */
.sovereignty-highlight {
  color: var(--accent-orange);
}

/* ==========================================
   STATEMENT CARD — INLINE STATS
   ========================================== */
.ai-story-stats {
  display: flex;
  gap: 0;
  margin-top: 28px;
  border-top: 1px solid rgba(120, 175, 46, 0.12);
  padding-top: 24px;
}

[data-theme="light"] .ai-story-stats {
  border-top-color: rgba(2, 94, 196, 0.15);
}

.ai-story-stats-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 16px;
  border-right: 1px solid rgba(120, 175, 46, 0.1);
}

.ai-story-stats-item:first-child {
  padding-left: 0;
}

.ai-story-stats-item:last-child {
  border-right: none;
}

[data-theme="light"] .ai-story-stats-item {
  border-right-color: rgba(2, 94, 196, 0.15);
}

.ai-story-stats-value {
  font-family: 'Geist Mono', monospace;
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 800;
  color: var(--accent-orange);
  line-height: 1.1;
}

.ai-story-stats-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==========================================
   LINE ART — INLINE FOREGROUND
   ========================================== */
.line-art {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
}

.line-art-group {
  will-change: transform, opacity;
  transform-box: fill-box;
  transform-origin: center;
}

/* Statement card line-art size is set in the STATEMENT CARD section above */

/* ==========================================
   ANIMATION STATE: is-init (hidden)
   ========================================== */
.line-art[data-art-state="is-init"] .line-art-part--outline,
.line-art[data-art-state="is-init"] .line-art-part--detail,
.line-art[data-art-state="is-init"] .line-art-part--node {
  stroke-dasharray: 500;
  stroke-dashoffset: 500;
  opacity: 0;
}

.line-art[data-art-state="is-init"] .line-art-part--node {
  stroke-dasharray: none;
  stroke-dashoffset: 0;
}

/* ==========================================
   ANIMATION STATE: is-revealed (draw-in)
   ========================================== */
.line-art[data-art-state="is-revealed"] .line-art-part--outline {
  stroke-dasharray: 500;
  stroke-dashoffset: 0;
  opacity: 1;
  transition: stroke-dashoffset 0.8s ease-out, opacity 0.4s ease;
}

.line-art[data-art-state="is-revealed"] .line-art-part--detail {
  stroke-dasharray: 500;
  stroke-dashoffset: 0;
  opacity: 1;
  transition: stroke-dashoffset 0.6s ease-out 0.3s, opacity 0.3s ease 0.3s;
}

.line-art[data-art-state="is-revealed"] .line-art-part--node {
  opacity: 1;
  transition: opacity 0.3s ease 0.6s;
}

/* ==========================================
   ANIMATION STATE: is-idle (subtle loop)
   ========================================== */
.line-art[data-art-state="is-idle"] .line-art-part--outline,
.line-art[data-art-state="is-idle"] .line-art-part--detail {
  stroke-dasharray: 500;
  stroke-dashoffset: 0;
  opacity: 1;
}

.line-art[data-art-state="is-idle"] .line-art-part--node {
  opacity: 1;
}

.line-art[data-art-state="is-idle"] .line-art-group {
  opacity: 0.85;
  transition: opacity 0.6s ease;
}

/* Idle: rotate (fibonacci, blueprint, starburst) */
.line-art--fibonacci[data-art-state="is-idle"] .line-art-group {
  animation: idle-rotate 20s linear infinite;
}

.line-art--blueprint[data-art-state="is-idle"] .line-art-group {
  animation: idle-rotate 30s linear infinite;
}

.line-art--starburst[data-art-state="is-idle"] .line-art-group {
  animation: idle-rotate 15s linear infinite;
}

/* Idle: pulse (eye, shield, network) */
.line-art--eye[data-art-state="is-idle"] .line-art-group,
.line-art--network[data-art-state="is-idle"] .line-art-group {
  animation: idle-pulse 3s ease-in-out infinite;
}

.line-art--shield[data-art-state="is-idle"] .line-art-group {
  animation: idle-pulse 5s ease-in-out infinite;
}

/* Idle: float (pipeline, layers, tree) */
.line-art--pipeline[data-art-state="is-idle"] .line-art-group,
.line-art--tree[data-art-state="is-idle"] .line-art-group {
  animation: idle-float 4s ease-in-out infinite;
}

.line-art--layers[data-art-state="is-idle"] .line-art-group {
  animation: idle-float 5s ease-in-out infinite;
}

/* ==========================================
   KEYFRAMES
   ========================================== */
@keyframes idle-rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes idle-pulse {

  0%,
  100% {
    opacity: 0.85;
  }

  50% {
    opacity: 1;
  }
}

@keyframes idle-float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

/* ==========================================
   SCROLL ENTRANCE ANIMATIONS
   ========================================== */
.ai-story .scroll-animate {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.ai-story .scroll-animate.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================
   RESPONSIVE — TABLET (768-1023px)
   ========================================== */
@media (max-width: 1023px) {
  .ai-story-inner {
    padding: 64px 2rem 80px;
    border-left: none;
    border-right: none;
  }

  .ai-story-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .ai-story-col-7,
  .ai-story-col-8,
  .ai-story-col-10,
  .ai-story-col-12,
  .ai-story-col-13 {
    grid-column: span 1;
  }

  .ai-story-col-20 {
    grid-column: span 2;
  }

  .line-art {
    width: 56px;
    height: 56px;
  }

  .ai-story-card--statement .line-art {
    width: 96px;
    height: 96px;
  }

  .ai-story-card--statement .ai-story-card__inner {
    gap: 32px;
  }

  .ai-story-stats {
    flex-wrap: wrap;
    gap: 16px 0;
  }

  .ai-story-stats-item {
    flex: 1 1 45%;
    border-right: none;
    padding: 0;
  }
}

/* ==========================================
   RESPONSIVE — MOBILE (640-767px)
   ========================================== */
@media (max-width: 767px) {
  .ai-story-inner {
    padding: 48px 1.25rem 64px;
  }

  .ai-story-grid {
    grid-template-columns: 1fr;
  }

  .ai-story-col-7,
  .ai-story-col-8,
  .ai-story-col-10,
  .ai-story-col-12,
  .ai-story-col-13,
  .ai-story-col-20 {
    grid-column: span 1;
  }

  .ai-story-card--statement {
    padding: 36px 24px;
    min-height: auto;
  }

  .ai-story-card--statement .ai-story-card__inner {
    flex-direction: column;
    gap: 24px;
    text-align: center;
  }

  .ai-story-statement__graphic {
    margin: 0 auto;
  }

  .ai-story-card--statement .ai-story-card__body {
    margin-left: auto;
    margin-right: auto;
  }

  .ai-story-stats {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px 0;
    text-align: center;
  }

  .ai-story-stats-item {
    flex: 1 1 50%;
    padding: 0;
  }

  .ai-story-card--statement h2 {
    letter-spacing: -0.5px;
  }

  .ai-story-card {
    min-height: auto;
  }

  .line-art {
    width: 48px;
    height: 48px;
  }

  .ai-story-card--statement .line-art {
    width: 72px;
    height: 72px;
  }

  /* No idle animations on mobile — draw-in only */
  .line-art[data-art-state="is-idle"] .line-art-group {
    animation: none !important;
  }
}

/* ==========================================
   RESPONSIVE — SMALL PHONE (<420px)
   ========================================== */
@media (max-width: 419px) {
  .line-art {
    width: 40px;
    height: 40px;
  }

  .ai-story-card--statement .line-art {
    width: 56px;
    height: 56px;
  }
}

/* ==========================================
   REDUCED MOTION
   ========================================== */
@media (prefers-reduced-motion: reduce) {
  .ai-story .scroll-animate {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .line-art[data-art-state="is-init"] .line-art-part--outline,
  .line-art[data-art-state="is-init"] .line-art-part--detail,
  .line-art[data-art-state="is-init"] .line-art-part--node {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
    opacity: 1;
  }

  .line-art .line-art-group {
    opacity: 0.85 !important;
    animation: none !important;
    transition: none !important;
  }

  .line-art .line-art-part--outline,
  .line-art .line-art-part--detail,
  .line-art .line-art-part--node {
    transition: none !important;
  }
}