// Featured-treatment variations for emphasizing Eklemce + Düello.
// All three are the SAME width (1060) so they stack cleanly on the canvas.

const FW = 1060; // artboard width
const T = window.THEMES.light;

// Shared: the existing Günün Oyunu hero tile (a visual anchor so the
// variations are shown in context, not floating alone).
function FeaturedDailyTile({ compact = false }) {
  const g = window.GAMES.find(x => x.id === 'kelimely');
  return (
    <div style={{
      background: g.accent,
      borderRadius: 16,
      padding: compact ? 16 : 20,
      position: 'relative', overflow: 'hidden',
      color: '#fff', height: '100%',
      display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
      minHeight: 180,
    }}>
      <img src={`icons/${g.id}.svg`} alt="" style={{
        position: 'absolute', right: -20, bottom: -20,
        width: 200, height: 200, objectFit: 'contain',
        opacity: 0.9, pointerEvents: 'none',
      }} />
      <div style={{
        position: 'relative', zIndex: 1,
        display: 'inline-flex', alignItems: 'center', gap: 6,
        padding: '4px 10px', borderRadius: 6,
        background: 'rgba(255,255,255,0.2)', alignSelf: 'flex-start',
        fontSize: 10, fontWeight: 800, letterSpacing: 1.5, textTransform: 'uppercase',
      }}>Günün Oyunu</div>
      <div style={{ position: 'relative', zIndex: 1 }}>
        <h3 style={{
          margin: 0, fontSize: compact ? 22 : 28, fontWeight: 800,
          letterSpacing: -0.8,
        }}>{g.name}</h3>
        <p style={{
          margin: '4px 0 10px', fontSize: 12, opacity: 0.85,
          maxWidth: 240,
        }}>{g.desc}</p>
        <span style={{
          display: 'inline-flex', alignItems: 'center', gap: 6,
          padding: '8px 16px', borderRadius: 10,
          background: '#fff', color: g.accent,
          fontWeight: 800, fontSize: 13,
        }}>
          <svg width="12" height="12" viewBox="0 0 16 16" fill="currentColor"><path d="M5 3l7 5-7 5V3z"/></svg>
          Oyna
        </span>
      </div>
    </div>
  );
}

// ═══════════════════════════════════════════════════════════════
// OPTION 1 — Featured Trio (differentiated hero row)
// Same 3-cell footprint as current, but Eklemce and Düello each get
// their own visual ritual instead of cloning the featured card.
// ═══════════════════════════════════════════════════════════════
function OptionFeaturedTrio() {
  const duello = GAMES.find(g => g.id === 'duello');
  const eklemce = GAMES.find(g => g.id === 'eklemce');
  return (
    <div style={{
      background: T.bg, padding: 24, fontFamily: 'Inter, sans-serif',
    }}>
      <div style={{
        display: 'grid',
        gridTemplateColumns: '2fr 1fr 1fr',
        gap: 12,
      }}>
        <FeaturedDailyTile />

        {/* Düello — "Live" multiplayer card */}
        <div style={{
          background: '#151821',
          color: '#fff', borderRadius: 16, padding: 16,
          position: 'relative', overflow: 'hidden', minHeight: 180,
          display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
        }}>
          {/* pulsing live dot */}
          <div style={{
            display: 'flex', alignItems: 'center', gap: 6,
            fontSize: 10, fontWeight: 800, letterSpacing: 1.5,
            textTransform: 'uppercase', color: '#fff',
          }}>
            <span style={{
              width: 7, height: 7, borderRadius: 999, background: '#ff3b5c',
              boxShadow: '0 0 0 4px rgba(255,59,92,0.25)',
            }} />
            Canlı
          </div>
          {/* Two opponent avatars */}
          <div style={{
            position: 'absolute', top: 14, right: 14,
            display: 'flex',
          }}>
            {['#E85A6D', '#6B9CF5'].map((c, i) => (
              <div key={i} style={{
                width: 26, height: 26, borderRadius: 999,
                background: c, color: '#fff',
                display: 'grid', placeItems: 'center',
                fontWeight: 800, fontSize: 11,
                border: '2px solid #151821',
                marginLeft: i ? -8 : 0,
              }}>{['A','M'][i]}</div>
            ))}
          </div>

          <div>
            <h3 style={{
              margin: 0, fontSize: 20, fontWeight: 800, letterSpacing: -0.5,
              display: 'flex', alignItems: 'center', gap: 6,
            }}>
              {duello.name}
              <span style={{
                fontSize: 9, fontWeight: 800, letterSpacing: 0.5,
                padding: '2px 6px', borderRadius: 4,
                background: '#E85A6D', textTransform: 'uppercase',
              }}>2P</span>
            </h3>
            <div style={{
              fontSize: 12, opacity: 0.7, marginTop: 3,
            }}>
              <strong style={{ color: '#fff', opacity: 1 }}>233</strong> oyuncu çevrimiçi
            </div>
            <button style={{
              marginTop: 12, padding: '8px 14px', borderRadius: 8,
              background: '#E85A6D', color: '#fff', border: 'none',
              fontWeight: 800, fontSize: 12, cursor: 'pointer',
              fontFamily: 'inherit', width: '100%',
            }}>Rakip Bul</button>
          </div>
        </div>

        {/* Eklemce — "Haftanın oyunu" with tappable block preview */}
        <div style={{
          background: eklemce.accent, color: '#fff',
          borderRadius: 16, padding: 16,
          position: 'relative', overflow: 'hidden', minHeight: 180,
          display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
        }}>
          <div style={{
            fontSize: 10, fontWeight: 800, letterSpacing: 1.5,
            textTransform: 'uppercase', opacity: 0.95,
            display: 'inline-flex', gap: 6, alignItems: 'center',
          }}>
            <span style={{ fontSize: 12 }}>✦</span> Haftanın Oyunu
          </div>

          {/* Three harf blocks */}
          <div style={{
            display: 'flex', gap: 4, justifyContent: 'center',
            margin: '12px 0',
          }}>
            {['KA', 'LE', 'M'].map((b, i) => (
              <div key={i} style={{
                padding: '10px 10px', borderRadius: 6,
                background: 'rgba(255,255,255,0.95)',
                color: eklemce.accent, fontWeight: 900, fontSize: 16,
                letterSpacing: 1, minWidth: 36, textAlign: 'center',
                boxShadow: '0 3px 0 rgba(0,0,0,0.12)',
                transform: `translateY(${[0, -3, 0][i]}px)`,
              }}>{b}</div>
            ))}
          </div>

          <div>
            <h3 style={{
              margin: 0, fontSize: 20, fontWeight: 800, letterSpacing: -0.5,
            }}>{eklemce.name}</h3>
            <div style={{
              fontSize: 11, opacity: 0.85, marginTop: 3,
            }}>Harf bloklarını birleştir</div>
          </div>
        </div>
      </div>
    </div>
  );
}

// ═══════════════════════════════════════════════════════════════
// OPTION 2 — Playable + Live pair under a ribbon
// Eklemce has a mini interactive preview; Düello is a live card.
// Framed by a "Öne Çıkanlar" ribbon that visually separates them.
// ═══════════════════════════════════════════════════════════════
function OptionLivePlayable() {
  const duello = GAMES.find(g => g.id === 'duello');
  const eklemce = GAMES.find(g => g.id === 'eklemce');
  const [blocks, setBlocks] = React.useState([
    { t: 'KE', picked: false }, { t: 'Lİ', picked: false },
    { t: 'ME', picked: false }, { t: 'CİK', picked: false },
    { t: 'YA', picked: false }, { t: 'ZI', picked: false },
  ]);
  const assembled = blocks.filter(b => b.picked).map(b => b.t).join('');
  const toggle = i => setBlocks(bs => bs.map((b, j) => j === i ? { ...b, picked: !b.picked } : b));
  const reset = () => setBlocks(bs => bs.map(b => ({ ...b, picked: false })));

  return (
    <div style={{
      background: T.bg, padding: 24, fontFamily: 'Inter, sans-serif',
    }}>
      {/* Daily hero — unchanged, for context */}
      <div style={{ marginBottom: 20 }}>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr', gap: 10 }}>
          <FeaturedDailyTile />
        </div>
      </div>

      {/* Öne Çıkanlar ribbon */}
      <div style={{
        display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
        marginBottom: 10, borderTop: `2px solid ${T.ink}`, paddingTop: 10,
      }}>
        <h3 style={{
          margin: 0,
          fontFamily: 'Fraunces, Georgia, serif',
          fontSize: 22, fontWeight: 700, color: T.ink, letterSpacing: -0.5,
        }}>Öne Çıkanlar</h3>
        <span style={{ fontSize: 11, color: T.inkSoft, fontStyle: 'italic' }}>
          Öne çıkardığımız özel oyunlar
        </span>
      </div>

      <div style={{
        display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12,
      }}>
        {/* Playable Eklemce */}
        <div style={{
          background: '#fff', border: `1px solid ${T.line}`, borderRadius: 16,
          padding: 18, position: 'relative', overflow: 'hidden',
          minHeight: 220,
        }}>
          <div style={{
            display: 'flex', alignItems: 'center', gap: 10,
            marginBottom: 12,
          }}>
            <div style={{
              width: 38, height: 38, borderRadius: 8, background: eklemce.accent,
              display: 'grid', placeItems: 'center',
            }}>
              <img src={`icons/${eklemce.id}.svg`} alt="" width="32" height="32"
                style={{ objectFit: 'contain' }} />
            </div>
            <div>
              <div style={{
                fontSize: 10, fontWeight: 800, letterSpacing: 1.5,
                textTransform: 'uppercase', color: eklemce.accent,
              }}>Şimdi dene</div>
              <div style={{
                fontFamily: 'Fraunces, Georgia, serif',
                fontSize: 20, fontWeight: 700, color: T.ink, letterSpacing: -0.3,
                lineHeight: 1, marginTop: 2,
              }}>{eklemce.name}</div>
            </div>
          </div>

          {/* Mini playable */}
          <div style={{
            background: T.bg2, borderRadius: 10, padding: '12px 10px',
            marginBottom: 10,
          }}>
            <div style={{
              fontSize: 10, color: T.inkSoft, letterSpacing: 0.5,
              textTransform: 'uppercase', fontWeight: 700,
              marginBottom: 6, textAlign: 'center',
            }}>
              Oluşturduğun kelime
            </div>
            <div style={{
              background: '#fff', borderRadius: 6, padding: 10,
              fontFamily: 'ui-monospace, monospace',
              fontSize: 18, fontWeight: 800, color: T.ink,
              letterSpacing: 2, textAlign: 'center',
              minHeight: 24, border: `1px dashed ${T.line}`,
            }}>
              {assembled || <span style={{ opacity: 0.3 }}>—</span>}
            </div>
          </div>

          <div style={{
            display: 'flex', gap: 4, flexWrap: 'wrap', justifyContent: 'center',
          }}>
            {blocks.map((b, i) => (
              <button key={i} onClick={() => toggle(i)} style={{
                padding: '8px 12px', borderRadius: 6,
                background: b.picked ? eklemce.accent : '#fff',
                color: b.picked ? '#fff' : T.ink,
                border: `1.5px solid ${b.picked ? eklemce.accent : T.line}`,
                fontFamily: 'inherit',
                fontWeight: 900, fontSize: 13, cursor: 'pointer',
                letterSpacing: 1, transition: 'all 120ms',
              }}>{b.t}</button>
            ))}
          </div>
          <div style={{
            display: 'flex', justifyContent: 'space-between', alignItems: 'center',
            marginTop: 10, fontSize: 11, color: T.inkSoft,
          }}>
            <button onClick={reset} style={{
              background: 'transparent', border: 'none',
              color: T.inkSoft, cursor: 'pointer', fontFamily: 'inherit',
              fontSize: 11, padding: 0,
            }}>↺ Sıfırla</button>
            <a href="#" onClick={e => e.preventDefault()} style={{
              color: eklemce.accent, fontWeight: 700, textDecoration: 'none',
            }}>Tam oyuna geç →</a>
          </div>
        </div>

        {/* Live Düello */}
        <div style={{
          background: '#151821', color: '#fff',
          borderRadius: 16, padding: 18, position: 'relative', overflow: 'hidden',
          minHeight: 220,
          display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
        }}>
          {/* Animated bg glow */}
          <div style={{
            position: 'absolute', inset: 0,
            background: 'radial-gradient(ellipse at 80% 40%, rgba(232,90,109,0.28), transparent 50%)',
            pointerEvents: 'none',
          }} />

          <div style={{ position: 'relative', zIndex: 1 }}>
            <div style={{
              display: 'flex', alignItems: 'center', justifyContent: 'space-between',
              marginBottom: 12,
            }}>
              <div style={{
                display: 'inline-flex', alignItems: 'center', gap: 6,
                fontSize: 10, fontWeight: 800, letterSpacing: 1.5,
                textTransform: 'uppercase',
              }}>
                <span style={{
                  width: 7, height: 7, borderRadius: 999, background: '#ff3b5c',
                  boxShadow: '0 0 0 4px rgba(255,59,92,0.3)',
                }} />
                Canlı · Çok Oyunculu
              </div>
              <span style={{
                fontSize: 9, fontWeight: 800, letterSpacing: 0.5,
                padding: '3px 7px', borderRadius: 4,
                background: '#E85A6D', textTransform: 'uppercase',
              }}>2 Kişilik</span>
            </div>

            <h3 style={{
              margin: 0, fontSize: 28, fontWeight: 800, letterSpacing: -0.8,
              fontFamily: 'Fraunces, Georgia, serif', fontWeight: 700,
            }}>{duello.name}</h3>
            <p style={{
              margin: '4px 0 0', fontSize: 12, opacity: 0.75,
              maxWidth: 320,
            }}>{duello.desc}</p>
          </div>

          {/* Live mini boards — 2 side by side */}
          <div style={{
            position: 'relative', zIndex: 1,
            display: 'flex', gap: 10, alignItems: 'center',
            margin: '14px 0',
          }}>
            <MiniDuelloBoard avatar="A" color="#6B9CF5" rows={[
              ['k','a','l','e','m'],['t','a','r','l','a'],
            ]} states={[
              ['a','c','a','a','p'],['p','c','a','a','a'],
            ]} />
            <div style={{
              fontSize: 20, fontWeight: 900, opacity: 0.3,
            }}>VS</div>
            <MiniDuelloBoard avatar="M" color="#E85A6D" rows={[
              ['k','i','t','a','p'],[' ',' ',' ',' ',' '],
            ]} states={[
              ['a','c','c','p','a'],['e','e','e','e','e'],
            ]} />
          </div>

          <div style={{
            position: 'relative', zIndex: 1,
            display: 'flex', gap: 8, alignItems: 'center',
          }}>
            <button style={{
              flex: 1, padding: '10px', borderRadius: 10,
              background: '#E85A6D', color: '#fff', border: 'none',
              fontWeight: 800, fontSize: 13, cursor: 'pointer',
              fontFamily: 'inherit',
            }}>Hemen Oda Kur</button>
            <button style={{
              padding: '10px 14px', borderRadius: 10,
              background: 'rgba(255,255,255,0.1)', color: '#fff',
              border: '1px solid rgba(255,255,255,0.15)',
              fontWeight: 700, fontSize: 13, cursor: 'pointer',
              fontFamily: 'inherit',
            }}>Kod Gir</button>
          </div>
          <div style={{
            position: 'relative', zIndex: 1,
            fontSize: 10, color: 'rgba(255,255,255,0.55)', marginTop: 8,
            textAlign: 'center',
          }}>
            Şu an <strong style={{ color: '#fff' }}>233</strong> oyuncu oynuyor · Ortalama bekleme 4sn
          </div>
        </div>
      </div>
    </div>
  );
}

function MiniDuelloBoard({ avatar, color, rows, states }) {
  return (
    <div style={{
      flex: 1, background: 'rgba(255,255,255,0.06)',
      borderRadius: 8, padding: 8,
      display: 'flex', flexDirection: 'column', gap: 6,
    }}>
      <div style={{
        display: 'flex', alignItems: 'center', gap: 6,
        fontSize: 10, opacity: 0.8,
      }}>
        <div style={{
          width: 16, height: 16, borderRadius: 999,
          background: color, color: '#fff',
          display: 'grid', placeItems: 'center',
          fontSize: 9, fontWeight: 800,
        }}>{avatar}</div>
        <span>Oyuncu {avatar}</span>
      </div>
      <div style={{
        display: 'flex', flexDirection: 'column', gap: 2, alignItems: 'center',
      }}>
        {rows.map((r, i) => <TileRow key={i} letters={r} states={states[i]} size={16} gap={2} />)}
      </div>
    </div>
  );
}

// ═══════════════════════════════════════════════════════════════
// OPTION 3 — Öne Çıkanlar Ribbon (two wide landscape cards)
// Lowest risk: reuse the current card language but put them in a
// separately-framed strip that earns its own identity.
// ═══════════════════════════════════════════════════════════════
function OptionRibbon() {
  const duello = GAMES.find(g => g.id === 'duello');
  const eklemce = GAMES.find(g => g.id === 'eklemce');
  return (
    <div style={{
      background: T.bg, padding: 24, fontFamily: 'Inter, sans-serif',
    }}>
      {/* Single-wide daily hero */}
      <div style={{ marginBottom: 22 }}>
        <FeaturedDailyTile />
      </div>

      {/* Ribbon with its own tinted background */}
      <div style={{
        background: T.paper,
        border: `1px solid ${T.line}`,
        borderRadius: 18,
        padding: 18,
        position: 'relative',
      }}>
        <div style={{
          position: 'absolute', top: -11, left: 20,
          background: T.ink, color: T.paper,
          padding: '3px 12px', borderRadius: 6,
          fontSize: 10, fontWeight: 800, letterSpacing: 1.5,
          textTransform: 'uppercase',
        }}>Öne Çıkanlar</div>

        <div style={{
          display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12,
          marginTop: 4,
        }}>
          <FeatureLandscape game={eklemce}
            tag="Hece ve kelime"
            tagline="Blokları birleştir, kelime yarat"
            badge={{ text: 'Hece Oyunu', bg: 'rgba(255,255,255,0.22)' }} />
          <FeatureLandscape game={duello}
            tag="Arkadaşla oyna"
            tagline="Gerçek zamanlı kelime düellosu"
            badge={{ text: 'Canlı · 2 Kişilik', bg: 'rgba(255,255,255,0.22)', pulse: true }} />
        </div>
      </div>
    </div>
  );
}

function FeatureLandscape({ game, tag, tagline, badge }) {
  return (
    <a href="#" onClick={e => e.preventDefault()} style={{
      position: 'relative', overflow: 'hidden',
      borderRadius: 14, padding: 18,
      background: game.accent, color: '#fff', textDecoration: 'none',
      display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
      minHeight: 170,
    }}>
      <img src={`icons/${game.id}.svg`} alt="" style={{
        position: 'absolute', right: -30, top: '50%',
        transform: 'translateY(-50%) scale(1.1)',
        width: 220, height: 220, objectFit: 'contain', pointerEvents: 'none',
      }} />
      <div style={{
        position: 'absolute', inset: 0,
        background: `linear-gradient(to right, ${game.accent} 20%, ${game.accent}aa 55%, transparent 85%)`,
        pointerEvents: 'none',
      }} />

      <div style={{ position: 'relative', zIndex: 1 }}>
        <div style={{
          display: 'inline-flex', alignItems: 'center', gap: 6,
          padding: '4px 10px', borderRadius: 999,
          background: badge.bg, backdropFilter: 'blur(4px)',
          fontSize: 10, fontWeight: 800, letterSpacing: 1,
          textTransform: 'uppercase',
        }}>
          {badge.pulse && (
            <span style={{
              width: 6, height: 6, borderRadius: 999, background: '#fff',
              boxShadow: '0 0 0 3px rgba(255,255,255,0.35)',
            }} />
          )}
          {badge.text}
        </div>
      </div>

      <div style={{ position: 'relative', zIndex: 1, maxWidth: '60%' }}>
        <div style={{
          fontSize: 10, letterSpacing: 1.5, textTransform: 'uppercase',
          opacity: 0.8, fontWeight: 700, marginBottom: 4,
        }}>{tag}</div>
        <h3 style={{
          margin: 0, fontSize: 30, fontWeight: 800, letterSpacing: -1,
          fontFamily: 'Fraunces, Georgia, serif', fontWeight: 700,
          lineHeight: 1,
        }}>{game.name}</h3>
        <p style={{
          margin: '6px 0 10px', fontSize: 12, opacity: 0.9,
        }}>{tagline}</p>
        <span style={{
          display: 'inline-flex', alignItems: 'center', gap: 6,
          padding: '7px 14px', borderRadius: 8,
          background: '#fff', color: game.accent,
          fontWeight: 800, fontSize: 12,
        }}>
          Oyna →
        </span>
      </div>
    </a>
  );
}

Object.assign(window, {
  OptionFeaturedTrio, OptionLivePlayable, OptionRibbon,
});
