<?php
$lang = $_GET['lang'] ?? 'tr';
if (!in_array($lang, ['tr', 'en', 'de', 'es'])) $lang = 'tr';

$strings = [
    'tr' => [
        'since'       => '1994\'ten beri kod yazıyoruz.',
        'subtitle'    => 'Yazılım geliştirici. Sistem mimarı. Problemlerin çözücüsü.',
        'about_title' => '// hakkında',
        'about'       => '30 yılı aşkın süredir yazılım geliştiriyorum. Küçük araçlardan kurumsal sistemlere, web uygulamalarından sunucu altyapılarına kadar her katmanda kod yazdım. Hâlâ yazıyorum.',
        'stack_title' => '// kullandıklarım',
        'work_title'  => '// ne yapıyorum',
        'work'        => 'Web tabanlı iş uygulamaları, SaaS ürünler, API tasarımı ve entegrasyonlar. Müşteri odaklı, sürdürülebilir yazılım.',
        'contact_title' => '// iletişim',
        'contact'     => 'mehmet@mehmetkarip.com',
        'lang_label'  => 'Dil',
    ],
    'en' => [
        'since'       => 'Writing code since 1994.',
        'subtitle'    => 'Software developer. System architect. Problem solver.',
        'about_title' => '// about',
        'about'       => 'Over 30 years of software development experience. From small utilities to enterprise systems, from web apps to server infrastructure — I\'ve written code at every layer. Still writing.',
        'stack_title' => '// stack',
        'work_title'  => '// what I do',
        'work'        => 'Web-based business applications, SaaS products, API design and integrations. Customer-focused, maintainable software.',
        'contact_title' => '// contact',
        'contact'     => 'mehmet@mehmetkarip.com',
        'lang_label'  => 'Language',
    ],
    'de' => [
        'since'       => 'Code schreiben seit 1994.',
        'subtitle'    => 'Softwareentwickler. Systemarchitekt. Problemlöser.',
        'about_title' => '// über mich',
        'about'       => 'Über 30 Jahre Erfahrung in der Softwareentwicklung. Von kleinen Tools bis zu Unternehmenssystemen, von Webanwendungen bis zur Serverinfrastruktur — ich habe auf jeder Ebene Code geschrieben. Ich schreibe noch immer.',
        'stack_title' => '// technologien',
        'work_title'  => '// was ich mache',
        'work'        => 'Webbasierte Geschäftsanwendungen, SaaS-Produkte, API-Design und Integrationen. Kundenorientierte, wartbare Software.',
        'contact_title' => '// kontakt',
        'contact'     => 'mehmet@mehmetkarip.com',
        'lang_label'  => 'Sprache',
    ],
    'es' => [
        'since'       => 'Escribiendo código desde 1994.',
        'subtitle'    => 'Desarrollador de software. Arquitecto de sistemas. Solucionador de problemas.',
        'about_title' => '// sobre mí',
        'about'       => 'Más de 30 años de experiencia en desarrollo de software. Desde pequeñas herramientas hasta sistemas empresariales, desde aplicaciones web hasta infraestructura de servidores — he escrito código en cada capa. Sigo escribiendo.',
        'stack_title' => '// tecnologías',
        'work_title'  => '// qué hago',
        'work'        => 'Aplicaciones de negocio basadas en web, productos SaaS, diseño e integración de APIs. Software orientado al cliente y mantenible.',
        'contact_title' => '// contacto',
        'contact'     => 'mehmet@mehmetkarip.com',
        'lang_label'  => 'Idioma',
    ],
];

$t = $strings[$lang];

$langs = [
    'tr' => 'TR',
    'en' => 'EN',
    'de' => 'DE',
    'es' => 'ES',
];

$hello = [
    'tr' => ['lang' => 'Python',     'code' => 'print("Merhaba Dünya")'],
    'en' => ['lang' => 'JavaScript', 'code' => 'console.log("Hello World")'],
    'de' => ['lang' => 'PHP',        'code' => 'echo "Hallo Welt";'],
    'es' => ['lang' => 'C',          'code' => 'printf("Hola Mundo\\n");'],
];
?>
<!DOCTYPE html>
<html lang="<?= $lang ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mehmet Karip</title>
    <style>
        :root {
            --bg:      #0d0d0d;
            --surface: #141414;
            --border:  #222;
            --text:    #c9c9c9;
            --muted:   #555;
            --accent:  #4ec9b0;
            --green:   #6a9955;
            --yellow:  #dcdcaa;
            --blue:    #569cd6;
            --font:    'Consolas', 'Courier New', monospace;
        }

        * { box-sizing: border-box; margin: 0; padding: 0; }

        body {
            background: var(--bg);
            color: var(--text);
            font-family: var(--font);
            font-size: 15px;
            line-height: 1.8;
            min-height: 100vh;
        }

        /* ── NAV ── */
        nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1.2rem 2rem;
            border-bottom: 1px solid var(--border);
        }

        .nav-logo {
            color: var(--accent);
            font-size: 1rem;
            letter-spacing: 0.05em;
        }

        .nav-logo span { color: var(--muted); }

        .lang-switcher {
            display: flex;
            gap: 0.4rem;
        }

        .lang-switcher a {
            color: var(--muted);
            text-decoration: none;
            font-size: 0.8rem;
            padding: 0.2rem 0.5rem;
            border: 1px solid transparent;
            border-radius: 3px;
            transition: color 0.2s, border-color 0.2s;
        }

        .lang-switcher a:hover { color: var(--text); }
        .lang-switcher a.active {
            color: var(--accent);
            border-color: var(--border);
        }

        /* ── HERO ── */
        .hero {
            max-width: 780px;
            margin: 5rem auto 0;
            padding: 0 2rem;
        }

        .hero-since {
            color: var(--green);
            font-size: 0.85rem;
            margin-bottom: 1.5rem;
            letter-spacing: 0.03em;
        }

        .hero-since::before { content: '// '; color: var(--muted); }

        .hero-name {
            font-size: clamp(2rem, 5vw, 3.2rem);
            color: #e8e8e8;
            font-weight: normal;
            letter-spacing: -0.01em;
            line-height: 1.2;
        }

        .hero-name .cursor {
            display: inline-block;
            width: 3px;
            height: 0.9em;
            background: var(--accent);
            margin-left: 6px;
            vertical-align: middle;
            animation: blink 1.1s step-end infinite;
        }

        @keyframes blink {
            0%, 100% { opacity: 1; }
            50%       { opacity: 0; }
        }

        .hero-subtitle {
            color: var(--muted);
            margin-top: 0.8rem;
            font-size: 0.9rem;
        }

        /* ── CODE BLOCK ── */
        .code-hello {
            margin: 3rem 0;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 6px;
            overflow: hidden;
        }

        .code-hello-bar {
            background: #1a1a1a;
            padding: 0.4rem 1rem;
            font-size: 0.75rem;
            color: var(--muted);
            border-bottom: 1px solid var(--border);
            display: flex;
            gap: 0.5rem;
            align-items: center;
        }

        .code-hello-bar .dot {
            width: 10px; height: 10px;
            border-radius: 50%;
            display: inline-block;
        }
        .dot-r { background: #ff5f57; }
        .dot-y { background: #ffbd2e; }
        .dot-g { background: #28c940; }

        .code-hello-body {
            padding: 1.2rem 1.5rem;
        }

        .code-line {
            display: flex;
            gap: 1.5rem;
            margin-bottom: 0.3rem;
        }

        .line-num {
            color: var(--muted);
            user-select: none;
            min-width: 1.5rem;
            text-align: right;
            font-size: 0.85rem;
        }

        .line-code { color: var(--yellow); }
        .line-code .kw  { color: var(--blue); }
        .line-code .str { color: #ce9178; }
        .line-code .fn  { color: var(--yellow); }
        .line-code .cm  { color: var(--green); }

        /* ── SECTIONS ── */
        .sections {
            max-width: 780px;
            margin: 0 auto;
            padding: 0 2rem 5rem;
        }

        .section {
            margin-top: 3.5rem;
        }

        .section-title {
            color: var(--green);
            font-size: 0.9rem;
            margin-bottom: 1rem;
        }

        .section-body {
            color: var(--text);
            font-size: 0.95rem;
            line-height: 1.9;
        }

        /* ── STACK ── */
        .stack-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            margin-top: 0.5rem;
        }

        .stack-item {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 4px;
            padding: 0.25rem 0.7rem;
            font-size: 0.8rem;
            color: var(--accent);
        }

        /* ── CONTACT ── */
        .contact-line {
            color: var(--text);
            font-size: 0.95rem;
        }

        .contact-line a {
            color: var(--accent);
            text-decoration: none;
        }

        .contact-line a:hover { text-decoration: underline; }

        /* ── FOOTER ── */
        footer {
            border-top: 1px solid var(--border);
            text-align: center;
            padding: 1.5rem;
            color: var(--muted);
            font-size: 0.78rem;
        }

        /* ── MULTI HELLO ── */
        .multi-hello {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 0.8rem;
            margin-top: 0.5rem;
        }

        .hello-item {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 4px;
            padding: 0.6rem 1rem;
            font-size: 0.82rem;
        }

        .hello-item .hl { color: var(--muted); font-size: 0.72rem; display: block; margin-bottom: 0.2rem; }
        .hello-item .hc { color: var(--yellow); }
        .hello-item .hc .kw  { color: var(--blue); }
        .hello-item .hc .str { color: #ce9178; }
        .hello-item .hc .fn  { color: var(--yellow); }

        @media (max-width: 600px) {
            nav { padding: 1rem; }
            .hero, .sections { padding: 0 1.2rem; }
            .hero { margin-top: 3rem; }
        }
    </style>
</head>
<body>

<nav>
    <div class="nav-logo">mehmetkarip<span>.com</span></div>
    <div class="lang-switcher">
        <?php foreach ($langs as $code => $label): ?>
            <a href="?lang=<?= $code ?>" class="<?= $lang === $code ? 'active' : '' ?>"><?= $label ?></a>
        <?php endforeach; ?>
    </div>
</nav>

<div class="hero">
    <div class="hero-since"><?= htmlspecialchars($t['since']) ?></div>
    <h1 class="hero-name">Mehmet Karip<span class="cursor"></span></h1>
    <p class="hero-subtitle"><?= htmlspecialchars($t['subtitle']) ?></p>

    <!-- Aktif dile göre hello world -->
    <div class="code-hello">
        <div class="code-hello-bar">
            <span class="dot dot-r"></span>
            <span class="dot dot-y"></span>
            <span class="dot dot-g"></span>
            <span style="margin-left:0.5rem"><?= htmlspecialchars($hello[$lang]['lang']) ?></span>
        </div>
        <div class="code-hello-body">
            <div class="code-line">
                <span class="line-num">1</span>
                <span class="line-code">
                    <?php
                    $code = htmlspecialchars($hello[$lang]['code']);
                    // basit syntax highlight
                    $code = preg_replace('/(print|console\.log|echo|printf)/', '<span class="fn">$1</span>', $code);
                    $code = preg_replace('/("(?:[^"\\\\]|\\\\.)*")/', '<span class="str">$1</span>', $code);
                    echo $code;
                    ?>
                </span>
            </div>
        </div>
    </div>
</div>

<div class="sections">

    <!-- Hakkında -->
    <div class="section">
        <div class="section-title"><?= htmlspecialchars($t['about_title']) ?></div>
        <div class="section-body"><?= htmlspecialchars($t['about']) ?></div>
    </div>

    <!-- Stack -->
    <div class="section">
        <div class="section-title"><?= htmlspecialchars($t['stack_title']) ?></div>
        <div class="stack-grid">
            <?php
            $stack = ['PHP', 'JavaScript', 'Node.js', 'React', 'MySQL', 'Linux', 'Nginx', 'Python', 'C/C++', 'REST API', 'Git'];
            foreach ($stack as $s):
            ?>
                <span class="stack-item"><?= $s ?></span>
            <?php endforeach; ?>
        </div>
    </div>

    <!-- Çok dilli Hello World -->
    <div class="section">
        <div class="section-title">// hello world</div>
        <div class="multi-hello">
            <div class="hello-item">
                <span class="hl">Python</span>
                <span class="hc"><span class="fn">print</span>(<span class="str">"Merhaba Dünya"</span>)</span>
            </div>
            <div class="hello-item">
                <span class="hl">JavaScript</span>
                <span class="hc"><span class="fn">console.log</span>(<span class="str">"Hello World"</span>)</span>
            </div>
            <div class="hello-item">
                <span class="hl">PHP</span>
                <span class="hc"><span class="kw">echo</span> <span class="str">"Hallo Welt"</span>;</span>
            </div>
            <div class="hello-item">
                <span class="hl">C</span>
                <span class="hc"><span class="fn">printf</span>(<span class="str">"Hola Mundo\n"</span>);</span>
            </div>
            <div class="hello-item">
                <span class="hl">Go</span>
                <span class="hc"><span class="fn">fmt.Println</span>(<span class="str">"Bonjour le Monde"</span>)</span>
            </div>
            <div class="hello-item">
                <span class="hl">Rust</span>
                <span class="hc"><span class="fn">println!</span>(<span class="str">"Ciao Mondo"</span>)</span>
            </div>
            <div class="hello-item">
                <span class="hl">Ruby</span>
                <span class="hc"><span class="fn">puts</span> <span class="str">"Olá Mundo"</span></span>
            </div>
            <div class="hello-item">
                <span class="hl">Java</span>
                <span class="hc"><span class="fn">System.out.println</span>(<span class="str">"مرحبا بالعالم"</span>)</span>
            </div>
        </div>
    </div>

    <!-- Ne yapıyorum -->
    <div class="section">
        <div class="section-title"><?= htmlspecialchars($t['work_title']) ?></div>
        <div class="section-body"><?= htmlspecialchars($t['work']) ?></div>
    </div>

    <!-- İletişim -->
    <div class="section">
        <div class="section-title"><?= htmlspecialchars($t['contact_title']) ?></div>
        <div class="contact-line">
            &gt; <a href="mailto:<?= htmlspecialchars($t['contact']) ?>"><?= htmlspecialchars($t['contact']) ?></a>
        </div>
    </div>

</div>

<footer>
    &copy; <?= date('Y') ?> Mehmet Karip &nbsp;·&nbsp; <?= date('Y') - 1994 ?> years of code
</footer>

</body>
</html>
